Maelstrom: Don't zoom in if there are multiple local players

From db5a0d3a454c2a11cf6e9d0f7f121548aecaf62d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 28 Apr 2026 00:33:22 -0700
Subject: [PATCH] Don't zoom in if there are multiple local players

---
 game/game.cpp | 32 ++++++++++++++++++++++++++------
 game/game.h   |  2 ++
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/game/game.cpp b/game/game.cpp
index e89c71e5..20df5566 100644
--- a/game/game.cpp
+++ b/game/game.cpp
@@ -603,7 +603,7 @@ GamePanelDelegate::OnDraw(DRAWLEVEL drawLevel)
 			int x = (gBorderStars[i]->xCoord << SPRITE_PRECISION);
 			int y = (gBorderStars[i]->yCoord << SPRITE_PRECISION);
 			GetRenderCoordinates(x, y);
-			if (gZoomGame ||
+			if (ZoomGame() ||
 				(x >= SPRITES_WIDTH && x < (GAME_WIDTH - SPRITES_WIDTH) &&
 				 y >= SPRITES_WIDTH && y < (GAME_HEIGHT - SPRITES_WIDTH))) {
 				screen->DrawPoint(x, y, gBorderStars[i]->color);
@@ -701,13 +701,29 @@ GamePanelDelegate::UpdateZoom()
 	SDL_GetRenderSafeArea(renderer, &rect);
 	SDL_SetRenderLogicalPresentation(renderer, saved_w, saved_h, saved_mode);
 
-	if (IsPhone() || IsTablet() || gZoomGame) {
+	int i, local_players = 0;
+	OBJ_LOOP(i, MAX_PLAYERS) {
+		if (!gPlayers[i]->IsValid()) {
+			continue;
+		}
+
+		if (IS_LOCAL_CONTROL(gPlayers[i]->GetControlType())) {
+			++local_players;
+		}
+	}
+	if (local_players > 1) {
+		m_zoomEnabled = false;
+	} else {
+		m_zoomEnabled = true;
+	}
+
+	if (IsPhone() || IsTablet() || ZoomGame()) {
 		StartZoomUI(rect);
 	} else {
 		StopZoomUI();
 	}
 
-	if (gZoomGame) {
+	if (ZoomGame()) {
 		if (!m_texture) {
 			m_texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_UNKNOWN, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH, GAME_HEIGHT);
 		}
@@ -723,7 +739,11 @@ GamePanelDelegate::UpdateZoom()
 			m_texture = nullptr;
 		}
 		if (m_zoomIn) {
-			m_zoomIn->Show();
+			if (m_zoomEnabled) {
+				m_zoomIn->Show();
+			} else {
+				m_zoomIn->Hide();
+			}
 		}
 		if (m_zoomOut) {
 			m_zoomOut->Hide();
@@ -762,7 +782,7 @@ GamePanelDelegate::StartZoomedDrawing()
 {
 	SDL_Renderer *renderer = screen->GetRenderer();
 
-	if (!gZoomGame) {
+	if (!ZoomGame()) {
 		screen->SetLogicalSize(GAME_WIDTH, GAME_HEIGHT);
 		return;
 	}
@@ -786,7 +806,7 @@ GamePanelDelegate::StopZoomedDrawing()
 {
 	SDL_Renderer *renderer = screen->GetRenderer();
 
-	if (!gZoomGame) {
+	if (!ZoomGame()) {
 		screen->SetLogicalSize(ui->X() + ui->Width() + ui->X(), ui->Y() + ui->Height() + ui->Y());
 		return;
 	}
diff --git a/game/game.h b/game/game.h
index 57ea492c..980cb686 100644
--- a/game/game.h
+++ b/game/game.h
@@ -48,6 +48,7 @@ class GamePanelDelegate : public UIPanelDelegate
 	void ShowTouchControls();
 	void HideTouchControls();
 	void HandleTouchFading();
+	bool ZoomGame() { return gZoomGame && m_zoomEnabled; }
 	void UpdateZoom();
 	void StartZoomUI(const SDL_Rect &rect);
 	void StopZoomUI();
@@ -117,6 +118,7 @@ class GamePanelDelegate : public UIPanelDelegate
 		STATE_START_NEXT_WAVE,
 	} m_state;
 
+	bool m_zoomEnabled = true;
 	SDL_Texture *m_texture = nullptr;
 	SDL_Rect m_savedClip;