Skip to content

Commit

Permalink
Fix falsely flipped fire feeding (#47092)
Browse files Browse the repository at this point in the history
Rename the negated boolean variable `no_fire` to `have_fire` and
un-negate its usage.

Make `have_fire` default true, so `player_activity::do_turn` will check
for the presence of fire at least once.
  • Loading branch information
wapcaplet authored Jan 29, 2021
1 parent 6dd0a5d commit 302ba1a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,7 @@ int get_auto_consume_moves( player &p, const bool food )
return 0;
}

// Try to add fuel to a fire. Return true if there is both fire and fuel; return false otherwise.
bool try_fuel_fire( player_activity &act, player &p, const bool starting_fire )
{
const tripoint pos = p.pos();
Expand Down
6 changes: 3 additions & 3 deletions src/player_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ void player_activity::do_turn( player &p )
}
// first to ensure sync with actor
synchronize_type_with_actor();
// Should happen before activity or it may fail du to 0 moves
if( *this && type->will_refuel_fires() && !no_fire ) {
no_fire = !try_fuel_fire( *this, p );
// Should happen before activity or it may fail due to 0 moves
if( *this && type->will_refuel_fires() && have_fire ) {
have_fire = try_fuel_fire( *this, p );
}
if( calendar::once_every( 30_minutes ) ) {
no_food_nearby_for_auto_consume = false;
Expand Down
5 changes: 3 additions & 2 deletions src/player_activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ class player_activity
*/
bool auto_resume = false;
/** Flag that will suppress the relatively expensive fire refueling search process.
*/
bool no_fire = true;
* Initially assume there is a fire unless the activity proves not to have one.
*/
bool have_fire = true;

player_activity();
// This constructor does not work with activities using the new activity_actor system
Expand Down

0 comments on commit 302ba1a

Please sign in to comment.