From 1d47645d075454874e5066d2d10156b481b15a17 Mon Sep 17 00:00:00 2001 From: Buginator Date: Thu, 15 Apr 2010 03:14:30 +0000 Subject: [PATCH] Don't broadcast to other players about a new player in NET_CreatePlayer(), we will only do NETBroadcastPlayerInfo() when a player has passed all the verification steps. This fixes ticket:1611 Correctly handle rejection of the verification process as well. 2.3:r10572 git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@10583 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/netplay/netplay.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/netplay/netplay.c b/lib/netplay/netplay.c index c5a06b689..3a54d4caf 100644 --- a/lib/netplay/netplay.c +++ b/lib/netplay/netplay.c @@ -443,7 +443,6 @@ static signed int NET_CreatePlayer(const char* name) NET_InitPlayer(index, false); // re-init everything NetPlay.players[index].allocated = true; sstrcpy(NetPlay.players[index].name, name); - NETBroadcastPlayerInfo(index); NetPlay.playercount++; sync_counter.joins++; return index; @@ -2259,7 +2258,11 @@ static void NETallowJoining(void) if (onBanList(clientAddress)) { - debug(LOG_INFO, "A player that you have kicked tried to rejoin the game, and was rejected. IP:%s", clientAddress); + char buf[256] = {'\0'}; + + ssprintf(buf, "** A player that you have kicked tried to rejoin the game, and was rejected. IP:%s", clientAddress ); + debug(LOG_INFO, buf); + NETlogEntry(buf, SYNC_FLAG, i); SocketSet_DelSocket(tmp_socket_set, tmp_socket[i]); socketClose(tmp_socket[i]); tmp_socket[i] = NULL; @@ -2291,7 +2294,7 @@ static void NETallowJoining(void) index = tmp; - debug(LOG_NET, "freeing temp socket %p (%d)", tmp_socket[i], __LINE__); + debug(LOG_NET, "freeing temp socket %p (%d), creating permanent socket.", tmp_socket[i], __LINE__); SocketSet_DelSocket(tmp_socket_set, tmp_socket[i]); NET_initBufferedSocket(connected_bsocket[index], tmp_socket[i]); SocketSet_AddSocket(socket_set, connected_bsocket[index]->socket); @@ -2320,7 +2323,11 @@ static void NETallowJoining(void) if (rejected) { - debug(LOG_INFO, "We were rejected, reason (%u)", (unsigned int) rejected); + char buf[256] = {'\0'}; + + ssprintf(buf, "** This player %u, was rejected, error code: %u",(unsigned int) index, (unsigned int) rejected); + debug(LOG_INFO, buf); + NETlogEntry(buf, SYNC_FLAG, index); NETbeginEncode(NET_REJECTED, index); NETuint8_t(&rejected); NETend(); @@ -2342,6 +2349,9 @@ static void NETallowJoining(void) NETlogEntry(buf, SYNC_FLAG, index); } + // Broadcast to everyone that a new player has joined + NETBroadcastPlayerInfo(index); + NETbeginEncode(NET_ACCEPTED, index); NETuint8_t(&index); NETend(); @@ -2803,17 +2813,16 @@ BOOL NETjoinGame(UDWORD gameNumber, const char* playername) } else if (type == NET_REJECTED) { - // :( uint8_t rejection = 0; NETbeginDecode(NET_REJECTED); - // WRY??? NETuint8_t(&rejection); NETend(); - debug(LOG_NET, "NET_REJECTED received. Better luck next time?"); + debug(LOG_NET, "NET_REJECTED received. Error code: %u", (unsigned int) rejection); setLobbyError((LOBBY_ERROR_TYPES)rejection); + NETclose(); } } }