]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
beginnings of qw protocol support
[xonotic/darkplaces.git] / cl_main.c
index 4509dedbfb602019dbedc6737377282eae55204f..83869387537cee5137982822ac258cf098ebe5d9 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -66,6 +66,8 @@ cvar_t cl_beams_lightatend = {CVAR_SAVE, "cl_beams_lightatend", "0","make a ligh
 
 cvar_t cl_noplayershadow = {CVAR_SAVE, "cl_noplayershadow", "0","hide player shadow"};
 
+cvar_t qport = {0, "qport", "0", "identification key for playing on qw servers (allows you to maintain a connection to a quakeworld server even if your port changes)"};
+
 cvar_t cl_prydoncursor = {0, "cl_prydoncursor", "0", "enables a mouse pointer which is able to click on entities in the world, useful for point and click mods, see PRYDON_CLIENTCURSOR extension in dpextensions.qc"};
 
 cvar_t cl_deathnoviewmodel = {0, "cl_deathnoviewmodel", "1", "hides gun model when dead"};
@@ -312,9 +314,9 @@ void CL_Disconnect(void)
                buf.data = bufdata;
                buf.maxsize = sizeof(bufdata);
                MSG_WriteByte(&buf, clc_disconnect);
-               NetConn_SendUnreliableMessage(cls.netcon, &buf);
-               NetConn_SendUnreliableMessage(cls.netcon, &buf);
-               NetConn_SendUnreliableMessage(cls.netcon, &buf);
+               NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol);
+               NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol);
+               NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol);
                NetConn_Close(cls.netcon);
                cls.netcon = NULL;
        }
@@ -1116,7 +1118,7 @@ void CL_LinkNetworkEntity(entity_t *e)
                // hide player shadow during intermission or nehahra movie
                if (!(e->render.effects & EF_NOSHADOW)
                 && !(e->render.flags & (RENDER_VIEWMODEL | RENDER_TRANSPARENT))
-                && (!(e->render.flags & RENDER_EXTERIORMODEL) || (!cl.intermission && cl.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
+                && (!(e->render.flags & RENDER_EXTERIORMODEL) || (!cl.intermission && cls.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
                        e->render.flags |= RENDER_SHADOW;
                // as soon as player is known we can call V_CalcRefDef
                if (!csqc_loaded)
@@ -1480,7 +1482,7 @@ extern void CL_ClientMovement_Replay();
 int CL_ReadFromServer(void)
 {
        CL_ReadDemoMessage();
-       CL_SendCmd();
+       CL_SendMove();
 
        r_refdef.time = cl.time;
        r_refdef.extraupdate = !r_speeds.integer;
@@ -1529,31 +1531,6 @@ int CL_ReadFromServer(void)
        return 0;
 }
 
-/*
-=================
-CL_SendCmd
-=================
-*/
-void CL_UpdatePrydonCursor(void);
-void CL_SendCmd(void)
-{
-       // send the reliable message (forwarded commands) if there is one
-       if (cls.netcon && cls.netcon->message.cursize && NetConn_CanSendMessage(cls.netcon))
-       {
-               if (developer.integer)
-               {
-                       Con_Print("CL_SendCmd: sending reliable message:\n");
-                       SZ_HexDumpToConsole(&cls.netcon->message);
-               }
-               if (NetConn_SendReliableMessage(cls.netcon, &cls.netcon->message) == -1)
-                       Host_Error("CL_WriteToServer: lost server connection");
-               SZ_Clear(&cls.netcon->message);
-       }
-
-       // send a move periodically
-       CL_SendMove();
-}
-
 // LordHavoc: pausedemo command
 static void CL_PauseDemo_f (void)
 {
@@ -1702,6 +1679,10 @@ void CL_Init (void)
 
        Cvar_RegisterVariable(&cl_deathnoviewmodel);
 
+       // for QW connections
+       Cvar_RegisterVariable(&qport);
+       Cvar_SetValueQuick(&qport, (rand() * RAND_MAX + rand()) & 0xffff);
+
        Cmd_AddCommand("timerefresh", CL_TimeRefresh_f, "turn quickly and print rendering statistcs");
 
        CL_Parse_Init();