]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - svvm_cmds.c
patch from div0 to fix disappearing items in nexuiz (trace_* globals in qc were not...
[xonotic/darkplaces.git] / svvm_cmds.c
index 863e94f5f6c9fb823eef9d144daab9fc7b153e23..c5db79beb498c8c9ef98a4c9446965b6ded87f99 100644 (file)
@@ -111,6 +111,7 @@ char *vm_sv_extensions =
 "DP_TE_SMALLFLASH "
 "DP_TE_SPARK "
 "DP_TE_STANDARDEFFECTBUILTINS "
+"DP_TRACE_HITCONTENTSMASK_SURFACEINFO "
 "DP_VIEWZOOM "
 "EXT_BITSHIFT "
 //"EXT_CSQC " // not ready yet
@@ -431,6 +432,7 @@ void PF_traceline (void)
        trace_t trace;
        int             move;
        prvm_edict_t    *ent;
+       prvm_eval_t *val;
 
        prog->xfunction->builtinsprofile += 30;
 
@@ -456,7 +458,23 @@ void PF_traceline (void)
                prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(trace.ent);
        else
                prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
-       // FIXME: add trace_endcontents
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dpstartcontents)))
+               val->_float = trace.startsupercontents;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents)))
+               val->_float = trace.hitsupercontents;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags)))
+               val->_float = trace.hitq3surfaceflags;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename)))
+       {
+               if (trace.hittexture)
+               {
+                       char *s = VM_GetTempString();
+                       strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH);
+                       val->string = PRVM_SetEngineString(s);
+               }
+               else
+                       val->string = 0;
+       }
 }
 
 
@@ -478,6 +496,7 @@ void PF_tracebox (void)
        trace_t trace;
        int             move;
        prvm_edict_t    *ent;
+       prvm_eval_t *val;
 
        prog->xfunction->builtinsprofile += 30;
 
@@ -505,6 +524,23 @@ void PF_tracebox (void)
                prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(trace.ent);
        else
                prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dpstartcontents)))
+               val->_float = trace.startsupercontents;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents)))
+               val->_float = trace.hitsupercontents;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags)))
+               val->_float = trace.hitq3surfaceflags;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename)))
+       {
+               if (trace.hittexture)
+               {
+                       char *s = VM_GetTempString();
+                       strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH);
+                       val->string = PRVM_SetEngineString(s);
+               }
+               else
+                       val->string = 0;
+       }
 }
 
 extern trace_t SV_Trace_Toss (prvm_edict_t *ent, prvm_edict_t *ignore);
@@ -513,6 +549,7 @@ void PF_tracetoss (void)
        trace_t trace;
        prvm_edict_t    *ent;
        prvm_edict_t    *ignore;
+       prvm_eval_t *val;
 
        prog->xfunction->builtinsprofile += 600;
 
@@ -535,6 +572,23 @@ void PF_tracetoss (void)
                prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(trace.ent);
        else
                prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(prog->edicts);
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dpstartcontents)))
+               val->_float = trace.startsupercontents;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents)))
+               val->_float = trace.hitsupercontents;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags)))
+               val->_float = trace.hitq3surfaceflags;
+       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename)))
+       {
+               if (trace.hittexture)
+               {
+                       char *s = VM_GetTempString();
+                       strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH);
+                       val->string = PRVM_SetEngineString(s);
+               }
+               else
+                       val->string = 0;
+       }
 }
 
 
@@ -2258,7 +2312,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;
 }
 
@@ -2280,7 +2334,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;
@@ -2293,7 +2347,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 (;;)
@@ -2440,6 +2494,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;
                }
@@ -2699,7 +2756,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);