devilutionX icon indicating copy to clipboard operation
devilutionX copied to clipboard

Trapped doors reset if you close the door then re-enter the level in multiplayer

Open ephphatha opened this issue 3 years ago • 6 comments

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.

ephphatha avatar Aug 03 '22 15:08 ephphatha

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

ephphatha avatar Aug 03 '22 15:08 ephphatha

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

qndel avatar Aug 03 '22 15:08 qndel

Confirmed vanilla bug

qndel avatar Aug 03 '22 15:08 qndel

if you can review https://github.com/diasurgical/devilutionX/pull/5169 then it should be easy for me to fix it, with out conflicts :)

AJenbo avatar Aug 03 '22 15:08 AJenbo

I wonder if this is also the case for chest using the Thaumaturgic shrines

AJenbo avatar Aug 03 '22 16:08 AJenbo

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 😅.

ephphatha avatar Aug 03 '22 21:08 ephphatha