]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_phys.c
reworked PRVM_EDICTFIELD* and PRVM_GLOBALFIELD* usage to have more
[xonotic/darkplaces.git] / sv_phys.c
index 541a105939ea937c01dde83ebbecf0287e0cd449..c0f89c89ecefe16aa75f31e8f891dce54ad5e3fc 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -52,7 +52,7 @@ int SV_GetPitchSign(prvm_edict_t *ent)
                        model->type == mod_alias
                        :
                        (
-                        (((unsigned char)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.pflags)) & PFLAGS_FULLDYNAMIC)
+                        (((unsigned char)PRVM_serveredictfloat(ent, pflags)) & PFLAGS_FULLDYNAMIC)
                         ||
                         ((gamemode == GAME_TENEBRAE) && ((unsigned int)ent->fields.server->effects & (16 | 32)))
                        )
@@ -73,7 +73,7 @@ int SV_GenericHitSuperContentsMask(const prvm_edict_t *passedict)
 {
        if (passedict)
        {
-               int dphitcontentsmask = (int)PRVM_EDICTFIELDFLOAT(passedict, prog->fieldoffsets.dphitcontentsmask);
+               int dphitcontentsmask = (int)PRVM_serveredictfloat(passedict, dphitcontentsmask);
                if (dphitcontentsmask)
                        return dphitcontentsmask;
                else if (passedict->fields.server->solid == SOLID_SLIDEBOX)
@@ -713,10 +713,10 @@ void SV_LinkEdict_TouchAreaGrid_Call(prvm_edict_t *touch, prvm_edict_t *ent)
        VectorSet (prog->globals.server->trace_plane_normal, 0, 0, 1);
        prog->globals.server->trace_plane_dist = 0;
        prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(ent);
-       PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dpstartcontents) = 0;
-       PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitcontents) = 0;
-       PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitq3surfaceflags) = 0;
-       PRVM_GLOBALFIELDSTRING(prog->globaloffsets.trace_dphittexturename) = 0;
+       PRVM_serverglobalfloat(trace_dpstartcontents) = 0;
+       PRVM_serverglobalfloat(trace_dphitcontents) = 0;
+       PRVM_serverglobalfloat(trace_dphitq3surfaceflags) = 0;
+       PRVM_serverglobalstring(trace_dphittexturename) = 0;
        PRVM_ExecuteProgram (touch->fields.server->touch, "QC function self.touch is missing");
 }
 
@@ -1013,7 +1013,7 @@ int SV_CheckContentsTransition(prvm_edict_t *ent, const int nContents)
        if(ent->fields.server->watertype != nContents)
        { // Changed Contents
                // Acquire Contents Transition Function from QC
-               if(PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.contentstransition))
+               if(PRVM_serveredictfunction(ent, contentstransition))
                { // Valid Function; Execute
                        // Assign Valid Function
                        bValidFunctionCall = true;
@@ -1025,7 +1025,7 @@ int SV_CheckContentsTransition(prvm_edict_t *ent, const int nContents)
                                // Assign Self
                                prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
                        // Execute VM Function
-                       PRVM_ExecuteProgram(PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.contentstransition), "contentstransition: NULL function");
+                       PRVM_ExecuteProgram(PRVM_serveredictfunction(ent, contentstransition), "contentstransition: NULL function");
                }
        }
 
@@ -1151,10 +1151,10 @@ void SV_Impact (prvm_edict_t *e1, trace_t *trace)
                VectorNegate(trace->plane.normal, prog->globals.server->trace_plane_normal);
                prog->globals.server->trace_plane_dist = -trace->plane.dist;
                prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(e1);
-               PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dpstartcontents) = 0;
-               PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitcontents) = 0;
-               PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitq3surfaceflags) = 0;
-               PRVM_GLOBALFIELDSTRING(prog->globaloffsets.trace_dphittexturename) = 0;
+               PRVM_serverglobalfloat(trace_dpstartcontents) = 0;
+               PRVM_serverglobalfloat(trace_dphitcontents) = 0;
+               PRVM_serverglobalfloat(trace_dphitq3surfaceflags) = 0;
+               PRVM_serverglobalstring(trace_dphittexturename) = 0;
                PRVM_ExecuteProgram (e2->fields.server->touch, "QC function self.touch is missing");
        }
 
@@ -1434,7 +1434,7 @@ static float SV_Gravity (prvm_edict_t *ent)
 {
        float ent_gravity;
 
-       ent_gravity = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.gravity);
+       ent_gravity = PRVM_serveredictfloat(ent, gravity);
        if (!ent_gravity)
                ent_gravity = 1.0f;
        return ent_gravity * sv_gravity.value * sv.frametime;
@@ -2505,7 +2505,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                if (ent->fields.server->movetype == MOVETYPE_BOUNCEMISSILE)
                {
                        float bouncefactor;
-                       bouncefactor = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.bouncefactor);
+                       bouncefactor = PRVM_serveredictfloat(ent, bouncefactor);
                        if (!bouncefactor)
                                bouncefactor = 1.0f;
 
@@ -2518,16 +2518,16 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        float bouncefactor;
                        float bouncestop;
 
-                       bouncefactor = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.bouncefactor);
+                       bouncefactor = PRVM_serveredictfloat(ent, bouncefactor);
                        if (!bouncefactor)
                                bouncefactor = 0.5f;
 
-                       bouncestop = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.bouncestop);
+                       bouncestop = PRVM_serveredictfloat(ent, bouncestop);
                        if (!bouncestop)
                                bouncestop = 60.0f / 800.0f;
 
                        ClipVelocity (ent->fields.server->velocity, trace.plane.normal, ent->fields.server->velocity, 1 + bouncefactor);
-                       ent_gravity = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.gravity);
+                       ent_gravity = PRVM_serveredictfloat(ent, gravity);
                        if (!ent_gravity)
                                ent_gravity = 1.0f;
                        // LordHavoc: fixed grenades not bouncing when fired down a slope
@@ -2639,7 +2639,7 @@ void SV_Physics_Step (prvm_edict_t *ent)
                        if (hitsound && (int)ent->fields.server->flags & FL_ONGROUND)
                        {
                                // DRESK - Check for Entity Land Event Function
-                               if(PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.movetypesteplandevent))
+                               if(PRVM_serveredictfunction(ent, movetypesteplandevent))
                                { // Valid Function; Execute
                                        // Prepare Parameters
                                                // Assign Velocity at Impact
@@ -2649,7 +2649,7 @@ void SV_Physics_Step (prvm_edict_t *ent)
                                                // Assign Self
                                                prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
                                        // Execute VM Function
-                                       PRVM_ExecuteProgram(PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.movetypesteplandevent), "movetypesteplandevent: NULL function");
+                                       PRVM_ExecuteProgram(PRVM_serveredictfunction(ent, movetypesteplandevent), "movetypesteplandevent: NULL function");
                                }
                                else
                                // Check for Engine Landing Sound