Describe the bug
Containers that do not have the Resealable flag will have their contents stay on the ground, after wielding them with the Wield command. I believe this is a bug, and the correct behavior happens with the Examine command, which allows the player to wield the container with its contents intact.
The Wield bug does not seem to exist with containers that can be resealed.
To Reproduce
Expected behavior
Wielding all containers preserves their contents.
Workaround
Use the Examine command to examine the tile with the container and wield it that way. This correctly preserves container contents.
Versions and configuration(please complete the following information):
Additional context
None
I can confirm this bug occurs in vanilla.
Ok, I know what's happening here. When game::wield( item_location ) is called it calls player::wield( item ) in the following line
u.wield( u.i_at( loc.obtain( u ) ) );
loc.obtain( u ) moves the item to the player's inventory, causing item::on_pickup() to be called which spills the contents. Other methods of wielding don't first put the item in the character's inventory, hence the inconsistency.
Should get to fixing this tomorrow.
Fixed by #28248
Most helpful comment
Ok, I know what's happening here. When
game::wield( item_location )is called it callsplayer::wield( item )in the following lineloc.obtain( u )moves the item to the player's inventory, causingitem::on_pickup()to be called which spills the contents. Other methods of wielding don't first put the item in the character's inventory, hence the inconsistency.Should get to fixing this tomorrow.