From 00c92cbdd7ca1bf9fbd1fc803cc811aef88aa0bc Mon Sep 17 00:00:00 2001 From: buginator Date: Sun, 5 Dec 2010 20:16:12 -0500 Subject: [PATCH] Fix bug introduced in 09ea0be7c30236809536db332be78b2967d3114d Changelog: Fix kicking of non-hosts who didn't have default color values. Only change colors if you are the host on the setup screen. Fixes ticket:2329 (cherry picked from commit fd2843e6431e43cc72b635c422fd18bb19d42c47) Conflicts: lib/netplay/netplay.c --- lib/netplay/netplay.c | 19 ++++++++++++++----- src/multiint.c | 5 ----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/netplay/netplay.c b/lib/netplay/netplay.c index 60b43108c..3183065b4 100644 --- a/lib/netplay/netplay.c +++ b/lib/netplay/netplay.c @@ -298,11 +298,7 @@ void NET_InitPlayers() NETinitQueue(NETnetQueue(i)); } NETinitQueue(NETbroadcastQueue()); - // Now switch player color of the host to what they normally use for SP games - if ( getPlayerColour(NET_HOST_ONLY) != war_GetSPcolor()) - { - changeColour(NET_HOST_ONLY, war_GetSPcolor()); - } + NetPlay.hostPlayer = NET_HOST_ONLY; // right now, host starts always at index zero NetPlay.playercount = 0; NetPlay.pMapFileHandle = NULL; @@ -342,6 +338,8 @@ static void NETSendPlayerInfoTo(uint32_t index, unsigned to) static void NETSendAllPlayerInfoTo(unsigned to) { static uint32_t indices[MAX_PLAYERS] = {0, 1, 2, 3, 4, 5, 6, 7}; + ASSERT_OR_RETURN( , NetPlay.isHost == true, "Invalid call for non-host"); + NETSendNPlayerInfoTo(indices, ARRAY_SIZE(indices), to); } @@ -2436,6 +2434,11 @@ BOOL NEThostGame(const char* SessionName, const char* PlayerName, NetPlay.players[0].connection = -1; NetPlay.playercount = 1; debug(LOG_NET, "Hosting but no comms"); + // Now switch player color of the host to what they normally use for SP games + if ( getPlayerColour(NET_HOST_ONLY) != war_GetSPcolor()) + { + changeColour(NET_HOST_ONLY, war_GetSPcolor()); + } return true; } @@ -2507,6 +2510,12 @@ BOOL NEThostGame(const char* SessionName, const char* PlayerName, MultiPlayerJoin(selectedPlayer); + // Now switch player color of the host to what they normally use for SP games + if ( getPlayerColour(NET_HOST_ONLY) != war_GetSPcolor()) + { + changeColour(NET_HOST_ONLY, war_GetSPcolor()); + } + allow_joining = true; NETregisterServer(0); diff --git a/src/multiint.c b/src/multiint.c index 7d12240b1..ccd66146a 100644 --- a/src/multiint.c +++ b/src/multiint.c @@ -3246,11 +3246,6 @@ BOOL startMultiOptions(BOOL bReenter) game.skDiff[i] = (DIFF_SLIDER_STOPS / 2); // reset AI (turn it on again) setPlayerColour(i,i); //reset all colors as well } - // Now switch player color of the host to what they normally use - if (getPlayerColour(NET_HOST_ONLY) != war_GetSPcolor()) - { - changeColour(NET_HOST_ONLY, war_GetSPcolor()); - } if(!NetPlay.bComms) // force skirmish if no comms. {