From 063c388fb6e4b7365d005cd25f56844ef94aca51 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 16 Nov 2025 10:27:24 -0800
Subject: [PATCH] Fixed using backspace in the high score entry
Fixes https://github.com/libsdl-org/Maelstrom/issues/3
---
netlogic/game.cpp | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/netlogic/game.cpp b/netlogic/game.cpp
index 578ca3af..d4c3bad8 100644
--- a/netlogic/game.cpp
+++ b/netlogic/game.cpp
@@ -801,6 +801,7 @@ static void DoGameOver(void)
/* -- Let them enter their name */
w = 0;
chars_in_handle = 0;
+ handle[chars_in_handle] = '\0';
while ( screen->PollEvent(&event) ) /* Loop, flushing events */;
SDL_StartTextInput();
@@ -813,10 +814,12 @@ static void DoGameOver(void)
case SDLK_RETURN:
done = true;
break;
+ case SDLK_BACKSPACE:
case SDLK_DELETE:
if ( chars_in_handle ) {
sound->PlaySound(gExplosionSound, 5);
--chars_in_handle;
+ handle[chars_in_handle] = '\0';
}
break;
default:
@@ -831,21 +834,16 @@ static void DoGameOver(void)
} else {
sound->PlaySound(gBonk, 5);
}
- screen->FillRect(x, 300-newyork_height+2,
- w, newyork_height, ourBlack);
-
handle[chars_in_handle] = '\0';
- w = DrawText(x, 300, handle,
- newyork, STYLE_NORM, 0xFF, 0xFF, 0xFF);
- screen->Update();
}
+
+ screen->FillRect(x, 300 - newyork_height + 2, w, newyork_height, ourBlack);
+ w = DrawText(x, 300, handle, newyork, STYLE_NORM, 0xFF, 0xFF, 0xFF);
+ screen->Update();
}
delete newyork;
SDL_StopTextInput();
- /* In case the user just pressed <Return> */
- handle[chars_in_handle] = '\0';
-
hScores[which].wave = gWave;
hScores[which].score = OurShip->GetScore();
SDL_strlcpy(hScores[which].name, handle, sizeof(hScores[which].name));