Found a 2 Mil cash card on a soldier, part of the output is calling itself a bug. Also, it's probably unintended that a max value cash card drops?

I've been seeing the seeing this is a bug text on quite a few odd items lately; it's not just cash cards.
Also, it's probably unintended that a max value cash card drops?
It's random, so rolling the maximum amount possible can happen legitimately.
I'm pretty sure that "seeing this is a bug" is caused by magazine code putting a null item inside charged items.
I checked another card I had on me, and it didn't have the text, so maybe it's something misloaded into the card.
There should probably be a maximum, does anyone think? I've never before seen anything near this high, and it's on a regular soldier, not in a bank vault or someplace. We all know it's usually not even near 100,000$, so there must already be some level of capping, right?
It's random, so rolling the maximum amount possible can happen legitimately.
It's not that random. The maximum amount you will ever roll on a cash card is only $1000, much less than this amount (which does exactly coincide with the maximum value a cash card can hold).
Could we potentially be seeing a negative overflow that gets capped to the maximum number of charges here?
@mugling The problem is in Item_group::create, but I don't know what the proper fix would be. The function calls e.ammo_set( default_ammo( e.ammo_type() ), e.ammo_capacity() );. ammo_capacity for the cash card is 200000000, that's where the bug happens.
The call only happens if the item group has "ammo" set (and the random roll triggers it) and if the cash card has 0 charges to begin with.
It can be reproduced very reliable with these changes:
"ammo": 100 in the the item group "mon_zombie_soldier_death_drops" (data/json/monsterdrops/zombie_soldier.json) - this ensures the ammo of the new item is always generated."rand_charges": [0,1] in the item type definition of "cash_card" (data/json/items/generic.json) - this makes half of the default created cards spawn with 0 charges, the other requirement to trigger the bug.One simple fix is to remove the 0 entry in "rand_charges", that would make all (randomly generated) cash cards spawn with at least one charge.
This is still happening. Just dropped one for me in build 5581
The bug mentioned by OP I think wasn't the maxxxed cash card but the 'this is a bug' description.
Ah, ok
I got a max value card, which seems bugged. But it doesn't have the "seeing this is a bug" text
I also got a max card in 0.C-5453. Zombie soldier as well, though no bug text.
This ArikVhedrovix's comment from duplicate issue should be useful:
Z Scientists seem to only drop cash cards with 0. Z soldier just dropped max 20000000 card.
Investigating this.
Interesting... LLDB itself crashes...
(lldb) c
Process 9727 resuming
Process 9727 stopped
* thread #1: tid = 0x1114b, 0x0000000100d37098 cataclysm-tiles`map::spawn_items(this=0x0000000126a13810, p=0x00000001198be3e8, new_items=size=12) + 1544 at map.cpp:4385, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100d37098 cataclysm-tiles`map::spawn_items(this=0x0000000126a13810, p=0x00000001198be3e8, new_items=size=12) + 1544 at map.cpp:4385
4382 if (new_item.made_of(LIQUID) && swimmable) {
4383 continue;
4384 }
-> 4385 item &it = add_item_or_charges(p, new_item);
4386 if( !it.is_null() ) {
4387 ret.push_back( &it );
4388 }
(lldb) p it
(item) $31 = {
rot = 0
last_rot_check = 0
fridge = 0
type = 0x000000011077afd8
contents = size=0 {}
name = "cash card"
damage_ = 0
curammo = 0x0000000000000000
item_vars = size=0 {}
corpse = 0x0000000000000000
techniques = size=0 {}
light = (luminance = 0, width = 0, direction = 0)
invlet = '\0'
charges = 0
active = false
burnt = 0
bday = 213356
poison = 0
frequency = 0
note = 0
irridation = 0
faults = size=0 {}
item_tags = size=0 {}
item_counter = 0
mission_id = -1
player_id = -1
components = size=0 {}
}
(lldb) c
Process 9727 resuming
Process 9727 stopped
* thread #1: tid = 0x1114b, 0x0000000100d37098 cataclysm-tiles`map::spawn_items(this=0x0000000126a13810, p=0x00000001198be3e8, new_items=size=12) + 1544 at map.cpp:4385, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100d37098 cataclysm-tiles`map::spawn_items(this=0x0000000126a13810, p=0x00000001198be3e8, new_items=size=12) + 1544 at map.cpp:4385
4382 if (new_item.made_of(LIQUID) && swimmable) {
4383 continue;
4384 }
-> 4385 item &it = add_item_or_charges(p, new_item);
4386 if( !it.is_null() ) {
4387 ret.push_back( &it );
4388 }
(lldb) p it
Segmentation fault: 11
BrettdeMacBook-Air:Cataclysm-DDA brett$
It is a little bit weird. I placed a zombie soldier and killed it using debug menu. When I am tracing the game in LLDB, LLDB itself crashes and the cash card dropped has 0 charge. But if I am running the game directly, the zombie soldier drops a cash card with 20000000 charges. WTF
I'd like to assign myself to this. I'm halfway there: rand_charges isn't read unless its JSON entry is within a spawn_data object/block. However, that's only part of the problem; 200,000,000 cash cards still appear for the reason that BevapDin cited above.
Most helpful comment
I'd like to assign myself to this. I'm halfway there:
rand_chargesisn't read unless its JSON entry is within aspawn_dataobject/block. However, that's only part of the problem; 200,000,000 cash cards still appear for the reason that BevapDin cited above.