From: lordhavoc Date: Sat, 6 Apr 2002 03:43:50 +0000 (+0000) Subject: added back the hacky NAT routing fix since it actually does work, the win32 problems... X-Git-Tag: RELEASE_0_2_0_RC1~537 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=02b521f4b01e12f4a4477bc44bf5dfca742c47b9 added back the hacky NAT routing fix since it actually does work, the win32 problems were unrelated and have been fixed git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1715 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_main.c b/cl_main.c index acba578a..11155759 100644 --- a/cl_main.c +++ b/cl_main.c @@ -878,6 +878,21 @@ void CL_SendCmd (void) // send the unreliable message CL_SendMove (&cmd); } +#ifndef NOROUTINGFIX + else + { + // LordHavoc: fix for NAT routing of netquake: + // bounce back a clc_nop message to the newly allocated server port, + // to establish a routing connection for incoming frames, + // the server waits for this before sending anything + if (realtime > cl.sendnoptime) + { + Con_DPrintf("sending clc_nop to get server's attention\n"); + cl.sendnoptime = realtime + 3; + MSG_WriteByte(&cls.message, clc_nop); + } + } +#endif if (cls.demoplayback) { diff --git a/server.h b/server.h index 8ceabc2b..5a330ffe 100644 --- a/server.h +++ b/server.h @@ -81,6 +81,12 @@ typedef struct client_s qboolean dropasap; // has been told to go to another level qboolean sendsignon; // only valid before spawned +#ifndef NOROUTINGFIX + // LordHavoc: to make netquake protocol get through NAT routers, have to wait for client to ack + qboolean waitingforconnect; // waiting for connect from client (stage 1) + qboolean sendserverinfo; // send server info in next datagram (stage 2) +#endif + double last_message; // reliable messages must be sent // periodically diff --git a/sv_main.c b/sv_main.c index fde0d749..d8c47b0d 100644 --- a/sv_main.c +++ b/sv_main.c @@ -333,7 +333,14 @@ void SV_ConnectClient (int clientnum) client->spawn_parms[i] = (&pr_global_struct->parm1)[i]; } +#if NOROUTINGFIX SV_SendServerinfo (client); +#else + // send serverinfo on first nop + client->waitingforconnect = true; + client->sendsignon = true; + client->spawned = false; // need prespawn, spawn, etc +#endif } @@ -1345,7 +1352,7 @@ qboolean SV_SendClientDatagram (client_t *client) MSG_WriteByte (&msg, svc_time); MSG_WriteFloat (&msg, sv.time); - if (!client->sendsignon) + if (client->spawned) { // add the client specific data to the datagram SV_WriteClientdataToMessage (client->edict, &msg); @@ -1448,6 +1455,14 @@ void SV_SendClientMessages (void) if (!host_client->active) continue; +#ifndef NOROUTINGFIX + if (host_client->sendserverinfo) + { + host_client->sendserverinfo = false; + SV_SendServerinfo (host_client); + } +#endif + if (host_client->spawned) { if (!SV_SendClientDatagram (host_client)) diff --git a/sv_user.c b/sv_user.c index deaea53f..174aed9f 100644 --- a/sv_user.c +++ b/sv_user.c @@ -72,7 +72,7 @@ void SV_SetIdealPitch (void) top[0] = sv_player->v.origin[0] + cosval*(i+3)*12; top[1] = sv_player->v.origin[1] + sinval*(i+3)*12; top[2] = sv_player->v.origin[2] + sv_player->v.view_ofs[2]; - + bottom[0] = top[0]; bottom[1] = top[1]; bottom[2] = top[2] - 160; @@ -150,7 +150,7 @@ void SV_UserFriction (void) // apply friction control = speed < sv_stopspeed.value ? sv_stopspeed.value : speed; newspeed = speed - sv.frametime*control*friction; - + if (newspeed < 0) newspeed = 0; else @@ -384,7 +384,7 @@ void SV_AirMove (void) else { // not on ground, so little effect on velocity SV_AirAccelerate (wishvel); - } + } } /* @@ -552,6 +552,14 @@ nextmsg: cmd = MSG_ReadChar (); +#ifndef NOROUTINGFIX + if (cmd != -1 && host_client->waitingforconnect) + { + host_client->waitingforconnect = false; + host_client->sendserverinfo = true; + } +#endif + switch (cmd) { case -1: