Attempting to fire causes a crash.
wield bow, press 'f'
I'm having the same on latest game compiled from source VERSION: 0.D-4506-ge5ea394
This happens with bow, but also with a crossbow which I forgot to 'r'eload...(when it shows as crossbow 0/1)
I did a little digging and this started with build 9143 per http://gorgon.narc.ro:8080/job/Cataclysm-Matrix/changes, which includes 64516a6b95b32e522ed6732b740a5cf178664d57
In avatar_action::fire():
On the else if line, the code starts by calling weapon.ammo_data():
The is_gun() condition is true, but the loop fails at finding a valid item.
auto mods = is_gun() ? gunmods() : toolmods();
for( const auto e : mods ) {
if( !e->type->mod->ammo_modifier.empty() &&
item_controller->has_template( e->ammo_current() ) ) {
return item_controller->find_template( e->ammo_current() );
}
The code ends by returning curammo:
But curammo is null:
> ? weapon.curammo
0x0000000000000000 <NULL>
So it's obviously crashing on a null pointer while dereferencing ammo here (in avatar_action::fire):
weapon.ammo_data()->ammo
Crashing with rifles as well, upon attempting to fire while the gun is _not loaded_. Happens 100% of the time.
Most helpful comment
In
avatar_action::fire():https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/avatar_action.cpp#L701-L709
On the
else ifline, the code starts by callingweapon.ammo_data():https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/item.cpp#L5878-L5902
The
is_gun()condition is true, but the loop fails at finding a valid item.The code ends by returning
curammo:https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/item.cpp#L5901
But
curammois null:So it's obviously crashing on a null pointer while dereferencing
ammohere (inavatar_action::fire):