Maelstrom: When someone plays more than once, remember their last handle and use that if possible.

https://github.com/libsdl-org/Maelstrom/commit/968eb45aa0acb356fe8eeb5b32653789d4c8e15e

From 968eb45aa0acb356fe8eeb5b32653789d4c8e15e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 30 Oct 2011 17:05:56 -0400
Subject: [PATCH] When someone plays more than once, remember their last handle
 and use that if possible.

---
 netlogic/game.cpp          | 12 ++++++++++--
 screenlib/UIElementLabel.h |  3 +++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/netlogic/game.cpp b/netlogic/game.cpp
index 48c985ba..3bd24328 100644
--- a/netlogic/game.cpp
+++ b/netlogic/game.cpp
@@ -1000,18 +1000,26 @@ static void DoGameOver(void)
 		}
 
 		/* -- Let them enter their name */
-		chars_in_handle = 0;
-		handle[0] = '\0';
+		const char *text = NULL;
 		label = panel->GetElement<UIElementLabel>("name_label");
 		if (label) {
 			label->Show();
 		}
 		label = panel->GetElement<UIElementLabel>("name");
 		if (label) {
+			text = label->GetText();
 			label->Show();
 		}
 		ui->Draw();
 
+		/* Get the previously used handle, if possible */
+		if (text) {
+			SDL_strlcpy(handle, text, sizeof(handle));
+		} else {
+			handle[0] = '\0';
+		}
+		chars_in_handle = SDL_strlen(handle);
+
 		while ( screen->PollEvent(&event) ) /* Loop, flushing events */;
 		SDL_StartTextInput();
 		while ( label && !done ) {
diff --git a/screenlib/UIElementLabel.h b/screenlib/UIElementLabel.h
index ce493679..80f6bf24 100644
--- a/screenlib/UIElementLabel.h
+++ b/screenlib/UIElementLabel.h
@@ -35,6 +35,9 @@ DECLARE_TYPESAFE_CLASS(UIElement)
 
 	override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
 
+	const char *GetText() {
+		return m_text;
+	}
 	void SetText(const char *text);
 	void SetTextColor(Uint8 R, Uint8 G, Uint8 B);
 	void SetTextColor(Uint32 color);