]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
Coordinates are now floats in network protocol (bloats it yes, but the accuracy allow...
[xonotic/darkplaces.git] / sv_main.c
index f2bf0ad5018ffdfa1bfac01b0021bce15ce2e49b..0d51ed41db7203cb10e75e9a3466db33869081bc 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -46,6 +46,7 @@ void SV_Init (void)
        extern  cvar_t  sv_accelerate;
        extern  cvar_t  sv_idealpitchscale;
        extern  cvar_t  sv_aim;
+       extern  cvar_t  sv_predict;
 
        Cvar_RegisterVariable (&sv_maxvelocity);
        Cvar_RegisterVariable (&sv_gravity);
@@ -57,6 +58,7 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_idealpitchscale);
        Cvar_RegisterVariable (&sv_aim);
        Cvar_RegisterVariable (&sv_nostep);
+       Cvar_RegisterVariable (&sv_predict);
 
        for (i=0 ; i<MAX_MODELS ; i++)
                sprintf (localmodels[i], "*%i", i);
@@ -84,9 +86,9 @@ void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count)
        if (sv.datagram.cursize > MAX_DATAGRAM-16)
                return; 
        MSG_WriteByte (&sv.datagram, svc_particle);
-       MSG_WriteCoord (&sv.datagram, org[0]);
-       MSG_WriteCoord (&sv.datagram, org[1]);
-       MSG_WriteCoord (&sv.datagram, org[2]);
+       MSG_WriteFloatCoord (&sv.datagram, org[0]);
+       MSG_WriteFloatCoord (&sv.datagram, org[1]);
+       MSG_WriteFloatCoord (&sv.datagram, org[2]);
        for (i=0 ; i<3 ; i++)
        {
                v = dir[i]*16;
@@ -167,7 +169,7 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
        MSG_WriteShort (&sv.datagram, channel);
        MSG_WriteByte (&sv.datagram, sound_num);
        for (i=0 ; i<3 ; i++)
-               MSG_WriteCoord (&sv.datagram, entity->v.origin[i]+0.5*(entity->v.mins[i]+entity->v.maxs[i]));
+               MSG_WriteFloatCoord (&sv.datagram, entity->v.origin[i]+0.5*(entity->v.mins[i]+entity->v.maxs[i]));
 }           
 
 /*
@@ -192,15 +194,11 @@ void SV_SendServerinfo (client_t *client)
        char                    message[2048];
 
        MSG_WriteByte (&client->message, svc_print);
-#ifdef NEHAHRA
-       sprintf (message, "%c\nDPNEHAHRA VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
-#else
-       sprintf (message, "%c\nDARKPLACES VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
-#endif
+       sprintf (message, "%c\nDARKPLACES VERSION %4.2f BUILD %i SERVER (%i CRC)", 2, VERSION, buildnumber, pr_crc);
        MSG_WriteString (&client->message,message);
 
        MSG_WriteByte (&client->message, svc_serverinfo);
-       MSG_WriteLong (&client->message, PROTOCOL_VERSION);
+       MSG_WriteLong (&client->message, DPPROTOCOL_VERSION);
        MSG_WriteByte (&client->message, svs.maxclients);
 
        if (!coop.value && deathmatch.value)
@@ -282,7 +280,7 @@ void SV_ConnectClient (int clientnum)
        else
        {
        // call the progs to get default spawn parms for the new client
-               PR_ExecuteProgram (pr_global_struct->SetNewParms);
+               PR_ExecuteProgram (pr_global_struct->SetNewParms, "QC function SetNewParms is missing");
                for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
                        client->spawn_parms[i] = (&pr_global_struct->parm1)[i];
        }
@@ -422,7 +420,7 @@ SV_WriteEntitiesToClient
 
 =============
 */
