]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added back the hacky NAT routing fix since it actually does work, the win32 problems...
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 6 Apr 2002 03:43:50 +0000 (03:43 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 6 Apr 2002 03:43:50 +0000 (03:43 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1715 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
server.h
sv_main.c
sv_user.c

index acba578a25b0a5336607f7001808c64dac45b92b..11155759efe41e82f4dddf51edca1791bf41101b 100644 (file)
--- 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)
        {
index 8ceabc2bdb86f6229d357171d26a31991cf35fe9..5a330ffefdd8b190f4e18b33cb4a2f2b03762fbb 100644 (file)
--- 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
 
index fde0d7490b0ba0d08ba7f645366f65fb292eee91..d8c47b0d5e7f3d4b6161d5259598ba55f294864c 100644 (file)
--- 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))
index deaea53ffd4ab16540ef276694b8bd3e001bc1ff..174aed9f14bd4bd519d01cfa8ff7728b2b713627 100644 (file)
--- 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: