81 - Duplicate Item UID [resolved]

Locked
User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

81 - Duplicate Item UID [resolved]

Post by Interkarma »

So far this happens only after loading a prior dungeon save. When looting a body, any item (other than gold) clicked on throws a duplicate item UID error. The item is also destroyed at the time.

Exiting and re-entering dungeon appears to solve this, as does starting a new game. I've attached a save to reproduce. Hack away at some enemies and loot their bodies afterwards.

Not sure if this is related to changes in item lists, or has been present for a while. Going to back-test against some older versions to see if this is a regression or not.

Edit: Can confirm problem exists in older builds. Treating this as my issue and will look into this when I can.
Attachments
SAVE89.zip
(74.73 KiB) Downloaded 152 times

User avatar
Midknightprince
Posts: 1324
Joined: Fri Aug 11, 2017 6:51 am
Location: San Antonio TX
Contact:

Re: (Live Code) - Duplicate Item UID

Post by Midknightprince »

@Interkarma
Yeah, this happend to me.
I thought I was imagining things .
You're awesome dude :D
Check out my YouTube Channel!

R.D.
Posts: 379
Joined: Fri Oct 07, 2016 10:41 am

Re: (Live Code) - Duplicate Item UID

Post by R.D. »

Looks like the problem has existed since my implementation of enemy equipment (commit bf6b282).

In the save game I'm testing, the duplicate uIDs of the equipment from the enemy are the same as the uIDs of magic items in the player character's inventory. Does that bring anything to mind Interkarma? Why does the item collection for the loot container of the corpse have the uIDs of the player's inventory in it, I wonder. Should uIDs be unique globally or just within a single item collection?

R.D.
Posts: 379
Joined: Fri Oct 07, 2016 10:41 am

Re: (Live Code) - Duplicate Item UID

Post by R.D. »

The problem seems to only happen on the first game loaded after starting DF Unity. If you load the save after loading another save, or load the same save twice, the problem doesn't happen.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: (Live Code) - Duplicate Item UID

Post by Interkarma »

UIDs should be globally unique. The only way to obtain a UID also increments to the next UID automatically, and the current UID position is saved with the player's game.

This error happens only when saving inside a dungeon then loading that save again. It doesn't happen if you do a full dungeon clear within a single session (i.e. after entering dungeon from outside). My feeling is the enemy equipment might not be serialized/deserialized properly, causing it to pick up a bad UID on load somehow. I'm about to hit the sack in the next 30 minutes or so, feeling a bit tired to chase this down further tonight. I'll take another look after work tomorrow.

Thank you for locating the commit where problem started. :)

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: (Live Code) - Duplicate Item UID

Post by Interkarma »

OK this should be fixed now in live code. There were two main problems:
  1. Enemy's own loot was being equipped but the DaggerfallUnityItem was not added to their item collection. While the equip table stores items at runtime, it's just serialized as a list of UIDs into loot collection. I've fixed this now so enemy's personal loot is added to their loot collection, which automatically transfers to corpse loot container on death (no need for any extra handling for this).
  2. Second issue was that enemy loot collection and equip table was not being serialized. I've made sure this is done now.
For any existing dungeon saves, player will need to exit/enter dungeon to generate correct data.

I've also changed enemy saving so they are always saved. This is first part of a larger fix for enemies respawning on load and duplicate loadIDs.

Locked