diff --git a/src/item.cpp b/src/item.cpp index 1dc503263ce9c..f7aab5d9f3a45 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -8124,6 +8124,7 @@ bool item::reload( Character &u, item_location ammo, int qty ) return false; } + bool ammo_from_map = !ammo.held_by( u ); item_location container; if( ammo->has_flag( flag_SPEEDLOADER ) ) { container = ammo; @@ -8215,6 +8216,9 @@ bool item::reload( Character &u, item_location ammo, int qty ) put_in( *ammo, item_pocket::pocket_type::MAGAZINE_WELL ); ammo.remove_item(); + if( ammo_from_map ) { + u.invalidate_weight_carried_cache(); + } return true; } @@ -8224,6 +8228,9 @@ bool item::reload( Character &u, item_location ammo, int qty ) u.inv->restack( u ); // emptied containers do not stack with non-empty ones } } + if( ammo_from_map ) { + u.invalidate_weight_carried_cache(); + } return true; } @@ -8721,6 +8728,8 @@ int item::fill_with( const item &contained, const int amount ) debugmsg( "tried to put an item (%s) in a container (%s) that cannot contain it", contained_item.typeId().str(), typeId().str() ); } + on_contents_changed(); + get_avatar().invalidate_weight_carried_cache(); return num_contained; } diff --git a/src/pickup.cpp b/src/pickup.cpp index d9f8725e38232..bb4d200f6c1c4 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -369,6 +369,8 @@ bool pick_one_up( item_location &loc, int quantity, bool &got_water, bool &offer loc.remove_item(); } player_character.moves -= moves_taken; + player_character.flag_encumbrance(); + player_character.invalidate_weight_carried_cache(); } return picked_up || !did_prompt; diff --git a/src/player.cpp b/src/player.cpp index 91ecb1ef57d93..cfbca279c54a0 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2433,6 +2433,7 @@ bool player::unload( item_location &loc, bool bypass_activity ) if( changed ) { it.on_contents_changed(); + invalidate_weight_carried_cache(); } return true; }