]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - svvm_cmds.c
added DP_ENT_GLOWMOD extension, like DP_ENT_COLORMOD but alters glow
[xonotic/darkplaces.git] / svvm_cmds.c
index 8bd628f5ea7e60caf2fc2fc48212a4cedb4d09f0..ede31ff32845761431c5389c1f8fe742c78f8495 100644 (file)
@@ -38,6 +38,7 @@ char *vm_sv_extensions =
 "DP_ENT_CUSTOMCOLORMAP "
 "DP_ENT_EXTERIORMODELTOCLIENT "
 "DP_ENT_GLOW "
+"DP_ENT_GLOWMOD "
 "DP_ENT_LOWPRECISION "
 "DP_ENT_SCALE "
 "DP_ENT_VIEWMODEL "
@@ -211,7 +212,7 @@ static void VM_SV_setorigin (void)
        }
        org = PRVM_G_VECTOR(OFS_PARM1);
        VectorCopy (org, e->fields.server->origin);
-       SV_LinkEdict (e, false);
+       SV_LinkEdict(e);
 }
 
 // TODO: rotate param isnt used.. could be a bug. please check this and remove it if possible [1/10/2008 Black]
@@ -228,7 +229,7 @@ static void SetMinMaxSize (prvm_edict_t *e, float *min, float *max, qboolean rot
        VectorCopy (max, e->fields.server->maxs);
        VectorSubtract (max, min, e->fields.server->size);
 
-       SV_LinkEdict (e, false);
+       SV_LinkEdict(e);
 }
 
 /*
@@ -582,7 +583,7 @@ static void VM_SV_traceline (void)
        if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v2[1]) || 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, SV_GenericHitSuperContentsMask(ent));
+       trace = SV_TraceLine(v1, v2, move, ent, SV_GenericHitSuperContentsMask(ent));
 
        VM_SetTraceGlobals(&trace);
 }
@@ -621,7 +622,7 @@ static void VM_SV_tracebox (void)
        if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v2[1]) || 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, SV_GenericHitSuperContentsMask(ent));
+       trace = SV_TraceBox(v1, m1, m2, v2, move, ent, SV_GenericHitSuperContentsMask(ent));
 
        VM_SetTraceGlobals(&trace);
 }
@@ -657,7 +658,7 @@ static trace_t SV_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore)
                VectorMA (tossent->fields.server->angles, 0.05, tossent->fields.server->avelocity, tossent->fields.server->angles);
                VectorScale (tossent->fields.server->velocity, 0.05, move);
                VectorAdd (tossent->fields.server->origin, move, end);
-               trace = SV_Move (tossent->fields.server->origin, tossent->fields.server->mins, tossent->fields.server->maxs, end, MOVE_NORMAL, tossent, SV_GenericHitSuperContentsMask(tossent));
+               trace = SV_TraceBox(tossent->fields.server->origin, tossent->fields.server->mins, tossent->fields.server->maxs, end, MOVE_NORMAL, tossent, SV_GenericHitSuperContentsMask(tossent));
                VectorCopy (trace.endpos, tossent->fields.server->origin);
                tossent->fields.server->velocity[2] -= gravity;
 
@@ -1077,19 +1078,19 @@ static void VM_SV_droptofloor (void)
        if (sv_gameplayfix_droptofloorstartsolid_nudgetocorrect.integer)
                SV_UnstickEntity(ent);
 
-       trace = SV_Move (ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+       trace = SV_TraceBox(ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
        if (trace.startsolid && sv_gameplayfix_droptofloorstartsolid.integer)
        {
                vec3_t offset, org;
                VectorSet(offset, 0.5f * (ent->fields.server->mins[0] + ent->fields.server->maxs[0]), 0.5f * (ent->fields.server->mins[1] + ent->fields.server->maxs[1]), ent->fields.server->mins[2]);
                VectorAdd(ent->fields.server->origin, offset, org);
-               trace = SV_Move (org, vec3_origin, vec3_origin, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+               trace = SV_TraceLine(org, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
                VectorSubtract(trace.endpos, offset, trace.endpos);
                if (trace.startsolid)
                {
                        Con_DPrintf("droptofloor at %f %f %f - COULD NOT FIX BADLY PLACED ENTITY\n", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
                        SV_UnstickEntity(ent);
-                       SV_LinkEdict (ent, false);
+                       SV_LinkEdict(ent);
                        ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
                        ent->fields.server->groundentity = 0;
                        PRVM_G_FLOAT(OFS_RETURN) = 1;
@@ -1099,7 +1100,7 @@ static void VM_SV_droptofloor (void)
                        Con_DPrintf("droptofloor at %f %f %f - FIXED BADLY PLACED ENTITY\n", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
                        VectorCopy (trace.endpos, ent->fields.server->origin);
                        SV_UnstickEntity(ent);
-                       SV_LinkEdict (ent, false);
+                       SV_LinkEdict(ent);
                        ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
                        ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
                        PRVM_G_FLOAT(OFS_RETURN) = 1;
@@ -1113,7 +1114,7 @@ static void VM_SV_droptofloor (void)
                {
                        if (trace.fraction < 1)
                                VectorCopy (trace.endpos, ent->fields.server->origin);
-                       SV_LinkEdict (ent, false);
+                       SV_LinkEdict(ent);
                        ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
                        ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
                        PRVM_G_FLOAT(OFS_RETURN) = 1;
@@ -1230,7 +1231,7 @@ static void VM_SV_aim (void)
 // try sending a trace straight
        VectorCopy (prog->globals.server->v_forward, dir);
        VectorMA (start, 2048, dir, end);
-       tr = SV_Move (start, vec3_origin, vec3_origin, end, MOVE_NORMAL, ent, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY);
+       tr = SV_TraceLine(start, end, MOVE_NORMAL, ent, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY);
        if (tr.ent && ((prvm_edict_t *)tr.ent)->fields.server->takedamage == DAMAGE_AIM
        && (!teamplay.integer || ent->fields.server->team <=0 || ent->fields.server->team != ((prvm_edict_t *)tr.ent)->fields.server->team) )
        {
@@ -1262,7 +1263,7 @@ static void VM_SV_aim (void)
                dist = DotProduct (dir, prog->globals.server->v_forward);
                if (dist < bestdist)
                        continue;       // to far to turn
-               tr = SV_Move (start, vec3_origin, vec3_origin, end, MOVE_NORMAL, ent, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY);
+               tr = SV_TraceLine(start, end, MOVE_NORMAL, ent, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY);
                if (tr.ent == check)
                {       // can shoot at this one
                        bestdist = dist;
@@ -1682,7 +1683,7 @@ static void VM_SV_copyentity (void)
                return;
        }
        memcpy(out->fields.vp, in->fields.vp, prog->progs->entityfields * 4);
-       SV_LinkEdict(out, false);
+       SV_LinkEdict(out);
 }
 
 
@@ -2615,7 +2616,7 @@ void SV_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatri
 {
        prvm_eval_t *val;
        float scale;
-       float pitchsign;
+       float pitchsign = 1;
        int modelindex;
        dp_model_t *model;
 
@@ -2628,7 +2629,6 @@ void SV_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatri
                Matrix4x4_CreateFromQuakeEntity(out, ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2] + ent->fields.server->view_ofs[2], ent->fields.server->v_angle[0], ent->fields.server->v_angle[1], ent->fields.server->v_angle[2], scale * cl_viewmodel_scale.value);
        else
        {
-               pitchsign = 1;
                if (
                        ((modelindex = (int)ent->fields.server->modelindex) >= 1 && modelindex < MAX_MODELS && (model = sv.models[(int)ent->fields.server->modelindex]))
                        ?
@@ -2691,7 +2691,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                return 2;
 
        modelindex = (int)ent->fields.server->modelindex;
-       if (modelindex <= 0 || modelindex > MAX_MODELS)
+       if (modelindex <= 0 || modelindex >= MAX_MODELS)
                return 3;
 
        model = sv.models[modelindex];
@@ -2783,7 +2783,7 @@ static void VM_SV_gettagindex (void)
 
        modelindex = (int)ent->fields.server->modelindex;
        tag_index = 0;
-       if (modelindex <= 0 || modelindex > MAX_MODELS)
+       if (modelindex <= 0 || modelindex >= MAX_MODELS)
                Con_DPrintf("gettagindex(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(ent));
        else
        {
@@ -2793,7 +2793,7 @@ static void VM_SV_gettagindex (void)
                                Con_Printf("gettagindex(entity #%i): tag \"%s\" not found\n", PRVM_NUM_FOR_EDICT(ent), tag_name);
        }
        PRVM_G_FLOAT(OFS_RETURN) = tag_index;
-};
+}
 
 //vector(entity ent, float tagindex) gettaginfo;
 static void VM_SV_gettaginfo (void)
@@ -2950,7 +2950,7 @@ static void VM_SV_setmodelindex (void)
                return;
        }
        i = (int)PRVM_G_FLOAT(OFS_PARM1);
-       if (i <= 0 || i > MAX_MODELS)
+       if (i <= 0 || i >= MAX_MODELS)
        {
                VM_Warning("setmodelindex: invalid modelindex\n");
                return;
@@ -2986,7 +2986,7 @@ static void VM_SV_modelnameforindex (void)
        PRVM_G_INT(OFS_RETURN) = OFS_NULL;
 
        i = (int)PRVM_G_FLOAT(OFS_PARM0);
-       if (i <= 0 || i > MAX_MODELS)
+       if (i <= 0 || i >= MAX_MODELS)
        {
                VM_Warning("modelnameforindex: invalid modelindex\n");
                return;