]> 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 4514e973742fc27af451e5f0ef2f99f3acb20694..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,11 +194,11 @@ void SV_SendServerinfo (client_t *client)
        char                    message[2048];
 
        MSG_WriteByte (&client->message, svc_print);
-       sprintf (message, "%c\nDARKPLACES VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
+       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)
@@ -278,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];
        }
@@ -545,7 +547,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
 
                dodelta = FALSE;
                if ((int)ent->v.effects & EF_DELTA)
-                       dodelta = cl.time < client->nextfullupdate[e]; // every half second a full update is forced
+                       dodelta = sv.time < client->nextfullupdate[e]; // every half second a full update is forced
 
                if (dodelta)
                {
@@ -554,7 +556,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                }
                else
                {
-                       client->nextfullupdate[e] = cl.time + 0.5;
+                       client->nextfullupdate[e] = sv.time + 0.5;
                        baseline = &ent->baseline;
                }
 
@@ -598,7 +600,7 @@ void SV_WriteEntitiesToClient (client_t *client, 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
                {
@@ -680,11 +682,11 @@ void SV_WriteEntitiesToClient (client_t *client, 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
@@ -741,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;
@@ -1015,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;
@@ -1117,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]);
                }
        }
@@ -1170,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];
        }