]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - svvm_cmds.c
a cosmetic change as suggested by div0:
[xonotic/darkplaces.git] / svvm_cmds.c
index 89760f551885a1ab34e2fc1fbb994262f451500c..e58daf81dd99d3cbaf42a050c9b80d602934fbd4 100644 (file)
@@ -7,6 +7,7 @@ cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2", "maximum cosine angle for quake's ver
 
 
 char *vm_sv_extensions =
+"BX_WAL_SUPPORT "
 "DP_CON_EXPANDCVAR "
 "DP_CON_ALIASPARAMETERS "
 "DP_BUTTONCHAT "
@@ -66,8 +67,10 @@ char *vm_sv_extensions =
 "DP_QC_MULTIPLETEMPSTRINGS "
 "DP_QC_RANDOMVEC "
 "DP_QC_SINCOSSQRTPOW "
+"DP_QC_STRFTIME "
 "DP_QC_STRINGBUFFERS "
 "DP_QC_STRINGCOLORFUNCTIONS "
+"DP_QC_UNLIMITEDTEMPSTRINGS "
 "DP_QC_TRACEBOX "
 "DP_QC_TRACETOSS "
 "DP_QC_TRACE_MOVETYPE_HITMODEL "
@@ -91,10 +94,12 @@ char *vm_sv_extensions =
 "DP_SV_DRAWONLYTOCLIENT "
 "DP_SV_DROPCLIENT "
 "DP_SV_EFFECT "
+"DP_SV_ENTITYCONTENTSTRANSITION "
 "DP_SV_NODRAWTOCLIENT "
 "DP_SV_PING "
 "DP_SV_PLAYERPHYSICS "
 "DP_SV_PRECACHEANYTIME "
+"DP_SV_PRINT "
 "DP_SV_PUNCHVECTOR "
 "DP_SV_ROTATINGBMODEL "
 "DP_SV_SETCOLOR "
@@ -487,20 +492,16 @@ 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);
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dpstartcontents)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dpstartcontents)))
                val->_float = trace.startsupercontents;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphitcontents)))
                val->_float = trace.hitsupercontents;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphitq3surfaceflags)))
                val->_float = trace.hitq3surfaceflags;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphittexturename)))
        {
                if (trace.hittexture)
-               {
-                       char *s = VM_GetTempString();
-                       strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH);
-                       val->string = PRVM_SetEngineString(s);
-               }
+                       val->string = PRVM_SetTempString(trace.hittexture->name);
                else
                        val->string = 0;
        }
@@ -553,20 +554,16 @@ 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)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dpstartcontents)))
                val->_float = trace.startsupercontents;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphitcontents)))
                val->_float = trace.hitsupercontents;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphitq3surfaceflags)))
                val->_float = trace.hitq3surfaceflags;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphittexturename)))
        {
                if (trace.hittexture)
-               {
-                       char *s = VM_GetTempString();
-                       strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH);
-                       val->string = PRVM_SetEngineString(s);
-               }
+                       val->string = PRVM_SetTempString(trace.hittexture->name);
                else
                        val->string = 0;
        }
@@ -604,20 +601,16 @@ 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)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dpstartcontents)))
                val->_float = trace.startsupercontents;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitcontents)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphitcontents)))
                val->_float = trace.hitsupercontents;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphitq3surfaceflags)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphitq3surfaceflags)))
                val->_float = trace.hitq3surfaceflags;
-       if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename)))
+       if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_dphittexturename)))
        {
                if (trace.hittexture)
-               {
-                       char *s = VM_GetTempString();
-                       strlcpy(s, trace.hittexture->name, VM_STRINGTEMP_LENGTH);
-                       val->string = PRVM_SetEngineString(s);
-               }
+                       val->string = PRVM_SetTempString(trace.hittexture->name);
                else
                        val->string = 0;
        }
@@ -796,7 +789,7 @@ void PF_findradius (void)
        maxs[0] = org[0] + (radius + 1);
        maxs[1] = org[1] + (radius + 1);
        maxs[2] = org[2] + (radius + 1);
-       numtouchedicts = SV_EntitiesInBox(mins, maxs, MAX_EDICTS, touchedicts);
+       numtouchedicts = World_EntitiesInBox(&sv.world, mins, maxs, MAX_EDICTS, touchedicts);
        if (numtouchedicts > MAX_EDICTS)
        {
                // this never happens
@@ -937,9 +930,10 @@ void PF_droptofloor (void)
 
        trace = SV_Move (ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, end, MOVE_NORMAL, ent);
 
-       if (trace.fraction != 1)
+       if (trace.fraction != 1 || (trace.startsolid && sv_gameplayfix_droptofloorstartsolid.integer))
        {
-               VectorCopy (trace.endpos, ent->fields.server->origin);
+               if (trace.fraction < 1)
+                       VectorCopy (trace.endpos, ent->fields.server->origin);
                SV_LinkEdict (ent, false);
                ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
                ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
@@ -1105,125 +1099,6 @@ void PF_aim (void)
        }
 }
 
