Maelstrom: Fixed build warnings

From 3b56b90792411e0956877513c5baeb8fb193fa2c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 11 Mar 2026 17:06:46 -0700
Subject: [PATCH] Fixed build warnings

---
 game/MaelstromUI.cpp      |  2 +-
 game/player.h             |  3 ---
 game/replay.cpp           |  5 +++--
 maclib/Mac_Resource.cpp   |  5 +++--
 maclib/macres.cpp         |  2 +-
 screenlib/UIArea.cpp      |  2 +-
 screenlib/UIBaseElement.h | 24 ++++++++++++------------
 7 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/game/MaelstromUI.cpp b/game/MaelstromUI.cpp
index 0b76030b..c78fd118 100644
--- a/game/MaelstromUI.cpp
+++ b/game/MaelstromUI.cpp
@@ -256,7 +256,7 @@ UITexture *
 MaelstromUI::CreateText(const char *text, const char *fontName, int fontSize, UIFontStyle fontStyle, Uint32 color)
 {
 	MFont *font;
-	Uint8 style;
+	Uint8 style = STYLE_NORM;
 	char *key;
 	size_t keysize;
 	SDL_Texture *texture;
diff --git a/game/player.h b/game/player.h
index e18bc02f..9d656141 100644
--- a/game/player.h
+++ b/game/player.h
@@ -165,9 +165,6 @@ class Player : public Object {
 	int Ghost;
 
 	Shot *shots[MAX_SHOTS];
-	int nextshot;
-	int shotodds;
-	int target;
 	int numshots;
 	Uint32 ship_color;
 
diff --git a/game/replay.cpp b/game/replay.cpp
index 9d2c0f8e..1da7d95f 100644
--- a/game/replay.cpp
+++ b/game/replay.cpp
@@ -292,8 +292,9 @@ printf("Replay complete!\n");
 		return false;
 	}
 	for (int i = 0; i < size; ++i) {
-		m_data.Read(value);
-		QueueInput(value);
+		if (m_data.Read(value)) {
+			QueueInput(value);
+		}
 	}
 
 	++m_frameCount;
diff --git a/maclib/Mac_Resource.cpp b/maclib/Mac_Resource.cpp
index d9228bbc..d2664c0a 100644
--- a/maclib/Mac_Resource.cpp
+++ b/maclib/Mac_Resource.cpp
@@ -233,8 +233,9 @@ static FILE *Open_MacRes(char **original, Uint32 *resbase)
 		}
 
 #ifdef SDL_PLATFORM_MACOS
-		newname = new char[strlen(dirname)+strlen("/../Resources/")+strlen(basename)+1];
-		sprintf(newname, "%s/../Resources/%s", dirname, basename);
+		len = strlen(dirname)+strlen("/../Resources/")+strlen(basename)+1;
+		newname = new char[len];
+		SDL_snprintf(newname, len, "%s/../Resources/%s", dirname, basename);
 		if ( (resfile=fopen(newname, "rb")) != NULL ) {
 			break;
 		}
diff --git a/maclib/macres.cpp b/maclib/macres.cpp
index dcbda37c..f19995db 100644
--- a/maclib/macres.cpp
+++ b/maclib/macres.cpp
@@ -439,7 +439,7 @@ int main(int argc, char *argv[])
 					Export(res, types[i], ids[j], argv[arg]);
 				} else {
 					char path[23];
-					sprintf(path,"%s/%s:%hu", argv[arg], types[i], ids[j]);
+					SDL_snprintf(path, sizeof(path), "%s/%s:%hu", argv[arg], types[i], ids[j]);
 					FILE *output;
 					Mac_ResData *D;
 					if ( (output=fopen(path, "w")) != NULL ) {
diff --git a/screenlib/UIArea.cpp b/screenlib/UIArea.cpp
index db898a0f..945c519a 100644
--- a/screenlib/UIArea.cpp
+++ b/screenlib/UIArea.cpp
@@ -361,7 +361,7 @@ UIArea::GetAnchorLocation(AnchorLocation spot, int *x, int *y) const
 void
 UIArea::CalculateAnchor(bool triggerRectChanged)
 {
-	int x, y;
+	int x = 0, y = 0;
 
 	if (!m_anchor.element) {
 		return;
diff --git a/screenlib/UIBaseElement.h b/screenlib/UIBaseElement.h
index 3d3f6405..3d027a8c 100644
--- a/screenlib/UIBaseElement.h
+++ b/screenlib/UIBaseElement.h
@@ -250,18 +250,18 @@ class UIBaseElement : public UIArea
 };
 
 /////////////////////////////////////////////////////////////////////////
-#define DECLARE_TYPESAFE_CLASS(BASECLASS)				\
-protected:								\
-	static UIElementType s_elementType;				\
-									\
-public:									\
-	static UIElementType GetType() {				\
-		if (!s_elementType) {					\
-			s_elementType = GenerateType();			\
-		}							\
-		return s_elementType;					\
-	}								\
-	virtual bool IsA(UIElementType type) {				\
+#define DECLARE_TYPESAFE_CLASS(BASECLASS)					\
+protected:													\
+	static UIElementType s_elementType;						\
+															\
+public:														\
+	static UIElementType GetType() {						\
+		if (!s_elementType) {								\
+			s_elementType = GenerateType();					\
+		}													\
+		return s_elementType;								\
+	}														\
+	virtual bool IsA(UIElementType type) override {			\
 		return BASECLASS::IsA(type) || type == GetType();	\
 	}
 /////////////////////////////////////////////////////////////////////////