Cataclysm-dda: Wielding some containers doesn't preserve their contents

Created on 10 Feb 2019  路  3Comments  路  Source: CleverRaven/Cataclysm-DDA

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

  1. Wield an empty bucket
  2. Put water into the bucket
  3. Drop the bucket on the ground
  4. Use the Wield command to wield the bucket. Observe that the liquid it contained is now on the ground.

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):

  • OS: Windows 8
  • Game Version: 0.C-37392-gc602844
  • Tiles
  • Mods loaded: Many. I'm not sure this matters, but I can provide the list, if this behavior isn't present in vanilla.

Additional context
None

<Bug> Items / Item Actions / Item Qualities

Most helpful comment

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.

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tsunder picture Tsunder  路  3Comments

jeremyshannon picture jeremyshannon  路  3Comments

BorkBorkGoesTheCode picture BorkBorkGoesTheCode  路  3Comments

Coolthulhu picture Coolthulhu  路  3Comments

Cyrano7 picture Cyrano7  路  3Comments