Skip to content

Commit b665e9d

Browse files
committed
Fix clients and/or host crashing due to the last client clicking ready too many times. Based on patch by Buggy.
Throw in a few checks for changing player position or team, too. Closes ticket:2346. Changelog: Fixed crash for all players when the last player clicks "Ready" too many times.
1 parent 528c9f4 commit b665e9d

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

lib/netplay/netplay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ extern LOBBY_ERROR_TYPES LobbyError; // from src/multiint.c
255255
** ie ("trunk", "2.1.3", ...)
256256
************************************************************************************
257257
**/
258-
char VersionString[VersionStringSize] = "2.3 svn"; // used for display in the lobby, not the actual version check
258+
char VersionString[VersionStringSize] = "2.3 git"; // used for display in the lobby, not the actual version check
259259
static int NETCODE_VERSION_MAJOR = 2; // major netcode version, used for compatibility check
260260
static int NETCODE_VERSION_MINOR = 95; // minor netcode version, used for compatibility check
261261
static int NETCODE_HASH = 0; // unused for now

src/multiint.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,9 +1558,9 @@ BOOL recvTeamRequest()
15581558
{
15591559
UBYTE player, team;
15601560

1561-
if(!NetPlay.isHost) // only host should act
1561+
if (!NetPlay.isHost || !bHosted) // Only host should act, and only if the game hasn't started yet.
15621562
{
1563-
ASSERT(false, "Host only routine detected for client!");
1563+
ASSERT(NetPlay.isHost, "Host only routine detected for client!");
15641564
return true;
15651565
}
15661566

@@ -1614,9 +1614,9 @@ BOOL recvReadyRequest()
16141614
UBYTE player;
16151615
BOOL bReady;
16161616

1617-
if(!NetPlay.isHost) // only host should act
1617+
if (!NetPlay.isHost || !bHosted) // Only host should act, and only if the game hasn't started yet.
16181618
{
1619-
ASSERT(false, "Host only routine detected for client!");
1619+
ASSERT(NetPlay.isHost, "Host only routine detected for client!");
16201620
return true;
16211621
}
16221622

@@ -1760,9 +1760,9 @@ BOOL recvColourRequest()
17601760
{
17611761
UBYTE player, col;
17621762

1763-
if(!NetPlay.isHost) // only host should act
1763+
if (!NetPlay.isHost || !bHosted) // Only host should act, and only if the game hasn't started yet.
17641764
{
1765-
ASSERT(false, "Host only routine detected for client!");
1765+
ASSERT(NetPlay.isHost, "Host only routine detected for client!");
17661766
return true;
17671767
}
17681768

@@ -1793,9 +1793,9 @@ BOOL recvPositionRequest()
17931793
{
17941794
UBYTE player, position;
17951795

1796-
if(!NetPlay.isHost) // only host should act
1796+
if (!NetPlay.isHost || !bHosted) // Only host should act, and only if the game hasn't started yet.
17971797
{
1798-
ASSERT(false, "Host only routine detected for client!");
1798+
ASSERT(NetPlay.isHost, "Host only routine detected for client!");
17991799
return true;
18001800
}
18011801

@@ -2820,6 +2820,11 @@ static void processMultiopWidgets(UDWORD id)
28202820
/* Start a multiplayer or skirmish game */
28212821
void startMultiplayerGame(void)
28222822
{
2823+
if (!bHosted)
2824+
{
2825+
debug(LOG_ERROR, "Multiple start requests received when we already started.");
2826+
return;
2827+
}
28232828
decideWRF(); // set up swrf & game.map
28242829
bMultiPlayer = true;
28252830
bMultiMessages = true;
@@ -2975,14 +2980,12 @@ void frontendMultiMessages(void)
29752980
break;
29762981

29772982
case NET_READY_REQUEST:
2978-
if (NetPlay.isHost)
2983+
recvReadyRequest();
2984+
2985+
// If hosting and game not yet started, try to start the game if everyone is ready.
2986+
if (NetPlay.isHost && bHosted && multiplayPlayersReady(false))
29792987
{
2980-
recvReadyRequest();
2981-
if (multiplayPlayersReady(false))
2982-
{
2983-
// if hosting try to start the game if everyone is ready
2984-
startMultiplayerGame();
2985-
}
2988+
startMultiplayerGame();
29862989
}
29872990
break;
29882991

0 commit comments

Comments
 (0)