Skip to content

Commit d6257bc

Browse files
committed
Fixes #383
1 parent 81b2832 commit d6257bc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/game/lobby.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ func advanceLobbyPredefineDrawer(lobby *Lobby, roundOver bool, newDrawer *Player
665665
},
666666
})
667667

668+
preSelectedWord := lobby.wordChoice[lobby.preSelectedWord]
668669
lobby.wordChoiceEndTime = getTimeAsMillis() + int64(wordChoiceDuration)*1000
669670
go func() {
670671
timer := time.NewTimer(time.Duration(wordChoiceDuration) * time.Second)
@@ -673,9 +674,15 @@ func advanceLobbyPredefineDrawer(lobby *Lobby, roundOver bool, newDrawer *Player
673674
lobby.mutex.Lock()
674675
defer lobby.mutex.Unlock()
675676

677+
// Timer is still from last round. Unlikely to happen, but there
678+
// was a bug report.
679+
if lobby.wordChoice[lobby.preSelectedWord] != preSelectedWord {
680+
return
681+
}
682+
676683
// We let the timer run out as long as it doesn't seem to cause any
677684
// issues and make sure it doesn't fire when it would break stuff.
678-
lobby.selectWord(int(lobby.preSelectedWord))
685+
lobby.selectWord(lobby.preSelectedWord)
679686
}()
680687

681688
lobby.SendYourTurnEvent(newDrawer)

0 commit comments

Comments
 (0)