-/*
-==============
-PF_changeyaw
-
-This was a major timewaster in progs, so it was converted to C
-==============
-*/
-void PF_changeyaw (void)
-{
-       prvm_edict_t            *ent;
-       float           ideal, current, move, speed;
-
-       ent = PRVM_PROG_TO_EDICT(prog->globals.server->self);
-       if (ent == prog->edicts)
-       {
-               VM_Warning("changeyaw: can not modify world entity\n");
-               return;
-       }
-       if (ent->priv.server->free)
-       {
-               VM_Warning("changeyaw: can not modify free entity\n");
-               return;
-       }
-       current = ANGLEMOD(ent->fields.server->angles[1]);
-       ideal = ent->fields.server->ideal_yaw;
-       speed = ent->fields.server->yaw_speed;
-
-       if (current == ideal)
-               return;
-       move = ideal - current;
-       if (ideal > current)
-       {
-               if (move >= 180)
-                       move = move - 360;
-       }
-       else
-       {
-               if (move <= -180)
-                       move = move + 360;
-       }
-       if (move > 0)
-       {
-               if (move > speed)
-                       move = speed;
-       }
-       else
-       {
-               if (move < -speed)
-                       move = -speed;
-       }
-
-       ent->fields.server->angles[1] = ANGLEMOD (current + move);
-}
-
-/*
-==============
-PF_changepitch
-==============
-*/
-void PF_changepitch (void)
-{
-       prvm_edict_t            *ent;
-       float           ideal, current, move, speed;
-       prvm_eval_t             *val;
-
-       ent = PRVM_G_EDICT(OFS_PARM0);
-       if (ent == prog->edicts)
-       {
-               VM_Warning("changepitch: can not modify world entity\n");
-               return;
-       }
-       if (ent->priv.server->free)
-       {
-               VM_Warning("changepitch: can not modify free entity\n");
-               return;
-       }
-       current = ANGLEMOD( ent->fields.server->angles[0] );
-       if ((val = PRVM_GETEDICTFIELDVALUE(ent, eval_idealpitch)))
-               ideal = val->_float;
-       else
-       {
-               VM_Warning("PF_changepitch: .float idealpitch and .float pitch_speed must be defined to use changepitch\n");
-               return;
-       }
-       if ((val = PRVM_GETEDICTFIELDVALUE(ent, eval_pitch_speed)))
-               speed = val->_float;
-       else
-       {
-               VM_Warning("PF_changepitch: .float idealpitch and .float pitch_speed must be defined to use changepitch\n");
-               return;
-       }
-
-       if (current == ideal)
-               return;
-       move = ideal - current;
-       if (ideal > current)
-       {
-               if (move >= 180)
-                       move = move - 360;
-       }
-       else
-       {
-               if (move <= -180)
-                       move = move + 360;
-       }
-       if (move > 0)
-       {
-               if (move > speed)
-                       move = speed;
-       }
-       else
-       {
-               if (move < -speed)
-                       move = -speed;
-       }
-
-       ent->fields.server->angles[0] = ANGLEMOD (current + move);
-}
-
 /*
 ===============================================================================
 
@@ -1665,7 +1540,7 @@ void PF_setcolor (void)
        client = svs.clients + entnum-1;
        if (client->edict)
        {
-               if ((val = PRVM_GETEDICTFIELDVALUE(client->edict, eval_clientcolors)))
+               if ((val = PRVM_EDICTFIELDVALUE(client->edict, prog->fieldoffsets.clientcolors)))
                        val->_float = i;
                client->edict->fields.server->team = (i & 15) + 1;
        }
@@ -1692,7 +1567,7 @@ void PF_effect (void)
        int i;
        const char *s;
        s = PRVM_G_STRING(OFS_PARM1);
-       if (!s || !s[0])
+       if (!s[0])
        {
                VM_Warning("effect: no model specified\n");
                return;
@@ -1704,6 +1579,19 @@ void PF_effect (void)
                VM_Warning("effect: model not precached\n");
                return;
        }
+
+       if (PRVM_G_FLOAT(OFS_PARM3) < 1)
+       {
+               VM_Warning("effect: framecount < 1\n");
+               return;
+       }
+
+       if (PRVM_G_FLOAT(OFS_PARM4) < 1)
+       {
+               VM_Warning("effect: framerate < 1\n");
+               return;
+       }
+
        SV_StartEffect(PRVM_G_VECTOR(OFS_PARM0), i, (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4));
 }
 
@@ -2225,10 +2113,10 @@ void PF_getsurfacetexture(void)
 {
        model_t *model;
        msurface_t *surface;
-       PRVM_G_INT(OFS_RETURN) = 0;
+       PRVM_G_INT(OFS_RETURN) = OFS_NULL;
        if (!(model = getmodel(PRVM_G_EDICT(OFS_PARM0))) || !(surface = getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
                return;
-       PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(surface->texture->name);
+       PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(surface->texture->name);
 }
 //PF_getsurfacenearpoint, // #438 float(entity e, vector p) getsurfacenearpoint = #438;
 void PF_getsurfacenearpoint(void)
@@ -2341,11 +2229,11 @@ void PF_setattachment (void)
        if (tagentity == NULL)
                tagentity = prog->edicts;
 
-       v = PRVM_GETEDICTFIELDVALUE(e, eval_tag_entity);
+       v = PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.tag_entity);
        if (v)
                v->edict = PRVM_EDICT_TO_PROG(tagentity);
 
-       v = PRVM_GETEDICTFIELDVALUE(e, eval_tag_index);
+       v = PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.tag_index);
        if (v)
                v->_float = 0;
        if (tagentity != NULL && tagentity != prog->edicts && tagname && tagname[0])
@@ -2380,7 +2268,7 @@ int SV_GetTagIndex (prvm_edict_t *e, const char *tagname)
 
 void SV_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatrix)
 {
-       float scale = PRVM_GETEDICTFIELDVALUE(ent, eval_scale)->_float;
+       float scale = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.scale)->_float;
        if (scale == 0)
                scale = 1;
        if (viewmatrix)
@@ -2456,9 +2344,9 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                SV_GetEntityMatrix(ent, &entitymatrix, false);
                Matrix4x4_Concat(&tagmatrix, &entitymatrix, out);
                // next iteration we process the parent entity
-               if ((val = PRVM_GETEDICTFIELDVALUE(ent, eval_tag_entity)) && val->edict)
+               if ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.tag_entity)) && val->edict)
                {
-                       tagindex = (int)PRVM_GETEDICTFIELDVALUE(ent, eval_tag_index)->_float;
+                       tagindex = (int)PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.tag_index)->_float;
                        ent = PRVM_EDICT_NUM(val->edict);
                }
                else
@@ -2467,7 +2355,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
        }
 
        // RENDER_VIEWMODEL magic
-       if ((val = PRVM_GETEDICTFIELDVALUE(ent, eval_viewmodelforclient)) && val->edict)
+       if ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.viewmodelforclient)) && val->edict)
        {
                Matrix4x4_Copy(&tagmatrix, out);
                ent = PRVM_EDICT_NUM(val->edict);
@@ -2679,7 +2567,7 @@ VM_cvar,                                  // #45 float(string s) cvar
 VM_localcmd,                           // #46 void(string s) localcmd
 VM_nextent,                                    // #47 entity(entity e) nextent
 PF_particle,                           // #48 void(vector o, vector d, float color, float count) particle
-PF_changeyaw,                          // #49 void() ChangeYaw
+VM_changeyaw,                          // #49 void() ChangeYaw
 NULL,                                          // #50
 VM_vectoangles,                                // #51 vector(vector v) vectoangles
 PF_WriteByte,                          // #52 void(float to, float f) WriteByte
@@ -2693,7 +2581,7 @@ PF_WriteEntity,                           // #59 void(float to, entity e) WriteEntity
 VM_sin,                                                // #60 float(float f) sin (DP_QC_SINCOSSQRTPOW)
 VM_cos,                                                // #61 float(float f) cos (DP_QC_SINCOSSQRTPOW)
 VM_sqrt,                                       // #62 float(float f) sqrt (DP_QC_SINCOSSQRTPOW)
-PF_changepitch,                                // #63 void(entity ent) changepitch (DP_QC_CHANGEPITCH)
+VM_changepitch,                                // #63 void(entity ent) changepitch (DP_QC_CHANGEPITCH)
 PF_tracetoss,                          // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
 VM_etos,                                       // #65 string(entity ent) etos (DP_QC_ETOS)
 NULL,                                          // #66
@@ -2780,7 +2668,25 @@ e10,                                             // #260-#269
 e10,                                           // #270-#279
 e10,                                           // #280-#289
 e10,                                           // #290-#299
-e10, e10, e10, e10, e10, e10, e10, e10, e10, e10,      // #300-399
+e10,                                           // #300-309
+e10,                                           // #310-319
+e10,                                           // #320-329
+NULL,                                          // #330
+NULL,                                          // #331
+NULL,                                          // #332
+NULL,                                          // #333
+NULL,                                          // #334
+NULL,                                          // #335
+NULL,                                          // #336
+NULL,                                          // #337
+NULL,                                          // #338
+VM_print,                                      // #339 void(string, ...) print (DP_SV_PRINT)
+e10,                                           // #340-349
+e10,                                           // #350-359
+e10,                                           // #360-369
+e10,                                           // #370-379
+e10,                                           // #380-389
+e10,                                           // #390-399
 VM_copyentity,                         // #400 void(entity from, entity to) copyentity (DP_QC_COPYENTITY)
 PF_setcolor,                           // #401 void(entity ent, float colors) setcolor (DP_QC_SETCOLOR)
 VM_findchain,                          // #402 entity(.string fld, string match) findchain (DP_QC_FINDCHAIN)
@@ -2858,7 +2764,8 @@ VM_atan,                                  // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
 VM_atan2,                                      // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
 VM_tan,                                                // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
 VM_strlennocol,                                // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
-VM_strdecolorize,                      // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
+VM_strdecolorize,                      // #477 string(string s) : DRESK - Decolorized String (DP_SV_STRINGCOLORFUNCTIONS)
+VM_strftime,                           // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME)
 NULL,                                          // #478
 NULL,                                          // #479
 e10, e10                                       // #480-499 (LordHavoc)