From 394ff8f28536dba16d27b50467c7f60de05f90ef Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sat, 28 Dec 2019 12:53:37 +0100 Subject: [PATCH] Change ENUMBRANCE_UPDATE item flag to boolean member: This means: - it's ignored when comparing items (items with the flag stack together with items that don't have the flag), - it's not saved, it's temporary anyway. --- src/character.cpp | 4 ++-- src/item.cpp | 2 +- src/item.h | 5 +++++ src/player.cpp | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index eee5bd5c8c1ea..5d2f75985b3f6 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -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 ) { diff --git a/src/item.cpp b/src/item.cpp index 149c566937a5e..4d5d3a848a292 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -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 ) diff --git a/src/item.h b/src/item.h index f0ac233d5ef52..b1a5017b510bc 100644 --- a/src/item.h +++ b/src/item.h @@ -2138,6 +2138,11 @@ class item : public visitable 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. diff --git a/src/player.cpp b/src/player.cpp index dfa0f4897b9c1..fbfe23d0c5b07 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -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();