From a8533b9468b12ea60e6dc989d9e814cd024110ee Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 15 Nov 2008 05:18:07 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@1137 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/mmulti_unstable.c | 76 +++++++-------------- polymer/eduke32/source/game.c | 4 +- 2 files changed, 28 insertions(+), 52 deletions(-) diff --git a/polymer/eduke32/build/src/mmulti_unstable.c b/polymer/eduke32/build/src/mmulti_unstable.c index bd0d4443e..1dd8e4b41 100644 --- a/polymer/eduke32/build/src/mmulti_unstable.c +++ b/polymer/eduke32/build/src/mmulti_unstable.c @@ -969,7 +969,7 @@ static int open_udp_socket(int ip, int port) udpsocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if ((signed)udpsocket == -1) { - initprintf("socket creation failed: %s\n", netstrerror()); + initprintf("mmulti_unstable: socket creation failed: %s\n", netstrerror()); return(0); } @@ -990,7 +990,7 @@ static int open_udp_socket(int ip, int port) addr.sin_port = htons((unsigned short)port); if (bind(udpsocket, (struct sockaddr *) &addr, sizeof(addr)) == -1) { - initprintf("socket binding failed: %s\n", netstrerror()); + initprintf("mmulti_unstable: socket binding failed: %s\n", netstrerror()); return(0); } @@ -1020,7 +1020,7 @@ static void send_peer_greeting(int ip, unsigned short port, short myid) static int wait_for_other_players(gcomtype *gcom, int myip) { PacketPeerGreeting packet; - unsigned short my_id = 1; + unsigned short my_id = 1; // we're always 1 so we sort as the first player int i, j; int rc; int ip; @@ -1093,20 +1093,6 @@ static int wait_for_other_players(gcomtype *gcom, int myip) send_peer_greeting(allowed_addresses[i].host, allowed_addresses[i].port, my_id); - - // resend greeting to other clients so they get ID for sorting - /* for (j=i;j>=0;j--) - { - int ii; - for (ii = 1; ii < max; ii++) - send_peer_greeting(allowed_addresses[j].host, - allowed_addresses[j].port, - heard_from[ii]); - - send_peer_greeting(allowed_addresses[j].host, - allowed_addresses[j].port, - heard_from[i]); - }*/ } } } @@ -1117,19 +1103,26 @@ static int wait_for_other_players(gcomtype *gcom, int myip) return(0); } - // found all the clients expected so send them our greeting + // found all the clients expected so relay all greetings for (j=max;j>=0;j--) if (allowed_addresses[j].host) { int ii; + + // send another copy of our greeting just in case they missed it + send_peer_greeting(allowed_addresses[j].host, + allowed_addresses[j].port, + my_id); + for (ii = 0; ii < max; ii++) send_peer_greeting(allowed_addresses[j].host, allowed_addresses[j].port, heard_from[ii]); + // greeting with 0x1337 id starts the game for clients send_peer_greeting(allowed_addresses[j].host, allowed_addresses[j].port, - 1337); + 0x1337); } /* ok, now everyone is talking to you. Sort them into player numbers... */ @@ -1292,17 +1285,17 @@ static int connect_to_server(gcomtype *gcom, int myip) for (i=0;inumplayers++; - max++; -// initprintf("max %d np %d\n",max,gcom->numplayers); - } + initprintf("New player with id 0x%X\n", + (int) packet.id); + gcom->numplayers++; + max++; } } } @@ -1396,11 +1385,11 @@ static int connect_to_server(gcomtype *gcom, int myip) gcom->myconnectindex = i; } - initprintf("mmulti_unstable: player #%i with id %d\n", i,heard_from[i]); +// initprintf("mmulti_unstable: player #%i with id %d\n",i,heard_from[i]); } // assert(gcom->myconnectindex); - initprintf("mmulti_unstable: We are player #%i\n", gcom->myconnectindex); +// initprintf("mmulti_unstable: We are player #%i\n", gcom->myconnectindex); return(1); } @@ -1835,14 +1824,6 @@ static int parse_udp_config(int argc, char **argv, gcomtype *gcom) for (i=0;i 1) { setgamepalette(g_player[myconnectindex].ps, titlepal, 11); @@ -10184,7 +10184,7 @@ static void Logo(void) gametext(160,190,"WAITING FOR PLAYERS",14,2); nextpage(); } - +*/ waitforeverybody(); flushperms();