Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix refueling of fires #31668

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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