Skip to content

Commit

Permalink
Bail out of fire processing code if we cook off some ammo.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingranade committed Dec 30, 2014
1 parent f4230a0 commit 805923f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,12 @@ bool map::process_fields_in_submap( submap *const current_submap,
int time_added = 0;

if( special || cookoff ) {
const long rounds_exploded = rng( 1, fuel->charges );
int charges_remaining = fuel->charges;
const long rounds_exploded = rng( 1, charges_remaining );
// Yank the exploding item off the map for the duration of the explosion
// so it doesn't blow itself up.
item temp_item = *fuel;
items_here.erase( fuel );
// cook off ammo instead of just burning it.
for(int j = 0; j < (rounds_exploded / 10) + 1; j++) {
if( cookoff ) {
Expand All @@ -631,8 +636,14 @@ bool map::process_fields_in_submap( submap *const current_submap,
ammo_effects( x, y, ammo_type->ammo_effects );
}
}
burn_amt = rounds_exploded;

charges_remaining -= rounds_exploded;
if( charges_remaining > 0 ) {
temp_item.charges = charges_remaining;
items_here.push_back( temp_item );
}
// Can't find an easy way to handle reinserting the ammo into a potentially
// invalidated list and continuing iteration, so just bail out.
break;
} else if( fuel->made_of("paper") ) {
//paper items feed the fire moderately.
base_burn_amt = 3;
Expand Down Expand Up @@ -729,14 +740,7 @@ bool map::process_fields_in_submap( submap *const current_submap,
}
}
if (!destroyed) {
if (ammo_type != NULL) {
burn_amt = std::min( burn_amt, (int)fuel->charges );
fuel->charges -= burn_amt;
consumed += burn_amt / base_burn_amt;
destroyed = fuel->charges <= 0;
} else {
destroyed = fuel->burn( burn_amt );
}
destroyed = fuel->burn( burn_amt );
}

//lower age is a longer lasting fire
Expand Down

0 comments on commit 805923f

Please sign in to comment.