Here’s a weird bug that took about a month to crack.
Sometimes when playing multiplayer, a party member, host or not, would get stuck in the wall, unable to move, but only visually for other party members. The player was moving around just fine on their screen. What was going on? Checking the network calls, everyone was receiving movement data, but that movement data wasn’t being applied.
A big problem was that this bug was not consistently reproducible. When I tested multiplayer a lot, it would never come up. But it would come up when I was not testing for it.
The first thing I tried was to force new tower creations to create new screens. This was relevant because a new screen would create new objects and reset all fields. But the bug persisted.
I began noticing patterns for when players would get stuck in walls. It would never happen on the first tower playthrough, but on the second and onwards if the host launches a new tower after completing one. Also, they would only be stuck in the bottom-left room on the floor. And then it hit me.
I am keeping a sequence number to prevent the display of movement using outdated data. For example, if a doggo moves from tile 0 to 4 (sequence 1), then 4 to 8 (sequence 2), then 8 to 12 (sequence 3), and that middle network call was delayed, we can show that the doggo moves from 0 to 4 (sequence 1), then teleports to 8, then moves from 8 to 12 (sequence 3). That movement from 4 to 8 (sequence 2) would eventually be received and dropped due to being a lower sequence than the last one displayed.
The problem occurs when the host starts a new tower, and movement data gets delayed. When a new tower is created, everyone’s sequence number is reset to 1, but party members could receive delayed movement data from the previous tower. The latest sequence received is a high number, but new movement data starts at 1, and therefore ignored.
Being stuck in the bottom-left room is relevant because the boss room is a single room on a floor, which means its floor coordinates always correspond to the bottom-left room.
The fix is to not reset the sequence number when a new tower is created. This would allow the party members to correctly ignore old movement data from the previous tower.
Leave a Reply