Cataclysm-dda: Certain Items Being Cloned On Load

Created on 2 Jul 2020  路  11Comments  路  Source: CleverRaven/Cataclysm-DDA

Describe the bug

When I load my save, the game displays an error (see screenshot), and several items (a wooden spear, a hacksaw, and a stone shovel) fall on the ground at my feet. These are all items that I _have_ had in my inventory at one point or another, but do not currently have in my inventory when saving the game. In the case of the hacksaw, the original doesn't even exist, as it has been crafted into a survivor utility belt.

Steps To Reproduce

  1. Load the attached save.
  2. Move one square.

Expected behavior

For items to not spontaneously appear on the ground at my feet when I load the game.

Screenshots

The Error
1

The Items (multiple due to testing, it's 1 of each per load)
2

Versions and configuration

  • OS: Windows

    • OS Version: 10.0 1909

  • Game Version: 0.E-3669-g1c69950 [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    No Fungal Monsters [No_Fungi]
    ]

Additional context

save_and_log.zip

(S1 - Need confirmation) Containers stale

Most helpful comment

Yep, just thrown my leather backpack with 60000 crowbars in it into my fireplace.

All 11 comments

Same as #41648

Is it? They seem like completely unrelated issues...

The game is freezing because items are being cloned on load, and now there are literally thousands of items in a pocket where they don't fit. The cause of that issue is what this one describes.

It is happening with me too. My water purification tablet got multiplied till it was so heavy that I couldn't lift it, then I threw it in the fire and got another (15) but it is multiplying again... I have a small cardboard box with (1000) toast-em and the box itself is over 100 Kg, and I have a bucket "with 2 items" that when I wield it it becomes "none" and the bucket itself weighs 1253003,05 Kg...

Every time I wield it I am thrown on the floor hahaha

Yep, just thrown my leather backpack with 60000 crowbars in it into my fireplace.

There are several points may be related to duplication.

  1. In my first PR #41484 I forgot to delete some codes used for testing
    3

Even this is redundant, it should have been fine though, but then there is something may break the if-statement.

temp1

Lets assume that can_contain is totally ok.
while trying to call item_pocket::insert_item , if the pocket is not container, magazine or magazine_well (for example: MOD), the item will be forced to be put into that pocket regardless of return value(true/false) . If the return value is false, that item will also be added to uninserted_items and put into "MIGRATION".
And even in the original codes
temp5
it may cause duplication for the same reason.

beside of this, in #41733 the pocket type was removed, I don't know what will happen if a pocket dosn't have a type in json defined. Edit: nevermind, they are by default CONTAINER type viaoptional()

The problem can only be reproduced by saving/loading several times, so it is a bit hard to track and test. Such problems may need confirmation of the author of nested container.

PS: the hard part of solving container problems is to fix the corrupted save. one json change may get things to somewhere they shouldn't be and break everything. For a bad save ppl don't even know where an item should be, how could the "combine" function work properly?(If A gun never has CONTAINER pocket, we know mods should be in MOD. But if it has? where should the mods be?) Can only devide pockets into different types(and combine) if they are "good" before loading.

I believe I have found a way to trigger this bug in a clean save file. Can someone please tell me whether this is the same bug or not?

Variant 1 - duplicated items drop on the ground

  1. Create a world with the following mod and start a new game
[
  {
    "type": "MOD_INFO",
    "ident": "BUG",
    "name": "BUG",
    "category": "items"
  },
  {
    "type": "GENERIC",
    "id": "this_changes_volume_between_versions",
    "category": "other",
    "name": {"str": "BUG"},
    "description": "BUG",
    "weight": "1 g",
    "price": 800,
    "material": [ "paper" ],
    "symbol": "*",
    "color": "light_gray",

    "volume": "4 L"
  }
]
  1. Wear a purse (capacity: 5L)
  2. Put 1 BUG in the purse
  3. Save and quit
  4. Change the volume of BUG from 4L to 6L
  5. What should happen when you load the save? As far as the game is concerned there is now a 6L item in a 5L pocket. I am told that when this happens items are supposed to end up in a limbo called "migration pocket" and get dropped on the ground one turn after the game loads. This does happen, but the current implementation is buggy (see below)
  6. See the assertion "err: item too big" as intended
  7. Wait one turn
  8. See that the purse is empty and there is 1 BUG on the ground as intended
  9. Save and quit
  10. Load again
  11. See the assertion again even though the BUG is supposed to no longer be in the purse at this point
  12. Wait 1 turn
  13. See 2 BUGs on the ground
  14. Repeat steps 10 through 14 until you have the desired number of BUGs

Variant 2 - duplicated items remain in the purse

Same as above except instead of step 2 you should wear a backpack (id: backpack) and put the purse in the backpack

Note that this seems different from what others have described - they say things like "60000 crowbars" but I see no way to find out the contents of my "purse with 11 items"

They merged a fix that fixed this, or something like this, for me. Can the poster try the save that had this problem and try to recreate it to see if it still happens on the latest experimental?

I can no longer reproduce the variant 1 I described above. Variant 2 is still not fully fixed ("purse with none" stays and BUG is never dropped on the ground see #42273), but it no longer causes duplication.

- OS: Linux
    - OS Version: LSB Version: :core-4.1-amd64:core-4.1-noarch; Distributor ID: Fedora; Description: Fedora release 32 (Thirty Two); Release: 32; Codename: ThirtyTwo; 
- Game Version: 0.E-4254-gfea0266 [64-bit]
- Graphics Version: Tiles
- Game Language: System language []
- Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    BUG [BUG]
]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not \'bump\' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

This issue has been automatically closed due to lack of activity. This does not mean that we do not value the issue. Feel free to request that it be re-opened if you are going to actively work on it

Was this page helpful?
0 / 5 - 0 ratings