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 the ENCUMBRANCE_UPDATE flag again: #36503

Merged
merged 2 commits into from
Dec 28, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,10 +1266,10 @@ void Character::check_item_encumbrance_flag()
{
bool update_required = check_encumbrance;
for( auto &i : worn ) {
if( !update_required && i.has_flag( "ENCUMBRANCE_UPDATE" ) ) {
if( !update_required && i.encumbrance_update_ ) {
update_required = true;
}
i.unset_flag( "ENCUMBRANCE_UPDATE" );
i.encumbrance_update_ = false;
}

if( update_required ) {
Expand Down
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3697,7 +3697,7 @@ void item::on_contents_changed()
convert( type->container->unseals_into );
}

set_flag( "ENCUMBRANCE_UPDATE" );
encumbrance_update_ = true;
}

void item::on_damage( int, damage_type )
Expand Down
5 changes: 5 additions & 0 deletions src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,11 @@ class item : public visitable<item>
int mission_id = -1; // Refers to a mission in game's master list
int player_id = -1; // Only give a mission to the right player!

// Set when the item / its content changes. Used for worn item with
// encumbrance depending on their content.
// This not part serialized or compared on purpose!
bool encumbrance_update_ = false;

private:
/**
* Accumulated rot, expressed as time the item has been in standard temperature.
Expand Down
4 changes: 2 additions & 2 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3318,10 +3318,10 @@ void player::process_items()
} else if( identifier == "adv_UPS_off" ) {
ch_UPS += w.ammo_remaining() / 0.6;
}
if( !update_required && w.has_flag( "ENCUMBRANCE_UPDATE" ) ) {
if( !update_required && w.encumbrance_update_ ) {
update_required = true;
}
w.unset_flag( "ENCUMBRANCE_UPDATE" );
w.encumbrance_update_ = false;
}
if( update_required ) {
reset_encumbrance();
Expand Down
2 changes: 1 addition & 1 deletion src/weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ int get_local_windchill( double temperature, double humidity, double windpower )
// model being designed for reasonable ambient temperature values,
// rather than extremely high ones.
windchill = 0.33 * std::min<float>( 150.00, humidity / 100.00 * 6.105 *
exp( 17.27 * tmptemp / ( 237.70 + tmptemp ) ) ) - 0.70 *
exp( 17.27 * tmptemp / ( 237.70 + tmptemp ) ) ) - 0.70 *
tmpwind - 4.00;
// Convert to Fahrenheit, but omit the '+ 32' because we are only dealing with a piece of the felt air temperature equation.
windchill = windchill * 9 / 5;
Expand Down