]> git.cworth.org Git - empires-server/commitdiff
Don't let a new prompt get started when another is active
authorCarl Worth <cworth@cworth.org>
Tue, 9 Jun 2020 15:10:11 +0000 (08:10 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 9 Jun 2020 15:10:11 +0000 (08:10 -0700)
This avoids any negative side effect from a race condition where two
clients request a game to start within a short time window of each
other. When one prompt is active, the server will ignore any further
incoming requests to start a new prompt, (until the active one is
completed).

empathy.js

index 8ecf9e10fc9bb26e2a2068a65dfb87a420138b15..29d31bf7d46fbd0595e2ad8e6b3506057da387db 100644 (file)
@@ -43,6 +43,11 @@ class Empathy extends Game {
     if (! prompt)
       return false;
 
+    /* Ignore any start request that comes in while a prompt is
+     * already being played. */
+    if (this.state.active_prompt)
+      return false;
+
     this.state.active_prompt = prompt;
 
     this.broadcast_event_object('start', prompt);