From: Carl Worth Date: Tue, 9 Jun 2020 15:10:11 +0000 (-0700) Subject: Don't let a new prompt get started when another is active X-Git-Url: https://git.cworth.org/git?p=empires-server;a=commitdiff_plain;h=c415c76ac632b8e55cf0260c52ebc7c77836614e Don't let a new prompt get started when another is active 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). --- diff --git a/empathy.js b/empathy.js index 8ecf9e1..29d31bf 100644 --- a/empathy.js +++ b/empathy.js @@ -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);