]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - svvm_cmds.c
removed detection of GL_NV_texture_shader extension which was previously used for...
[xonotic/darkplaces.git] / svvm_cmds.c
index e62b2511b1d300b7b8ef518a35255af70892fef1..860d7a027742355823f97d2924bdde17791b6f61 100644 (file)
@@ -4,7 +4,7 @@
 // Server
 
 #define PF_WARNING(s) do{Con_Printf(s);PRVM_PrintState();return;}while(0)
-cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2"}; //"0.93"}; // LordHavoc: disabled autoaim by default
+cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2", "maximum cosine angle for quake's vertical autoaim, a value above 1 completely disables the autoaim, quake used 0.93"}; //"0.93"}; // LordHavoc: disabled autoaim by default
 
 
 char *vm_sv_extensions =
@@ -265,9 +265,12 @@ void PF_sprint (void)
        }
 
        client = svs.clients + entnum-1;
+       if (!client->netconnection)
+               return;
+
        VM_VarString(1, string, sizeof(string));
-       MSG_WriteChar(&client->message,svc_print);
-       MSG_WriteString(&client->message, string);
+       MSG_WriteChar(&client->netconnection->message,svc_print);
+       MSG_WriteString(&client->netconnection->message, string);
 }
 
 
@@ -295,9 +298,12 @@ void PF_centerprint (void)
        }
 
        client = svs.clients + entnum-1;
+       if (!client->netconnection)
+               return;
+
        VM_VarString(1, string, sizeof(string));
-       MSG_WriteChar(&client->message,svc_centerprint);
-       MSG_WriteString(&client->message, string);
+       MSG_WriteChar(&client->netconnection->message,svc_centerprint);
+       MSG_WriteString(&client->netconnection->message, string);
 }
 
 /*
@@ -433,6 +439,9 @@ void PF_traceline (void)
        move = PRVM_G_FLOAT(OFS_PARM2);
        ent = PRVM_G_EDICT(OFS_PARM3);
 
+       if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v1[2]) || IS_NAN(v2[2]))
+               PRVM_ERROR("%s: NAN errors detected in traceline('%f %f %f', '%f %f %f', %i, entity %i)\n", PRVM_NAME, v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent));
+
        trace = SV_Move (v1, vec3_origin, vec3_origin, v2, move, ent);
 
        prog->globals.server->trace_allsolid = trace.allsolid;
@@ -479,6 +488,9 @@ void PF_tracebox (void)
        move = PRVM_G_FLOAT(OFS_PARM4);
        ent = PRVM_G_EDICT(OFS_PARM5);
 
+       if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v1[2]) || IS_NAN(v2[2]))
+               PRVM_ERROR("%s: NAN errors detected in tracebox('%f %f %f', '%f %f %f', '%f %f %f', '%f %f %f', %i, entity %i)\n", PRVM_NAME, v1[0], v1[1], v1[2], m1[0], m1[1], m1[2], m2[0], m2[1], m2[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent));
+
        trace = SV_Move (v1, m1, m2, v2, move, ent);
 
        prog->globals.server->trace_allsolid = trace.allsolid;
@@ -869,11 +881,11 @@ void PF_lightstyle (void)
 
        for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
        {
-               if (client->active)
+               if (client->active && client->netconnection)
                {
-                       MSG_WriteChar (&client->message, svc_lightstyle);
-                       MSG_WriteChar (&client->message,style);
-                       MSG_WriteString (&client->message, val);
+                       MSG_WriteChar (&client->netconnection->message, svc_lightstyle);
+                       MSG_WriteChar (&client->netconnection->message,style);
+                       MSG_WriteString (&client->netconnection->message, val);
                }
        }
 }
@@ -1126,13 +1138,13 @@ sizebuf_t *WriteDest (void)
        case MSG_ONE:
                ent = PRVM_PROG_TO_EDICT(prog->globals.server->msg_entity);
                entnum = PRVM_NUM_FOR_EDICT(ent);
-               if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active)
+               if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active || !svs.clients[entnum-1].netconnection)
                {
                        Con_Printf ("WriteDest: tried to write to non-client\n");
                        return &sv.reliable_datagram;
                }
                else
-                       return &svs.clients[entnum-1].message;
+                       return &svs.clients[entnum-1].netconnection->message;
 
        default:
                Con_Printf ("WriteDest: bad destination\n");
@@ -2246,7 +2258,7 @@ int SV_GetEntityLocalTagMatrix(prvm_edict_t *ent, int tagindex, matrix4x4_t *out
                        frame = 0;
                return Mod_Alias_GetTagMatrix(model, model->animscenes[frame].firstframe, tagindex, out);
        }
-       Matrix4x4_CreateIdentity(out);
+       *out = identitymatrix;
        return 0;
 }
 
@@ -2268,7 +2280,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
        matrix4x4_t entitymatrix, tagmatrix, attachmatrix;
        model_t *model;
 
-       Matrix4x4_CreateIdentity(out); // warnings and errors return identical matrix
+       *out = identitymatrix; // warnings and errors return identical matrix
 
        if (ent == prog->edicts)
                return 1;
@@ -2281,7 +2293,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
 
        model = sv.models[modelindex];
 
-       Matrix4x4_CreateIdentity(&tagmatrix);
+       tagmatrix = identitymatrix;
        // DP_GFX_QUAKE3MODELTAGS, scan all chain and stop on unattached entity
        attachloop = 0;
        for (;;)
@@ -2428,6 +2440,9 @@ void PF_spawnclient (void)
                {
                        prog->xfunction->builtinsprofile += 100;
                        SV_ConnectClient (i, NULL);
+                       // this has to be set or else ClientDisconnect won't be called
+                       // we assume the qc will call ClientConnect...
+                       svs.clients[i].clientconnectcalled = true;
                        ed = PRVM_EDICT_NUM(i + 1);
                        break;
                }
@@ -2687,7 +2702,7 @@ NULL,                                             // #476
 NULL,                                          // #477
 NULL,                                          // #478
 NULL,                                          // #479
-e10, e10                                       // #471-499 (LordHavoc)
+e10, e10                                       // #480-499 (LordHavoc)
 };
 
 const int vm_sv_numbuiltins = sizeof(vm_sv_builtins) / sizeof(prvm_builtin_t);