Closed Demid65 closed 6 months ago
I appreciate you taking the time to solve this issue. However I can't necessarily recreate the bug. Loading a pawn twice doesn't result in any errors for me. Could you give some more information on what is exactly breaking and how to reproduce this?
Well, it will help in general, but it needs to be systematically fixed for all things, not just pawns, because it does not fix #91 for me. Also save game have a huge next ids section, I suggest you to use this instead doing +1
<uniqueIDsManager>
<nextThingID>264429</nextThingID>
<nextBillID>8</nextBillID>
<nextFactionID>20</nextFactionID>
<nextLordID>62</nextLordID>
<nextTaleID>3440</nextTaleID>
<nextPassingShipID>4</nextPassingShipID>
<nextWorldObjectID>57</nextWorldObjectID>
<nextMapID>6</nextMapID>
<nextCaravanID>11</nextCaravanID>
<nextAreaID>36</nextAreaID>
<nextTransporterGroupID>11</nextTransporterGroupID>
<nextAncientCryptosleepCasketGroupID>1</nextAncientCryptosleepCasketGroupID>
<nextJobID>941329</nextJobID>
<nextSignalTagID>1</nextSignalTagID>
<nextWorldFeatureID>4</nextWorldFeatureID>
<nextHediffID>8135</nextHediffID>
<nextBattleID>106</nextBattleID>
<nextLogID>19830</nextLogID>
<nextLetterID>256</nextLetterID>
<nextArchivedDialogID>2</nextArchivedDialogID>
<nextMessageID>1716</nextMessageID>
<nextZoneID>4</nextZoneID>
<nextQuestID>31</nextQuestID>
<nextGameConditionID>10</nextGameConditionID>
<nextIdeoID>14</nextIdeoID>
<nextPreceptID>832</nextPreceptID>
<nextPresenceDemandID>28</nextPresenceDemandID>
<nextTransportShipID>18</nextTransportShipID>
<nextShipJobID>65</nextShipJobID>
<nextAbilityID>589</nextAbilityID>
<nextGeneID>6488</nextGeneID>
<nextStorageGroupID>10</nextStorageGroupID>
</uniqueIDsManager>
Fox example: psy abilities inside the pawn def have it's own ids. Hediffs inside the pawn def have it's own ids. Equipment inside the pawn def have it's own ids, etc... All those things are being copied and need to be renumbered recursively on load/copy.
Specifically for psy abilities: when you have a copy of a pawn with psy abilities, only one pawn can use them. All the copies will fail to do so and/or cast the ability as if it was done by the initial pawn.
Theoretically these issues sounds far, but I am just unable to reproduce it. I've tried doing the following;
This results in no issues and both seem to cast their own psycast.
Your order is off, you need to:
That is it, after that just continue playing, save/load, try to cast psycasts on different pawns, you'll see weird stuff I've described. Also red errors will begin to emerge at some point saying it can't find some objects or objects have the same ids. Broken save (rename to report_test_01.rws): report_test_01.txt
I appreciate you taking the time to solve this issue. However I can't necessarily recreate the bug. Loading a pawn twice doesn't result in any errors for me. Could you give some more information on what is exactly breaking and how to reproduce this?
As I stated before:
This happens because A and A2 have identical ThingID and relations are resolved trough ThingID. Same thing happens with sharkman, but with psycasts and abilities, which also have their IDs.
The fix I provided solves the issue with Pawn.ThingID but does not do anything for psycasts or other things.
Well, it will help in general, but it needs to be systematically fixed for all things, not just pawns, because it does not fix #91 for me. Also save game have a huge next ids section, I suggest you to use this instead doing +1
I will take a look at that.
I think I managed to reproduce it, but seems like there's a lot more weird stuff going on. I'm going to have to take a deeper look into the whole saving/loading. Sorry for all the trouble.
@ISOR3X I'm glad you managed to reproduce it. Just remember that all IDs in the game are supposed to be unique, must be unique even. When a game encounters an ID collision it does not know what to do, which results in weird behaviour. At first, it looks like it continues to function with ID collision, but at some point, usually at save/load, or quest/relation generation, it will fail, which will be indicated in the console.
Closing the pull request, since we would need a better solution that the one I provided.
Added a fix for the issue with duplicate ThingID on pawn loading. Additionally, clearing the relations for the loaded pawn on collision, to prevent broken relations.