Skip to content

Commit

Permalink
Merge pull request #31668 from ifreund/refuel-fire-fix
Browse files Browse the repository at this point in the history
Fix refueling of fires
  • Loading branch information
ZhilkinSerg authored Jun 20, 2019
2 parents fb8947e + 79f3328 commit d34fab8
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,16 +1413,22 @@ void try_fuel_fire( player_activity &act, player &p, const bool starting_fire )
fire_data fd( 1, contained );
time_duration fire_age = g->m.get_field_age( *best_fire, fd_fire );

// Maybe TODO: - refuelling in the rain could use more fuel
// Maybe TODO: - refueling in the rain could use more fuel
// First, simulate expected burn per turn, to see if we need more fuel
map_stack fuel_on_fire = g->m.i_at( *best_fire );
for( item &it : fuel_on_fire ) {
it.simulate_burn( fd );
// Uncontained fires grow below -50_minutes age
// Unconstrained fires grow below -50_minutes age
if( !contained && fire_age < -40_minutes && fd.fuel_produced > 1.0f && !it.made_of( LIQUID ) ) {
// Too much - we don't want a firestorm!
// Put item back to refuelling pile
move_item( p, it, 0, *best_fire - pos, *refuel_spot - pos, nullptr, -1 );
// Move item back to refueling pile
// Note: this handles messages (they're the generic "you drop x")
drop_on_map( p, item_drop_reason::deliberate, { it }, *refuel_spot );

const int distance = std::max( rl_dist( *best_fire, *refuel_spot ), 1 );
p.mod_moves( -Pickup::cost_to_move_item( p, it ) * distance );

g->m.i_rem( *best_fire, &it );
return;
}
}
Expand All @@ -1443,8 +1449,13 @@ void try_fuel_fire( player_activity &act, player &p, const bool starting_fire )
float last_fuel = fd.fuel_produced;
it.simulate_burn( fd );
if( fd.fuel_produced > last_fuel ) {
// Note: move_item() handles messages (they're the generic "you drop x")
move_item( p, it, 0, *refuel_spot - p.pos(), *best_fire - p.pos(), nullptr, -1 );
// Note: this handles messages (they're the generic "you drop x")
drop_on_map( p, item_drop_reason::deliberate, { it }, *best_fire );

const int distance = std::max( rl_dist( *refuel_spot, *best_fire ), 1 );
p.mod_moves( -Pickup::cost_to_move_item( p, it ) * distance );

g->m.i_rem( *refuel_spot, &it );
return;
}
}
Expand Down

0 comments on commit d34fab8

Please sign in to comment.