-void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
+void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
 {
        int             e, i, clentnum, bits, alpha, glowcolor, glowsize, scale, colormod, modred, modgreen, modblue, dodelta, effects;
        byte    *pvs;
@@ -549,7 +547,7 @@ void SV_WriteEntitiesToClient (edict_t      *clent, sizebuf_t *msg)
 
                dodelta = FALSE;
                if ((int)ent->v.effects & EF_DELTA)
-                       dodelta = cl.time < ent->nextfullupdate; // every half second a full update is forced
+                       dodelta = sv.time < client->nextfullupdate[e]; // every half second a full update is forced
 
                if (dodelta)
                {
@@ -558,7 +556,7 @@ void SV_WriteEntitiesToClient (edict_t      *clent, sizebuf_t *msg)
                }
                else
                {
-                       ent->nextfullupdate = cl.time + 0.5;
+                       client->nextfullupdate[e] = sv.time + 0.5;
                        baseline = &ent->baseline;
                }
 
@@ -602,7 +600,7 @@ void SV_WriteEntitiesToClient (edict_t      *clent, sizebuf_t *msg)
                        angles[0] = angles[0] * movelerp + ent->stepoldangles[0];
                        angles[1] = angles[1] * movelerp + ent->stepoldangles[1];
                        angles[2] = angles[2] * movelerp + ent->stepoldangles[2];
-                       VectorMA(origin, host_client->ping, ent->v.velocity, origin);
+                       VectorMA(origin, host_client->latency, ent->v.velocity, origin);
                }
                else // copy as they are
                {
@@ -684,11 +682,11 @@ void SV_WriteEntitiesToClient (edict_t    *clent, sizebuf_t *msg)
                if (bits & U_COLORMAP)  MSG_WriteByte (msg, ent->v.colormap);
                if (bits & U_SKIN)              MSG_WriteByte (msg, ent->v.skin);
                if (bits & U_EFFECTS)   MSG_WriteByte (msg, ent->v.effects);
-               if (bits & U_ORIGIN1)   MSG_WriteCoord (msg, origin[0]);
+               if (bits & U_ORIGIN1)   MSG_WriteFloatCoord (msg, origin[0]);
                if (bits & U_ANGLE1)    MSG_WriteAngle(msg, angles[0]);
-               if (bits & U_ORIGIN2)   MSG_WriteCoord (msg, origin[1]);
+               if (bits & U_ORIGIN2)   MSG_WriteFloatCoord (msg, origin[1]);
                if (bits & U_ANGLE2)    MSG_WriteAngle(msg, angles[1]);
-               if (bits & U_ORIGIN3)   MSG_WriteCoord (msg, origin[2]);
+               if (bits & U_ORIGIN3)   MSG_WriteFloatCoord (msg, origin[2]);
                if (bits & U_ANGLE3)    MSG_WriteAngle(msg, angles[2]);
 
                // LordHavoc: new stuff
@@ -745,7 +743,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
                MSG_WriteByte (msg, ent->v.dmg_save);
                MSG_WriteByte (msg, ent->v.dmg_take);
                for (i=0 ; i<3 ; i++)
-                       MSG_WriteCoord (msg, other->v.origin[i] + 0.5*(other->v.mins[i] + other->v.maxs[i]));
+                       MSG_WriteFloatCoord (msg, other->v.origin[i] + 0.5*(other->v.mins[i] + other->v.maxs[i]));
        
                ent->v.dmg_take = 0;
                ent->v.dmg_save = 0;
@@ -880,7 +878,7 @@ qboolean SV_SendClientDatagram (client_t *client)
 // add the client specific data to the datagram
        SV_WriteClientdataToMessage (client->edict, &msg);
 
-       SV_WriteEntitiesToClient (client->edict, &msg);
+       SV_WriteEntitiesToClient (client, client->edict, &msg);
 
 // copy the server datagram if there is space
        if (msg.cursize + sv.datagram.cursize < msg.maxsize)
@@ -1019,8 +1017,7 @@ void SV_SendClientMessages (void)
                                SV_DropClient (false);  // went to another level
                        else
                        {
-                               if (NET_SendMessage (host_client->netconnection
-                               , &host_client->message) == -1)
+                               if (NET_SendMessage (host_client->netconnection, &host_client->message) == -1)
                                        SV_DropClient (true);   // if the message couldn't send, kick off
                                SZ_Clear (&host_client->message);
                                host_client->last_message = realtime;
@@ -1121,7 +1118,7 @@ void SV_CreateBaseline (void)
                MSG_WriteByte (&sv.signon, svent->baseline.skin);
                for (i=0 ; i<3 ; i++)
                {
-                       MSG_WriteCoord(&sv.signon, svent->baseline.origin[i]);
+                       MSG_WriteFloatCoord(&sv.signon, svent->baseline.origin[i]);
                        MSG_WriteAngle(&sv.signon, svent->baseline.angles[i]);
                }
        }
@@ -1174,7 +1171,7 @@ void SV_SaveSpawnparms (void)
 
        // call the progs to get default spawn parms for the new client
                pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
-               PR_ExecuteProgram (pr_global_struct->SetChangeParms);
+               PR_ExecuteProgram (pr_global_struct->SetChangeParms, "QC function SetChangeParms is missing");
                for (j=0 ; j<NUM_SPAWN_PARMS ; j++)
                        host_client->spawn_parms[j] = (&pr_global_struct->parm1)[j];
        }
@@ -1341,23 +1338,3 @@ void SV_SpawnServer (char *server)
        
        Con_DPrintf ("Server spawned.\n");
 }
-
-// LordHavoc: added light checking to the server
-int RecursiveLightPoint (vec3_t color, mnode_t *node, vec3_t start, vec3_t end);
-void SV_LightPoint (vec3_t color, vec3_t p)
-{
-       vec3_t          end;
-       
-       if (!sv.worldmodel->lightdata)
-       {
-               color[0] = color[1] = color[2] = 255;
-               return;
-       }
-       
-       end[0] = p[0];
-       end[1] = p[1];
-       end[2] = p[2] - 2048;
-
-       color[0] = color[1] = color[2] = 0;
-       RecursiveLightPoint (color, sv.worldmodel->nodes, p, end);
-}