Skip to content

Commit eea0d02

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 d79e365 commit eea0d02

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

‎lib/netplay/netplay.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ extern LOBBY_ERROR_TYPES LobbyError; // from src/multiint.c
256256
** ie ("trunk", "2.1.3", ...)
257257
************************************************************************************
258258
**/
259-
char VersionString[VersionStringSize] = "3.0 beta 2"; // used for display in the lobby, not the actual version check
259+
char VersionString[VersionStringSize] = "3.0 git"; // used for display in the lobby, not the actual version check
260260
static int NETCODE_VERSION_MAJOR = 3; // major netcode version, used for compatibility check
261261
static int NETCODE_VERSION_MINOR = 2; // minor netcode version, used for compatibility check
262262
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
@@ -1552,9 +1552,9 @@ BOOL recvTeamRequest()
15521552
{
15531553
UBYTE player, team;
15541554

1555-
if(!NetPlay.isHost) // only host should act
1555+
if (!NetPlay.isHost || !bHosted) // Only host should act, and only if the game hasn't started yet.
15561556
{
1557-
ASSERT(false, "Host only routine detected for client!");
1557+
ASSERT(NetPlay.isHost, "Host only routine detected for client!");
15581558
return true;
15591559
}
15601560

@@ -1608,9 +1608,9 @@ BOOL recvReadyRequest()
16081608
UBYTE player;
16091609
BOOL bReady;
16101610

1611-
if(!NetPlay.isHost) // only host should act
1611+
if (!NetPlay.isHost || !bHosted) // Only host should act, and only if the game hasn't started yet.
16121612
{
1613-
ASSERT(false, "Host only routine detected for client!");
1613+
ASSERT(NetPlay.isHost, "Host only routine detected for client!");
16141614
return true;
16151615
}
16161616

@@ -1754,9 +1754,9 @@ BOOL recvColourRequest()
17541754
{
17551755
UBYTE player, col;
17561756

1757-
if(!NetPlay.isHost) // only host should act
1757+
if (!NetPlay.isHost || !bHosted) // Only host should act, and only if the game hasn't started yet.
17581758
{
1759-
ASSERT(false, "Host only routine detected for client!");
1759+
ASSERT(NetPlay.isHost, "Host only routine detected for client!");
17601760
return true;
17611761
}
17621762

@@ -1787,9 +1787,9 @@ BOOL recvPositionRequest()
17871787
{
17881788
UBYTE player, position;
17891789

1790-
if(!NetPlay.isHost) // only host should act
1790+
if (!NetPlay.isHost || !bHosted) // Only host should act, and only if the game hasn't started yet.
17911791
{
1792-
ASSERT(false, "Host only routine detected for client!");
1792+
ASSERT(NetPlay.isHost, "Host only routine detected for client!");
17931793
return true;
17941794
}
17951795

@@ -2833,6 +2833,11 @@ static void processMultiopWidgets(UDWORD id)
28332833
/* Start a multiplayer or skirmish game */
28342834
void startMultiplayerGame(void)
28352835
{
2836+
if (!bHosted)
2837+
{
2838+
debug(LOG_ERROR, "Multiple start requests received when we already started.");
2839+
return;
2840+
}
28362841
decideWRF(); // set up swrf & game.map
28372842
bMultiPlayer = true;
28382843
bMultiMessages = true;
@@ -2992,14 +2997,12 @@ void frontendMultiMessages(void)
29922997
break;
29932998

29942999
case NET_READY_REQUEST:
2995-
if (NetPlay.isHost)
3000+
recvReadyRequest();
3001+
3002+
// If hosting and game not yet started, try to start the game if everyone is ready.
3003+
if (NetPlay.isHost && bHosted && multiplayPlayersReady(false))
29963004
{
2997-
recvReadyRequest();
2998-
if (multiplayPlayersReady(false))
2999-
{
3000-
// if hosting try to start the game if everyone is ready
3001-
startMultiplayerGame();
3002-
}
3005+
startMultiplayerGame();
30033006
}
30043007
break;
30053008

0 commit comments

Comments
 (0)