https://github.com/libsdl-org/Maelstrom/commit/e8eb37928097841727464dce0611061b900fbdd6
From e8eb37928097841727464dce0611061b900fbdd6 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 17 Nov 2011 02:43:09 -0500
Subject: [PATCH] Fixed some issues with Deathmatch mode.
---
game/Maelstrom_Globals.h | 1 +
game/game.cpp | 2 +-
game/gameinfo.cpp | 5 +++--
game/gameinfo.h | 2 +-
game/lobby.cpp | 5 +++--
game/main.cpp | 1 +
game/netplay.cpp | 11 ++---------
7 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/game/Maelstrom_Globals.h b/game/Maelstrom_Globals.h
index 6a4e46e1..a44d2195 100644
--- a/game/Maelstrom_Globals.h
+++ b/game/Maelstrom_Globals.h
@@ -44,6 +44,7 @@
// Preferences keys
#define PREFERENCES_HANDLE "Handle"
+#define PREFERENCES_DEATHMATCH "Network.Deathmatch"
// The Font Server :)
extern FontServ *fontserv;
diff --git a/game/game.cpp b/game/game.cpp
index 339ac43f..be66e008 100644
--- a/game/game.cpp
+++ b/game/game.cpp
@@ -536,7 +536,7 @@ GamePanelDelegate::DoHousekeeping()
}
/* -- Make sure someone is still playing... */
- bool PlayersLeft;
+ bool PlayersLeft = false;
for ( i=0; i < gNumPlayers; ++i ) {
if ( gPlayers[i]->Kicking() ) {
PlayersLeft = true;
diff --git a/game/gameinfo.cpp b/game/gameinfo.cpp
index aff77464..9795e4ee 100644
--- a/game/gameinfo.cpp
+++ b/game/gameinfo.cpp
@@ -37,6 +37,7 @@ GameInfo::Reset()
void
GameInfo::SetSinglePlayer(Uint8 wave, Uint8 lives, Uint8 turbo)
{
+ Reset();
this->gameID = 1;
this->seed = GetRandSeed();
this->wave = wave;
@@ -46,14 +47,14 @@ GameInfo::SetSinglePlayer(Uint8 wave, Uint8 lives, Uint8 turbo)
}
void
-GameInfo::SetMultiplayerHost(Uint32 gameID, const char *name)
+GameInfo::SetMultiplayerHost(Uint32 gameID, Uint8 deathMatch, const char *name)
{
this->gameID = gameID;
this->seed = GetRandSeed();
this->wave = DEFAULT_START_WAVE;
this->lives = DEFAULT_START_LIVES;
this->turbo = DEFAULT_START_TURBO;
- this->deathMatch = 0;
+ this->deathMatch = deathMatch;
players[HOST_PLAYER].playerID = gameID;
SDL_strlcpy(players[HOST_PLAYER].name, name ? name : "",
sizeof(players[HOST_PLAYER].name));
diff --git a/game/gameinfo.h b/game/gameinfo.h
index 864cc1f7..969c8819 100644
--- a/game/gameinfo.h
+++ b/game/gameinfo.h
@@ -84,7 +84,7 @@ class GameInfo
void SetSinglePlayer(Uint8 wave, Uint8 lives, Uint8 turbo);
- void SetMultiplayerHost(Uint32 gameID, const char *name);
+ void SetMultiplayerHost(Uint32 gameID, Uint8 deathMatch, const char *name);
void SetLocalID(Uint32 playerID) {
localID = playerID;
diff --git a/game/lobby.cpp b/game/lobby.cpp
index 3b244ed4..763e1016 100644
--- a/game/lobby.cpp
+++ b/game/lobby.cpp
@@ -324,7 +324,9 @@ LobbyDialogDelegate::SetState(LOBBY_STATE state)
SendLeaveRequest();
}
} else if (state == STATE_HOSTING) {
- m_game.SetMultiplayerHost(m_uniqueID, prefs->GetString(PREFERENCES_HANDLE));
+ m_game.SetMultiplayerHost(m_uniqueID,
+ prefs->GetNumber(PREFERENCES_DEATHMATCH),
+ prefs->GetString(PREFERENCES_HANDLE));
} else if (state == STATE_LISTING) {
ClearGameList();
}
@@ -508,7 +510,6 @@ void
LobbyDialogDelegate::ClearGameInfo()
{
m_game.Reset();
- m_game.deathMatch = (Uint8)prefs->GetNumber("Network.Deathmatch");
}
void
diff --git a/game/main.cpp b/game/main.cpp
index b4f3b9c6..499fba6b 100644
--- a/game/main.cpp
+++ b/game/main.cpp
@@ -67,6 +67,7 @@ static void RunSinglePlayerGame()
if (InitNetData(false) < 0) {
return;
}
+ AddLocalPlayer(HOST_PLAYER);
NewGame();
HaltNetData();
}
diff --git a/game/netplay.cpp b/game/netplay.cpp
index cdca7eb3..633e3c8b 100644
--- a/game/netplay.cpp
+++ b/game/netplay.cpp
@@ -168,21 +168,14 @@ int CheckPlayers(void)
if ( GotPlayer[i] )
++gNumPlayers;
}
- /* Add ourselves if needed */
- if ( gNumPlayers == 0 ) {
- AddLocalPlayer(HOST_PLAYER);
- gNumPlayers = 1;
- FoundUs = 1;
- }
for ( i=0; i<gNumPlayers; ++i ) {
if ( ! GotPlayer[i] ) {
- error(
-"Player %d not specified! Use the -player option for all players.\r\n", i+1);
+ error("Player %d not specified!\r\n", i+1);
return(-1);
}
}
if ( ! FoundUs ) {
- error("Which player are you? (Use the -player N option)\r\n");
+ error("Which player are you?\r\n");
return(-1);
}
if ( (gOurPlayer+1) > gNumPlayers ) {