From 1e6204da07147945e3cfb59c9cac6a08e01a6be9 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sun, 6 Jun 2021 17:17:47 -0700 Subject: [PATCH] Don't repeat queued events when saving immediately after they're dequeued for play. --- src/events/nonRandomEvent.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/events/nonRandomEvent.js b/src/events/nonRandomEvent.js index ab955569109..d6e124fba54 100644 --- a/src/events/nonRandomEvent.js +++ b/src/events/nonRandomEvent.js @@ -173,8 +173,8 @@ App.Events.playNonrandomEvent = function() { } d.append(App.Events.renderEventDebugger()); } else { - // pick the next scheduled, nonrandom, or queued event, if there is one - const event = App.Events.getNextNonrandomEvent() || App.Events.dequeueNextQueuedEvent(); + // pick the next scheduled or nonrandom event, if there is one + const event = App.Events.getNextNonrandomEvent(); if (event) { // record the chosen event in 'current' (pre-play!) history as well as current state so that it will serialize out correctly if saved from this passage // WARNING: THIS IS ***NOT*** THE ACTIVE STATE PAGE! @@ -183,8 +183,16 @@ App.Events.playNonrandomEvent = function() { event.execute(d); V.passageSwitchHandler = clearEvent; } else { - // no more events for this week, move on to random events (or ordinary Nonrandom for now, until we get rid of globalThis.nonRandomEvent) - setTimeout(() => Engine.play("Nonrandom Event"), Engine.minDomActionDelay); + // play the next queued event, if there is one + const qEvent = App.Events.dequeueNextQueuedEvent(); + if (qEvent) { + // we don't need to alter history when playing queued events, because the event instance is deterministically at the head of the queue already + qEvent.execute(d); + V.passageSwitchHandler = clearEvent; + } else { + // no more events for this week, move on to random events (or ordinary Nonrandom for now, until we get rid of globalThis.nonRandomEvent) + setTimeout(() => Engine.play("Nonrandom Event"), Engine.minDomActionDelay); + } } } } -- GitLab