Maelstrom: Fixed backwards stutter at the end of the wave

From 3b535f122bfd2bb871e4f9ef9a18da0e2773dd5f Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 26 Apr 2026 11:56:20 -0700
Subject: [PATCH] Fixed backwards stutter at the end of the wave

Make sure that we draw the frame before starting the fade in DoBonus()
---
 game/game.cpp | 14 +++++++-------
 game/game.h   |  1 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/game/game.cpp b/game/game.cpp
index 36aa1612..ea2bd917 100644
--- a/game/game.cpp
+++ b/game/game.cpp
@@ -415,7 +415,7 @@ GamePanelDelegate::OnTick()
 		return;
 	}
 
-	if ( gGameInfo.GetLocalState() & STATE_BONUS ) {
+	if (m_state == STATE_START_BONUS || (gGameInfo.GetLocalState() & STATE_BONUS)) {
 		return;
 	}
 
@@ -578,17 +578,13 @@ GamePanelDelegate::OnDraw(DRAWLEVEL drawLevel)
 		return;
 	}
 
-	if (m_state != STATE_PLAYING) {
+	if (m_state != STATE_PLAYING && m_state != STATE_START_BONUS) {
 		return;
 	}
 
 	/* Draw the status frame */
 	DrawStatus(false);
 
-	if ( gGameInfo.GetLocalState() & STATE_BONUS ) {
-		return;
-	}
-
 	StartZoomedDrawing();
 
 	if (m_background) {
@@ -626,6 +622,10 @@ GamePanelDelegate::OnDraw(DRAWLEVEL drawLevel)
 	}
 
 	StopZoomedDrawing();
+
+	if (m_state == STATE_START_BONUS) {
+		DoBonus();
+	}
 }
 
 bool
@@ -1459,7 +1459,7 @@ GamePanelDelegate::NextWave()
 	}
 
 	if (gWave != (gGameInfo.wave - 1)) {
-		DoBonus();
+		m_state = STATE_START_BONUS;
 	} else {
 		m_state = STATE_START_NEXT_WAVE;
 	}
diff --git a/game/game.h b/game/game.h
index c7eeb2c7..57ea492c 100644
--- a/game/game.h
+++ b/game/game.h
@@ -102,6 +102,7 @@ class GamePanelDelegate : public UIPanelDelegate
 
 	enum {
 		STATE_PLAYING,
+		STATE_START_BONUS,
 		STATE_SHOW_BONUS,
 		STATE_BONUS_SHOW_VALUE,
 		STATE_BONUS_SHOW_MULTIPLIER,