audinowho / PMDODump

All content generation for PMDO. BEWARE SPOILERS.
MIT License
52 stars 12 forks source link

Desync on Tutor Spawn #434

Closed issuebotaudinowho[bot] closed 5 months ago

issuebotaudinowho[bot] commented 5 months ago

Discord: 2tousent#0 <@712344233570205776>

RC: Another desync, found this after the quicksave messed things up: https://media.discordapp.net/attachments/759800392568668171/1204084962417057852/image.png?ex=65d37281&is=65c0fd81&hm=22427c9f77ae2d79a2fe0da95d23112bd5fe15061f183986f6137d95c9fb6c69&=&format=webp&quality=lossless&width=840&height=670 It happens somewhere arround this part, on b2f, but only sometimes: Sometimes the murkrow dissapears into the grass, and that's fine, but sometimes it approaches and causes the desync.


Exception Depth: 0
System.InvalidOperationException: Recorded action failed: Move Down [1]

Lua Trace:
stack traceback:

Coroutine Trace:
RogueEssence.Dungeon.DungeonScene+<ProcessPlayerInput>d__113
RogueEssence.Dungeon.DungeonScene+<ProcessInput>d__192
RogueEssence.Dungeon.DungeonScene+<ProcessInput>d__191
RogueEssence.GameManager+<ScreenMainCoroutine>d__65```
![image](https://cdn.discordapp.com/attachments/818266922734190603/1204108091096956978/Ambush_Forest_Desync.rsrec?ex=65d3880c&is=65c1130c&hm=3d4fd1320645f8f4359423ae4307e9dccaa05b5988e8c51c5fd4236ef0efc0fd&)
audinowho commented 5 months ago

https://github.com/audinowho/DumpAsset/commit/2e3ad65d39c614337f890e19296092d628f6a939

The desync manifested as the tutor spawning code giving a random spawn despite all randoms being tied to the dungeon seed. The desync occurred on the Lua level, because iterating through lua tables has an INDETERMINATE ORDER. When possible moves were being iterated, they came in random order and thus a replay-independent random choice was made, even when the random index was replay-dependent.

Caution must be taken from here on to make sure natural dictionary iteration does not occur in any lua script that is called in dungeon, or bad things like this will happen! We now have a COMMON.GetSortedKeys(dict) method to ensure a consistent order of iteration for lua dictionaries.