]> git.cworth.org Git - empires-server/commitdiff
empires: Return immediately from reveal_next if we aren't in the REVEAL state
authorCarl Worth <cworth@cworth.org>
Sun, 17 May 2020 19:28:35 +0000 (12:28 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 17 May 2020 19:28:35 +0000 (12:28 -0700)
I think this fix came about after Kevin did some testing by mashing on
all of the host buttons as fast as possible.

It's definitely a correct fix as far as it's true we shouldn't be
revealing anything if we're not in the REVEAL state. But I think we're
due for a better audit of what's happening to various pieces of state
on state transitions, (such as, shouldn't the interval timer get
cleared before we _leave_ the REVEAL state).

empires.js

index b0fc79ea2fb664c52246549f6c720a81b2f93391..2794c47ee41006098f3547ec685049eef7f0d520 100644 (file)
@@ -79,6 +79,12 @@ class Game {
   }
 
   reveal_next() {
+    /* Don't try to reveal anything if we aren't in the reveal state. */
+    if (this.state != GameState.REVEAL) {
+      clearInterval(this.reveal_interval);
+      return;
+    }
+
     if (this.reveal_index >= this.characters_to_reveal.length) {
       clearInterval(this.reveal_interval);
       this.broadcast_event("character-reveal", '{"character":""}');