From 1bb7de16b6833c668a898f18f78f97a243ac2d9f Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 5 Apr 2026 19:19:48 -0700
Subject: [PATCH] Fixed the spawn locations when the second player slot is
empty
---
game/player.cpp | 21 +++++++++++++++++++++
game/player.h | 8 +-------
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/game/player.cpp b/game/player.cpp
index e8854afe..6e993a09 100644
--- a/game/player.cpp
+++ b/game/player.cpp
@@ -792,6 +792,27 @@ Player::CanGetAchievement()
return false;
}
+void
+Player::SetSpawnPosition()
+{
+ int offset = gGameInfo.GetNumPlayers() == 2 ? SPRITES_WIDTH : 0;
+ int index = 0;
+ for (int i = 0; i < MAX_PLAYERS; ++i) {
+ if (!gPlayers[i]->IsValid()) {
+ continue;
+ }
+
+ if (i == Index) {
+ break;
+ }
+ ++index;
+ }
+ SetPos(
+ (((GAME_WIDTH/2-((gGameInfo.GetNumPlayers()/2-index)*(2*SPRITES_WIDTH)))+offset-SPRITES_WIDTH/2)*SCALE_FACTOR),
+ (((GAME_HEIGHT/2)-SPRITES_WIDTH/2)*SCALE_FACTOR) - SPRITES_WIDTH
+ );
+}
+
/* Private functions... */
int
diff --git a/game/player.h b/game/player.h
index 51ea5d7a..3924a0ae 100644
--- a/game/player.h
+++ b/game/player.h
@@ -167,13 +167,7 @@ class Player : public Object {
}
bool CanGetAchievement();
- void SetSpawnPosition() {
- int offset = gGameInfo.GetNumPlayers() == 2 ? SPRITES_WIDTH : 0;
- SetPos(
- (((GAME_WIDTH/2-((gGameInfo.GetNumPlayers()/2-Index)*(2*SPRITES_WIDTH)))+offset-SPRITES_WIDTH/2)*SCALE_FACTOR),
- (((GAME_HEIGHT/2)-SPRITES_WIDTH/2)*SCALE_FACTOR) - SPRITES_WIDTH
- );
- }
+ void SetSpawnPosition();
void GetCameraPos(int *X, int *Y) {
*X = CameraX;