Trapped doors reset if you close the door then re-enter the level in multiplayer
Operating System
Windows x64
DevilutionX version
Other (please specify version number)
Describe
UpdateTrapState returns early if it uses a door as a trigger and the door is closed. This means that in a multiplayer game a player can set off a trap twice by leaving the level and replaying the delta
To Reproduce
Start or join a multiplayer game find a level with a trapped door open the door, close it, and observe the door is "Closed door" and not "Trapped door" (if playing as a rogue) Leave the level then re-enter Observe the door label is "Trapped door" (if playing as a rogue) Open the door, note the trap fires again
Expected Behavior
Traps on doors should only trigger once
Additional context
I suspect this can happen in vanilla but haven't found a trapped door yet to be able to test.
Actually this might be because close door messages aren't processed when replaying the delta? Probably need a handler to clear trap flag so the door is marked as being touched
For easy testing in vanilla: 0x441CC2 - C7 45 F4 0A000000 - mov [ebp-0C],0000000A { 10 } 0x441CC2 - C7 45 F4 64000000 - mov [ebp-0C],00000064 { 100 } = guaranteed traps :P
Confirmed vanilla bug
if you can review https://github.com/diasurgical/devilutionX/pull/5169 then it should be easy for me to fix it, with out conflicts :)
I wonder if this is also the case for chest using the Thaumaturgic shrines
I wonder if this is also the case for chest using the Thaumaturgic shrines
Looks like it could be an issue depending on the order messages are played back. In vanilla if a chest spawns after the shrine it will get it's state changed after the shrine refill logic runs so won't be correct. With master using unordered object deltas devx is harder to predict, we would need to order the messages or somehow prevent the change to selflag while ensuring trapflag is updated.
Edit: guess that's why they're singleplayer only 😂, would be nice to solve that and let them spawn in multi.
Been meaning to finish reviewing that PR as well, it's an open tab 😅.