]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
combined glClear calls, may be a speedup
[xonotic/darkplaces.git] / sv_main.c
index 454d6a038309792a50ec5e7bdcdac6eaf32473db..a22d9395cbfcbaf99effde9ce4f0791f6b4b1c56 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -124,13 +124,13 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
        int                     ent;
        
        if (volume < 0 || volume > 255)
-               Sys_Error ("SV_StartSound: volume = %i", volume);
+               Host_Error ("SV_StartSound: volume = %i", volume);
 
        if (attenuation < 0 || attenuation > 4)
-               Sys_Error ("SV_StartSound: attenuation = %f", attenuation);
+               Host_Error ("SV_StartSound: attenuation = %f", attenuation);
 
        if (channel < 0 || channel > 7)
-               Sys_Error ("SV_StartSound: channel = %i", channel);
+               Host_Error ("SV_StartSound: channel = %i", channel);
 
        if (sv.datagram.cursize > MAX_DATAGRAM-16)
                return; 
@@ -193,9 +193,9 @@ void SV_SendServerinfo (client_t *client)
 
        MSG_WriteByte (&client->message, svc_print);
 #ifdef NEHAHRA
-       sprintf (message, "%c\nDPNEHAHRA VERSION %4.2f SERVER (%i CRC)", 2, DP_VERSION, pr_crc);
+       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, DP_VERSION, pr_crc);
+       sprintf (message, "%c\nDARKPLACES VERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
 #endif
        MSG_WriteString (&client->message,message);
 
@@ -277,12 +277,6 @@ void SV_ConnectClient (int clientnum)
        client->message.maxsize = sizeof(client->msgbuf);
        client->message.allowoverflow = true;           // we can catch it
 
-#ifdef IDGODS
-       client->privileged = IsID(&client->netconnection->addr);
-#else  
-       client->privileged = false;                             
-#endif
-
        if (sv.loadgame)
                memcpy (client->spawn_parms, spawn_parms, sizeof(spawn_parms));
        else
@@ -441,8 +435,17 @@ void SV_WriteEntitiesToClient (edict_t     *clent, sizebuf_t *msg)
 // find the client's PVS
        VectorAdd (clent->v.origin, clent->v.view_ofs, org);
        pvs = SV_FatPVS (org);
+       /*
+       if (dpprotocol)
+       {
+               MSG_WriteByte(msg, svc_playerposition);
+               MSG_WriteFloat(msg, org[0]);
+               MSG_WriteFloat(msg, org[1]);
+               MSG_WriteFloat(msg, org[2]);
+       }
+       */
 
-       clentnum = NUM_FOR_EDICT(clent); // LordHavoc: for comparison purposes
+       clentnum = EDICT_TO_PROG(clent); // LordHavoc: for comparison purposes
 // send over all entities (except the client) that touch the pvs
        ent = NEXT_EDICT(sv.edicts);
        for (e=1 ; e<sv.num_edicts ; e++, ent = NEXT_EDICT(ent))
@@ -482,37 +485,37 @@ void SV_WriteEntitiesToClient (edict_t    *clent, sizebuf_t *msg)
                colormod = 255;
                effects = ent->v.effects;
 
-               if (val = GETEDICTFIELDVALUE(ent, eval_alpha))
+               if ((val = GETEDICTFIELDVALUE(ent, eval_alpha)))
                if ((alpha = (int) (val->_float * 255.0)) == 0)
                        alpha = 255;
-               if (val = GETEDICTFIELDVALUE(ent, eval_renderamt)) // HalfLife support
-                       alpha -= (int) val->_float;
+               if ((val = GETEDICTFIELDVALUE(ent, eval_renderamt)) && val->_float != 0) // HalfLife support
+                       alpha = (int) val->_float;
                if (alpha < 0) alpha = 0;
                if (alpha > 255) alpha = 255;
 
-               if (val = GETEDICTFIELDVALUE(ent, eval_glow_size))
-                       glowsize = (int) val->_float >> 3;
-               if (glowsize > 127) glowsize = 127;
-               if (glowsize < -128) glowsize = -128;
+               if ((val = GETEDICTFIELDVALUE(ent, eval_glow_size)))
+                       glowsize = (int) val->_float >> 2;
+               if (glowsize > 255) glowsize = 255;
+               if (glowsize < 0) glowsize = 0;
 
-               if (val = GETEDICTFIELDVALUE(ent, eval_scale))
+               if ((val = GETEDICTFIELDVALUE(ent, eval_scale)))
                if ((scale = (int) (val->_float * 16.0)) == 0) scale = 16;
                if (scale < 0) scale = 0;
                if (scale > 255) scale = 255;
 
-               if (val = GETEDICTFIELDVALUE(ent, eval_glow_trail))
+               if ((val = GETEDICTFIELDVALUE(ent, eval_glow_trail)))
                if (val->_float != 0)
                        bits |= U_GLOWTRAIL;
 
-               if (val = GETEDICTFIELDVALUE(ent, eval_glow_color))
+               if ((val = GETEDICTFIELDVALUE(ent, eval_glow_color)))
                if (val->_float != 0)
                        glowcolor = (int) val->_float;
 
-               if (val = GETEDICTFIELDVALUE(ent, eval_fullbright))
+               if ((val = GETEDICTFIELDVALUE(ent, eval_fullbright)))
                if (val->_float != 0)
                        effects |= EF_FULLBRIGHT;
 
-               if (val = GETEDICTFIELDVALUE(ent, eval_colormod))
+               if ((val = GETEDICTFIELDVALUE(ent, eval_colormod)))
                if (val->vector[0] != 0 || val->vector[1] != 0 || val->vector[2] != 0)
                {
                        modred = val->vector[0] * 8.0;if (modred < 0) modred = 0;if (modred > 7) modred = 7;
@@ -599,11 +602,13 @@ 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);
                }
                else // copy as they are
                {
-                       VectorCopy(ent->v.origin, origin);
+//                     VectorCopy(ent->v.origin, origin);
                        VectorCopy(ent->v.angles, angles);
+                       VectorMA(ent->v.origin, host_client->latency, ent->v.velocity, origin);
                        if (ent->v.movetype == MOVETYPE_STEP) // monster, but airborn, update lerp info
                        {
                                // update lerp positions
@@ -679,7 +684,7 @@ 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_WriteCoord (msg, origin[0]);
                if (bits & U_ANGLE1)    MSG_WriteAngle(msg, angles[0]);
                if (bits & U_ORIGIN2)   MSG_WriteCoord (msg, origin[1]);
                if (bits & U_ANGLE2)    MSG_WriteAngle(msg, angles[1]);
@@ -1055,7 +1060,7 @@ int SV_ModelIndex (char *name)
                if (!strcmp(sv.model_precache[i], name))
                        return i;
        if (i==MAX_MODELS || !sv.model_precache[i])
-               Sys_Error ("SV_ModelIndex: model %s not precached", name);
+               Host_Error ("SV_ModelIndex: model %s not precached", name);
        return i;
 }
 
@@ -1336,23 +1341,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);
-}