reworked progs loading so that entvars_t and globalvars_t are no longer
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 8 Jun 2011 19:23:52 +0000 (19:23 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 8 Jun 2011 19:23:52 +0000 (19:23 +0000)
required to match (if they do match, the relevant fields will match the
structs, otherwise name lookups are used), this means the PROGHEADER_CRC
no longer has to match either...  and same for csqc and menuqc

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11190 d7cf8633-e32d-0410-b094-e92efae38249

21 files changed:
cl_collision.c
clprogdefs.h
clvm_cmds.c
csprogs.c
gl_rmain.c
host.c
host_cmd.c
menu.c
mprogdefs.h
progsvm.h
protocol.c
prvm_cmds.c
prvm_edict.c
sv_demo.c
sv_main.c
sv_move.c
sv_phys.c
sv_user.c
svvm_cmds.c
todo
world.c

index 0f8ab40..8c95406 100644 (file)
@@ -130,7 +130,7 @@ dp_model_t *CL_GetModelFromEdict(prvm_edict_t *ed)
 {
        if (!ed || ed->priv.server->free)
                return NULL;
-       return CL_GetModelByIndex((int)ed->fields.client->modelindex);
+       return CL_GetModelByIndex((int)PRVM_clientedictfloat(ed, modelindex));
 }
 
 void CL_LinkEdict(prvm_edict_t *ent)
@@ -145,9 +145,9 @@ void CL_LinkEdict(prvm_edict_t *ent)
 
        // set the abs box
 
-       if (ent->fields.client->solid == SOLID_BSP)
+       if (PRVM_clientedictfloat(ent, solid) == SOLID_BSP)
        {
-               dp_model_t *model = CL_GetModelByIndex( (int)ent->fields.client->modelindex );
+               dp_model_t *model = CL_GetModelByIndex( (int)PRVM_clientedictfloat(ent, modelindex) );
                if (model == NULL)
                {
                        Con_Printf("edict %i: SOLID_BSP with invalid modelindex!\n", PRVM_NUM_FOR_EDICT(ent));
@@ -160,39 +160,39 @@ void CL_LinkEdict(prvm_edict_t *ent)
                        if (!model->TraceBox)
                                Con_DPrintf("edict %i: SOLID_BSP with non-collidable model\n", PRVM_NUM_FOR_EDICT(ent));
 
-                       if (ent->fields.client->angles[0] || ent->fields.client->angles[2] || ent->fields.client->avelocity[0] || ent->fields.client->avelocity[2])
+                       if (PRVM_clientedictvector(ent, angles)[0] || PRVM_clientedictvector(ent, angles)[2] || PRVM_clientedictvector(ent, avelocity)[0] || PRVM_clientedictvector(ent, avelocity)[2])
                        {
-                               VectorAdd(ent->fields.client->origin, model->rotatedmins, mins);
-                               VectorAdd(ent->fields.client->origin, model->rotatedmaxs, maxs);
+                               VectorAdd(PRVM_clientedictvector(ent, origin), model->rotatedmins, mins);
+                               VectorAdd(PRVM_clientedictvector(ent, origin), model->rotatedmaxs, maxs);
                        }
-                       else if (ent->fields.client->angles[1] || ent->fields.client->avelocity[1])
+                       else if (PRVM_clientedictvector(ent, angles)[1] || PRVM_clientedictvector(ent, avelocity)[1])
                        {
-                               VectorAdd(ent->fields.client->origin, model->yawmins, mins);
-                               VectorAdd(ent->fields.client->origin, model->yawmaxs, maxs);
+                               VectorAdd(PRVM_clientedictvector(ent, origin), model->yawmins, mins);
+                               VectorAdd(PRVM_clientedictvector(ent, origin), model->yawmaxs, maxs);
                        }
                        else
                        {
-                               VectorAdd(ent->fields.client->origin, model->normalmins, mins);
-                               VectorAdd(ent->fields.client->origin, model->normalmaxs, maxs);
+                               VectorAdd(PRVM_clientedictvector(ent, origin), model->normalmins, mins);
+                               VectorAdd(PRVM_clientedictvector(ent, origin), model->normalmaxs, maxs);
                        }
                }
                else
                {
                        // SOLID_BSP with no model is valid, mainly because some QC setup code does so temporarily
-                       VectorAdd(ent->fields.client->origin, ent->fields.client->mins, mins);
-                       VectorAdd(ent->fields.client->origin, ent->fields.client->maxs, maxs);
+                       VectorAdd(PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), mins);
+                       VectorAdd(PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, maxs), maxs);
                }
        }
        else
        {
-               VectorAdd(ent->fields.client->origin, ent->fields.client->mins, mins);
-               VectorAdd(ent->fields.client->origin, ent->fields.client->maxs, maxs);
+               VectorAdd(PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), mins);
+               VectorAdd(PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, maxs), maxs);
        }
 
-       VectorCopy(mins, ent->fields.client->absmin);
-       VectorCopy(maxs, ent->fields.client->absmax);
+       VectorCopy(mins, PRVM_clientedictvector(ent, absmin));
+       VectorCopy(maxs, PRVM_clientedictvector(ent, absmax));
 
-       World_LinkEdict(&cl.world, ent, ent->fields.client->absmin, ent->fields.client->absmax);
+       World_LinkEdict(&cl.world, ent, PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax));
 }
 
 int CL_GenericHitSuperContentsMask(const prvm_edict_t *passedict)
@@ -202,16 +202,16 @@ int CL_GenericHitSuperContentsMask(const prvm_edict_t *passedict)
                int dphitcontentsmask = (int)PRVM_clientedictfloat(passedict, dphitcontentsmask);
                if (dphitcontentsmask)
                        return dphitcontentsmask;
-               else if (passedict->fields.client->solid == SOLID_SLIDEBOX)
+               else if (PRVM_clientedictfloat(passedict, solid) == SOLID_SLIDEBOX)
                {
-                       if ((int)passedict->fields.client->flags & FL_MONSTER)
+                       if ((int)PRVM_clientedictfloat(passedict, flags) & FL_MONSTER)
                                return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_MONSTERCLIP;
                        else
                                return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP;
                }
-               else if (passedict->fields.client->solid == SOLID_CORPSE)
+               else if (PRVM_clientedictfloat(passedict, solid) == SOLID_CORPSE)
                        return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY;
-               else if (passedict->fields.client->solid == SOLID_TRIGGER)
+               else if (PRVM_clientedictfloat(passedict, solid) == SOLID_TRIGGER)
                        return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY;
                else
                        return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_CORPSE;
@@ -297,7 +297,7 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
        // precalculate prog value for passedict for comparisons
        passedictprog = prog != NULL ? PRVM_EDICT_TO_PROG(passedict) : 0;
        // precalculate passedict's owner edict pointer for comparisons
-       traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.client->owner) : NULL;
+       traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_clientedictedict(passedict, owner)) : NULL;
 
        // collide against network entities
        if (hitnetworkbrushmodels)
@@ -382,9 +382,9 @@ skipnetworkplayers:
        {
                touch = touchedicts[i];
 
-               if (touch->fields.client->solid < SOLID_BBOX)
+               if (PRVM_clientedictfloat(touch, solid) < SOLID_BBOX)
                        continue;
-               if (type == MOVE_NOMONSTERS && touch->fields.client->solid != SOLID_BSP)
+               if (type == MOVE_NOMONSTERS && PRVM_clientedictfloat(touch, solid) != SOLID_BSP)
                        continue;
 
                if (passedict)
@@ -396,32 +396,32 @@ skipnetworkplayers:
                        if (traceowner == touch)
                                continue;
                        // don't clip owner against owned entities
-                       if (passedictprog == touch->fields.client->owner)
+                       if (passedictprog == PRVM_clientedictedict(touch, owner))
                                continue;
                        // don't clip points against points (they can't collide)
-                       if (VectorCompare(touch->fields.client->mins, touch->fields.client->maxs) && (type != MOVE_MISSILE || !((int)touch->fields.client->flags & FL_MONSTER)))
+                       if (VectorCompare(PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)))
                                continue;
                }
 
-               bodysupercontents = touch->fields.client->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
+               bodysupercontents = PRVM_clientedictfloat(touch, solid) == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
 
                // might interact, so do an exact clip
                model = NULL;
-               if ((int) touch->fields.client->solid == SOLID_BSP || type == MOVE_HITMODEL)
+               if ((int) PRVM_clientedictfloat(touch, solid) == SOLID_BSP || type == MOVE_HITMODEL)
                        model = CL_GetModelFromEdict(touch);
                if (model)
-                       Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2], touch->fields.client->angles[0], touch->fields.client->angles[1], touch->fields.client->angles[2], 1);
+                       Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2], PRVM_clientedictvector(touch, angles)[0], PRVM_clientedictvector(touch, angles)[1], PRVM_clientedictvector(touch, angles)[2], 1);
                else
-                       Matrix4x4_CreateTranslate(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2]);
+                       Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]);
                Matrix4x4_Invert_Simple(&imatrix, &matrix);
-               if ((int)touch->fields.client->flags & FL_MONSTER)
-                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask);
+               if ((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)
+                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask);
                else
-                       Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
+                       Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
 
                if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
                        *hitnetworkentity = 0;
-               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.client->solid == SOLID_BSP);
+               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_clientedictfloat(touch, solid) == SOLID_BSP);
        }
 
 finished:
@@ -530,7 +530,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        // precalculate prog value for passedict for comparisons
        passedictprog = prog != NULL ? PRVM_EDICT_TO_PROG(passedict) : 0;
        // precalculate passedict's owner edict pointer for comparisons
-       traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.client->owner) : NULL;
+       traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_clientedictedict(passedict, owner)) : NULL;
 
        // collide against network entities
        if (hitnetworkbrushmodels)
@@ -615,9 +615,9 @@ skipnetworkplayers:
        {
                touch = touchedicts[i];
 
-               if (touch->fields.client->solid < SOLID_BBOX)
+               if (PRVM_clientedictfloat(touch, solid) < SOLID_BBOX)
                        continue;
-               if (type == MOVE_NOMONSTERS && touch->fields.client->solid != SOLID_BSP)
+               if (type == MOVE_NOMONSTERS && PRVM_clientedictfloat(touch, solid) != SOLID_BSP)
                        continue;
 
                if (passedict)
@@ -629,32 +629,32 @@ skipnetworkplayers:
                        if (traceowner == touch)
                                continue;
                        // don't clip owner against owned entities
-                       if (passedictprog == touch->fields.client->owner)
+                       if (passedictprog == PRVM_clientedictedict(touch, owner))
                                continue;
                        // don't clip points against points (they can't collide)
-                       if (VectorCompare(touch->fields.client->mins, touch->fields.client->maxs) && (type != MOVE_MISSILE || !((int)touch->fields.client->flags & FL_MONSTER)))
+                       if (VectorCompare(PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)))
                                continue;
                }
 
-               bodysupercontents = touch->fields.client->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
+               bodysupercontents = PRVM_clientedictfloat(touch, solid) == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
 
                // might interact, so do an exact clip
                model = NULL;
-               if ((int) touch->fields.client->solid == SOLID_BSP || type == MOVE_HITMODEL)
+               if ((int) PRVM_clientedictfloat(touch, solid) == SOLID_BSP || type == MOVE_HITMODEL)
                        model = CL_GetModelFromEdict(touch);
                if (model)
-                       Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2], touch->fields.client->angles[0], touch->fields.client->angles[1], touch->fields.client->angles[2], 1);
+                       Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2], PRVM_clientedictvector(touch, angles)[0], PRVM_clientedictvector(touch, angles)[1], PRVM_clientedictvector(touch, angles)[2], 1);
                else
-                       Matrix4x4_CreateTranslate(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2]);
+                       Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]);
                Matrix4x4_Invert_Simple(&imatrix, &matrix);
-               if (type == MOVE_MISSILE && (int)touch->fields.client->flags & FL_MONSTER)
-                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
+               if (type == MOVE_MISSILE && (int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)
+                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
                else
-                       Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, hitsurfaces);
+                       Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, hitsurfaces);
 
                if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
                        *hitnetworkentity = 0;
-               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.client->solid == SOLID_BSP);
+               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_clientedictfloat(touch, solid) == SOLID_BSP);
        }
 
 finished:
@@ -804,7 +804,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        // figure out whether this is a point trace for comparisons
        pointtrace = VectorCompare(clipmins, clipmaxs);
        // precalculate passedict's owner edict pointer for comparisons
-       traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.client->owner) : NULL;
+       traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_clientedictedict(passedict, owner)) : NULL;
 
        // collide against network entities
        if (hitnetworkbrushmodels)
@@ -889,9 +889,9 @@ skipnetworkplayers:
        {
                touch = touchedicts[i];
 
-               if (touch->fields.client->solid < SOLID_BBOX)
+               if (PRVM_clientedictfloat(touch, solid) < SOLID_BBOX)
                        continue;
-               if (type == MOVE_NOMONSTERS && touch->fields.client->solid != SOLID_BSP)
+               if (type == MOVE_NOMONSTERS && PRVM_clientedictfloat(touch, solid) != SOLID_BSP)
                        continue;
 
                if (passedict)
@@ -903,32 +903,32 @@ skipnetworkplayers:
                        if (traceowner == touch)
                                continue;
                        // don't clip owner against owned entities
-                       if (passedictprog == touch->fields.client->owner)
+                       if (passedictprog == PRVM_clientedictedict(touch, owner))
                                continue;
                        // don't clip points against points (they can't collide)
-                       if (pointtrace && VectorCompare(touch->fields.client->mins, touch->fields.client->maxs) && (type != MOVE_MISSILE || !((int)touch->fields.client->flags & FL_MONSTER)))
+                       if (pointtrace && VectorCompare(PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)))
                                continue;
                }
 
-               bodysupercontents = touch->fields.client->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
+               bodysupercontents = PRVM_clientedictfloat(touch, solid) == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
 
                // might interact, so do an exact clip
                model = NULL;
-               if ((int) touch->fields.client->solid == SOLID_BSP || type == MOVE_HITMODEL)
+               if ((int) PRVM_clientedictfloat(touch, solid) == SOLID_BSP || type == MOVE_HITMODEL)
                        model = CL_GetModelFromEdict(touch);
                if (model)
-                       Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2], touch->fields.client->angles[0], touch->fields.client->angles[1], touch->fields.client->angles[2], 1);
+                       Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2], PRVM_clientedictvector(touch, angles)[0], PRVM_clientedictvector(touch, angles)[1], PRVM_clientedictvector(touch, angles)[2], 1);
                else
-                       Matrix4x4_CreateTranslate(&matrix, touch->fields.client->origin[0], touch->fields.client->origin[1], touch->fields.client->origin[2]);
+                       Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]);
                Matrix4x4_Invert_Simple(&imatrix, &matrix);
-               if ((int)touch->fields.client->flags & FL_MONSTER)
-                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
+               if ((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)
+                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
                else
-                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask);
+                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask);
 
                if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
                        *hitnetworkentity = 0;
-               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.client->solid == SOLID_BSP);
+               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_clientedictfloat(touch, solid) == SOLID_BSP);
        }
 
 finished:
index b9354fb..bee62ab 100644 (file)
@@ -4,6 +4,7 @@
 #ifndef CLPROGDEFS_H
 #define CLPROGDEFS_H
 
+/*
 typedef struct cl_globalvars_s
 {
        int                     pad[28];
@@ -92,5 +93,6 @@ typedef struct cl_entvars_s
 } cl_entvars_t;
 
 #define CL_PROGHEADER_CRC 52195
+*/
 
 #endif
index 3c153c8..cedd208 100644 (file)
@@ -34,7 +34,7 @@ void CSQC_RelinkCSQCEntities (void);
 static void VM_CL_makevectors (void)
 {
        VM_SAFEPARMCOUNT(1, VM_CL_makevectors);
-       AngleVectors (PRVM_G_VECTOR(OFS_PARM0), prog->globals.client->v_forward, prog->globals.client->v_right, prog->globals.client->v_up);
+       AngleVectors (PRVM_G_VECTOR(OFS_PARM0), PRVM_clientglobalvector(v_forward), PRVM_clientglobalvector(v_right), PRVM_clientglobalvector(v_up));
 }
 
 // #2 void(entity e, vector o) setorigin
@@ -56,7 +56,7 @@ void VM_CL_setorigin (void)
                return;
        }
        org = PRVM_G_VECTOR(OFS_PARM1);
-       VectorCopy (org, e->fields.client->origin);
+       VectorCopy (org, PRVM_clientedictvector(e, origin));
        CL_LinkEdict(e);
 }
 
@@ -69,9 +69,9 @@ static void SetMinMaxSize (prvm_edict_t *e, float *min, float *max)
                        PRVM_ERROR("SetMinMaxSize: backwards mins/maxs");
 
        // set derived values
-       VectorCopy (min, e->fields.client->mins);
-       VectorCopy (max, e->fields.client->maxs);
-       VectorSubtract (max, min, e->fields.client->size);
+       VectorCopy (min, PRVM_clientedictvector(e, mins));
+       VectorCopy (max, PRVM_clientedictvector(e, maxs));
+       VectorSubtract (max, min, PRVM_clientedictvector(e, size));
 
        CL_LinkEdict (e);
 }
@@ -87,8 +87,8 @@ void VM_CL_setmodel (void)
        VM_SAFEPARMCOUNT(2, VM_CL_setmodel);
 
        e = PRVM_G_EDICT(OFS_PARM0);
-       e->fields.client->modelindex = 0;
-       e->fields.client->model = 0;
+       PRVM_clientedictfloat(e, modelindex) = 0;
+       PRVM_clientedictstring(e, model) = 0;
 
        m = PRVM_G_STRING(OFS_PARM1);
        mod = NULL;
@@ -97,8 +97,8 @@ void VM_CL_setmodel (void)
                if (!strcmp(cl.csqc_model_precache[i]->name, m))
                {
                        mod = cl.csqc_model_precache[i];
-                       e->fields.client->model = PRVM_SetEngineString(mod->name);
-                       e->fields.client->modelindex = -(i+1);
+                       PRVM_clientedictstring(e, model) = PRVM_SetEngineString(mod->name);
+                       PRVM_clientedictfloat(e, modelindex) = -(i+1);
                        break;
                }
        }
@@ -109,8 +109,8 @@ void VM_CL_setmodel (void)
                        mod = cl.model_precache[i];
                        if (mod && !strcmp(mod->name, m))
                        {
-                               e->fields.client->model = PRVM_SetEngineString(mod->name);
-                               e->fields.client->modelindex = i;
+                               PRVM_clientedictstring(e, model) = PRVM_SetEngineString(mod->name);
+                               PRVM_clientedictfloat(e, modelindex) = i;
                                break;
                        }
                }
@@ -320,10 +320,10 @@ trace_t CL_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore, int *svent)
        vec3_t original_avelocity;
        trace_t trace;
 
-       VectorCopy(tossent->fields.client->origin   , original_origin   );
-       VectorCopy(tossent->fields.client->velocity , original_velocity );
-       VectorCopy(tossent->fields.client->angles   , original_angles   );
-       VectorCopy(tossent->fields.client->avelocity, original_avelocity);
+       VectorCopy(PRVM_clientedictvector(tossent, origin)   , original_origin   );
+       VectorCopy(PRVM_clientedictvector(tossent, velocity) , original_velocity );
+       VectorCopy(PRVM_clientedictvector(tossent, angles)   , original_angles   );
+       VectorCopy(PRVM_clientedictvector(tossent, avelocity), original_avelocity);
 
        gravity = PRVM_clientedictfloat(tossent, gravity);
        if (!gravity)
@@ -332,21 +332,21 @@ trace_t CL_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore, int *svent)
 
        for (i = 0;i < 200;i++) // LordHavoc: sanity check; never trace more than 10 seconds
        {
-               tossent->fields.client->velocity[2] -= gravity;
-               VectorMA (tossent->fields.client->angles, 0.05, tossent->fields.client->avelocity, tossent->fields.client->angles);
-               VectorScale (tossent->fields.client->velocity, 0.05, move);
-               VectorAdd (tossent->fields.client->origin, move, end);
-               trace = CL_TraceBox(tossent->fields.client->origin, tossent->fields.client->mins, tossent->fields.client->maxs, end, MOVE_NORMAL, tossent, CL_GenericHitSuperContentsMask(tossent), true, true, NULL, true);
-               VectorCopy (trace.endpos, tossent->fields.client->origin);
+               PRVM_clientedictvector(tossent, velocity)[2] -= gravity;
+               VectorMA (PRVM_clientedictvector(tossent, angles), 0.05, PRVM_clientedictvector(tossent, avelocity), PRVM_clientedictvector(tossent, angles));
+               VectorScale (PRVM_clientedictvector(tossent, velocity), 0.05, move);
+               VectorAdd (PRVM_clientedictvector(tossent, origin), move, end);
+               trace = CL_TraceBox(PRVM_clientedictvector(tossent, origin), PRVM_clientedictvector(tossent, mins), PRVM_clientedictvector(tossent, maxs), end, MOVE_NORMAL, tossent, CL_GenericHitSuperContentsMask(tossent), true, true, NULL, true);
+               VectorCopy (trace.endpos, PRVM_clientedictvector(tossent, origin));
 
                if (trace.fraction < 1)
                        break;
        }
 
-       VectorCopy(original_origin   , tossent->fields.client->origin   );
-       VectorCopy(original_velocity , tossent->fields.client->velocity );
-       VectorCopy(original_angles   , tossent->fields.client->angles   );
-       VectorCopy(original_avelocity, tossent->fields.client->avelocity);
+       VectorCopy(original_origin   , PRVM_clientedictvector(tossent, origin)   );
+       VectorCopy(original_velocity , PRVM_clientedictvector(tossent, velocity) );
+       VectorCopy(original_angles   , PRVM_clientedictvector(tossent, angles)   );
+       VectorCopy(original_avelocity, PRVM_clientedictvector(tossent, avelocity));
 
        return trace;
 }
@@ -423,7 +423,7 @@ int CSQC_EntitiesInBox (vec3_t mins, vec3_t maxs, int maxlist, prvm_edict_t **li
        {
                if (ent->priv.required->free)
                        continue;
-               if(BoxesOverlap(mins, maxs, ent->fields.client->absmin, ent->fields.client->absmax))
+               if(BoxesOverlap(mins, maxs, PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax)))
                        list[k++] = ent;
        }
        return k;
@@ -472,20 +472,20 @@ static void VM_CL_findradius (void)
                ent = touchedicts[i];
                // Quake did not return non-solid entities but darkplaces does
                // (note: this is the reason you can't blow up fallen zombies)
-               if (ent->fields.client->solid == SOLID_NOT && !sv_gameplayfix_blowupfallenzombies.integer)
+               if (PRVM_clientedictfloat(ent, solid) == SOLID_NOT && !sv_gameplayfix_blowupfallenzombies.integer)
                        continue;
                // LordHavoc: compare against bounding box rather than center so it
                // doesn't miss large objects, and use DotProduct instead of Length
                // for a major speedup
-               VectorSubtract(org, ent->fields.client->origin, eorg);
+               VectorSubtract(org, PRVM_clientedictvector(ent, origin), eorg);
                if (sv_gameplayfix_findradiusdistancetobox.integer)
                {
-                       eorg[0] -= bound(ent->fields.client->mins[0], eorg[0], ent->fields.client->maxs[0]);
-                       eorg[1] -= bound(ent->fields.client->mins[1], eorg[1], ent->fields.client->maxs[1]);
-                       eorg[2] -= bound(ent->fields.client->mins[2], eorg[2], ent->fields.client->maxs[2]);
+                       eorg[0] -= bound(PRVM_clientedictvector(ent, mins)[0], eorg[0], PRVM_clientedictvector(ent, maxs)[0]);
+                       eorg[1] -= bound(PRVM_clientedictvector(ent, mins)[1], eorg[1], PRVM_clientedictvector(ent, maxs)[1]);
+                       eorg[2] -= bound(PRVM_clientedictvector(ent, mins)[2], eorg[2], PRVM_clientedictvector(ent, maxs)[2]);
                }
                else
-                       VectorMAMAM(1, eorg, -0.5f, ent->fields.client->mins, -0.5f, ent->fields.client->maxs, eorg);
+                       VectorMAMAM(1, eorg, -0.5f, PRVM_clientedictvector(ent, mins), -0.5f, PRVM_clientedictvector(ent, maxs), eorg);
                if (DotProduct(eorg, eorg) < radius2)
                {
                        PRVM_EDICTFIELDEDICT(ent, chainfield) = PRVM_EDICT_TO_PROG(chain);
@@ -508,7 +508,7 @@ static void VM_CL_droptofloor (void)
        // assume failure if it returns early
        PRVM_G_FLOAT(OFS_RETURN) = 0;
 
-       ent = PRVM_PROG_TO_EDICT(prog->globals.client->self);
+       ent = PRVM_PROG_TO_EDICT(PRVM_clientglobaledict(self));
        if (ent == prog->edicts)
        {
                VM_Warning("droptofloor: can not modify world entity\n");
@@ -520,15 +520,15 @@ static void VM_CL_droptofloor (void)
                return;
        }
 
-       VectorCopy (ent->fields.client->origin, end);
+       VectorCopy (PRVM_clientedictvector(ent, origin), end);
        end[2] -= 256;
 
-       trace = CL_TraceBox(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
+       trace = CL_TraceBox(PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), PRVM_clientedictvector(ent, maxs), end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
 
        if (trace.fraction != 1)
        {
-               VectorCopy (trace.endpos, ent->fields.client->origin);
-               ent->fields.client->flags = (int)ent->fields.client->flags | FL_ONGROUND;
+               VectorCopy (trace.endpos, PRVM_clientedictvector(ent, origin));
+               PRVM_clientedictfloat(ent, flags) = (int)PRVM_clientedictfloat(ent, flags) | FL_ONGROUND;
                PRVM_clientedictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
                PRVM_G_FLOAT(OFS_RETURN) = 1;
                // if support is destroyed, keep suspended (gross hack for floating items in various maps)
@@ -570,8 +570,8 @@ static void VM_CL_checkbottom (void)
        ent = PRVM_G_EDICT(OFS_PARM0);
        PRVM_G_FLOAT(OFS_RETURN) = 0;
 
-       VectorAdd (ent->fields.client->origin, ent->fields.client->mins, mins);
-       VectorAdd (ent->fields.client->origin, ent->fields.client->maxs, maxs);
+       VectorAdd (PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), mins);
+       VectorAdd (PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, maxs), maxs);
 
 // if all of the points under the corners are solid world, don't bother
 // with the tougher checks
@@ -739,7 +739,7 @@ void VM_CL_R_AddEntities (void)
        CSQC_RelinkAllEntities(drawmask);
        CL_RelinkLightFlashes();
 
-       prog->globals.client->time = cl.time;
+       PRVM_clientglobalfloat(time) = cl.time;
        for(i=1;i<prog->num_edicts;i++)
        {
                // so we can easily check if CSQC entity #edictnum is currently drawn
@@ -754,7 +754,7 @@ void VM_CL_R_AddEntities (void)
                CSQC_Predraw(ed);
                if(ed->priv.required->free)
                        continue;
-               if(!((int)ed->fields.client->drawmask & drawmask))
+               if(!((int)PRVM_clientedictfloat(ed, drawmask) & drawmask))
                        continue;
                CSQC_AddRenderEdict(ed, i);
        }
@@ -1038,9 +1038,9 @@ void VM_CL_R_AddDynamicLight (void)
        coronaintensity = (pflags & PFLAGS_CORONA) != 0;
        castshadow = (pflags & PFLAGS_NOSHADOW) == 0;
 
-       VectorScale(prog->globals.client->v_forward, radius, forward);
-       VectorScale(prog->globals.client->v_right, -radius, left);
-       VectorScale(prog->globals.client->v_up, radius, up);
+       VectorScale(PRVM_clientglobalvector(v_forward), radius, forward);
+       VectorScale(PRVM_clientglobalvector(v_right), -radius, left);
+       VectorScale(PRVM_clientglobalvector(v_up), radius, up);
        Matrix4x4_FromVectors(&matrix, forward, left, up, org);
 
        R_RTLight_Update(&r_refdef.scene.templights[r_refdef.scene.numlights], false, &matrix, col, style, cubemapname, castshadow, coronaintensity, coronasizescale, ambientscale, diffusescale, specularscale, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
@@ -1173,8 +1173,8 @@ static void VM_CL_setmodelindex (void)
 
        i = (int)PRVM_G_FLOAT(OFS_PARM1);
 
-       t->fields.client->model = 0;
-       t->fields.client->modelindex = 0;
+       PRVM_clientedictstring(t, model) = 0;
+       PRVM_clientedictfloat(t, modelindex) = 0;
 
        if (!i)
                return;
@@ -1185,8 +1185,8 @@ static void VM_CL_setmodelindex (void)
                VM_Warning("VM_CL_setmodelindex: null model\n");
                return;
        }
-       t->fields.client->model = PRVM_SetEngineString(model->name);
-       t->fields.client->modelindex = i;
+       PRVM_clientedictstring(t, model) = PRVM_SetEngineString(model->name);
+       PRVM_clientedictfloat(t, modelindex) = i;
 
        // TODO: check if this breaks needed consistency and maybe add a cvar for it too?? [1/10/2008 Black]
        if (model)
@@ -1235,7 +1235,7 @@ static void VM_CL_trailparticles (void)
 
        if (i < 0)
                return;
-       CL_ParticleEffect(i, 1, start, end, t->fields.client->velocity, t->fields.client->velocity, NULL, prog->argc >= 5 ? (int)PRVM_G_FLOAT(OFS_PARM4) : 0);
+       CL_ParticleEffect(i, 1, start, end, PRVM_clientedictvector(t, velocity), PRVM_clientedictvector(t, velocity), NULL, prog->argc >= 5 ? (int)PRVM_G_FLOAT(OFS_PARM4) : 0);
 }
 
 //#337 void(float effectnum, vector origin, vector dir, float count[, float color]) pointparticles (EXT_CSQC)
@@ -1335,21 +1335,21 @@ static void VM_CL_getinputstate (void)
        {
                if (cl.movecmd[i].sequence == frame)
                {
-                       VectorCopy(cl.movecmd[i].viewangles, prog->globals.client->input_angles);
-                       prog->globals.client->input_buttons = cl.movecmd[i].buttons; // FIXME: this should not be directly exposed to csqc (translation layer needed?)
-                       prog->globals.client->input_movevalues[0] = cl.movecmd[i].forwardmove;
-                       prog->globals.client->input_movevalues[1] = cl.movecmd[i].sidemove;
-                       prog->globals.client->input_movevalues[2] = cl.movecmd[i].upmove;
-                       prog->globals.client->input_timelength = cl.movecmd[i].frametime;
+                       VectorCopy(cl.movecmd[i].viewangles, PRVM_clientglobalvector(input_angles));
+                       PRVM_clientglobalfloat(input_buttons) = cl.movecmd[i].buttons; // FIXME: this should not be directly exposed to csqc (translation layer needed?)
+                       PRVM_clientglobalvector(input_movevalues)[0] = cl.movecmd[i].forwardmove;
+                       PRVM_clientglobalvector(input_movevalues)[1] = cl.movecmd[i].sidemove;
+                       PRVM_clientglobalvector(input_movevalues)[2] = cl.movecmd[i].upmove;
+                       PRVM_clientglobalfloat(input_timelength) = cl.movecmd[i].frametime;
                        if(cl.movecmd[i].crouch)
                        {
-                               VectorCopy(cl.playercrouchmins, prog->globals.client->pmove_mins);
-                               VectorCopy(cl.playercrouchmaxs, prog->globals.client->pmove_maxs);
+                               VectorCopy(cl.playercrouchmins, PRVM_clientglobalvector(pmove_mins));
+                               VectorCopy(cl.playercrouchmaxs, PRVM_clientglobalvector(pmove_maxs));
                        }
                        else
                        {
-                               VectorCopy(cl.playerstandmins, prog->globals.client->pmove_mins);
-                               VectorCopy(cl.playerstandmaxs, prog->globals.client->pmove_maxs);
+                               VectorCopy(cl.playerstandmins, PRVM_clientglobalvector(pmove_mins));
+                               VectorCopy(cl.playerstandmaxs, PRVM_clientglobalvector(pmove_maxs));
                        }
                        PRVM_G_FLOAT(OFS_RETURN) = true;
                }
@@ -1596,13 +1596,13 @@ static void VM_CL_makestatic (void)
 
                // copy it to the current state
                memset(staticent, 0, sizeof(*staticent));
-               staticent->render.model = CL_GetModelByIndex((int)ent->fields.client->modelindex);
-               staticent->render.framegroupblend[0].frame = (int)ent->fields.client->frame;
+               staticent->render.model = CL_GetModelByIndex((int)PRVM_clientedictfloat(ent, modelindex));
+               staticent->render.framegroupblend[0].frame = (int)PRVM_clientedictfloat(ent, frame);
                staticent->render.framegroupblend[0].lerp = 1;
                // make torchs play out of sync
                staticent->render.framegroupblend[0].start = lhrandom(-10, -1);
-               staticent->render.skinnum = (int)ent->fields.client->skin;
-               staticent->render.effects = (int)ent->fields.client->effects;
+               staticent->render.skinnum = (int)PRVM_clientedictfloat(ent, skin);
+               staticent->render.effects = (int)PRVM_clientedictfloat(ent, effects);
                staticent->render.alpha = PRVM_clientedictfloat(ent, alpha);
                staticent->render.scale = PRVM_clientedictfloat(ent, scale);
                VectorCopy(PRVM_clientedictvector(ent, colormod), staticent->render.colormod);
@@ -1622,12 +1622,12 @@ static void VM_CL_makestatic (void)
                if (renderflags & RF_USEAXIS)
                {
                        vec3_t left;
-                       VectorNegate(prog->globals.client->v_right, left);
-                       Matrix4x4_FromVectors(&staticent->render.matrix, prog->globals.client->v_forward, left, prog->globals.client->v_up, ent->fields.client->origin);
+                       VectorNegate(PRVM_clientglobalvector(v_right), left);
+                       Matrix4x4_FromVectors(&staticent->render.matrix, PRVM_clientglobalvector(v_forward), left, PRVM_clientglobalvector(v_up), PRVM_clientedictvector(ent, origin));
                        Matrix4x4_Scale(&staticent->render.matrix, staticent->render.scale, 1);
                }
                else
-                       Matrix4x4_CreateFromQuakeEntity(&staticent->render.matrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], staticent->render.scale);
+                       Matrix4x4_CreateFromQuakeEntity(&staticent->render.matrix, PRVM_clientedictvector(ent, origin)[0], PRVM_clientedictvector(ent, origin)[1], PRVM_clientedictvector(ent, origin)[2], PRVM_clientedictvector(ent, angles)[0], PRVM_clientedictvector(ent, angles)[1], PRVM_clientedictvector(ent, angles)[2], staticent->render.scale);
 
                // either fullbright or lit
                if(!r_fullbright.integer)
@@ -2134,11 +2134,11 @@ void VM_CL_setattachment (void)
        tagindex = 0;
        if (tagentity != NULL && tagentity != prog->edicts && tagname && tagname[0])
        {
-               modelindex = (int)tagentity->fields.client->modelindex;
+               modelindex = (int)PRVM_clientedictfloat(tagentity, modelindex);
                model = CL_GetModelByIndex(modelindex);
                if (model)
                {
-                       tagindex = Mod_Alias_GetTagIndexForName(model, (int)tagentity->fields.client->skin, tagname);
+                       tagindex = Mod_Alias_GetTagIndexForName(model, (int)PRVM_clientedictfloat(tagentity, skin), tagname);
                        if (tagindex == 0)
                                Con_DPrintf("setattachment(edict %i, edict %i, string \"%s\"): tried to find tag named \"%s\" on entity %i (model \"%s\") but could not find it\n", PRVM_NUM_FOR_EDICT(e), PRVM_NUM_FOR_EDICT(tagentity), tagname, tagname, PRVM_NUM_FOR_EDICT(tagentity), model->name);
                }
@@ -2157,7 +2157,7 @@ int CL_GetTagIndex (prvm_edict_t *e, const char *tagname)
 {
        dp_model_t *model = CL_GetModelFromEdict(e);
        if (model)
-               return Mod_Alias_GetTagIndexForName(model, (int)e->fields.client->skin, tagname);
+               return Mod_Alias_GetTagIndexForName(model, (int)PRVM_clientedictfloat(e, skin), tagname);
        else
                return -1;
 }
@@ -2175,7 +2175,7 @@ int CL_GetExtendedTagInfo (prvm_edict_t *e, int tagindex, int *parentindex, cons
         && (model = CL_GetModelFromEdict(e))
         && model->animscenes)
        {
-               r = Mod_Alias_GetExtendedTagInfoForIndex(model, (int)e->fields.client->skin, e->priv.server->frameblend, &e->priv.server->skeleton, tagindex - 1, parentindex, tagname, tag_localmatrix);
+               r = Mod_Alias_GetExtendedTagInfoForIndex(model, (int)PRVM_clientedictfloat(e, skin), e->priv.server->frameblend, &e->priv.server->skeleton, tagindex - 1, parentindex, tagname, tag_localmatrix);
 
                if(!r) // success?
                        *parentindex += 1;
@@ -2211,16 +2211,16 @@ void CL_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatri
                vec3_t left;
                vec3_t up;
                vec3_t origin;
-               VectorScale(prog->globals.client->v_forward, scale, forward);
-               VectorScale(prog->globals.client->v_right, -scale, left);
-               VectorScale(prog->globals.client->v_up, scale, up);
-               VectorCopy(ent->fields.client->origin, origin);
+               VectorScale(PRVM_clientglobalvector(v_forward), scale, forward);
+               VectorScale(PRVM_clientglobalvector(v_right), -scale, left);
+               VectorScale(PRVM_clientglobalvector(v_up), scale, up);
+               VectorCopy(PRVM_clientedictvector(ent, origin), origin);
                Matrix4x4_FromVectors(out, forward, left, up, origin);
        }
        else
        {
                pitchsign = CL_GetPitchSign(ent);
-               Matrix4x4_CreateFromQuakeEntity(out, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], pitchsign * ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], scale);
+               Matrix4x4_CreateFromQuakeEntity(out, PRVM_clientedictvector(ent, origin)[0], PRVM_clientedictvector(ent, origin)[1], PRVM_clientedictvector(ent, origin)[2], pitchsign * PRVM_clientedictvector(ent, angles)[0], PRVM_clientedictvector(ent, angles)[1], PRVM_clientedictvector(ent, angles)[2], scale);
        }
 }
 
@@ -2303,7 +2303,7 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
 
                /*
                // Cl_bob, ported from rendering code
-               if (ent->fields.client->health > 0 && cl_bob.value && cl_bobcycle.value)
+               if (PRVM_clientedictfloat(ent, health) > 0 && cl_bob.value && cl_bobcycle.value)
                {
                        double bob, cycle;
                        // LordHavoc: this code is *weird*, but not replacable (I think it
@@ -2318,7 +2318,7 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                                cycle = sin(M_PI + M_PI * (cycle-cl_bobup.value)/(1.0 - cl_bobup.value));
                        // bob is proportional to velocity in the xy plane
                        // (don't count Z, or jumping messes it up)
-                       bob = sqrt(ent->fields.client->velocity[0]*ent->fields.client->velocity[0] + ent->fields.client->velocity[1]*ent->fields.client->velocity[1])*cl_bob.value;
+                       bob = sqrt(PRVM_clientedictvector(ent, velocity)[0]*PRVM_clientedictvector(ent, velocity)[0] + PRVM_clientedictvector(ent, velocity)[1]*PRVM_clientedictvector(ent, velocity)[1])*cl_bob.value;
                        bob = bob*0.3 + bob*0.7*cycle;
                        Matrix4x4_AdjustOrigin(out, 0, 0, bound(-7, bob, 4));
                }
@@ -2379,8 +2379,8 @@ void VM_CL_gettaginfo (void)
        e = PRVM_G_EDICT(OFS_PARM0);
        tagindex = (int)PRVM_G_FLOAT(OFS_PARM1);
        returncode = CL_GetTagMatrix(&tag_matrix, e, tagindex);
-       Matrix4x4_ToVectors(&tag_matrix, prog->globals.client->v_forward, le, prog->globals.client->v_up, PRVM_G_VECTOR(OFS_RETURN));
-       VectorScale(le, -1, prog->globals.client->v_right);
+       Matrix4x4_ToVectors(&tag_matrix, PRVM_clientglobalvector(v_forward), le, PRVM_clientglobalvector(v_up), PRVM_G_VECTOR(OFS_RETURN));
+       VectorScale(le, -1, PRVM_clientglobalvector(v_right));
        model = CL_GetModelFromEdict(e);
        VM_GenerateFrameGroupBlend(e->priv.server->framegroupblend, e);
        VM_FrameBlendFromFrameGroupBlend(e->priv.server->frameblend, e->priv.server->framegroupblend, model);
@@ -2919,7 +2919,7 @@ void VM_CL_GetEntity (void)
                        PRVM_G_FLOAT(OFS_RETURN) = Matrix4x4_ScaleFromMatrix(&cl.entities[entnum].render.matrix);
                        break;  
                case 6: // origin + v_forward, v_right, v_up
-                       Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, prog->globals.client->v_forward, prog->globals.client->v_right, prog->globals.client->v_up, PRVM_G_VECTOR(OFS_RETURN)); 
+                       Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, PRVM_clientglobalvector(v_forward), PRVM_clientglobalvector(v_right), PRVM_clientglobalvector(v_up), PRVM_G_VECTOR(OFS_RETURN));        
                        break;  
                case 7: // alpha
                        PRVM_G_FLOAT(OFS_RETURN) = cl.entities[entnum].render.alpha;
@@ -3368,8 +3368,8 @@ qboolean CL_CheckBottom (prvm_edict_t *ent)
        int             x, y;
        float   mid, bottom;
 
-       VectorAdd (ent->fields.client->origin, ent->fields.client->mins, mins);
-       VectorAdd (ent->fields.client->origin, ent->fields.client->maxs, maxs);
+       VectorAdd (PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), mins);
+       VectorAdd (PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, maxs), maxs);
 
 // if all of the points under the corners are solid world, don't bother
 // with the tougher checks
@@ -3438,36 +3438,36 @@ qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        prvm_edict_t            *enemy;
 
 // try the move
-       VectorCopy (ent->fields.client->origin, oldorg);
-       VectorAdd (ent->fields.client->origin, move, neworg);
+       VectorCopy (PRVM_clientedictvector(ent, origin), oldorg);
+       VectorAdd (PRVM_clientedictvector(ent, origin), move, neworg);
 
 // flying monsters don't step up
-       if ( (int)ent->fields.client->flags & (FL_SWIM | FL_FLY) )
+       if ( (int)PRVM_clientedictfloat(ent, flags) & (FL_SWIM | FL_FLY) )
        {
        // try one move with vertical motion, then one without
                for (i=0 ; i<2 ; i++)
                {
-                       VectorAdd (ent->fields.client->origin, move, neworg);
-                       enemy = PRVM_PROG_TO_EDICT(ent->fields.client->enemy);
+                       VectorAdd (PRVM_clientedictvector(ent, origin), move, neworg);
+                       enemy = PRVM_PROG_TO_EDICT(PRVM_clientedictedict(ent, enemy));
                        if (i == 0 && enemy != prog->edicts)
                        {
-                               dz = ent->fields.client->origin[2] - PRVM_PROG_TO_EDICT(ent->fields.client->enemy)->fields.client->origin[2];
+                               dz = PRVM_clientedictvector(ent, origin)[2] - PRVM_clientedictvector(PRVM_PROG_TO_EDICT(PRVM_clientedictedict(ent, enemy)), origin)[2];
                                if (dz > 40)
                                        neworg[2] -= 8;
                                if (dz < 30)
                                        neworg[2] += 8;
                        }
-                       trace = CL_TraceBox(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->maxs, neworg, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+                       trace = CL_TraceBox(PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), PRVM_clientedictvector(ent, maxs), neworg, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
                        if (settrace)
                                CL_VM_SetTraceGlobals(&trace, svent);
 
                        if (trace.fraction == 1)
                        {
                                VectorCopy(trace.endpos, traceendpos);
-                               if (((int)ent->fields.client->flags & FL_SWIM) && !(CL_PointSuperContents(traceendpos) & SUPERCONTENTS_LIQUIDSMASK))
+                               if (((int)PRVM_clientedictfloat(ent, flags) & FL_SWIM) && !(CL_PointSuperContents(traceendpos) & SUPERCONTENTS_LIQUIDSMASK))
                                        return false;   // swim monster left water
 
-                               VectorCopy (traceendpos, ent->fields.client->origin);
+                               VectorCopy (traceendpos, PRVM_clientedictvector(ent, origin));
                                if (relink)
                                        CL_LinkEdict(ent);
                                return true;
@@ -3485,14 +3485,14 @@ qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        VectorCopy (neworg, end);
        end[2] -= sv_stepheight.value*2;
 
-       trace = CL_TraceBox(neworg, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+       trace = CL_TraceBox(neworg, PRVM_clientedictvector(ent, mins), PRVM_clientedictvector(ent, maxs), end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
        if (settrace)
                CL_VM_SetTraceGlobals(&trace, svent);
 
        if (trace.startsolid)
        {
                neworg[2] -= sv_stepheight.value;
-               trace = CL_TraceBox(neworg, ent->fields.client->mins, ent->fields.client->maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+               trace = CL_TraceBox(neworg, PRVM_clientedictvector(ent, mins), PRVM_clientedictvector(ent, maxs), end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
                if (settrace)
                        CL_VM_SetTraceGlobals(&trace, svent);
                if (trace.startsolid)
@@ -3501,12 +3501,12 @@ qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        if (trace.fraction == 1)
        {
        // if monster had the ground pulled out, go ahead and fall
-               if ( (int)ent->fields.client->flags & FL_PARTIALGROUND )
+               if ( (int)PRVM_clientedictfloat(ent, flags) & FL_PARTIALGROUND )
                {
-                       VectorAdd (ent->fields.client->origin, move, ent->fields.client->origin);
+                       VectorAdd (PRVM_clientedictvector(ent, origin), move, PRVM_clientedictvector(ent, origin));
                        if (relink)
                                CL_LinkEdict(ent);
-                       ent->fields.client->flags = (int)ent->fields.client->flags & ~FL_ONGROUND;
+                       PRVM_clientedictfloat(ent, flags) = (int)PRVM_clientedictfloat(ent, flags) & ~FL_ONGROUND;
                        return true;
                }
 
@@ -3514,23 +3514,23 @@ qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        }
 
 // check point traces down for dangling corners
-       VectorCopy (trace.endpos, ent->fields.client->origin);
+       VectorCopy (trace.endpos, PRVM_clientedictvector(ent, origin));
 
        if (!CL_CheckBottom (ent))
        {
-               if ( (int)ent->fields.client->flags & FL_PARTIALGROUND )
+               if ( (int)PRVM_clientedictfloat(ent, flags) & FL_PARTIALGROUND )
                {       // entity had floor mostly pulled out from underneath it
                        // and is trying to correct
                        if (relink)
                                CL_LinkEdict(ent);
                        return true;
                }
-               VectorCopy (oldorg, ent->fields.client->origin);
+               VectorCopy (oldorg, PRVM_clientedictvector(ent, origin));
                return false;
        }
 
-       if ( (int)ent->fields.client->flags & FL_PARTIALGROUND )
-               ent->fields.client->flags = (int)ent->fields.client->flags & ~FL_PARTIALGROUND;
+       if ( (int)PRVM_clientedictfloat(ent, flags) & FL_PARTIALGROUND )
+               PRVM_clientedictfloat(ent, flags) = (int)PRVM_clientedictfloat(ent, flags) & ~FL_PARTIALGROUND;
 
        PRVM_clientedictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
 
@@ -3561,7 +3561,7 @@ static void VM_CL_walkmove (void)
        // assume failure if it returns early
        PRVM_G_FLOAT(OFS_RETURN) = 0;
 
-       ent = PRVM_PROG_TO_EDICT(prog->globals.client->self);
+       ent = PRVM_PROG_TO_EDICT(PRVM_clientglobaledict(self));
        if (ent == prog->edicts)
        {
                VM_Warning("walkmove: can not modify world entity\n");
@@ -3576,7 +3576,7 @@ static void VM_CL_walkmove (void)
        dist = PRVM_G_FLOAT(OFS_PARM1);
        settrace = prog->argc >= 3 && PRVM_G_FLOAT(OFS_PARM2);
 
-       if ( !( (int)ent->fields.client->flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) )
+       if ( !( (int)PRVM_clientedictfloat(ent, flags) & (FL_ONGROUND|FL_FLY|FL_SWIM) ) )
                return;
 
        yaw = yaw*M_PI*2 / 360;
@@ -3587,14 +3587,14 @@ static void VM_CL_walkmove (void)
 
 // save program state, because CL_movestep may call other progs
        oldf = prog->xfunction;
-       oldself = prog->globals.client->self;
+       oldself = PRVM_clientglobaledict(self);
 
        PRVM_G_FLOAT(OFS_RETURN) = CL_movestep(ent, move, true, false, settrace);
 
 
 // restore program state
        prog->xfunction = oldf;
-       prog->globals.client->self = oldself;
+       PRVM_clientglobaledict(self) = oldself;
 }
 
 /*
@@ -3645,8 +3645,8 @@ static void VM_CL_checkpvs (void)
                return;
        }
 
-       VectorAdd(viewee->fields.server->origin, viewee->fields.server->mins, mi);
-       VectorAdd(viewee->fields.server->origin, viewee->fields.server->maxs, ma);
+       VectorAdd(PRVM_serveredictvector(viewee, origin), PRVM_serveredictvector(viewee, mins), mi);
+       VectorAdd(PRVM_serveredictvector(viewee, origin), PRVM_serveredictvector(viewee, maxs), ma);
 
 #if 1
        if(!sv.worldmodel->brush.GetPVS || !sv.worldmodel->brush.BoxTouchingPVS)
@@ -3810,18 +3810,18 @@ static void VM_CL_skel_get_bonerel(void)
        matrix4x4_t matrix;
        vec3_t forward, left, up, origin;
        VectorClear(PRVM_G_VECTOR(OFS_RETURN));
-       VectorClear(prog->globals.client->v_forward);
-       VectorClear(prog->globals.client->v_right);
-       VectorClear(prog->globals.client->v_up);
+       VectorClear(PRVM_clientglobalvector(v_forward));
+       VectorClear(PRVM_clientglobalvector(v_right));
+       VectorClear(PRVM_clientglobalvector(v_up));
        if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
                return;
        if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
                return;
        matrix = skeleton->relativetransforms[bonenum];
        Matrix4x4_ToVectors(&matrix, forward, left, up, origin);
-       VectorCopy(forward, prog->globals.client->v_forward);
-       VectorNegate(left, prog->globals.client->v_right);
-       VectorCopy(up, prog->globals.client->v_up);
+       VectorCopy(forward, PRVM_clientglobalvector(v_forward));
+       VectorNegate(left, PRVM_clientglobalvector(v_right));
+       VectorCopy(up, PRVM_clientglobalvector(v_up));
        VectorCopy(origin, PRVM_G_VECTOR(OFS_RETURN));
 }
 
@@ -3835,9 +3835,9 @@ static void VM_CL_skel_get_boneabs(void)
        matrix4x4_t temp;
        vec3_t forward, left, up, origin;
        VectorClear(PRVM_G_VECTOR(OFS_RETURN));
-       VectorClear(prog->globals.client->v_forward);
-       VectorClear(prog->globals.client->v_right);
-       VectorClear(prog->globals.client->v_up);
+       VectorClear(PRVM_clientglobalvector(v_forward));
+       VectorClear(PRVM_clientglobalvector(v_right));
+       VectorClear(PRVM_clientglobalvector(v_up));
        if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
                return;
        if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
@@ -3850,9 +3850,9 @@ static void VM_CL_skel_get_boneabs(void)
                Matrix4x4_Concat(&matrix, &skeleton->relativetransforms[bonenum], &temp);
        }
        Matrix4x4_ToVectors(&matrix, forward, left, up, origin);
-       VectorCopy(forward, prog->globals.client->v_forward);
-       VectorNegate(left, prog->globals.client->v_right);
-       VectorCopy(up, prog->globals.client->v_up);
+       VectorCopy(forward, PRVM_clientglobalvector(v_forward));
+       VectorNegate(left, PRVM_clientglobalvector(v_right));
+       VectorCopy(up, PRVM_clientglobalvector(v_up));
        VectorCopy(origin, PRVM_G_VECTOR(OFS_RETURN));
 }
 
@@ -3868,9 +3868,9 @@ static void VM_CL_skel_set_bone(void)
                return;
        if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
                return;
-       VectorCopy(prog->globals.client->v_forward, forward);
-       VectorNegate(prog->globals.client->v_right, left);
-       VectorCopy(prog->globals.client->v_up, up);
+       VectorCopy(PRVM_clientglobalvector(v_forward), forward);
+       VectorNegate(PRVM_clientglobalvector(v_right), left);
+       VectorCopy(PRVM_clientglobalvector(v_up), up);
        VectorCopy(PRVM_G_VECTOR(OFS_PARM2), origin);
        Matrix4x4_FromVectors(&matrix, forward, left, up, origin);
        skeleton->relativetransforms[bonenum] = matrix;
@@ -3890,9 +3890,9 @@ static void VM_CL_skel_mul_bone(void)
        if (bonenum < 0 || bonenum >= skeleton->model->num_bones)
                return;
        VectorCopy(PRVM_G_VECTOR(OFS_PARM2), origin);
-       VectorCopy(prog->globals.client->v_forward, forward);
-       VectorNegate(prog->globals.client->v_right, left);
-       VectorCopy(prog->globals.client->v_up, up);
+       VectorCopy(PRVM_clientglobalvector(v_forward), forward);
+       VectorNegate(PRVM_clientglobalvector(v_right), left);
+       VectorCopy(PRVM_clientglobalvector(v_up), up);
        Matrix4x4_FromVectors(&matrix, forward, left, up, origin);
        temp = skeleton->relativetransforms[bonenum];
        Matrix4x4_Concat(&skeleton->relativetransforms[bonenum], &matrix, &temp);
@@ -3912,9 +3912,9 @@ static void VM_CL_skel_mul_bones(void)
        if (skeletonindex < 0 || skeletonindex >= MAX_EDICTS || !(skeleton = prog->skeletons[skeletonindex]))
                return;
        VectorCopy(PRVM_G_VECTOR(OFS_PARM3), origin);
-       VectorCopy(prog->globals.client->v_forward, forward);
-       VectorNegate(prog->globals.client->v_right, left);
-       VectorCopy(prog->globals.client->v_up, up);
+       VectorCopy(PRVM_clientglobalvector(v_forward), forward);
+       VectorNegate(PRVM_clientglobalvector(v_right), left);
+       VectorCopy(PRVM_clientglobalvector(v_up), up);
        Matrix4x4_FromVectors(&matrix, forward, left, up, origin);
        firstbone = max(0, firstbone);
        lastbone = min(lastbone, skeleton->model->num_bones - 1);
index 7510472..6a6ca99 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -244,29 +244,29 @@ void CSQC_R_RecalcView (void);
 static void CSQC_SetGlobals (void)
 {
        CSQC_BEGIN
-               prog->globals.client->time = cl.time;
-               prog->globals.client->frametime = max(0, cl.time - cl.oldtime);
-               prog->globals.client->servercommandframe = cls.servermovesequence;
-               prog->globals.client->clientcommandframe = cl.movecmd[0].sequence;
-               VectorCopy(cl.viewangles, prog->globals.client->input_angles);
+               PRVM_clientglobalfloat(time) = cl.time;
+               PRVM_clientglobalfloat(frametime) = max(0, cl.time - cl.oldtime);
+               PRVM_clientglobalfloat(servercommandframe) = cls.servermovesequence;
+               PRVM_clientglobalfloat(clientcommandframe) = cl.movecmd[0].sequence;
+               VectorCopy(cl.viewangles, PRVM_clientglobalvector(input_angles));
                // // FIXME: this actually belongs into getinputstate().. [12/17/2007 Black]
-               prog->globals.client->input_buttons = cl.movecmd[0].buttons;
-               VectorSet(prog->globals.client->input_movevalues, cl.movecmd[0].forwardmove, cl.movecmd[0].sidemove, cl.movecmd[0].upmove);
+               PRVM_clientglobalfloat(input_buttons) = cl.movecmd[0].buttons;
+               VectorSet(PRVM_clientglobalvector(input_movevalues), cl.movecmd[0].forwardmove, cl.movecmd[0].sidemove, cl.movecmd[0].upmove);
                VectorCopy(cl.csqc_vieworiginfromengine, cl.csqc_vieworigin);
                VectorCopy(cl.csqc_viewanglesfromengine, cl.csqc_viewangles);
 
                // LordHavoc: Spike says not to do this, but without pmove_org the
                // CSQC is useless as it can't alter the view origin without
                // completely replacing it
-               Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, prog->globals.client->pmove_org);
-               VectorCopy(cl.movement_velocity, prog->globals.client->pmove_vel);
+               Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, PRVM_clientglobalvector(pmove_org));
+               VectorCopy(cl.movement_velocity, PRVM_clientglobalvector(pmove_vel));
                PRVM_clientglobalfloat(pmove_onground) = cl.onground;
                PRVM_clientglobalfloat(pmove_inwater) = cl.inwater;
 
                VectorCopy(cl.viewangles, PRVM_clientglobalvector(view_angles));
                VectorCopy(cl.punchangle, PRVM_clientglobalvector(view_punchangle));
                VectorCopy(cl.punchvector, PRVM_clientglobalvector(view_punchvector));
-               prog->globals.client->maxclients = cl.maxclients;
+               PRVM_clientglobalfloat(maxclients) = cl.maxclients;
 
                CSQC_R_RecalcView();
        CSQC_END
@@ -275,25 +275,25 @@ static void CSQC_SetGlobals (void)
 void CSQC_Predraw (prvm_edict_t *ed)
 {
        int b;
-       if(!ed->fields.client->predraw)
+       if(!PRVM_clientedictfunction(ed, predraw))
                return;
-       b = prog->globals.client->self;
-       prog->globals.client->self = PRVM_EDICT_TO_PROG(ed);
-       PRVM_ExecuteProgram(ed->fields.client->predraw, "CSQC_Predraw: NULL function\n");
-       prog->globals.client->self = b;
+       b = PRVM_clientglobaledict(self);
+       PRVM_clientglobaledict(self) = PRVM_EDICT_TO_PROG(ed);
+       PRVM_ExecuteProgram(PRVM_clientedictfunction(ed, predraw), "CSQC_Predraw: NULL function\n");
+       PRVM_clientglobaledict(self) = b;
 }
 
 void CSQC_Think (prvm_edict_t *ed)
 {
        int b;
-       if(ed->fields.client->think)
-       if(ed->fields.client->nextthink && ed->fields.client->nextthink <= prog->globals.client->time)
+       if(PRVM_clientedictfunction(ed, think))
+       if(PRVM_clientedictfloat(ed, nextthink) && PRVM_clientedictfloat(ed, nextthink) <= PRVM_clientglobalfloat(time))
        {
-               ed->fields.client->nextthink = 0;
-               b = prog->globals.client->self;
-               prog->globals.client->self = PRVM_EDICT_TO_PROG(ed);
-               PRVM_ExecuteProgram(ed->fields.client->think, "CSQC_Think: NULL function\n");
-               prog->globals.client->self = b;
+               PRVM_clientedictfloat(ed, nextthink) = 0;
+               b = PRVM_clientglobaledict(self);
+               PRVM_clientglobaledict(self) = PRVM_EDICT_TO_PROG(ed);
+               PRVM_ExecuteProgram(PRVM_clientedictfunction(ed, think), "CSQC_Think: NULL function\n");
+               PRVM_clientglobaledict(self) = b;
        }
 }
 
@@ -339,14 +339,14 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
        entrender->userwavefunc_param[3] = PRVM_clientedictfloat(ed, userwavefunc_param3);
 
        entrender->model = model;
-       entrender->skinnum = (int)ed->fields.client->skin;
+       entrender->skinnum = (int)PRVM_clientedictfloat(ed, skin);
        entrender->effects |= entrender->model->effects;
        renderflags = (int)PRVM_clientedictfloat(ed, renderflags);
        entrender->alpha = PRVM_clientedictfloat(ed, alpha);
        entrender->scale = scale = PRVM_clientedictfloat(ed, scale);
        VectorCopy(PRVM_clientedictvector(ed, colormod), entrender->colormod);
        VectorCopy(PRVM_clientedictvector(ed, glowmod), entrender->glowmod);
-       if(ed->fields.client->effects)  entrender->effects |= (int)ed->fields.client->effects;
+       if(PRVM_clientedictfloat(ed, effects))  entrender->effects |= (int)PRVM_clientedictfloat(ed, effects);
        if (!entrender->alpha)
                entrender->alpha = 1.0f;
        if (!entrender->scale)
@@ -379,7 +379,7 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
                if(renderflags & RF_ADDITIVE)           entrender->flags |= RENDER_ADDITIVE;
        }
 
-       c = (int)ed->fields.client->colormap;
+       c = (int)PRVM_clientedictfloat(ed, colormap);
        if (c <= 0)
                CL_SetEntityColormapColors(entrender, -1);
        else if (c <= cl.maxclients && cl.scores != NULL)
@@ -439,8 +439,8 @@ qboolean CL_VM_InputEvent (qboolean down, int key, int ascii)
                        r = false;
                else
                {
-                       prog->globals.client->time = cl.time;
-                       prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+                       PRVM_clientglobalfloat(time) = cl.time;
+                       PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
                        PRVM_G_FLOAT(OFS_PARM0) = !down; // 0 is down, 1 is up
                        PRVM_G_FLOAT(OFS_PARM1) = key;
                        PRVM_G_FLOAT(OFS_PARM2) = ascii;
@@ -463,8 +463,8 @@ qboolean CL_VM_UpdateView (void)
        R_TimeReport("pre-UpdateView");
        CSQC_BEGIN
                //VectorCopy(cl.viewangles, oldangles);
-               prog->globals.client->time = cl.time;
-               prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+               PRVM_clientglobalfloat(time) = cl.time;
+               PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
                CSQC_SetGlobals();
                // clear renderable entity and light lists to prevent crashes if the
                // CSQC_UpdateView function does not call R_ClearScene as it should
@@ -492,8 +492,8 @@ qboolean CL_VM_ConsoleCommand (const char *cmd)
        CSQC_BEGIN
        if (PRVM_clientfunction(CSQC_ConsoleCommand))
        {
-               prog->globals.client->time = cl.time;
-               prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+               PRVM_clientglobalfloat(time) = cl.time;
+               PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
                restorevm_tempstringsbuf_cursize = vm_tempstringsbuf.cursize;
                PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(cmd);
                PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_ConsoleCommand), "QC function CSQC_ConsoleCommand is missing");
@@ -514,8 +514,8 @@ qboolean CL_VM_Parse_TempEntity (void)
        if(PRVM_clientfunction(CSQC_Parse_TempEntity))
        {
                t = msg_readcount;
-               prog->globals.client->time = cl.time;
-               prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+               PRVM_clientglobalfloat(time) = cl.time;
+               PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
                PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Parse_TempEntity), "QC function CSQC_Parse_TempEntity is missing");
                r = CSQC_RETURNVAL != 0;
                if(!r)
@@ -596,8 +596,8 @@ void CL_VM_Parse_StuffCmd (const char *msg)
        CSQC_BEGIN
        if(PRVM_clientfunction(CSQC_Parse_StuffCmd))
        {
-               prog->globals.client->time = cl.time;
-               prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+               PRVM_clientglobalfloat(time) = cl.time;
+               PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
                restorevm_tempstringsbuf_cursize = vm_tempstringsbuf.cursize;
                PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(msg);
                PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Parse_StuffCmd), "QC function CSQC_Parse_StuffCmd is missing");
@@ -611,8 +611,8 @@ void CL_VM_Parse_StuffCmd (const char *msg)
 static void CL_VM_Parse_Print (const char *msg)
 {
        int restorevm_tempstringsbuf_cursize;
-       prog->globals.client->time = cl.time;
-       prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+       PRVM_clientglobalfloat(time) = cl.time;
+       PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
        restorevm_tempstringsbuf_cursize = vm_tempstringsbuf.cursize;
        PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(msg);
        PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Parse_Print), "QC function CSQC_Parse_Print is missing");
@@ -663,8 +663,8 @@ void CL_VM_Parse_CenterPrint (const char *msg)
        CSQC_BEGIN
        if(PRVM_clientfunction(CSQC_Parse_CenterPrint))
        {
-               prog->globals.client->time = cl.time;
-               prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+               PRVM_clientglobalfloat(time) = cl.time;
+               PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
                restorevm_tempstringsbuf_cursize = vm_tempstringsbuf.cursize;
                PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(msg);
                PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Parse_CenterPrint), "QC function CSQC_Parse_CenterPrint is missing");
@@ -701,8 +701,8 @@ qboolean CL_VM_Event_Sound(int sound_num, float volume, int channel, float atten
                CSQC_BEGIN
                if(PRVM_clientfunction(CSQC_Event_Sound))
                {
-                       prog->globals.client->time = cl.time;
-                       prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+                       PRVM_clientglobalfloat(time) = cl.time;
+                       PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
                        PRVM_G_FLOAT(OFS_PARM0) = ent;
                        PRVM_G_FLOAT(OFS_PARM1) = channel;
                        PRVM_G_INT(OFS_PARM2) = PRVM_SetTempString(cl.sound_name[sound_num] );
@@ -757,8 +757,8 @@ float CL_VM_Event (float event)             //[515]: needed ? I'd say "YES", but don't know
        CSQC_BEGIN
        if(PRVM_clientfunction(CSQC_Event))
        {
-               prog->globals.client->time = cl.time;
-               prog->globals.client->self = cl.csqc_server2csqcentitynumber[cl.playerentity];
+               PRVM_clientglobalfloat(time) = cl.time;
+               PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
                PRVM_G_FLOAT(OFS_PARM0) = event;
                PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Event), "QC function CSQC_Event is missing");
                r = CSQC_RETURNVAL;
@@ -777,18 +777,18 @@ void CSQC_ReadEntities (void)
        }
 
        CSQC_BEGIN
-               prog->globals.client->time = cl.time;
-               oldself = prog->globals.client->self;
+               PRVM_clientglobalfloat(time) = cl.time;
+               oldself = PRVM_clientglobaledict(self);
                while(1)
                {
                        entnum = MSG_ReadShort();
                        if(!entnum || msg_badread)
                                break;
                        realentnum = entnum & 0x7FFF;
-                       prog->globals.client->self = cl.csqc_server2csqcentitynumber[realentnum];
+                       PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[realentnum];
                        if(entnum & 0x8000)
                        {
-                               if(prog->globals.client->self)
+                               if(PRVM_clientglobaledict(self))
                                {
                                        PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Ent_Remove), "QC function CSQC_Ent_Remove is missing");
                                        cl.csqc_server2csqcentitynumber[realentnum] = 0;
@@ -804,14 +804,14 @@ void CSQC_ReadEntities (void)
                        }
                        else
                        {
-                               if(!prog->globals.client->self)
+                               if(!PRVM_clientglobaledict(self))
                                {
                                        if(!PRVM_clientfunction(CSQC_Ent_Spawn))
                                        {
                                                prvm_edict_t    *ed;
                                                ed = PRVM_ED_Alloc();
-                                               ed->fields.client->entnum = realentnum;
-                                               prog->globals.client->self = cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT_TO_PROG(ed);
+                                               PRVM_clientedictfloat(ed, entnum) = realentnum;
+                                               PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT_TO_PROG(ed);
                                        }
                                        else
                                        {
@@ -819,9 +819,9 @@ void CSQC_ReadEntities (void)
                                                // the qc function should set entnum, too (this way it also can return world [2/1/2008 Andreas]
                                                PRVM_G_FLOAT(OFS_PARM0) = (float) realentnum;
                                                // make sure no one gets wrong ideas
-                                               prog->globals.client->self = 0;
+                                               PRVM_clientglobaledict(self) = 0;
                                                PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Ent_Spawn), "QC function CSQC_Ent_Spawn is missing");
-                                               prog->globals.client->self = cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT( PRVM_G_INT( OFS_RETURN ) );
+                                               PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT( PRVM_G_INT( OFS_RETURN ) );
                                        }
                                        PRVM_G_FLOAT(OFS_PARM0) = 1;
                                        PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Ent_Update), "QC function CSQC_Ent_Update is missing");
@@ -832,7 +832,7 @@ void CSQC_ReadEntities (void)
                                }
                        }
                }
-               prog->globals.client->self = oldself;
+               PRVM_clientglobaledict(self) = oldself;
        CSQC_END
 }
 
@@ -872,7 +872,7 @@ void CL_VM_CB_FreeEdict(prvm_edict_t *ed)
        R_DecalSystem_Reset(&entrender->decalsystem);
        memset(entrender, 0, sizeof(*entrender));
        World_UnlinkEdict(ed);
-       memset(ed->fields.client, 0, sizeof(*ed->fields.client));
+       memset(ed->fields.vp, 0, prog->entityfields * 4);
        VM_RemoveEdictSkeleton(ed);
        World_Physics_RemoveFromEntity(&cl.world, ed);
        World_Physics_RemoveJointFromEntity(&cl.world, ed);
@@ -890,9 +890,9 @@ void CL_VM_CB_CountEdicts(void)
                if (ent->priv.server->free)
                        continue;
                active++;
-               if (ent->fields.client->solid)
+               if (PRVM_clientedictfloat(ent, solid))
                        solid++;
-               if (ent->fields.client->model)
+               if (PRVM_clientedictstring(ent, model))
                        models++;
        }
 
@@ -1017,7 +1017,6 @@ void CL_VM_Init (void)
 
        // allocate the mempools
        prog->progs_mempool = Mem_AllocPool(csqc_progname.string, 0, NULL);
-       prog->headercrc = CL_PROGHEADER_CRC;
        prog->edictprivate_size = 0; // no private struct used
        prog->name = CL_NAME;
        prog->num_edicts = 1;
@@ -1082,16 +1081,16 @@ void CL_VM_Init (void)
                prog->flag |= PRVM_OP_STATE;
 
        // set time
-       prog->globals.client->time = cl.time;
-       prog->globals.client->self = 0;
+       PRVM_clientglobalfloat(time) = cl.time;
+       PRVM_clientglobaledict(self) = 0;
 
-       prog->globals.client->mapname = PRVM_SetEngineString(cl.worldname);
-       prog->globals.client->player_localentnum = cl.playerentity;
+       PRVM_clientglobalstring(mapname) = PRVM_SetEngineString(cl.worldname);
+       PRVM_clientglobalfloat(player_localentnum) = cl.playerentity;
 
        // set map description (use world entity 0)
        PRVM_clientedictstring(prog->edicts, message) = PRVM_SetEngineString(cl.worldmessage);
-       VectorCopy(cl.world.mins, prog->edicts->fields.client->mins);
-       VectorCopy(cl.world.maxs, prog->edicts->fields.client->maxs);
+       VectorCopy(cl.world.mins, PRVM_clientedictvector(prog->edicts, mins));
+       VectorCopy(cl.world.maxs, PRVM_clientedictvector(prog->edicts, maxs));
 
        // call the prog init
        PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Init), "QC function CSQC_Init is missing");
@@ -1114,8 +1113,8 @@ void CL_VM_ShutDown (void)
        if(!cl.csqc_loaded)
                return;
        CSQC_BEGIN
-               prog->globals.client->time = cl.time;
-               prog->globals.client->self = 0;
+               PRVM_clientglobalfloat(time) = cl.time;
+               PRVM_clientglobaledict(self) = 0;
                if (PRVM_clientfunction(CSQC_Shutdown))
                        PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_Shutdown), "QC function CSQC_Shutdown is missing");
                PRVM_ResetProg();
@@ -1140,7 +1139,7 @@ qboolean CL_VM_GetEntitySoundOrigin(int entnum, vec3_t out)
        if(!ed->priv.required->free)
        {
                mod = CL_GetModelFromEdict(ed);
-               VectorCopy(ed->fields.client->origin, out);
+               VectorCopy(PRVM_clientedictvector(ed, origin), out);
                if(CL_GetTagMatrix (&matrix, ed, 0) == 0)
                        Matrix4x4_OriginFromMatrix(&matrix, out);
                if (mod && mod->soundfromcenter)
@@ -1171,8 +1170,8 @@ qboolean CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clip
                        {
                                Matrix4x4_ToVectors(viewmatrix, forward, left, up, origin);
                                AnglesFromVectors(ang, forward, up, false);
-                               prog->globals.client->time = cl.time;
-                               prog->globals.client->self = entnum;
+                               PRVM_clientglobalfloat(time) = cl.time;
+                               PRVM_clientglobaledict(self) = entnum;
                                VectorCopy(origin, PRVM_G_VECTOR(OFS_PARM0));
                                VectorCopy(ang, PRVM_G_VECTOR(OFS_PARM1));
                                VectorCopy(forward, PRVM_clientglobalvector(v_forward));
index 35b11c2..8574aeb 100644 (file)
@@ -7141,7 +7141,7 @@ static void R_DrawEntityBBoxes_Callback(const entity_render_t *ent, const rtligh
        for (i = 0;i < numsurfaces;i++)
        {
                edict = PRVM_EDICT_NUM(surfacelist[i]);
-               switch ((int)edict->fields.server->solid)
+               switch ((int)PRVM_serveredictfloat(edict, solid))
                {
                        case SOLID_NOT:      Vector4Set(color, 1, 1, 1, 0.05);break;
                        case SOLID_TRIGGER:  Vector4Set(color, 1, 0, 1, 0.10);break;
diff --git a/host.c b/host.c
index d8909c1..e7a37d9 100644 (file)
--- a/host.c
+++ b/host.c
@@ -468,11 +468,11 @@ void SV_DropClient(qboolean crash)
        {
                // call the prog function for removing a client
                // this will set the body to a dead frame, among other things
-               int saveSelf = prog->globals.server->self;
+               int saveSelf = PRVM_serverglobaledict(self);
                host_client->clientconnectcalled = false;
-               prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
-               PRVM_ExecuteProgram(prog->globals.server->ClientDisconnect, "QC function ClientDisconnect is missing");
-               prog->globals.server->self = saveSelf;
+               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
+               PRVM_ExecuteProgram(PRVM_serverfunction(ClientDisconnect), "QC function ClientDisconnect is missing");
+               PRVM_serverglobaledict(self) = saveSelf;
        }
 
        if (host_client->netconnection)
index 1f12018..6f368f0 100644 (file)
@@ -218,8 +218,8 @@ void Host_God_f (void)
                return;
        }
 
-       host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_GODMODE;
-       if (!((int)host_client->edict->fields.server->flags & FL_GODMODE) )
+       PRVM_serveredictfloat(host_client->edict, flags) = (int)PRVM_serveredictfloat(host_client->edict, flags) ^ FL_GODMODE;
+       if (!((int)PRVM_serveredictfloat(host_client->edict, flags) & FL_GODMODE) )
                SV_ClientPrint("godmode OFF\n");
        else
                SV_ClientPrint("godmode ON\n");
@@ -233,8 +233,8 @@ void Host_Notarget_f (void)
                return;
        }
 
-       host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_NOTARGET;
-       if (!((int)host_client->edict->fields.server->flags & FL_NOTARGET) )
+       PRVM_serveredictfloat(host_client->edict, flags) = (int)PRVM_serveredictfloat(host_client->edict, flags) ^ FL_NOTARGET;
+       if (!((int)PRVM_serveredictfloat(host_client->edict, flags) & FL_NOTARGET) )
                SV_ClientPrint("notarget OFF\n");
        else
                SV_ClientPrint("notarget ON\n");
@@ -250,16 +250,16 @@ void Host_Noclip_f (void)
                return;
        }
 
-       if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
+       if (PRVM_serveredictfloat(host_client->edict, movetype) != MOVETYPE_NOCLIP)
        {
                noclip_anglehack = true;
-               host_client->edict->fields.server->movetype = MOVETYPE_NOCLIP;
+               PRVM_serveredictfloat(host_client->edict, movetype) = MOVETYPE_NOCLIP;
                SV_ClientPrint("noclip ON\n");
        }
        else
        {
                noclip_anglehack = false;
-               host_client->edict->fields.server->movetype = MOVETYPE_WALK;
+               PRVM_serveredictfloat(host_client->edict, movetype) = MOVETYPE_WALK;
                SV_ClientPrint("noclip OFF\n");
        }
 }
@@ -279,14 +279,14 @@ void Host_Fly_f (void)
                return;
        }
 
-       if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
+       if (PRVM_serveredictfloat(host_client->edict, movetype) != MOVETYPE_FLY)
        {
-               host_client->edict->fields.server->movetype = MOVETYPE_FLY;
+               PRVM_serveredictfloat(host_client->edict, movetype) = MOVETYPE_FLY;
                SV_ClientPrint("flymode ON\n");
        }
        else
        {
-               host_client->edict->fields.server->movetype = MOVETYPE_WALK;
+               PRVM_serveredictfloat(host_client->edict, movetype) = MOVETYPE_WALK;
                SV_ClientPrint("flymode OFF\n");
        }
 }
@@ -578,7 +578,7 @@ void Host_Savegame_to (const char *name)
 
        memset(comment, 0, sizeof(comment));
        if(isserver)
-               dpsnprintf(comment, sizeof(comment), "%-21.21s kills:%3i/%3i", PRVM_GetString(prog->edicts->fields.server->message), (int)prog->globals.server->killed_monsters, (int)prog->globals.server->total_monsters);
+               dpsnprintf(comment, sizeof(comment), "%-21.21s kills:%3i/%3i", PRVM_GetString(PRVM_serveredictstring(prog->edicts, message)), (int)PRVM_serverglobalfloat(killed_monsters), (int)PRVM_serverglobalfloat(total_monsters));
        else
                dpsnprintf(comment, sizeof(comment), "(crash dump of %s progs)", PRVM_NAME);
        // convert space to _ to make stdio happy
@@ -716,7 +716,7 @@ void Host_Savegame_f (void)
                        return;
                }
 
-               if (svs.clients[0].active && svs.clients[0].edict->fields.server->deadflag)
+               if (svs.clients[0].active && PRVM_serveredictfloat(svs.clients[0].edict, deadflag))
                {
                        Con_Print("Can't savegame with a dead player\n");
                        return;
@@ -944,7 +944,7 @@ void Host_Loadgame_f (void)
                        while (entnum >= prog->max_edicts)
                                PRVM_MEM_IncreaseEdicts();
                        ent = PRVM_EDICT_NUM(entnum);
-                       memset (ent->fields.server, 0, prog->entityfields * 4);
+                       memset(ent->fields.vp, 0, prog->entityfields * 4);
                        ent->priv.server->free = false;
 
                        if(developer_entityparsing.integer)
@@ -1195,7 +1195,7 @@ void Host_Name_f (void)
        if (j >= 0 && strlen(host_client->name) < sizeof(host_client->name) - 2)
                memcpy(host_client->name + strlen(host_client->name), STRING_COLOR_DEFAULT_STR, strlen(STRING_COLOR_DEFAULT_STR) + 1);
 
-       host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
+       PRVM_serveredictstring(host_client->edict, netname) = PRVM_SetEngineString(host_client->name);
        if (strcmp(host_client->old_name, host_client->name))
        {
                if (host_client->spawned)
@@ -1388,7 +1388,7 @@ void Host_Say(qboolean teamonly)
        // note: save is not a valid edict if fromServer is true
        save = host_client;
        for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
-               if (host_client->active && (!teamonly || host_client->edict->fields.server->team == save->edict->fields.server->team))
+               if (host_client->active && (!teamonly || PRVM_serveredictfloat(host_client->edict, team) == PRVM_serveredictfloat(save->edict, team)))
                        SV_ClientPrint(text);
        host_client = save;
 
@@ -1575,9 +1575,9 @@ void Host_Color(int changetop, int changebottom)
        if (host_client->edict && PRVM_clientfunction(SV_ChangeTeam))
        {
                Con_DPrint("Calling SV_ChangeTeam\n");
-               prog->globals.server->time = sv.time;
+               PRVM_serverglobalfloat(time) = sv.time;
                prog->globals.generic[OFS_PARM0] = playercolor;
-               prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
+               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
                PRVM_ExecuteProgram(PRVM_clientfunction(SV_ChangeTeam), "QC function SV_ChangeTeam is missing");
        }
        else
@@ -1585,7 +1585,7 @@ void Host_Color(int changetop, int changebottom)
                if (host_client->edict)
                {
                        PRVM_serveredictfloat(host_client->edict, clientcolors) = playercolor;
-                       host_client->edict->fields.server->team = bottom + 1;
+                       PRVM_serveredictfloat(host_client->edict, team) = bottom + 1;
                }
                host_client->colors = playercolor;
                if (host_client->old_colors != host_client->colors)
@@ -1674,15 +1674,15 @@ Host_Kill_f
 */
 void Host_Kill_f (void)
 {
-       if (host_client->edict->fields.server->health <= 0)
+       if (PRVM_serveredictfloat(host_client->edict, health) <= 0)
        {
                SV_ClientPrint("Can't suicide -- already dead!\n");
                return;
        }
 
-       prog->globals.server->time = sv.time;
-       prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
-       PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
+       PRVM_serverglobalfloat(time) = sv.time;
+       PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
+       PRVM_ExecuteProgram (PRVM_serverfunction(ClientKill), "QC function ClientKill is missing");
 }
 
 
@@ -1798,29 +1798,29 @@ void Host_Spawn_f (void)
                if (PRVM_serverfunction(RestoreGame))
                {
                        Con_DPrint("Calling RestoreGame\n");
-                       prog->globals.server->time = sv.time;
-                       prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
+                       PRVM_serverglobalfloat(time) = sv.time;
+                       PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
                        PRVM_ExecuteProgram(PRVM_serverfunction(RestoreGame), "QC function RestoreGame is missing");
                }
        }
        else
        {
-               //Con_Printf("Host_Spawn_f: host_client->edict->netname = %s, host_client->edict->netname = %s, host_client->name = %s\n", PRVM_GetString(host_client->edict->fields.server->netname), PRVM_GetString(host_client->edict->fields.server->netname), host_client->name);
+               //Con_Printf("Host_Spawn_f: host_client->edict->netname = %s, host_client->edict->netname = %s, host_client->name = %s\n", PRVM_GetString(PRVM_serveredictstring(host_client->edict, netname)), PRVM_GetString(PRVM_serveredictstring(host_client->edict, netname)), host_client->name);
 
                // copy spawn parms out of the client_t
                for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
-                       (&prog->globals.server->parm1)[i] = host_client->spawn_parms[i];
+                       (&PRVM_serverglobalfloat(parm1))[i] = host_client->spawn_parms[i];
 
                // call the spawn function
                host_client->clientconnectcalled = true;
-               prog->globals.server->time = sv.time;
-               prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
-               PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
+               PRVM_serverglobalfloat(time) = sv.time;
+               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
+               PRVM_ExecuteProgram (PRVM_serverfunction(ClientConnect), "QC function ClientConnect is missing");
 
                if (cls.state == ca_dedicated)
                        Con_Printf("%s connected\n", host_client->name);
 
-               PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
+               PRVM_ExecuteProgram (PRVM_serverfunction(PutClientInServer), "QC function PutClientInServer is missing");
        }
 
        if (!host_client->netconnection)
@@ -1860,19 +1860,19 @@ void Host_Spawn_f (void)
        // send some stats
        MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
        MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALSECRETS);
-       MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_secrets);
+       MSG_WriteLong (&host_client->netconnection->message, (int)PRVM_serverglobalfloat(total_secrets));
 
        MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
        MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALMONSTERS);
-       MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_monsters);
+       MSG_WriteLong (&host_client->netconnection->message, (int)PRVM_serverglobalfloat(total_monsters));
 
        MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
        MSG_WriteByte (&host_client->netconnection->message, STAT_SECRETS);
-       MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->found_secrets);
+       MSG_WriteLong (&host_client->netconnection->message, (int)PRVM_serverglobalfloat(found_secrets));
 
        MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
        MSG_WriteByte (&host_client->netconnection->message, STAT_MONSTERS);
-       MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->killed_monsters);
+       MSG_WriteLong (&host_client->netconnection->message, (int)PRVM_serverglobalfloat(killed_monsters));
 
        // send a fixangle
        // Never send a roll angle, because savegames can catch the server
@@ -1882,15 +1882,15 @@ void Host_Spawn_f (void)
        if (sv.loadgame)
        {
                MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
-               MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[0], sv.protocol);
-               MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[1], sv.protocol);
+               MSG_WriteAngle (&host_client->netconnection->message, PRVM_serveredictvector(host_client->edict, v_angle)[0], sv.protocol);
+               MSG_WriteAngle (&host_client->netconnection->message, PRVM_serveredictvector(host_client->edict, v_angle)[1], sv.protocol);
                MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
        }
        else
        {
                MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
-               MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
-               MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
+               MSG_WriteAngle (&host_client->netconnection->message, PRVM_serveredictvector(host_client->edict, angles)[0], sv.protocol);
+               MSG_WriteAngle (&host_client->netconnection->message, PRVM_serveredictvector(host_client->edict, angles)[1], sv.protocol);
                MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
        }
 
@@ -2052,21 +2052,21 @@ void Host_Give_f (void)
                        if (t[0] == '6')
                        {
                                if (t[1] == 'a')
-                                       host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_PROXIMITY_GUN;
+                                       PRVM_serveredictfloat(host_client->edict, items) = (int)PRVM_serveredictfloat(host_client->edict, items) | HIT_PROXIMITY_GUN;
                                else
-                                       host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | IT_GRENADE_LAUNCHER;
+                                       PRVM_serveredictfloat(host_client->edict, items) = (int)PRVM_serveredictfloat(host_client->edict, items) | IT_GRENADE_LAUNCHER;
                        }
                        else if (t[0] == '9')
-                               host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_LASER_CANNON;
+                               PRVM_serveredictfloat(host_client->edict, items) = (int)PRVM_serveredictfloat(host_client->edict, items) | HIT_LASER_CANNON;
                        else if (t[0] == '0')
-                               host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_MJOLNIR;
+                               PRVM_serveredictfloat(host_client->edict, items) = (int)PRVM_serveredictfloat(host_client->edict, items) | HIT_MJOLNIR;
                        else if (t[0] >= '2')
-                               host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
+                               PRVM_serveredictfloat(host_client->edict, items) = (int)PRVM_serveredictfloat(host_client->edict, items) | (IT_SHOTGUN << (t[0] - '2'));
                }
                else
                {
                        if (t[0] >= '2')
-                               host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
+                               PRVM_serveredictfloat(host_client->edict, items) = (int)PRVM_serveredictfloat(host_client->edict, items) | (IT_SHOTGUN << (t[0] - '2'));
                }
                break;
 
@@ -2074,69 +2074,69 @@ void Host_Give_f (void)
                if (gamemode == GAME_ROGUE)
                        PRVM_serveredictfloat(host_client->edict, ammo_shells1) = v;
 
-               host_client->edict->fields.server->ammo_shells = v;
+               PRVM_serveredictfloat(host_client->edict, ammo_shells) = v;
                break;
        case 'n':
                if (gamemode == GAME_ROGUE)
                {
                        PRVM_serveredictfloat(host_client->edict, ammo_nails1) = v;
-                       if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
-                               host_client->edict->fields.server->ammo_nails = v;
+                       if (PRVM_serveredictfloat(host_client->edict, weapon) <= IT_LIGHTNING)
+                               PRVM_serveredictfloat(host_client->edict, ammo_nails) = v;
                }
                else
                {
-                       host_client->edict->fields.server->ammo_nails = v;
+                       PRVM_serveredictfloat(host_client->edict, ammo_nails) = v;
                }
                break;
        case 'l':
                if (gamemode == GAME_ROGUE)
                {
                        PRVM_serveredictfloat(host_client->edict, ammo_lava_nails) = v;
-                       if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
-                               host_client->edict->fields.server->ammo_nails = v;
+                       if (PRVM_serveredictfloat(host_client->edict, weapon) > IT_LIGHTNING)
+                               PRVM_serveredictfloat(host_client->edict, ammo_nails) = v;
                }
                break;
        case 'r':
                if (gamemode == GAME_ROGUE)
                {
                        PRVM_serveredictfloat(host_client->edict, ammo_rockets1) = v;
-                       if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
-                               host_client->edict->fields.server->ammo_rockets = v;
+                       if (PRVM_serveredictfloat(host_client->edict, weapon) <= IT_LIGHTNING)
+                               PRVM_serveredictfloat(host_client->edict, ammo_rockets) = v;
                }
                else
                {
-                       host_client->edict->fields.server->ammo_rockets = v;
+                       PRVM_serveredictfloat(host_client->edict, ammo_rockets) = v;
                }
                break;
        case 'm':
                if (gamemode == GAME_ROGUE)
                {
                        PRVM_serveredictfloat(host_client->edict, ammo_multi_rockets) = v;
-                       if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
-                               host_client->edict->fields.server->ammo_rockets = v;
+                       if (PRVM_serveredictfloat(host_client->edict, weapon) > IT_LIGHTNING)
+                               PRVM_serveredictfloat(host_client->edict, ammo_rockets) = v;
                }
                break;
        case 'h':
-               host_client->edict->fields.server->health = v;
+               PRVM_serveredictfloat(host_client->edict, health) = v;
                break;
        case 'c':
                if (gamemode == GAME_ROGUE)
                {
                        PRVM_serveredictfloat(host_client->edict, ammo_cells1) = v;
-                       if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
-                               host_client->edict->fields.server->ammo_cells = v;
+                       if (PRVM_serveredictfloat(host_client->edict, weapon) <= IT_LIGHTNING)
+                               PRVM_serveredictfloat(host_client->edict, ammo_cells) = v;
                }
                else
                {
-                       host_client->edict->fields.server->ammo_cells = v;
+                       PRVM_serveredictfloat(host_client->edict, ammo_cells) = v;
                }
                break;
        case 'p':
                if (gamemode == GAME_ROGUE)
                {
                        PRVM_serveredictfloat(host_client->edict, ammo_plasma) = v;
-                       if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
-                               host_client->edict->fields.server->ammo_cells = v;
+                       if (PRVM_serveredictfloat(host_client->edict, weapon) > IT_LIGHTNING)
+                               PRVM_serveredictfloat(host_client->edict, ammo_cells) = v;
                }
                break;
        }
@@ -2150,7 +2150,7 @@ prvm_edict_t      *FindViewthing (void)
        for (i=0 ; i<prog->num_edicts ; i++)
        {
                e = PRVM_EDICT_NUM(i);
-               if (!strcmp (PRVM_GetString(e->fields.server->classname), "viewthing"))
+               if (!strcmp (PRVM_GetString(PRVM_serveredictstring(e, classname)), "viewthing"))
                        return e;
        }
        Con_Print("No viewthing on map\n");
@@ -2183,8 +2183,8 @@ void Host_Viewmodel_f (void)
                return;
        }
 
-       e->fields.server->frame = 0;
-       cl.model_precache[(int)e->fields.server->modelindex] = m;
+       PRVM_serveredictfloat(e, frame) = 0;
+       cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)] = m;
 }
 
 /*
@@ -2206,13 +2206,13 @@ void Host_Viewframe_f (void)
        SV_VM_End();
        if (!e)
                return;
-       m = cl.model_precache[(int)e->fields.server->modelindex];
+       m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)];
 
        f = atoi(Cmd_Argv(1));
        if (f >= m->numframes)
                f = m->numframes-1;
 
-       e->fields.server->frame = f;
+       PRVM_serveredictfloat(e, frame) = f;
 }
 
 
@@ -2242,13 +2242,13 @@ void Host_Viewnext_f (void)
        SV_VM_End();
        if (!e)
                return;
-       m = cl.model_precache[(int)e->fields.server->modelindex];
+       m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)];
 
-       e->fields.server->frame = e->fields.server->frame + 1;
-       if (e->fields.server->frame >= m->numframes)
-               e->fields.server->frame = m->numframes - 1;
+       PRVM_serveredictfloat(e, frame) = PRVM_serveredictfloat(e, frame) + 1;
+       if (PRVM_serveredictfloat(e, frame) >= m->numframes)
+               PRVM_serveredictfloat(e, frame) = m->numframes - 1;
 
-       PrintFrameName (m, (int)e->fields.server->frame);
+       PrintFrameName (m, (int)PRVM_serveredictfloat(e, frame));
 }
 
 /*
@@ -2270,13 +2270,13 @@ void Host_Viewprev_f (void)
        if (!e)
                return;
 
-       m = cl.model_precache[(int)e->fields.server->modelindex];
+       m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)];
 
-       e->fields.server->frame = e->fields.server->frame - 1;
-       if (e->fields.server->frame < 0)
-               e->fields.server->frame = 0;
+       PRVM_serveredictfloat(e, frame) = PRVM_serveredictfloat(e, frame) - 1;
+       if (PRVM_serveredictfloat(e, frame) < 0)
+               PRVM_serveredictfloat(e, frame) = 0;
 
-       PrintFrameName (m, (int)e->fields.server->frame);
+       PrintFrameName (m, (int)PRVM_serveredictfloat(e, frame));
 }
 
 /*
diff --git a/menu.c b/menu.c
index f0ef7c0..5df5370 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -5300,7 +5300,6 @@ void MP_Init (void)
        PRVM_Begin;
        PRVM_InitProg(PRVM_MENUPROG);
 
-       prog->headercrc = M_PROGHEADER_CRC;
        prog->edictprivate_size = 0; // no private struct used
        prog->name = M_NAME;
        prog->num_edicts = 1;
index 3ca5093..c7993b7 100644 (file)
@@ -1,14 +1,22 @@
 
+#ifndef MPROGDEFS_H
+#define MPROGDEFS_H
+
 /* file generated by qcc, do not modify */
 
+/*
 typedef struct m_globalvars_s
 {
        int     pad[28];
        int     self;
 } m_globalvars_t;
 
-/*typedef struct m_entvars_s
+typedef struct m_entvars_s
 {
-} m_entvars_t;*/
+} m_entvars_t;
 
 #define M_PROGHEADER_CRC 10020
+
+*/
+
+#endif
index 9794111..60c3f21 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -110,8 +110,8 @@ typedef struct prvm_edict_s
        union
        {
                vec_t *vp;
-               entvars_t               *server;
-               cl_entvars_t    *client;
+//             entvars_t               *server;
+//             cl_entvars_t    *client;
        } fields;
 } prvm_edict_t;
 
@@ -528,8 +528,8 @@ typedef struct prvm_prog_s
 
        union {
                vec_t *generic;
-               globalvars_t *server;
-               cl_globalvars_t *client;
+//             globalvars_t *server;
+//             cl_globalvars_t *client;
        } globals;
 
        int                                     maxknownstrings;
@@ -564,9 +564,6 @@ typedef struct prvm_prog_s
        int                                     localstack[PRVM_LOCALSTACK_SIZE];
        int                                     localstack_used;
 
-       unsigned short          headercrc; // [INIT]
-       unsigned short          headercrc2; // [INIT] alternate CRC for tenebrae progs.dat
-
        unsigned short          filecrc;
 
        //============================================================================
index 3ae47c5..7e60463 100644 (file)
@@ -553,7 +553,7 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
                                        msg->allowoverflow = true;
                                        PRVM_G_INT(OFS_PARM0) = sv.writeentitiestoclient_cliententitynumber;
                                        PRVM_G_FLOAT(OFS_PARM1) = sendflags;
-                                       prog->globals.server->self = number;
+                                       PRVM_serverglobaledict(self) = number;
                                        PRVM_ExecuteProgram(PRVM_serveredictfunction(ed, SendEntity), "Null SendEntity\n");
                                        msg->allowoverflow = false;
                                        if(PRVM_G_FLOAT(OFS_RETURN) && msg->cursize + 2 <= maxsize)
index 819bada..df5ea5e 100644 (file)
@@ -6845,7 +6845,7 @@ void VM_getsurfaceclippedpoint(void)
        animatemodel(model, ed);
        applytransform_inverted(PRVM_G_VECTOR(OFS_PARM2), ed, p);
        clippointtosurface(ed, model, surface, p, out);
-       VectorAdd(out, ed->fields.server->origin, PRVM_G_VECTOR(OFS_RETURN));
+       VectorAdd(out, PRVM_serveredictvector(ed, origin), PRVM_G_VECTOR(OFS_RETURN));
 }
 
 //PF_getsurfacenumtriangles, // #??? float(entity e, float s) getsurfacenumtriangles = #???;
@@ -6924,7 +6924,7 @@ void VM_physics_enable(void)
                return;
        }
        // entity should have MOVETYPE_PHYSICS already set, this can damage memory (making leaked allocation) so warn about this even if non-developer
-       if (ed->fields.server->movetype != MOVETYPE_PHYSICS)
+       if (PRVM_serveredictfloat(ed, movetype) != MOVETYPE_PHYSICS)
        {
                VM_Warning("VM_physics_enable: entity is not MOVETYPE_PHYSICS!\n");
                return;
@@ -6948,14 +6948,14 @@ void VM_physics_addforce(void)
                return;
        }
        // entity should have MOVETYPE_PHYSICS already set, this can damage memory (making leaked allocation) so warn about this even if non-developer
-       if (ed->fields.server->movetype != MOVETYPE_PHYSICS)
+       if (PRVM_serveredictfloat(ed, movetype) != MOVETYPE_PHYSICS)
        {
                VM_Warning("VM_physics_addforce: entity is not MOVETYPE_PHYSICS!\n");
                return;
        }
        f.type = ODEFUNC_RELFORCEATPOS;
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
-       VectorSubtract(ed->fields.server->origin, PRVM_G_VECTOR(OFS_PARM2), f.v2);
+       VectorSubtract(PRVM_serveredictvector(ed, origin), PRVM_G_VECTOR(OFS_PARM2), f.v2);
        VM_physics_ApplyCmd(ed, &f);
 }
 
@@ -6974,7 +6974,7 @@ void VM_physics_addtorque(void)
                return;
        }
        // entity should have MOVETYPE_PHYSICS already set, this can damage memory (making leaked allocation) so warn about this even if non-developer
-       if (ed->fields.server->movetype != MOVETYPE_PHYSICS)
+       if (PRVM_serveredictfloat(ed, movetype) != MOVETYPE_PHYSICS)
        {
                VM_Warning("VM_physics_addtorque: entity is not MOVETYPE_PHYSICS!\n");
                return;
index fcc0b53..ffe917a 100644 (file)
@@ -1972,8 +1972,6 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, const char **re
        prog->progs_crc = LittleLong(dprograms->crc);
        if (prog->progs_version != PROG_VERSION)
                PRVM_ERROR ("%s: %s has wrong version number (%i should be %i)", PRVM_NAME, filename, prog->progs_version, PROG_VERSION);
-       if (prog->progs_crc != prog->headercrc && prog->progs_crc != prog->headercrc2)
-               PRVM_ERROR ("%s: %s system vars have been modified (CRC of progs.dat systemvars %i != engine %i), progdefs.h is out of date", PRVM_NAME, filename, prog->progs_crc, prog->headercrc);
        instatements = (dstatement_t *)((unsigned char *)dprograms + LittleLong(dprograms->ofs_statements));
        prog->progs_numstatements = LittleLong(dprograms->numstatements);
        inglobaldefs = (ddef_t *)((unsigned char *)dprograms + LittleLong(dprograms->ofs_globaldefs));
@@ -3018,21 +3016,20 @@ static qboolean PRVM_IsEdictRelevant(prvm_edict_t *edict)
        {
                case PRVM_SERVERPROG:
                        {
-                               entvars_t *ev = edict->fields.server;
-                               if(ev->solid) // can block other stuff, or is a trigger?
+                               if(PRVM_serveredictfloat(edict, solid)) // can block other stuff, or is a trigger?
                                        return true;
-                               if(ev->modelindex) // visible ent?
+                               if(PRVM_serveredictfloat(edict, modelindex)) // visible ent?
                                        return true;
-                               if(ev->effects) // particle effect?
+                               if(PRVM_serveredictfloat(edict, effects)) // particle effect?
                                        return true;
-                               if(ev->think) // has a think function?
-                                       if(ev->nextthink > 0) // that actually will eventually run?
+                               if(PRVM_serveredictfunction(edict, think)) // has a think function?
+                                       if(PRVM_serveredictfloat(edict, nextthink) > 0) // that actually will eventually run?
                                                return true;
-                               if(ev->takedamage)
+                               if(PRVM_serveredictfloat(edict, takedamage))
                                        return true;
                                if(*prvm_leaktest_ignore_classnames.string)
                                {
-                                       if(strstr(va(" %s ", prvm_leaktest_ignore_classnames.string), va(" %s ", PRVM_GetString(ev->classname))))
+                                       if(strstr(va(" %s ", prvm_leaktest_ignore_classnames.string), va(" %s ", PRVM_GetString(PRVM_serveredictstring(edict, classname)))))
                                                return true;
                                }
                        }
@@ -3040,19 +3037,18 @@ static qboolean PRVM_IsEdictRelevant(prvm_edict_t *edict)
                case PRVM_CLIENTPROG:
                        {
                                // TODO someone add more stuff here
-                               cl_entvars_t *ev = edict->fields.client;
-                               if(ev->entnum) // csqc networked
+                               if(PRVM_clientedictfloat(edict, entnum)) // csqc networked
                                        return true;
-                               if(ev->modelindex) // visible ent?
+                               if(PRVM_clientedictfloat(edict, modelindex)) // visible ent?
                                        return true;
-                               if(ev->effects) // particle effect?
+                               if(PRVM_clientedictfloat(edict, effects)) // particle effect?
                                        return true;
-                               if(ev->think) // has a think function?
-                                       if(ev->nextthink > 0) // that actually will eventually run?
+                               if(PRVM_clientedictfunction(edict, think)) // has a think function?
+                                       if(PRVM_clientedictfloat(edict, nextthink) > 0) // that actually will eventually run?
                                                return true;
                                if(*prvm_leaktest_ignore_classnames.string)
                                {
-                                       if(strstr(va(" %s ", prvm_leaktest_ignore_classnames.string), va(" %s ", PRVM_GetString(ev->classname))))
+                                       if(strstr(va(" %s ", prvm_leaktest_ignore_classnames.string), va(" %s ", PRVM_GetString(PRVM_clientedictstring(edict, classname)))))
                                                return true;
                                }
                        }
@@ -3073,7 +3069,7 @@ static qboolean PRVM_IsEdictReferenced(prvm_edict_t *edict, int mark)
        switch(prog - prog_list)
        {
                case PRVM_SERVERPROG:
-                       targetname = PRVM_GetString(edict->fields.server->targetname);
+                       targetname = PRVM_GetString(PRVM_serveredictstring(edict, targetname));
                        break;
        }
 
@@ -3099,7 +3095,7 @@ static qboolean PRVM_IsEdictReferenced(prvm_edict_t *edict, int mark)
                        continue;
                if(targetname)
                {
-                       const char *target = PRVM_GetString(ed->fields.server->target);
+                       const char *target = PRVM_GetString(PRVM_serveredictstring(ed, target));
                        if(target)
                                if(!strcmp(target, targetname))
                                        return true;
index c237f2f..f6f00d3 100644 (file)
--- a/sv_demo.c
+++ b/sv_demo.c
@@ -44,7 +44,7 @@ void SV_WriteDemoMessage(client_t *client, sizebuf_t *sendbuffer, qboolean clien
        FS_Write(client->sv_demo_file, &len, 4);
        for(i = 0; i < 3; ++i)
        {
-               f = LittleFloat(client->edict->fields.server->v_angle[i]);
+               f = LittleFloat(PRVM_serveredictvector(client->edict, v_angle)[i]);
                FS_Write(client->sv_demo_file, &f, 4);
        }
        FS_Write(client->sv_demo_file, sendbuffer->data, sendbuffer->cursize);
index 69ea9d2..d8e232d 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -752,7 +752,7 @@ void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int v
        else
                MSG_WriteByte (&sv.datagram, sound_num);
        for (i = 0;i < 3;i++)
-               MSG_WriteCoord (&sv.datagram, entity->fields.server->origin[i]+0.5*(entity->fields.server->mins[i]+entity->fields.server->maxs[i]), sv.protocol);
+               MSG_WriteCoord (&sv.datagram, PRVM_serveredictvector(entity, origin)[i]+0.5*(PRVM_serveredictvector(entity, mins)[i]+PRVM_serveredictvector(entity, maxs)[i]), sv.protocol);
        SV_FlushBroadcastMessages();
 }
 
@@ -970,7 +970,7 @@ void SV_SendServerinfo (client_t *client)
        else
                MSG_WriteByte (&client->netconnection->message, GAME_COOP);
 
-       MSG_WriteString (&client->netconnection->message,PRVM_GetString(prog->edicts->fields.server->message));
+       MSG_WriteString (&client->netconnection->message,PRVM_GetString(PRVM_serveredictstring(prog->edicts, message)));
 
        for (i = 1;i < MAX_MODELS && sv.model_precache[i][0];i++)
                MSG_WriteString (&client->netconnection->message, sv.model_precache[i]);
@@ -982,8 +982,8 @@ void SV_SendServerinfo (client_t *client)
 
 // send music
        MSG_WriteByte (&client->netconnection->message, svc_cdtrack);
-       MSG_WriteByte (&client->netconnection->message, (int)prog->edicts->fields.server->sounds);
-       MSG_WriteByte (&client->netconnection->message, (int)prog->edicts->fields.server->sounds);
+       MSG_WriteByte (&client->netconnection->message, (int)PRVM_serveredictfloat(prog->edicts, sounds));
+       MSG_WriteByte (&client->netconnection->message, (int)PRVM_serveredictfloat(prog->edicts, sounds));
 
 // set view
 // store this in clientcamera, too
@@ -1075,10 +1075,10 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
        {
                // call the progs to get default spawn parms for the new client
                // set self to world to intentionally cause errors with broken SetNewParms code in some mods
-               prog->globals.server->self = 0;
-               PRVM_ExecuteProgram (prog->globals.server->SetNewParms, "QC function SetNewParms is missing");
+               PRVM_serverglobaledict(self) = 0;
+               PRVM_ExecuteProgram (PRVM_serverfunction(SetNewParms), "QC function SetNewParms is missing");
                for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
-                       client->spawn_parms[i] = (&prog->globals.server->parm1)[i];
+                       client->spawn_parms[i] = (&PRVM_serverglobalfloat(parm1))[i];
 
                // set up the entity for this client (including .colormap, .team, etc)
                PRVM_ED_ClearEdict(client->edict);
@@ -1133,18 +1133,18 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c
 
        // this 2 billion unit check is actually to detect NAN origins
        // (we really don't want to send those)
-       if (!(VectorLength2(ent->fields.server->origin) < 2000000000.0*2000000000.0))
+       if (!(VectorLength2(PRVM_serveredictvector(ent, origin)) < 2000000000.0*2000000000.0))
                return false;
 
        // EF_NODRAW prevents sending for any reason except for your own
        // client, so we must keep all clients in this superset
-       effects = (unsigned)ent->fields.server->effects;
+       effects = (unsigned)PRVM_serveredictfloat(ent, effects);
 
        // we can omit invisible entities with no effects that are not clients
        // LordHavoc: this could kill tags attached to an invisible entity, I
        // just hope we never have to support that case
-       i = (int)ent->fields.server->modelindex;
-       modelindex = (i >= 1 && i < MAX_MODELS && ent->fields.server->model && *PRVM_GetString(ent->fields.server->model) && sv.models[i]) ? i : 0;
+       i = (int)PRVM_serveredictfloat(ent, modelindex);
+       modelindex = (i >= 1 && i < MAX_MODELS && PRVM_serveredictstring(ent, model) && *PRVM_GetString(PRVM_serveredictstring(ent, model)) && sv.models[i]) ? i : 0;
 
        flags = 0;
        i = (int)(PRVM_serveredictfloat(ent, glow_size) * 0.25f);
@@ -1222,14 +1222,14 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c
        *cs = defaultstate;
        cs->active = ACTIVE_NETWORK;
        cs->number = enumber;
-       VectorCopy(ent->fields.server->origin, cs->origin);
-       VectorCopy(ent->fields.server->angles, cs->angles);
+       VectorCopy(PRVM_serveredictvector(ent, origin), cs->origin);
+       VectorCopy(PRVM_serveredictvector(ent, angles), cs->angles);
        cs->flags = flags;
        cs->effects = effects;
-       cs->colormap = (unsigned)ent->fields.server->colormap;
+       cs->colormap = (unsigned)PRVM_serveredictfloat(ent, colormap);
        cs->modelindex = modelindex;
-       cs->skin = (unsigned)ent->fields.server->skin;
-       cs->frame = (unsigned)ent->fields.server->frame;
+       cs->skin = (unsigned)PRVM_serveredictfloat(ent, skin);
+       cs->frame = (unsigned)PRVM_serveredictfloat(ent, frame);
        cs->viewmodelforclient = PRVM_serveredictedict(ent, viewmodelforclient);
        cs->exteriormodelforclient = PRVM_serveredictedict(ent, exteriormodeltoclient);
        cs->nodrawtoclient = PRVM_serveredictedict(ent, nodrawtoclient);
@@ -1296,11 +1296,11 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c
        if (f)
                cs->effects |= ((unsigned int)f & 0xff) << 24;
 
-       if (ent->fields.server->movetype == MOVETYPE_STEP)
+       if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_STEP)
                cs->flags |= RENDER_STEP;
        if (cs->number != sv.writeentitiestoclient_cliententitynumber && (cs->effects & EF_LOWPRECISION) && cs->origin[0] >= -32768 && cs->origin[1] >= -32768 && cs->origin[2] >= -32768 && cs->origin[0] <= 32767 && cs->origin[1] <= 32767 && cs->origin[2] <= 32767)
                cs->flags |= RENDER_LOWPRECISION;
-       if (ent->fields.server->colormap >= 1024)
+       if (PRVM_serveredictfloat(ent, colormap) >= 1024)
                cs->flags |= RENDER_COLORMAPPED;
        if (cs->viewmodelforclient)
                cs->flags |= RENDER_VIEWMODEL; // show relative to the view
@@ -1358,8 +1358,8 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c
        else
        {
                // if there is no model (or it could not be loaded), use the physics box
-               VectorAdd(cs->origin, ent->fields.server->mins, cullmins);
-               VectorAdd(cs->origin, ent->fields.server->maxs, cullmaxs);
+               VectorAdd(cs->origin, PRVM_serveredictvector(ent, mins), cullmins);
+               VectorAdd(cs->origin, PRVM_serveredictvector(ent, maxs), cullmaxs);
        }
        if (specialvisibilityradius)
        {
@@ -1497,7 +1497,7 @@ qboolean SV_CanSeeBox(int numtraces, vec_t enlarge, vec3_t eye, vec3_t entboxmin
        for (touchindex = 0;touchindex < originalnumtouchedicts;touchindex++)
        {
                touch = touchedicts[touchindex];
-               if (touch->fields.server->solid != SOLID_BSP)
+               if (PRVM_serveredictfloat(touch, solid) != SOLID_BSP)
                        continue;
                model = SV_GetModelFromEdict(touch);
                if (!model || !model->brush.TraceLineOfSight)
@@ -1506,7 +1506,7 @@ qboolean SV_CanSeeBox(int numtraces, vec_t enlarge, vec3_t eye, vec3_t entboxmin
                alpha = PRVM_serveredictfloat(touch, alpha);
                if (alpha && alpha < 1)
                        continue;
-               if ((int)touch->fields.server->effects & EF_ADDITIVE)
+               if ((int)PRVM_serveredictfloat(touch, effects) & EF_ADDITIVE)
                        continue;
                touchedicts[numtouchedicts++] = touch;
        }
@@ -1529,7 +1529,7 @@ qboolean SV_CanSeeBox(int numtraces, vec_t enlarge, vec3_t eye, vec3_t entboxmin
                        {
                                // get the entity matrix
                                pitchsign = SV_GetPitchSign(touch);
-                               Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2], pitchsign * touch->fields.server->angles[0], touch->fields.server->angles[1], touch->fields.server->angles[2], 1);
+                               Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2], pitchsign * PRVM_serveredictvector(touch, angles)[0], PRVM_serveredictvector(touch, angles)[1], PRVM_serveredictvector(touch, angles)[2], 1);
                                Matrix4x4_Invert_Simple(&imatrix, &matrix);
                                // see if the ray hits this entity
                                Matrix4x4_Transform(&imatrix, eye, starttransformed);
@@ -1564,8 +1564,8 @@ void SV_MarkWriteEntityStateToClient(entity_state_t *s)
 
        if (s->customizeentityforclient)
        {
-               prog->globals.server->self = s->number;
-               prog->globals.server->other = sv.writeentitiestoclient_cliententitynumber;
+               PRVM_serverglobaledict(self) = s->number;
+               PRVM_serverglobaledict(other) = sv.writeentitiestoclient_cliententitynumber;
                PRVM_ExecuteProgram(s->customizeentityforclient, "customizeentityforclient: NULL function");
                if(!PRVM_G_FLOAT(OFS_RETURN) || !SV_PrepareEntityForSending(PRVM_EDICT_NUM(s->number), s, s->number))
                        return;
@@ -1700,8 +1700,8 @@ void SV_AddCameraEyes(void)
                {
                        if(PRVM_serveredictfunction(ed, camera_transform))
                        {
-                               prog->globals.server->self = e;
-                               prog->globals.server->other = sv.writeentitiestoclient_cliententitynumber;
+                               PRVM_serverglobaledict(self) = e;
+                               PRVM_serverglobaledict(other) = sv.writeentitiestoclient_cliententitynumber;
                                VectorCopy(sv.writeentitiestoclient_eyes[0], PRVM_serverglobalvector(trace_endpos));
                                VectorCopy(sv.writeentitiestoclient_eyes[0], PRVM_G_VECTOR(OFS_PARM0));
                                VectorClear(PRVM_G_VECTOR(OFS_PARM1));
@@ -1728,8 +1728,8 @@ void SV_AddCameraEyes(void)
                if(!cameras[j])
                        continue;
                ed = PRVM_EDICT_NUM(cameras[j]);
-               VectorAdd(ed->fields.server->origin, ed->fields.server->mins, mi);
-               VectorAdd(ed->fields.server->origin, ed->fields.server->maxs, ma);
+               VectorAdd(PRVM_serveredictvector(ed, origin), PRVM_serveredictvector(ed, mins), mi);
+               VectorAdd(PRVM_serveredictvector(ed, origin), PRVM_serveredictvector(ed, maxs), ma);
                for(k = 0; k < sv.writeentitiestoclient_numeyes; ++k)
                if(eye_levels[k] <= MAX_EYE_RECURSION)
                {
@@ -1777,7 +1777,7 @@ void SV_WriteEntitiesToClient(client_t *client, prvm_edict_t *clent, sizebuf_t *
        // get eye location
        sv.writeentitiestoclient_cliententitynumber = PRVM_EDICT_TO_PROG(clent); // LordHavoc: for comparison purposes
        camera = PRVM_EDICT_NUM( client->clientcamera );
-       VectorAdd(camera->fields.server->origin, clent->fields.server->view_ofs, eye);
+       VectorAdd(PRVM_serveredictvector(camera, origin), PRVM_serveredictvector(clent, view_ofs), eye);
        sv.writeentitiestoclient_pvsbytes = 0;
        // get the PVS values for the eye location, later FatPVS calls will merge
        if (sv.worldmodel && sv.worldmodel->brush.FatPVS)
@@ -1792,7 +1792,7 @@ void SV_WriteEntitiesToClient(client_t *client, prvm_edict_t *clent, sizebuf_t *
        {
                vec_t predtime = bound(0, host_client->ping, sv_cullentities_trace_prediction_time.value);
                vec3_t predeye;
-               VectorMA(eye, predtime, camera->fields.server->velocity, predeye);
+               VectorMA(eye, predtime, PRVM_serveredictvector(camera, velocity), predeye);
                if (SV_CanSeeBox(1, 0, eye, predeye, predeye))
                {
                        VectorCopy(predeye, sv.writeentitiestoclient_eyes[sv.writeentitiestoclient_numeyes]);
@@ -1887,7 +1887,7 @@ static void SV_CleanupEnts (void)
 
        ent = PRVM_NEXT_EDICT(prog->edicts);
        for (e=1 ; e<prog->num_edicts ; e++, ent = PRVM_NEXT_EDICT(ent))
-               ent->fields.server->effects = (int)ent->fields.server->effects & ~EF_MUZZLEFLASH;
+               PRVM_serveredictfloat(ent, effects) = (int)PRVM_serveredictfloat(ent, effects) & ~EF_MUZZLEFLASH;
 }
 
 /*
@@ -1911,17 +1911,17 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
 //
 // send a damage message
 //
-       if (ent->fields.server->dmg_take || ent->fields.server->dmg_save)
+       if (PRVM_serveredictfloat(ent, dmg_take) || PRVM_serveredictfloat(ent, dmg_save))
        {
-               other = PRVM_PROG_TO_EDICT(ent->fields.server->dmg_inflictor);
+               other = PRVM_PROG_TO_EDICT(PRVM_serveredictedict(ent, dmg_inflictor));
                MSG_WriteByte (msg, svc_damage);
-               MSG_WriteByte (msg, (int)ent->fields.server->dmg_save);
-               MSG_WriteByte (msg, (int)ent->fields.server->dmg_take);
+               MSG_WriteByte (msg, (int)PRVM_serveredictfloat(ent, dmg_save));
+               MSG_WriteByte (msg, (int)PRVM_serveredictfloat(ent, dmg_take));
                for (i=0 ; i<3 ; i++)
-                       MSG_WriteCoord (msg, other->fields.server->origin[i] + 0.5*(other->fields.server->mins[i] + other->fields.server->maxs[i]), sv.protocol);
+                       MSG_WriteCoord (msg, PRVM_serveredictvector(other, origin)[i] + 0.5*(PRVM_serveredictvector(other, mins)[i] + PRVM_serveredictvector(other, maxs)[i]), sv.protocol);
 
-               ent->fields.server->dmg_take = 0;
-               ent->fields.server->dmg_save = 0;
+               PRVM_serveredictfloat(ent, dmg_take) = 0;
+               PRVM_serveredictfloat(ent, dmg_save) = 0;
        }
 
 //
@@ -1930,15 +1930,15 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
        SV_SetIdealPitch ();            // how much to look up / down ideally
 
 // a fixangle might get lost in a dropped packet.  Oh well.
-       if(ent->fields.server->fixangle)
+       if(PRVM_serveredictfloat(ent, fixangle))
        {
                // angle fixing was requested by global thinking code...
                // so store the current angles for later use
-               memcpy(host_client->fixangle_angles, ent->fields.server->angles, sizeof(host_client->fixangle_angles));
+               memcpy(host_client->fixangle_angles, PRVM_serveredictvector(ent, angles), sizeof(host_client->fixangle_angles));
                host_client->fixangle_angles_set = TRUE;
 
                // and clear fixangle for the next frame
-               ent->fields.server->fixangle = 0;
+               PRVM_serveredictfloat(ent, fixangle) = 0;
        }
 
        if (host_client->fixangle_angles_set)
@@ -1952,15 +1952,15 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
        // stuff the sigil bits into the high bits of items for sbar, or else
        // mix in items2
        if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE)
-               items = (int)ent->fields.server->items | ((int)PRVM_serveredictfloat(ent, items2) << 23);
+               items = (int)PRVM_serveredictfloat(ent, items) | ((int)PRVM_serveredictfloat(ent, items2) << 23);
        else
-               items = (int)ent->fields.server->items | ((int)prog->globals.server->serverflags << 28);
+               items = (int)PRVM_serveredictfloat(ent, items) | ((int)PRVM_serverglobalfloat(serverflags) << 28);
 
        VectorCopy(PRVM_serveredictvector(ent, punchvector), punchvector);
 
        // cache weapon model name and index in client struct to save time
        // (this search can be almost 1% of cpu time!)
-       s = PRVM_GetString(ent->fields.server->weaponmodel);
+       s = PRVM_GetString(PRVM_serveredictstring(ent, weaponmodel));
        if (strcmp(s, client->weaponmodel))
        {
                strlcpy(client->weaponmodel, s, sizeof(client->weaponmodel));
@@ -1973,46 +1973,46 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
 
        bits = 0;
 
-       if ((int)ent->fields.server->flags & FL_ONGROUND)
+       if ((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)
                bits |= SU_ONGROUND;
-       if (ent->fields.server->waterlevel >= 2)
+       if (PRVM_serveredictfloat(ent, waterlevel) >= 2)
                bits |= SU_INWATER;
-       if (ent->fields.server->idealpitch)
+       if (PRVM_serveredictfloat(ent, idealpitch))
                bits |= SU_IDEALPITCH;
 
        for (i=0 ; i<3 ; i++)
        {
-               if (ent->fields.server->punchangle[i])
+               if (PRVM_serveredictvector(ent, punchangle)[i])
                        bits |= (SU_PUNCH1<<i);
                if (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_NEHAHRABJP && sv.protocol != PROTOCOL_NEHAHRABJP2 && sv.protocol != PROTOCOL_NEHAHRABJP3)
                        if (punchvector[i])
                                bits |= (SU_PUNCHVEC1<<i);
-               if (ent->fields.server->velocity[i])
+               if (PRVM_serveredictvector(ent, velocity)[i])
                        bits |= (SU_VELOCITY1<<i);
        }
 
        gravity = PRVM_serveredictfloat(ent, gravity);if (!gravity) gravity = 1.0f;
 
        memset(stats, 0, sizeof(int[MAX_CL_STATS]));
-       stats[STAT_VIEWHEIGHT] = (int)ent->fields.server->view_ofs[2];
+       stats[STAT_VIEWHEIGHT] = (int)PRVM_serveredictvector(ent, view_ofs)[2];
        stats[STAT_ITEMS] = items;
-       stats[STAT_WEAPONFRAME] = (int)ent->fields.server->weaponframe;
-       stats[STAT_ARMOR] = (int)ent->fields.server->armorvalue;
+       stats[STAT_WEAPONFRAME] = (int)PRVM_serveredictfloat(ent, weaponframe);
+       stats[STAT_ARMOR] = (int)PRVM_serveredictfloat(ent, armorvalue);
        stats[STAT_WEAPON] = client->weaponmodelindex;
-       stats[STAT_HEALTH] = (int)ent->fields.server->health;
-       stats[STAT_AMMO] = (int)ent->fields.server->currentammo;
-       stats[STAT_SHELLS] = (int)ent->fields.server->ammo_shells;
-       stats[STAT_NAILS] = (int)ent->fields.server->ammo_nails;
-       stats[STAT_ROCKETS] = (int)ent->fields.server->ammo_rockets;
-       stats[STAT_CELLS] = (int)ent->fields.server->ammo_cells;
-       stats[STAT_ACTIVEWEAPON] = (int)ent->fields.server->weapon;
+       stats[STAT_HEALTH] = (int)PRVM_serveredictfloat(ent, health);
+       stats[STAT_AMMO] = (int)PRVM_serveredictfloat(ent, currentammo);
+       stats[STAT_SHELLS] = (int)PRVM_serveredictfloat(ent, ammo_shells);
+       stats[STAT_NAILS] = (int)PRVM_serveredictfloat(ent, ammo_nails);
+       stats[STAT_ROCKETS] = (int)PRVM_serveredictfloat(ent, ammo_rockets);
+       stats[STAT_CELLS] = (int)PRVM_serveredictfloat(ent, ammo_cells);
+       stats[STAT_ACTIVEWEAPON] = (int)PRVM_serveredictfloat(ent, weapon);
        stats[STAT_VIEWZOOM] = viewzoom;
-       stats[STAT_TOTALSECRETS] = (int)prog->globals.server->total_secrets;
-       stats[STAT_TOTALMONSTERS] = (int)prog->globals.server->total_monsters;
+       stats[STAT_TOTALSECRETS] = (int)PRVM_serverglobalfloat(total_secrets);
+       stats[STAT_TOTALMONSTERS] = (int)PRVM_serverglobalfloat(total_monsters);
        // the QC bumps these itself by sending svc_'s, so we have to keep them
        // zero or they'll be corrected by the engine
-       //stats[STAT_SECRETS] = prog->globals.server->found_secrets;
-       //stats[STAT_MONSTERS] = prog->globals.server->killed_monsters;
+       //stats[STAT_SECRETS] = PRVM_serverglobalfloat(found_secrets);
+       //stats[STAT_MONSTERS] = PRVM_serverglobalfloat(killed_monsters);
 
        // movement settings for prediction
        // note: these are not sent in protocols with lower MAX_CL_STATS limits
@@ -2086,16 +2086,16 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
                MSG_WriteChar (msg, stats[STAT_VIEWHEIGHT]);
 
        if (bits & SU_IDEALPITCH)
-               MSG_WriteChar (msg, (int)ent->fields.server->idealpitch);
+               MSG_WriteChar (msg, (int)PRVM_serveredictfloat(ent, idealpitch));
 
        for (i=0 ; i<3 ; i++)
        {
                if (bits & (SU_PUNCH1<<i))
                {
                        if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
-                               MSG_WriteChar(msg, (int)ent->fields.server->punchangle[i]);
+                               MSG_WriteChar(msg, (int)PRVM_serveredictvector(ent, punchangle)[i]);
                        else
-                               MSG_WriteAngle16i(msg, ent->fields.server->punchangle[i]);
+                               MSG_WriteAngle16i(msg, PRVM_serveredictvector(ent, punchangle)[i]);
                }
                if (bits & (SU_PUNCHVEC1<<i))
                {
@@ -2107,9 +2107,9 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
                if (bits & (SU_VELOCITY1<<i))
                {
                        if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3 || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4)
-                               MSG_WriteChar(msg, (int)(ent->fields.server->velocity[i] * (1.0f / 16.0f)));
+                               MSG_WriteChar(msg, (int)(PRVM_serveredictvector(ent, velocity)[i] * (1.0f / 16.0f)));
                        else
-                               MSG_WriteCoord32f(msg, ent->fields.server->velocity[i]);
+                               MSG_WriteCoord32f(msg, PRVM_serveredictvector(ent, velocity)[i]);
                }
        }
 
@@ -2394,12 +2394,12 @@ static void SV_UpdateToReliableMessages (void)
                host_client->edict = PRVM_EDICT_NUM(i+1);
 
                // DP_SV_CLIENTNAME
-               name = PRVM_GetString(host_client->edict->fields.server->netname);
+               name = PRVM_GetString(PRVM_serveredictstring(host_client->edict, netname));
                if (name == NULL)
                        name = "";
                // always point the string back at host_client->name to keep it safe
                strlcpy (host_client->name, name, sizeof (host_client->name));
-               host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
+               PRVM_serveredictstring(host_client->edict, netname) = PRVM_SetEngineString(host_client->name);
                if (strcmp(host_client->old_name, host_client->name))
                {
                        if (host_client->spawned)
@@ -2456,7 +2456,7 @@ static void SV_UpdateToReliableMessages (void)
                }
 
                // frags
-               host_client->frags = (int)host_client->edict->fields.server->frags;
+               host_client->frags = (int)PRVM_serveredictfloat(host_client->edict, frags);
                if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC)
                        if(!host_client->spawned && host_client->netconnection)
                                host_client->frags = -666;
@@ -2965,7 +2965,7 @@ dp_model_t *SV_GetModelFromEdict(prvm_edict_t *ed)
        int modelindex;
        if (!ed || ed->priv.server->free)
                return NULL;
-       modelindex = (int)ed->fields.server->modelindex;
+       modelindex = (int)PRVM_serveredictfloat(ed, modelindex);
        return (modelindex > 0 && modelindex < MAX_MODELS) ? sv.models[modelindex] : NULL;
 }
 
@@ -2991,14 +2991,14 @@ static void SV_CreateBaseline (void)
 
                if (svent->priv.server->free)
                        continue;
-               if (entnum > svs.maxclients && !svent->fields.server->modelindex)
+               if (entnum > svs.maxclients && !PRVM_serveredictfloat(svent, modelindex))
                        continue;
 
                // create entity baseline
-               VectorCopy (svent->fields.server->origin, svent->priv.server->baseline.origin);
-               VectorCopy (svent->fields.server->angles, svent->priv.server->baseline.angles);
-               svent->priv.server->baseline.frame = (int)svent->fields.server->frame;
-               svent->priv.server->baseline.skin = (int)svent->fields.server->skin;
+               VectorCopy (PRVM_serveredictvector(svent, origin), svent->priv.server->baseline.origin);
+               VectorCopy (PRVM_serveredictvector(svent, angles), svent->priv.server->baseline.angles);
+               svent->priv.server->baseline.frame = (int)PRVM_serveredictfloat(svent, frame);
+               svent->priv.server->baseline.skin = (int)PRVM_serveredictfloat(svent, skin);
                if (entnum > 0 && entnum <= svs.maxclients)
                {
                        svent->priv.server->baseline.colormap = entnum;
@@ -3007,7 +3007,7 @@ static void SV_CreateBaseline (void)
                else
                {
                        svent->priv.server->baseline.colormap = 0;
-                       svent->priv.server->baseline.modelindex = (int)svent->fields.server->modelindex;
+                       svent->priv.server->baseline.modelindex = (int)PRVM_serveredictfloat(svent, modelindex);
                }
 
                large = false;
@@ -3111,7 +3111,7 @@ void SV_SaveSpawnparms (void)
 {
        int             i, j;
 
-       svs.serverflags = (int)prog->globals.server->serverflags;
+       svs.serverflags = (int)PRVM_serverglobalfloat(serverflags);
 
        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
        {
@@ -3119,10 +3119,10 @@ void SV_SaveSpawnparms (void)
                        continue;
 
        // call the progs to get default spawn parms for the new client
-               prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
-               PRVM_ExecuteProgram (prog->globals.server->SetChangeParms, "QC function SetChangeParms is missing");
+               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
+               PRVM_ExecuteProgram (PRVM_serverfunction(SetChangeParms), "QC function SetChangeParms is missing");
                for (j=0 ; j<NUM_SPAWN_PARMS ; j++)
-                       host_client->spawn_parms[j] = (&prog->globals.server->parm1)[j];
+                       host_client->spawn_parms[j] = (&PRVM_serverglobalfloat(parm1))[j];
        }
 }
 
@@ -3292,7 +3292,7 @@ void SV_SpawnServer (const char *server)
        prog->allowworldwrites = true;
        sv.paused = false;
 
-       prog->globals.server->time = sv.time = 1.0;
+       PRVM_serverglobalfloat(time) = sv.time = 1.0;
 
        Mod_ClearUsed();
        worldmodel->used = true;
@@ -3323,26 +3323,26 @@ void SV_SpawnServer (const char *server)
 //
        // AK possible hack since num_edicts is still 0
        ent = PRVM_EDICT_NUM(0);
-       memset (ent->fields.server, 0, prog->entityfields * 4);
+       memset (ent->fields.vp, 0, prog->entityfields * 4);
        ent->priv.server->free = false;
-       ent->fields.server->model = PRVM_SetEngineString(sv.worldname);
-       ent->fields.server->modelindex = 1;             // world model
-       ent->fields.server->solid = SOLID_BSP;
-       ent->fields.server->movetype = MOVETYPE_PUSH;
-       VectorCopy(sv.world.mins, ent->fields.server->mins);
-       VectorCopy(sv.world.maxs, ent->fields.server->maxs);
-       VectorCopy(sv.world.mins, ent->fields.server->absmin);
-       VectorCopy(sv.world.maxs, ent->fields.server->absmax);
+       PRVM_serveredictstring(ent, model) = PRVM_SetEngineString(sv.worldname);
+       PRVM_serveredictfloat(ent, modelindex) = 1;             // world model
+       PRVM_serveredictfloat(ent, solid) = SOLID_BSP;
+       PRVM_serveredictfloat(ent, movetype) = MOVETYPE_PUSH;
+       VectorCopy(sv.world.mins, PRVM_serveredictvector(ent, mins));
+       VectorCopy(sv.world.maxs, PRVM_serveredictvector(ent, maxs));
+       VectorCopy(sv.world.mins, PRVM_serveredictvector(ent, absmin));
+       VectorCopy(sv.world.maxs, PRVM_serveredictvector(ent, absmax));
 
        if (coop.value)
-               prog->globals.server->coop = coop.integer;
+               PRVM_serverglobalfloat(coop) = coop.integer;
        else
-               prog->globals.server->deathmatch = deathmatch.integer;
+               PRVM_serverglobalfloat(deathmatch) = deathmatch.integer;
 
-       prog->globals.server->mapname = PRVM_SetEngineString(sv.name);
+       PRVM_serverglobalstring(mapname) = PRVM_SetEngineString(sv.name);
 
 // serverflags are for cross level information (sigils)
-       prog->globals.server->serverflags = svs.serverflags;
+       PRVM_serverglobalfloat(serverflags) = svs.serverflags;
 
        // we need to reset the spawned flag on all connected clients here so that
        // their thinks don't run during startup (before PutClientInServer)
@@ -3367,14 +3367,14 @@ void SV_SpawnServer (const char *server)
 
 
        // LordHavoc: clear world angles (to fix e3m3.bsp)
-       VectorClear(prog->edicts->fields.server->angles);
+       VectorClear(PRVM_serveredictvector(prog->edicts, angles));
 
 // all setup is completed, any further precache statements are errors
 //     sv.state = ss_active; // LordHavoc: workaround for svc_precache bug
        prog->allowworldwrites = false;
 
 // run two frames to allow everything to settle
-       prog->globals.server->time = sv.time = 1.0001;
+       PRVM_serverglobalfloat(time) = sv.time = 1.0001;
        for (i = 0;i < 2;i++)
        {
                sv.frametime = 0.1;
@@ -3409,20 +3409,20 @@ void SV_SpawnServer (const char *server)
 
                        // copy spawn parms out of the client_t
                        for (j=0 ; j< NUM_SPAWN_PARMS ; j++)
-                               (&prog->globals.server->parm1)[j] = host_client->spawn_parms[j];
+                               (&PRVM_serverglobalfloat(parm1))[j] = host_client->spawn_parms[j];
 
                        // call the spawn function
                        host_client->clientconnectcalled = true;
-                       prog->globals.server->time = sv.time;
-                       prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
-                       PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
-                       PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
+                       PRVM_serverglobalfloat(time) = sv.time;
+                       PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
+                       PRVM_ExecuteProgram (PRVM_serverfunction(ClientConnect), "QC function ClientConnect is missing");
+                       PRVM_ExecuteProgram (PRVM_serverfunction(PutClientInServer), "QC function PutClientInServer is missing");
                        host_client->spawned = true;
                }
        }
 
        // update the map title cvar
-       strlcpy(sv.worldmessage, PRVM_GetString(prog->edicts->fields.server->message), sizeof(sv.worldmessage)); // map title (not related to filename)
+       strlcpy(sv.worldmessage, PRVM_GetString(PRVM_serveredictstring(prog->edicts, message)), sizeof(sv.worldmessage)); // map title (not related to filename)
        Cvar_SetQuick(&sv_worldmessage, sv.worldmessage);
 
        Con_DPrint("Server spawned.\n");
@@ -3461,12 +3461,12 @@ static void SV_VM_CB_InitEdict(prvm_edict_t *e)
        if (num >= 0 && num < svs.maxclients)
        {
                // set colormap and team on newly created player entity
-               e->fields.server->colormap = num + 1;
-               e->fields.server->team = (svs.clients[num].colors & 15) + 1;
+               PRVM_serveredictfloat(e, colormap) = num + 1;
+               PRVM_serveredictfloat(e, team) = (svs.clients[num].colors & 15) + 1;
                // set netname/clientcolors back to client values so that
                // DP_SV_CLIENTNAME and DP_SV_CLIENTCOLORS will not immediately
                // reset them
-               e->fields.server->netname = PRVM_SetEngineString(svs.clients[num].name);
+               PRVM_serveredictstring(e, netname) = PRVM_SetEngineString(svs.clients[num].name);
                PRVM_serveredictfloat(e, clientcolors) = svs.clients[num].colors;
                // NEXUIZ_PLAYERMODEL and NEXUIZ_PLAYERSKIN
                PRVM_serveredictstring(e, playermodel) = PRVM_SetEngineString(svs.clients[num].playermodel);
@@ -3510,16 +3510,16 @@ static void SV_VM_CB_FreeEdict(prvm_edict_t *ed)
 
        World_UnlinkEdict(ed);          // unlink from world bsp
 
-       ed->fields.server->model = 0;
-       ed->fields.server->takedamage = 0;
-       ed->fields.server->modelindex = 0;
-       ed->fields.server->colormap = 0;
-       ed->fields.server->skin = 0;
-       ed->fields.server->frame = 0;
-       VectorClear(ed->fields.server->origin);
-       VectorClear(ed->fields.server->angles);
-       ed->fields.server->nextthink = -1;
-       ed->fields.server->solid = 0;
+       PRVM_serveredictstring(ed, model) = 0;
+       PRVM_serveredictfloat(ed, takedamage) = 0;
+       PRVM_serveredictfloat(ed, modelindex) = 0;
+       PRVM_serveredictfloat(ed, colormap) = 0;
+       PRVM_serveredictfloat(ed, skin) = 0;
+       PRVM_serveredictfloat(ed, frame) = 0;
+       VectorClear(PRVM_serveredictvector(ed, origin));
+       VectorClear(PRVM_serveredictvector(ed, angles));
+       PRVM_serveredictfloat(ed, nextthink) = -1;
+       PRVM_serveredictfloat(ed, solid) = 0;
 
        VM_RemoveEdictSkeleton(ed);
        World_Physics_RemoveFromEntity(&sv.world, ed);
@@ -3549,11 +3549,11 @@ static void SV_VM_CB_CountEdicts(void)
                if (ent->priv.server->free)
                        continue;
                active++;
-               if (ent->fields.server->solid)
+               if (PRVM_serveredictfloat(ent, solid))
                        solid++;
-               if (ent->fields.server->model)
+               if (PRVM_serveredictstring(ent, model))
                        models++;
-               if (ent->fields.server->movetype == MOVETYPE_STEP)
+               if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_STEP)
                        step++;
        }
 
@@ -3571,14 +3571,14 @@ static qboolean SV_VM_CB_LoadEdict(prvm_edict_t *ent)
        {
                if (deathmatch.integer)
                {
-                       if (((int)ent->fields.server->spawnflags & SPAWNFLAG_NOT_DEATHMATCH))
+                       if (((int)PRVM_serveredictfloat(ent, spawnflags) & SPAWNFLAG_NOT_DEATHMATCH))
                        {
                                return false;
                        }
                }
-               else if ((current_skill <= 0 && ((int)ent->fields.server->spawnflags & SPAWNFLAG_NOT_EASY  ))
-                       || (current_skill == 1 && ((int)ent->fields.server->spawnflags & SPAWNFLAG_NOT_MEDIUM))
-                       || (current_skill >= 2 && ((int)ent->fields.server->spawnflags & SPAWNFLAG_NOT_HARD  )))
+               else if ((current_skill <= 0 && ((int)PRVM_serveredictfloat(ent, spawnflags) & SPAWNFLAG_NOT_EASY  ))
+                       || (current_skill == 1 && ((int)PRVM_serveredictfloat(ent, spawnflags) & SPAWNFLAG_NOT_MEDIUM))
+                       || (current_skill >= 2 && ((int)PRVM_serveredictfloat(ent, spawnflags) & SPAWNFLAG_NOT_HARD  )))
                {
                        return false;
                }
@@ -3596,8 +3596,6 @@ static void SV_VM_Setup(void)
        prog->progs_mempool = Mem_AllocPool("Server Progs", 0, NULL);
        prog->builtins = vm_sv_builtins;
        prog->numbuiltins = vm_sv_numbuiltins;
-       prog->headercrc = PROGHEADER_CRC;
-       prog->headercrc2 = PROGHEADER_CRC_TENEBRAE;
        prog->max_edicts = 512;
        if (sv.protocol == PROTOCOL_QUAKE)
                prog->limit_edicts = 640; // before quake mission pack 1 this was 512
@@ -3631,30 +3629,145 @@ static void SV_VM_Setup(void)
        // some mods compiled with scrambling compilers lack certain critical
        // global names and field names such as "self" and "time" and "nextthink"
        // so we have to set these offsets manually, matching the entvars_t
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, angles);
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, chain);
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, classname);
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, frame);
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, groundentity);
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, ideal_yaw);
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, nextthink);
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, think);
-       PRVM_ED_FindFieldOffset_FromStruct(entvars_t, yaw_speed);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, self);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, time);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, v_forward);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, v_right);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, v_up);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_allsolid);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_startsolid);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_fraction);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_inwater);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_inopen);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_endpos);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_plane_normal);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_plane_dist);
-       PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_ent);
-       // OP_STATE is always supported on server (due to entvars_t)
+       // but we only do this if the prog header crc matches, otherwise it's totally freeform
+       if (prog->progs_crc == PROGHEADER_CRC || prog->progs_crc == PROGHEADER_CRC_TENEBRAE)
+       {
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, modelindex);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, absmin);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, absmax);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, ltime);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, movetype);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, solid);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, origin);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, oldorigin);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, velocity);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, angles);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, avelocity);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, punchangle);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, classname);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, model);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, frame);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, skin);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, effects);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, mins);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, maxs);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, size);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, touch);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, use);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, think);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, blocked);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, nextthink);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, groundentity);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, health);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, frags);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, weapon);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, weaponmodel);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, weaponframe);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, currentammo);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, ammo_shells);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, ammo_nails);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, ammo_rockets);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, ammo_cells);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, items);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, takedamage);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, chain);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, deadflag);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, view_ofs);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, button0);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, button1);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, button2);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, impulse);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, fixangle);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, v_angle);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, idealpitch);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, netname);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, enemy);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, flags);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, colormap);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, team);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, max_health);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, teleport_time);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, armortype);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, armorvalue);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, waterlevel);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, watertype);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, ideal_yaw);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, yaw_speed);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, aiment);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, goalentity);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, spawnflags);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, target);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, targetname);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, dmg_take);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, dmg_save);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, dmg_inflictor);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, owner);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, movedir);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, message);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, sounds);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, noise);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, noise1);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, noise2);
+               PRVM_ED_FindFieldOffset_FromStruct(entvars_t, noise3);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, self);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, other);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, world);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, time);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, frametime);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, force_retouch);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, mapname);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, deathmatch);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, coop);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, teamplay);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, serverflags);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, total_secrets);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, total_monsters);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, found_secrets);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, killed_monsters);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm1);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm2);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm3);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm4);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm5);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm6);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm7);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm8);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm9);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm10);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm11);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm12);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm13);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm14);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm15);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, parm16);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, v_forward);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, v_up);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, v_right);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_allsolid);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_startsolid);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_fraction);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_endpos);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_plane_normal);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_plane_dist);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_ent);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_inopen);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, trace_inwater);
+               PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, msg_entity);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, main);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, StartFrame);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, PlayerPreThink);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, PlayerPostThink);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, ClientKill);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, ClientConnect);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, PutClientInServer);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, ClientDisconnect);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, SetNewParms);
+//             PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, SetChangeParms);
+       }
+       else
+               Con_DPrintf("%s: %s system vars have been modified (CRC %i != engine %i), will not load in other engines", PRVM_NAME, sv_progs.string, prog->progs_crc, PROGHEADER_CRC);
+
+       // OP_STATE is always supported on server because we add fields/globals for it
        prog->flag |= PRVM_OP_STATE;
 
        VM_CustomStats_Clear();//[515]: csqc
@@ -3669,7 +3782,7 @@ void SV_VM_Begin(void)
        PRVM_Begin;
        PRVM_SetProg( PRVM_SERVERPROG );
 
-       prog->globals.server->time = (float) sv.time;
+       PRVM_serverglobalfloat(time) = (float) sv.time;
 }
 
 void SV_VM_End(void)
index f8a1cfb..d93d1f8 100644 (file)
--- a/sv_move.c
+++ b/sv_move.c
@@ -40,8 +40,8 @@ qboolean SV_CheckBottom (prvm_edict_t *ent)
        int             x, y;
        float   mid, bottom;
 
-       VectorAdd (ent->fields.server->origin, ent->fields.server->mins, mins);
-       VectorAdd (ent->fields.server->origin, ent->fields.server->maxs, maxs);
+       VectorAdd (PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), mins);
+       VectorAdd (PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, maxs), maxs);
 
 // if all of the points under the corners are solid world, don't bother
 // with the tougher checks
@@ -114,39 +114,39 @@ qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        prvm_edict_t            *enemy;
 
 // try the move
-       VectorCopy (ent->fields.server->origin, oldorg);
-       VectorAdd (ent->fields.server->origin, move, neworg);
+       VectorCopy (PRVM_serveredictvector(ent, origin), oldorg);
+       VectorAdd (PRVM_serveredictvector(ent, origin), move, neworg);
 
 // flying monsters don't step up
-       if ( (int)ent->fields.server->flags & (FL_SWIM | FL_FLY) )
+       if ( (int)PRVM_serveredictfloat(ent, flags) & (FL_SWIM | FL_FLY) )
        {
        // try one move with vertical motion, then one without
                for (i=0 ; i<2 ; i++)
                {
-                       VectorAdd (ent->fields.server->origin, move, neworg);
+                       VectorAdd (PRVM_serveredictvector(ent, origin), move, neworg);
                        if (noenemy)
                                enemy = prog->edicts;
                        else
                        {
-                               enemy = PRVM_PROG_TO_EDICT(ent->fields.server->enemy);
+                               enemy = PRVM_PROG_TO_EDICT(PRVM_serveredictedict(ent, enemy));
                                if (i == 0 && enemy != prog->edicts)
                                {
-                                       dz = ent->fields.server->origin[2] - PRVM_PROG_TO_EDICT(ent->fields.server->enemy)->fields.server->origin[2];
+                                       dz = PRVM_serveredictvector(ent, origin)[2] - PRVM_serveredictvector(enemy, origin)[2];
                                        if (dz > 40)
                                                neworg[2] -= 8;
                                        if (dz < 30)
                                                neworg[2] += 8;
                                }
                        }
-                       trace = SV_TraceBox(ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, neworg, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+                       trace = SV_TraceBox(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), neworg, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
 
                        if (trace.fraction == 1)
                        {
                                VectorCopy(trace.endpos, traceendpos);
-                               if (((int)ent->fields.server->flags & FL_SWIM) && !(SV_PointSuperContents(traceendpos) & SUPERCONTENTS_LIQUIDSMASK))
+                               if (((int)PRVM_serveredictfloat(ent, flags) & FL_SWIM) && !(SV_PointSuperContents(traceendpos) & SUPERCONTENTS_LIQUIDSMASK))
                                        return false;   // swim monster left water
 
-                               VectorCopy (traceendpos, ent->fields.server->origin);
+                               VectorCopy (traceendpos, PRVM_serveredictvector(ent, origin));
                                if (relink)
                                {
                                        SV_LinkEdict(ent);
@@ -167,27 +167,27 @@ qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        VectorCopy (neworg, end);
        end[2] -= sv_stepheight.value*2;
 
-       trace = SV_TraceBox(neworg, ent->fields.server->mins, ent->fields.server->maxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+       trace = SV_TraceBox(neworg, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
 
        if (trace.startsolid)
        {
                neworg[2] -= sv_stepheight.value;
-               trace = SV_TraceBox(neworg, ent->fields.server->mins, ent->fields.server->maxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+               trace = SV_TraceBox(neworg, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
                if (trace.startsolid)
                        return false;
        }
        if (trace.fraction == 1)
        {
        // if monster had the ground pulled out, go ahead and fall
-               if ( (int)ent->fields.server->flags & FL_PARTIALGROUND )
+               if ( (int)PRVM_serveredictfloat(ent, flags) & FL_PARTIALGROUND )
                {
-                       VectorAdd (ent->fields.server->origin, move, ent->fields.server->origin);
+                       VectorAdd (PRVM_serveredictvector(ent, origin), move, PRVM_serveredictvector(ent, origin));
                        if (relink)
                        {
                                SV_LinkEdict(ent);
                                SV_LinkEdict_TouchAreaGrid(ent);
                        }
-                       ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND;
+                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
                        return true;
                }
 
@@ -195,11 +195,11 @@ qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
        }
 
 // check point traces down for dangling corners
-       VectorCopy (trace.endpos, ent->fields.server->origin);
+       VectorCopy (trace.endpos, PRVM_serveredictvector(ent, origin));
 
        if (!SV_CheckBottom (ent))
        {
-               if ( (int)ent->fields.server->flags & FL_PARTIALGROUND )
+               if ( (int)PRVM_serveredictfloat(ent, flags) & FL_PARTIALGROUND )
                {       // entity had floor mostly pulled out from underneath it
                        // and is trying to correct
                        if (relink)
@@ -209,24 +209,24 @@ qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean
                        }
                        return true;
                }
-               VectorCopy (oldorg, ent->fields.server->origin);
+               VectorCopy (oldorg, PRVM_serveredictvector(ent, origin));
                return false;
        }
 
-       if ( (int)ent->fields.server->flags & FL_PARTIALGROUND )
-               ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_PARTIALGROUND;
+       if ( (int)PRVM_serveredictfloat(ent, flags) & FL_PARTIALGROUND )
+               PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_PARTIALGROUND;
 
 // gameplayfix: check if reached pretty steep plane and bail
-       if ( ! ( (int)ent->fields.server->flags & (FL_SWIM | FL_FLY) ) && sv_gameplayfix_nostepmoveonsteepslopes.integer )
+       if ( ! ( (int)PRVM_serveredictfloat(ent, flags) & (FL_SWIM | FL_FLY) ) && sv_gameplayfix_nostepmoveonsteepslopes.integer )
        {
                if (trace.plane.normal[ 2 ] < 0.5)
                {
-                       VectorCopy (oldorg, ent->fields.server->origin);
+                       VectorCopy (oldorg, PRVM_serveredictvector(ent, origin));
                        return false;
                }
        }
 
-       ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
+       PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
 
 // the move is ok
        if (relink)
@@ -255,7 +255,7 @@ qboolean SV_StepDirection (prvm_edict_t *ent, float yaw, float dist)
        vec3_t          move, oldorigin;
        float           delta;
 
-       ent->fields.server->ideal_yaw = yaw;
+       PRVM_serveredictfloat(ent, ideal_yaw) = yaw;
        VM_changeyaw();
 
        yaw = yaw*M_PI*2 / 360;
@@ -263,13 +263,13 @@ qboolean SV_StepDirection (prvm_edict_t *ent, float yaw, float dist)
        move[1] = sin(yaw)*dist;
        move[2] = 0;
 
-       VectorCopy (ent->fields.server->origin, oldorigin);
+       VectorCopy (PRVM_serveredictvector(ent, origin), oldorigin);
        if (SV_movestep (ent, move, false, false, false))
        {
-               delta = ent->fields.server->angles[YAW] - ent->fields.server->ideal_yaw;
+               delta = PRVM_serveredictvector(ent, angles)[YAW] - PRVM_serveredictfloat(ent, ideal_yaw);
                if (delta > 45 && delta < 315)
                {               // not turned far enough, so don't take the step
-                       VectorCopy (oldorigin, ent->fields.server->origin);
+                       VectorCopy (oldorigin, PRVM_serveredictvector(ent, origin));
                }
                SV_LinkEdict(ent);
                SV_LinkEdict_TouchAreaGrid(ent);
@@ -289,7 +289,7 @@ SV_FixCheckBottom
 */
 void SV_FixCheckBottom (prvm_edict_t *ent)
 {
-       ent->fields.server->flags = (int)ent->fields.server->flags | FL_PARTIALGROUND;
+       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) | FL_PARTIALGROUND;
 }
 
 
@@ -307,11 +307,11 @@ void SV_NewChaseDir (prvm_edict_t *actor, prvm_edict_t *enemy, float dist)
        float                   d[3];
        float           tdir, olddir, turnaround;
 
-       olddir = ANGLEMOD((int)(actor->fields.server->ideal_yaw/45)*45);
+       olddir = ANGLEMOD((int)(PRVM_serveredictfloat(actor, ideal_yaw)/45)*45);
        turnaround = ANGLEMOD(olddir - 180);
 
-       deltax = enemy->fields.server->origin[0] - actor->fields.server->origin[0];
-       deltay = enemy->fields.server->origin[1] - actor->fields.server->origin[1];
+       deltax = PRVM_serveredictvector(enemy, origin)[0] - PRVM_serveredictvector(actor, origin)[0];
+       deltay = PRVM_serveredictvector(enemy, origin)[1] - PRVM_serveredictvector(actor, origin)[1];
        if (deltax>10)
                d[1]= 0;
        else if (deltax<-10)
@@ -374,7 +374,7 @@ void SV_NewChaseDir (prvm_edict_t *actor, prvm_edict_t *enemy, float dist)
        if (turnaround != DI_NODIR && SV_StepDirection(actor, turnaround, dist) )
                        return;
 
-       actor->fields.server->ideal_yaw = olddir;               // can't move
+       PRVM_serveredictfloat(actor, ideal_yaw) = olddir;               // can't move
 
 // if a bridge was pulled out from underneath a monster, it may not have
 // a valid standing position at all
@@ -417,23 +417,23 @@ void SV_MoveToGoal (void)
 
        VM_SAFEPARMCOUNT(1, SV_MoveToGoal);
 
-       ent = PRVM_PROG_TO_EDICT(prog->globals.server->self);
-       goal = PRVM_PROG_TO_EDICT(ent->fields.server->goalentity);
+       ent = PRVM_PROG_TO_EDICT(PRVM_serverglobaledict(self));
+       goal = PRVM_PROG_TO_EDICT(PRVM_serveredictedict(ent, goalentity));
        dist = PRVM_G_FLOAT(OFS_PARM0);
 
-       if ( !( (int)ent->fields.server->flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) )
+       if ( !( (int)PRVM_serveredictfloat(ent, flags) & (FL_ONGROUND|FL_FLY|FL_SWIM) ) )
        {
                PRVM_G_FLOAT(OFS_RETURN) = 0;
                return;
        }
 
 // if the next step hits the enemy, return immediately
-       if ( PRVM_PROG_TO_EDICT(ent->fields.server->enemy) != prog->edicts &&  SV_CloseEnough (ent, goal, dist) )
+       if ( PRVM_PROG_TO_EDICT(PRVM_serveredictedict(ent, enemy)) != prog->edicts &&  SV_CloseEnough (ent, goal, dist) )
                return;
 
 // bump around...
        if ( (rand()&3)==1 ||
-       !SV_StepDirection (ent, ent->fields.server->ideal_yaw, dist))
+       !SV_StepDirection (ent, PRVM_serveredictfloat(ent, ideal_yaw), dist))
        {
                SV_NewChaseDir (ent, goal, dist);
        }
index 61a5dc4..9c8b532 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -54,7 +54,7 @@ int SV_GetPitchSign(prvm_edict_t *ent)
                        (
                         (((unsigned char)PRVM_serveredictfloat(ent, pflags)) & PFLAGS_FULLDYNAMIC)
                         ||
-                        ((gamemode == GAME_TENEBRAE) && ((unsigned int)ent->fields.server->effects & (16 | 32)))
+                        ((gamemode == GAME_TENEBRAE) && ((unsigned int)PRVM_serveredictfloat(ent, effects) & (16 | 32)))
                        )
           )
                return -1;
@@ -76,16 +76,16 @@ int SV_GenericHitSuperContentsMask(const prvm_edict_t *passedict)
                int dphitcontentsmask = (int)PRVM_serveredictfloat(passedict, dphitcontentsmask);
                if (dphitcontentsmask)
                        return dphitcontentsmask;
-               else if (passedict->fields.server->solid == SOLID_SLIDEBOX)
+               else if (PRVM_serveredictfloat(passedict, solid) == SOLID_SLIDEBOX)
                {
-                       if ((int)passedict->fields.server->flags & FL_MONSTER)
+                       if ((int)PRVM_serveredictfloat(passedict, flags) & FL_MONSTER)
                                return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_MONSTERCLIP;
                        else
                                return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP;
                }
-               else if (passedict->fields.server->solid == SOLID_CORPSE)
+               else if (PRVM_serveredictfloat(passedict, solid) == SOLID_CORPSE)
                        return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY;
-               else if (passedict->fields.server->solid == SOLID_TRIGGER)
+               else if (PRVM_serveredictfloat(passedict, solid) == SOLID_TRIGGER)
                        return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY;
                else
                        return SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_CORPSE;
@@ -169,7 +169,7 @@ trace_t SV_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
        // precalculate prog value for passedict for comparisons
        passedictprog = PRVM_EDICT_TO_PROG(passedict);
        // precalculate passedict's owner edict pointer for comparisons
-       traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.server->owner) : 0;
+       traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_serveredictedict(passedict, owner)) : 0;
 
        // clip to entities
        // because this uses World_EntitiestoBox, we know all entity boxes overlap
@@ -185,9 +185,9 @@ trace_t SV_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
        {
                touch = touchedicts[i];
 
-               if (touch->fields.server->solid < SOLID_BBOX)
+               if (PRVM_serveredictfloat(touch, solid) < SOLID_BBOX)
                        continue;
-               if (type == MOVE_NOMONSTERS && touch->fields.server->solid != SOLID_BSP)
+               if (type == MOVE_NOMONSTERS && PRVM_serveredictfloat(touch, solid) != SOLID_BSP)
                        continue;
 
                if (passedict)
@@ -199,36 +199,36 @@ trace_t SV_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
                        if (traceowner == touch)
                                continue;
                        // don't clip owner against owned entities
-                       if (passedictprog == touch->fields.server->owner)
+                       if (passedictprog == PRVM_serveredictedict(touch, owner))
                                continue;
                        // don't clip points against points (they can't collide)
-                       if (VectorCompare(touch->fields.server->mins, touch->fields.server->maxs) && (type != MOVE_MISSILE || !((int)touch->fields.server->flags & FL_MONSTER)))
+                       if (VectorCompare(PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)))
                                continue;
                }
 
-               bodysupercontents = touch->fields.server->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
+               bodysupercontents = PRVM_serveredictfloat(touch, solid) == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
 
                // might interact, so do an exact clip
                model = NULL;
-               if ((int) touch->fields.server->solid == SOLID_BSP || type == MOVE_HITMODEL)
+               if ((int) PRVM_serveredictfloat(touch, solid) == SOLID_BSP || type == MOVE_HITMODEL)
                {
                        model = SV_GetModelFromEdict(touch);
                        pitchsign = SV_GetPitchSign(touch);
                }
                if (model)
-                       Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2], pitchsign * touch->fields.server->angles[0], touch->fields.server->angles[1], touch->fields.server->angles[2], 1);
+                       Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2], pitchsign * PRVM_serveredictvector(touch, angles)[0], PRVM_serveredictvector(touch, angles)[1], PRVM_serveredictvector(touch, angles)[2], 1);
                else
-                       Matrix4x4_CreateTranslate(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2]);
+                       Matrix4x4_CreateTranslate(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2]);
                Matrix4x4_Invert_Simple(&imatrix, &matrix);
                VM_GenerateFrameGroupBlend(touch->priv.server->framegroupblend, touch);
                VM_FrameBlendFromFrameGroupBlend(touch->priv.server->frameblend, touch->priv.server->framegroupblend, model);
                VM_UpdateEdictSkeleton(touch, model, touch->priv.server->frameblend);
-               if (type == MOVE_MISSILE && (int)touch->fields.server->flags & FL_MONSTER)
-                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask);
+               if (type == MOVE_MISSILE && (int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)
+                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask);
                else
-                       Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
+                       Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
 
-               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.server->solid == SOLID_BSP);
+               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_serveredictfloat(touch, solid) == SOLID_BSP);
        }
 
 finished:
@@ -335,7 +335,7 @@ trace_t SV_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        // precalculate prog value for passedict for comparisons
        passedictprog = PRVM_EDICT_TO_PROG(passedict);
        // precalculate passedict's owner edict pointer for comparisons
-       traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.server->owner) : 0;
+       traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_serveredictedict(passedict, owner)) : 0;
 
        // clip to entities
        // because this uses World_EntitiestoBox, we know all entity boxes overlap
@@ -351,9 +351,9 @@ trace_t SV_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        {
                touch = touchedicts[i];
 
-               if (touch->fields.server->solid < SOLID_BBOX)
+               if (PRVM_serveredictfloat(touch, solid) < SOLID_BBOX)
                        continue;
-               if (type == MOVE_NOMONSTERS && touch->fields.server->solid != SOLID_BSP)
+               if (type == MOVE_NOMONSTERS && PRVM_serveredictfloat(touch, solid) != SOLID_BSP)
                        continue;
 
                if (passedict)
@@ -365,36 +365,36 @@ trace_t SV_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
                        if (traceowner == touch)
                                continue;
                        // don't clip owner against owned entities
-                       if (passedictprog == touch->fields.server->owner)
+                       if (passedictprog == PRVM_serveredictedict(touch, owner))
                                continue;
                        // don't clip points against points (they can't collide)
-                       if (VectorCompare(touch->fields.server->mins, touch->fields.server->maxs) && (type != MOVE_MISSILE || !((int)touch->fields.server->flags & FL_MONSTER)))
+                       if (VectorCompare(PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)))
                                continue;
                }
 
-               bodysupercontents = touch->fields.server->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
+               bodysupercontents = PRVM_serveredictfloat(touch, solid) == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
 
                // might interact, so do an exact clip
                model = NULL;
-               if ((int) touch->fields.server->solid == SOLID_BSP || type == MOVE_HITMODEL)
+               if ((int) PRVM_serveredictfloat(touch, solid) == SOLID_BSP || type == MOVE_HITMODEL)
                {
                        model = SV_GetModelFromEdict(touch);
                        pitchsign = SV_GetPitchSign(touch);
                }
                if (model)
-                       Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2], pitchsign * touch->fields.server->angles[0], touch->fields.server->angles[1], touch->fields.server->angles[2], 1);
+                       Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2], pitchsign * PRVM_serveredictvector(touch, angles)[0], PRVM_serveredictvector(touch, angles)[1], PRVM_serveredictvector(touch, angles)[2], 1);
                else
-                       Matrix4x4_CreateTranslate(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2]);
+                       Matrix4x4_CreateTranslate(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2]);
                Matrix4x4_Invert_Simple(&imatrix, &matrix);
                VM_GenerateFrameGroupBlend(touch->priv.server->framegroupblend, touch);
                VM_FrameBlendFromFrameGroupBlend(touch->priv.server->frameblend, touch->priv.server->framegroupblend, model);
                VM_UpdateEdictSkeleton(touch, model, touch->priv.server->frameblend);
-               if (type == MOVE_MISSILE && (int)touch->fields.server->flags & FL_MONSTER)
-                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
+               if (type == MOVE_MISSILE && (int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)
+                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
                else
-                       Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, false);
+                       Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, false);
 
-               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.server->solid == SOLID_BSP);
+               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_serveredictfloat(touch, solid) == SOLID_BSP);
        }
 
 finished:
@@ -548,7 +548,7 @@ trace_t SV_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        // figure out whether this is a point trace for comparisons
        pointtrace = VectorCompare(clipmins, clipmaxs);
        // precalculate passedict's owner edict pointer for comparisons
-       traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.server->owner) : 0;
+       traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_serveredictedict(passedict, owner)) : 0;
 
        // clip to entities
        // because this uses World_EntitiestoBox, we know all entity boxes overlap
@@ -564,9 +564,9 @@ trace_t SV_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        {
                touch = touchedicts[i];
 
-               if (touch->fields.server->solid < SOLID_BBOX)
+               if (PRVM_serveredictfloat(touch, solid) < SOLID_BBOX)
                        continue;
-               if (type == MOVE_NOMONSTERS && touch->fields.server->solid != SOLID_BSP)
+               if (type == MOVE_NOMONSTERS && PRVM_serveredictfloat(touch, solid) != SOLID_BSP)
                        continue;
 
                if (passedict)
@@ -578,36 +578,36 @@ trace_t SV_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
                        if (traceowner == touch)
                                continue;
                        // don't clip owner against owned entities
-                       if (passedictprog == touch->fields.server->owner)
+                       if (passedictprog == PRVM_serveredictedict(touch, owner))
                                continue;
                        // don't clip points against points (they can't collide)
-                       if (pointtrace && VectorCompare(touch->fields.server->mins, touch->fields.server->maxs) && (type != MOVE_MISSILE || !((int)touch->fields.server->flags & FL_MONSTER)))
+                       if (pointtrace && VectorCompare(PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)))
                                continue;
                }
 
-               bodysupercontents = touch->fields.server->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
+               bodysupercontents = PRVM_serveredictfloat(touch, solid) == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY;
 
                // might interact, so do an exact clip
                model = NULL;
-               if ((int) touch->fields.server->solid == SOLID_BSP || type == MOVE_HITMODEL)
+               if ((int) PRVM_serveredictfloat(touch, solid) == SOLID_BSP || type == MOVE_HITMODEL)
                {
                        model = SV_GetModelFromEdict(touch);
                        pitchsign = SV_GetPitchSign(touch);
                }
                if (model)
-                       Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2], pitchsign * touch->fields.server->angles[0], touch->fields.server->angles[1], touch->fields.server->angles[2], 1);
+                       Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2], pitchsign * PRVM_serveredictvector(touch, angles)[0], PRVM_serveredictvector(touch, angles)[1], PRVM_serveredictvector(touch, angles)[2], 1);
                else
-                       Matrix4x4_CreateTranslate(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2]);
+                       Matrix4x4_CreateTranslate(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2]);
                Matrix4x4_Invert_Simple(&imatrix, &matrix);
                VM_GenerateFrameGroupBlend(touch->priv.server->framegroupblend, touch);
                VM_FrameBlendFromFrameGroupBlend(touch->priv.server->frameblend, touch->priv.server->framegroupblend, model);
                VM_UpdateEdictSkeleton(touch, model, touch->priv.server->frameblend);
-               if (type == MOVE_MISSILE && (int)touch->fields.server->flags & FL_MONSTER)
-                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
+               if (type == MOVE_MISSILE && (int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)
+                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
                else
-                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.server->mins, touch->fields.server->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask);
+                       Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask);
 
-               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, touch->fields.server->solid == SOLID_BSP);
+               Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_serveredictfloat(touch, solid) == SOLID_BSP);
        }
 
 finished:
@@ -632,7 +632,7 @@ trace_t SV_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
 #if COLLISIONPARANOID < 3
                if (trace.startsolid || endstuck)
 #endif
-                       Con_Printf("%s{e%i:%f %f %f:%f %f %f:%f:%f %f %f%s%s}\n", (trace.startsolid || endstuck) ? "^3" : "", passedict ? (int)(passedict - prog->edicts) : -1, passedict->fields.server->origin[0], passedict->fields.server->origin[1], passedict->fields.server->origin[2], end[0] - passedict->fields.server->origin[0], end[1] - passedict->fields.server->origin[1], end[2] - passedict->fields.server->origin[2], trace.fraction, trace.endpos[0] - passedict->fields.server->origin[0], trace.endpos[1] - passedict->fields.server->origin[1], trace.endpos[2] - passedict->fields.server->origin[2], trace.startsolid ? " startstuck" : "", endstuck ? " endstuck" : "");
+                       Con_Printf("%s{e%i:%f %f %f:%f %f %f:%f:%f %f %f%s%s}\n", (trace.startsolid || endstuck) ? "^3" : "", passedict ? (int)(passedict - prog->edicts) : -1, PRVM_serveredictvector(passedict, origin)[0], PRVM_serveredictvector(passedict, origin)[1], PRVM_serveredictvector(passedict, origin)[2], end[0] - PRVM_serveredictvector(passedict, origin)[0], end[1] - PRVM_serveredictvector(passedict, origin)[1], end[2] - PRVM_serveredictvector(passedict, origin)[2], trace.fraction, trace.endpos[0] - PRVM_serveredictvector(passedict, origin)[0], trace.endpos[1] - PRVM_serveredictvector(passedict, origin)[1], trace.endpos[2] - PRVM_serveredictvector(passedict, origin)[2], trace.startsolid ? " startstuck" : "", endstuck ? " endstuck" : "");
        }
        return trace;
 }
@@ -674,17 +674,17 @@ int SV_PointSuperContents(const vec3_t point)
                touch = touchedicts[i];
 
                // we only care about SOLID_BSP for pointcontents
-               if (touch->fields.server->solid != SOLID_BSP)
+               if (PRVM_serveredictfloat(touch, solid) != SOLID_BSP)
                        continue;
 
                // might interact, so do an exact clip
                model = SV_GetModelFromEdict(touch);
                if (!model || !model->PointSuperContents)
                        continue;
-               Matrix4x4_CreateFromQuakeEntity(&matrix, touch->fields.server->origin[0], touch->fields.server->origin[1], touch->fields.server->origin[2], touch->fields.server->angles[0], touch->fields.server->angles[1], touch->fields.server->angles[2], 1);
+               Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2], PRVM_serveredictvector(touch, angles)[0], PRVM_serveredictvector(touch, angles)[1], PRVM_serveredictvector(touch, angles)[2], 1);
                Matrix4x4_Invert_Simple(&imatrix, &matrix);
                Matrix4x4_Transform(&imatrix, point, transformed);
-               frame = (int)touch->fields.server->frame;
+               frame = (int)PRVM_serveredictfloat(touch, frame);
                supercontents |= model->PointSuperContents(model, bound(0, frame, (model->numframes - 1)), transformed);
        }
 
@@ -701,23 +701,23 @@ Linking entities into the world culling system
 
 void SV_LinkEdict_TouchAreaGrid_Call(prvm_edict_t *touch, prvm_edict_t *ent)
 {
-       prog->globals.server->self = PRVM_EDICT_TO_PROG(touch);
-       prog->globals.server->other = PRVM_EDICT_TO_PROG(ent);
-       prog->globals.server->time = sv.time;
-       prog->globals.server->trace_allsolid = false;
-       prog->globals.server->trace_startsolid = false;
-       prog->globals.server->trace_fraction = 1;
-       prog->globals.server->trace_inwater = false;
-       prog->globals.server->trace_inopen = true;
-       VectorCopy (touch->fields.server->origin, prog->globals.server->trace_endpos);
-       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_serverglobaledict(self) = PRVM_EDICT_TO_PROG(touch);
+       PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(ent);
+       PRVM_serverglobalfloat(time) = sv.time;
+       PRVM_serverglobalfloat(trace_allsolid) = false;
+       PRVM_serverglobalfloat(trace_startsolid) = false;
+       PRVM_serverglobalfloat(trace_fraction) = 1;
+       PRVM_serverglobalfloat(trace_inwater) = false;
+       PRVM_serverglobalfloat(trace_inopen) = true;
+       VectorCopy (PRVM_serveredictvector(touch, origin), PRVM_serverglobalvector(trace_endpos));
+       VectorSet (PRVM_serverglobalvector(trace_plane_normal), 0, 0, 1);
+       PRVM_serverglobalfloat(trace_plane_dist) = 0;
+       PRVM_serverglobaledict(trace_ent) = PRVM_EDICT_TO_PROG(ent);
        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");
+       PRVM_ExecuteProgram (PRVM_serveredictfunction(touch, touch), "QC function self.touch is missing");
 }
 
 void SV_LinkEdict_TouchAreaGrid(prvm_edict_t *ent)
@@ -732,7 +732,7 @@ void SV_LinkEdict_TouchAreaGrid(prvm_edict_t *ent)
        if (ent->priv.server->free)
                return;
 
-       if (ent->fields.server->solid == SOLID_NOT)
+       if (PRVM_serveredictfloat(ent, solid) == SOLID_NOT)
                return;
 
        // build a list of edicts to touch, because the link loop can be corrupted
@@ -745,18 +745,18 @@ void SV_LinkEdict_TouchAreaGrid(prvm_edict_t *ent)
                numtouchedicts = MAX_EDICTS;
        }
 
-       old_self = prog->globals.server->self;
-       old_other = prog->globals.server->other;
+       old_self = PRVM_serverglobaledict(self);
+       old_other = PRVM_serverglobaledict(other);
        for (i = 0;i < numtouchedicts;i++)
        {
                touch = touchedicts[i];
-               if (touch != ent && (int)touch->fields.server->solid == SOLID_TRIGGER && touch->fields.server->touch)
+               if (touch != ent && (int)PRVM_serveredictfloat(touch, solid) == SOLID_TRIGGER && PRVM_serveredictfunction(touch, touch))
                {
                        SV_LinkEdict_TouchAreaGrid_Call(touch, ent);
                }
        }
-       prog->globals.server->self = old_self;
-       prog->globals.server->other = old_other;
+       PRVM_serverglobaledict(self) = old_self;
+       PRVM_serverglobaledict(other) = old_other;
 }
 
 static void RotateBBox(const vec3_t mins, const vec3_t maxs, const vec3_t angles, vec3_t rotatedmins, vec3_t rotatedmaxs)
@@ -808,7 +808,7 @@ void SV_LinkEdict (prvm_edict_t *ent)
        if (ent->priv.server->free)
                return;
 
-       modelindex = (int)ent->fields.server->modelindex;
+       modelindex = (int)PRVM_serveredictfloat(ent, modelindex);
        if (modelindex < 0 || modelindex >= MAX_MODELS)
        {
                Con_Printf("edict %i: SOLID_BSP with invalid modelindex!\n", PRVM_NUM_FOR_EDICT(ent));
@@ -822,55 +822,55 @@ void SV_LinkEdict (prvm_edict_t *ent)
 
 // set the abs box
 
-       if (ent->fields.server->movetype == MOVETYPE_PHYSICS)
+       if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_PHYSICS)
        {
                // TODO maybe should do this for rotating SOLID_BSP too? Would behave better with rotating doors
                // TODO special handling for spheres?
-               RotateBBox(ent->fields.server->mins, ent->fields.server->maxs, ent->fields.server->angles, mins, maxs);
-               VectorAdd(ent->fields.server->origin, mins, mins);
-               VectorAdd(ent->fields.server->origin, maxs, maxs);
+               RotateBBox(PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, angles), mins, maxs);
+               VectorAdd(PRVM_serveredictvector(ent, origin), mins, mins);
+               VectorAdd(PRVM_serveredictvector(ent, origin), maxs, maxs);
        }
-       else if (ent->fields.server->solid == SOLID_BSP)
+       else if (PRVM_serveredictfloat(ent, solid) == SOLID_BSP)
        {
                if (model != NULL)
                {
                        if (!model->TraceBox)
                                Con_DPrintf("edict %i: SOLID_BSP with non-collidable model\n", PRVM_NUM_FOR_EDICT(ent));
 
-                       if (ent->fields.server->angles[0] || ent->fields.server->angles[2] || ent->fields.server->avelocity[0] || ent->fields.server->avelocity[2])
+                       if (PRVM_serveredictvector(ent, angles)[0] || PRVM_serveredictvector(ent, angles)[2] || PRVM_serveredictvector(ent, avelocity)[0] || PRVM_serveredictvector(ent, avelocity)[2])
                        {
-                               VectorAdd(ent->fields.server->origin, model->rotatedmins, mins);
-                               VectorAdd(ent->fields.server->origin, model->rotatedmaxs, maxs);
+                               VectorAdd(PRVM_serveredictvector(ent, origin), model->rotatedmins, mins);
+                               VectorAdd(PRVM_serveredictvector(ent, origin), model->rotatedmaxs, maxs);
                        }
-                       else if (ent->fields.server->angles[1] || ent->fields.server->avelocity[1])
+                       else if (PRVM_serveredictvector(ent, angles)[1] || PRVM_serveredictvector(ent, avelocity)[1])
                        {
-                               VectorAdd(ent->fields.server->origin, model->yawmins, mins);
-                               VectorAdd(ent->fields.server->origin, model->yawmaxs, maxs);
+                               VectorAdd(PRVM_serveredictvector(ent, origin), model->yawmins, mins);
+                               VectorAdd(PRVM_serveredictvector(ent, origin), model->yawmaxs, maxs);
                        }
                        else
                        {
-                               VectorAdd(ent->fields.server->origin, model->normalmins, mins);
-                               VectorAdd(ent->fields.server->origin, model->normalmaxs, maxs);
+                               VectorAdd(PRVM_serveredictvector(ent, origin), model->normalmins, mins);
+                               VectorAdd(PRVM_serveredictvector(ent, origin), model->normalmaxs, maxs);
                        }
                }
                else
                {
                        // SOLID_BSP with no model is valid, mainly because some QC setup code does so temporarily
-                       VectorAdd(ent->fields.server->origin, ent->fields.server->mins, mins);
-                       VectorAdd(ent->fields.server->origin, ent->fields.server->maxs, maxs);
+                       VectorAdd(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), mins);
+                       VectorAdd(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, maxs), maxs);
                }
        }
        else
        {
-               VectorAdd(ent->fields.server->origin, ent->fields.server->mins, mins);
-               VectorAdd(ent->fields.server->origin, ent->fields.server->maxs, maxs);
+               VectorAdd(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), mins);
+               VectorAdd(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, maxs), maxs);
        }
 
 //
 // to make items easier to pick up and allow them to be grabbed off
 // of shelves, the abs sizes are expanded
 //
-       if ((int)ent->fields.server->flags & FL_ITEM)
+       if ((int)PRVM_serveredictfloat(ent, flags) & FL_ITEM)
        {
                mins[0] -= 15;
                mins[1] -= 15;
@@ -891,8 +891,8 @@ void SV_LinkEdict (prvm_edict_t *ent)
                maxs[2] += 1;
        }
 
-       VectorCopy(mins, ent->fields.server->absmin);
-       VectorCopy(maxs, ent->fields.server->absmax);
+       VectorCopy(mins, PRVM_serveredictvector(ent, absmin));
+       VectorCopy(maxs, PRVM_serveredictvector(ent, absmax));
 
        World_LinkEdict(&sv.world, ent, mins, maxs);
 }
@@ -918,13 +918,13 @@ static int SV_TestEntityPosition (prvm_edict_t *ent, vec3_t offset)
        vec3_t org;
        trace_t trace;
        contents = SV_GenericHitSuperContentsMask(ent);
-       VectorAdd(ent->fields.server->origin, offset, org);
-       trace = SV_TraceBox(org, ent->fields.server->mins, ent->fields.server->maxs, ent->fields.server->origin, MOVE_NOMONSTERS, ent, contents);
+       VectorAdd(PRVM_serveredictvector(ent, origin), offset, org);
+       trace = SV_TraceBox(org, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, origin), MOVE_NOMONSTERS, ent, contents);
        if (trace.startsupercontents & contents)
                return true;
        else
        {
-               if (sv.worldmodel->brushq1.numclipnodes && !VectorCompare(ent->fields.server->mins, ent->fields.server->maxs))
+               if (sv.worldmodel->brushq1.numclipnodes && !VectorCompare(PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs)))
                {
                        // q1bsp/hlbsp use hulls and if the entity does not exactly match
                        // a hull size it is incorrectly tested, so this code tries to
@@ -932,8 +932,8 @@ static int SV_TestEntityPosition (prvm_edict_t *ent, vec3_t offset)
                        // FIXME: this breaks entities larger than the hull size
                        int i;
                        vec3_t v, m1, m2, s;
-                       VectorAdd(org, ent->fields.server->mins, m1);
-                       VectorAdd(org, ent->fields.server->maxs, m2);
+                       VectorAdd(org, PRVM_serveredictvector(ent, mins), m1);
+                       VectorAdd(org, PRVM_serveredictvector(ent, maxs), m2);
                        VectorSubtract(m2, m1, s);
 #define EPSILON (1.0f / 32.0f)
                        if (s[0] >= EPSILON*2) {m1[0] += EPSILON;m2[0] -= EPSILON;}
@@ -950,19 +950,19 @@ static int SV_TestEntityPosition (prvm_edict_t *ent, vec3_t offset)
                }
        }
        // if the trace found a better position for the entity, move it there
-       if (VectorDistance2(trace.endpos, ent->fields.server->origin) >= 0.0001)
+       if (VectorDistance2(trace.endpos, PRVM_serveredictvector(ent, origin)) >= 0.0001)
        {
 #if 0
                // please switch back to this code when trace.endpos sometimes being in solid bug is fixed
-               VectorCopy(trace.endpos, ent->fields.server->origin);
+               VectorCopy(trace.endpos, PRVM_serveredictvector(ent, origin));
 #else
                // verify if the endpos is REALLY outside solid
                VectorCopy(trace.endpos, org);
-               trace = SV_TraceBox(org, ent->fields.server->mins, ent->fields.server->maxs, org, MOVE_NOMONSTERS, ent, contents);
+               trace = SV_TraceBox(org, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), org, MOVE_NOMONSTERS, ent, contents);
                if(trace.startsolid)
                        Con_Printf("SV_TestEntityPosition: trace.endpos detected to be in solid. NOT using it.\n");
                else
-                       VectorCopy(org, ent->fields.server->origin);
+                       VectorCopy(org, PRVM_serveredictvector(ent, origin));
 #endif
        }
        return false;
@@ -984,10 +984,10 @@ void SV_CheckAllEnts (void)
        {
                if (check->priv.server->free)
                        continue;
-               if (check->fields.server->movetype == MOVETYPE_PUSH
-                || check->fields.server->movetype == MOVETYPE_NONE
-                || check->fields.server->movetype == MOVETYPE_FOLLOW
-                || check->fields.server->movetype == MOVETYPE_NOCLIP)
+               if (PRVM_serveredictfloat(check, movetype) == MOVETYPE_PUSH
+                || PRVM_serveredictfloat(check, movetype) == MOVETYPE_NONE
+                || PRVM_serveredictfloat(check, movetype) == MOVETYPE_FOLLOW
+                || PRVM_serveredictfloat(check, movetype) == MOVETYPE_NOCLIP)
                        continue;
 
                if (SV_TestEntityPosition (check, vec3_origin))
@@ -1010,7 +1010,7 @@ int SV_CheckContentsTransition(prvm_edict_t *ent, const int nContents)
        // Default Valid Function Call to False
        bValidFunctionCall = false;
 
-       if(ent->fields.server->watertype != nContents)
+       if(PRVM_serveredictfloat(ent, watertype) != nContents)
        { // Changed Contents
                // Acquire Contents Transition Function from QC
                if(PRVM_serveredictfunction(ent, contentstransition))
@@ -1019,11 +1019,11 @@ int SV_CheckContentsTransition(prvm_edict_t *ent, const int nContents)
                        bValidFunctionCall = true;
                        // Prepare Parameters (Original Contents, New Contents)
                                // Original Contents
-                               PRVM_G_FLOAT(OFS_PARM0) = ent->fields.server->watertype;
+                               PRVM_G_FLOAT(OFS_PARM0) = PRVM_serveredictfloat(ent, watertype);
                                // New Contents
                                PRVM_G_FLOAT(OFS_PARM1) = nContents;
                                // Assign Self
-                               prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
+                               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent);
                        // Execute VM Function
                        PRVM_ExecuteProgram(PRVM_serveredictfunction(ent, contentstransition), "contentstransition: NULL function");
                }
@@ -1049,32 +1049,32 @@ void SV_CheckVelocity (prvm_edict_t *ent)
 //
        for (i=0 ; i<3 ; i++)
        {
-               if (IS_NAN(ent->fields.server->velocity[i]))
+               if (IS_NAN(PRVM_serveredictvector(ent, velocity)[i]))
                {
-                       Con_Printf("Got a NaN velocity on entity #%i (%s)\n", PRVM_NUM_FOR_EDICT(ent), PRVM_GetString(ent->fields.server->classname));
-                       ent->fields.server->velocity[i] = 0;
+                       Con_Printf("Got a NaN velocity on entity #%i (%s)\n", PRVM_NUM_FOR_EDICT(ent), PRVM_GetString(PRVM_serveredictstring(ent, classname)));
+                       PRVM_serveredictvector(ent, velocity)[i] = 0;
                }
-               if (IS_NAN(ent->fields.server->origin[i]))
+               if (IS_NAN(PRVM_serveredictvector(ent, origin)[i]))
                {
-                       Con_Printf("Got a NaN origin on entity #%i (%s)\n", PRVM_NUM_FOR_EDICT(ent), PRVM_GetString(ent->fields.server->classname));
-                       ent->fields.server->origin[i] = 0;
+                       Con_Printf("Got a NaN origin on entity #%i (%s)\n", PRVM_NUM_FOR_EDICT(ent), PRVM_GetString(PRVM_serveredictstring(ent, classname)));
+                       PRVM_serveredictvector(ent, origin)[i] = 0;
                }
        }
 
        // LordHavoc: a hack to ensure that the (rather silly) id1 quakec
        // player_run/player_stand1 does not horribly malfunction if the
        // velocity becomes a denormalized float
-       if (VectorLength2(ent->fields.server->velocity) < 0.0001)
-               VectorClear(ent->fields.server->velocity);
+       if (VectorLength2(PRVM_serveredictvector(ent, velocity)) < 0.0001)
+               VectorClear(PRVM_serveredictvector(ent, velocity));
 
        // LordHavoc: max velocity fix, inspired by Maddes's source fixes, but this is faster
-       wishspeed = DotProduct(ent->fields.server->velocity, ent->fields.server->velocity);
+       wishspeed = DotProduct(PRVM_serveredictvector(ent, velocity), PRVM_serveredictvector(ent, velocity));
        if (wishspeed > sv_maxvelocity.value * sv_maxvelocity.value)
        {
                wishspeed = sv_maxvelocity.value / sqrt(wishspeed);
-               ent->fields.server->velocity[0] *= wishspeed;
-               ent->fields.server->velocity[1] *= wishspeed;
-               ent->fields.server->velocity[2] *= wishspeed;
+               PRVM_serveredictvector(ent, velocity)[0] *= wishspeed;
+               PRVM_serveredictvector(ent, velocity)[1] *= wishspeed;
+               PRVM_serveredictvector(ent, velocity)[2] *= wishspeed;
        }
 }
 
@@ -1094,21 +1094,21 @@ qboolean SV_RunThink (prvm_edict_t *ent)
 
        // don't let things stay in the past.
        // it is possible to start that way by a trigger with a local time.
-       if (ent->fields.server->nextthink <= 0 || ent->fields.server->nextthink > sv.time + sv.frametime)
+       if (PRVM_serveredictfloat(ent, nextthink) <= 0 || PRVM_serveredictfloat(ent, nextthink) > sv.time + sv.frametime)
                return true;
 
        for (iterations = 0;iterations < 128  && !ent->priv.server->free;iterations++)
        {
-               prog->globals.server->time = max(sv.time, ent->fields.server->nextthink);
-               ent->fields.server->nextthink = 0;
-               prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
-               prog->globals.server->other = PRVM_EDICT_TO_PROG(prog->edicts);
-               PRVM_ExecuteProgram (ent->fields.server->think, "QC function self.think is missing");
+               PRVM_serverglobalfloat(time) = max(sv.time, PRVM_serveredictfloat(ent, nextthink));
+               PRVM_serveredictfloat(ent, nextthink) = 0;
+               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent);
+               PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(prog->edicts);
+               PRVM_ExecuteProgram (PRVM_serveredictfunction(ent, think), "QC function self.think is missing");
                // mods often set nextthink to time to cause a think every frame,
                // we don't want to loop in that case, so exit if the new nextthink is
                // <= the time the qc was told, also exit if it is past the end of the
                // frame
-               if (ent->fields.server->nextthink <= prog->globals.server->time || ent->fields.server->nextthink > sv.time + sv.frametime || !sv_gameplayfix_multiplethinksperframe.integer)
+               if (PRVM_serveredictfloat(ent, nextthink) <= PRVM_serverglobalfloat(time) || PRVM_serveredictfloat(ent, nextthink) > sv.time + sv.frametime || !sv_gameplayfix_multiplethinksperframe.integer)
                        break;
        }
        return !ent->priv.server->free;
@@ -1129,37 +1129,37 @@ void SV_Impact (prvm_edict_t *e1, trace_t *trace)
        int old_self, old_other;
        prvm_edict_t *e2 = (prvm_edict_t *)trace->ent;
 
-       old_self = prog->globals.server->self;
-       old_other = prog->globals.server->other;
+       old_self = PRVM_serverglobaledict(self);
+       old_other = PRVM_serverglobaledict(other);
        restorevm_tempstringsbuf_cursize = vm_tempstringsbuf.cursize;
 
        VM_SetTraceGlobals(trace);
 
-       prog->globals.server->time = sv.time;
-       if (!e1->priv.server->free && !e2->priv.server->free && e1->fields.server->touch && e1->fields.server->solid != SOLID_NOT)
+       PRVM_serverglobalfloat(time) = sv.time;
+       if (!e1->priv.server->free && !e2->priv.server->free && PRVM_serveredictfunction(e1, touch) && PRVM_serveredictfloat(e1, solid) != SOLID_NOT)
        {
-               prog->globals.server->self = PRVM_EDICT_TO_PROG(e1);
-               prog->globals.server->other = PRVM_EDICT_TO_PROG(e2);
-               PRVM_ExecuteProgram (e1->fields.server->touch, "QC function self.touch is missing");
+               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(e1);
+               PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(e2);
+               PRVM_ExecuteProgram (PRVM_serveredictfunction(e1, touch), "QC function self.touch is missing");
        }
 
-       if (!e1->priv.server->free && !e2->priv.server->free && e2->fields.server->touch && e2->fields.server->solid != SOLID_NOT)
+       if (!e1->priv.server->free && !e2->priv.server->free && PRVM_serveredictfunction(e2, touch) && PRVM_serveredictfloat(e2, solid) != SOLID_NOT)
        {
-               prog->globals.server->self = PRVM_EDICT_TO_PROG(e2);
-               prog->globals.server->other = PRVM_EDICT_TO_PROG(e1);
-               VectorCopy(e2->fields.server->origin, prog->globals.server->trace_endpos);
-               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_serverglobaledict(self) = PRVM_EDICT_TO_PROG(e2);
+               PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(e1);
+               VectorCopy(PRVM_serveredictvector(e2, origin), PRVM_serverglobalvector(trace_endpos));
+               VectorNegate(trace->plane.normal, PRVM_serverglobalvector(trace_plane_normal));
+               PRVM_serverglobalfloat(trace_plane_dist) = -trace->plane.dist;
+               PRVM_serverglobaledict(trace_ent) = PRVM_EDICT_TO_PROG(e1);
                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");
+               PRVM_ExecuteProgram (PRVM_serveredictfunction(e2, touch), "QC function self.touch is missing");
        }
 
-       prog->globals.server->self = old_self;
-       prog->globals.server->other = old_other;
+       PRVM_serverglobaledict(self) = old_self;
+       PRVM_serverglobaledict(other) = old_other;
        vm_tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
 }
 
@@ -1218,7 +1218,7 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
        gravity = 0;
 
        if(sv_gameplayfix_nogravityonground.integer)
-               if((int)ent->fields.server->flags & FL_ONGROUND)
+               if((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)
                        applygravity = false;
 
        if (applygravity)
@@ -1226,25 +1226,25 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
                if (sv_gameplayfix_gravityunaffectedbyticrate.integer)
                {
                        gravity = SV_Gravity(ent) * 0.5f;
-                       ent->fields.server->velocity[2] -= gravity;
+                       PRVM_serveredictvector(ent, velocity)[2] -= gravity;
                }
                else
                {
                        applygravity = false;
-                       ent->fields.server->velocity[2] -= SV_Gravity(ent);
+                       PRVM_serveredictvector(ent, velocity)[2] -= SV_Gravity(ent);
                }
        }
        blocked = 0;
-       VectorCopy(ent->fields.server->velocity, original_velocity);
-       VectorCopy(ent->fields.server->velocity, primal_velocity);
+       VectorCopy(PRVM_serveredictvector(ent, velocity), original_velocity);
+       VectorCopy(PRVM_serveredictvector(ent, velocity), primal_velocity);
        numplanes = 0;
        time_left = time;
        for (bumpcount = 0;bumpcount < MAX_CLIP_PLANES;bumpcount++)
        {
-               if (!ent->fields.server->velocity[0] && !ent->fields.server->velocity[1] && !ent->fields.server->velocity[2])
+               if (!PRVM_serveredictvector(ent, velocity)[0] && !PRVM_serveredictvector(ent, velocity)[1] && !PRVM_serveredictvector(ent, velocity)[2])
                        break;
 
-               VectorScale(ent->fields.server->velocity, time_left, push);
+               VectorScale(PRVM_serveredictvector(ent, velocity), time_left, push);
                if(!SV_PushEntity(&trace, ent, push, false, false))
                {
                        // we got teleported by a touch function
@@ -1268,8 +1268,8 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
                                        trace.ent = prog->edicts;
                                }
 
-                               ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
-                               ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
+                               PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) | FL_ONGROUND;
+                               PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
                        }
                }
                else if (stepheight)
@@ -1280,42 +1280,42 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
                        trace_t steptrace;
                        trace_t steptrace2;
                        trace_t steptrace3;
-                       //Con_Printf("step %f %f %f : ", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
+                       //Con_Printf("step %f %f %f : ", PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2]);
                        VectorSet(steppush, 0, 0, stepheight);
-                       VectorCopy(ent->fields.server->origin, org);
+                       VectorCopy(PRVM_serveredictvector(ent, origin), org);
                        if(!SV_PushEntity(&steptrace, ent, steppush, false, false))
                        {
                                blocked |= 8;
                                break;
                        }
-                       //Con_Printf("%f %f %f : ", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
+                       //Con_Printf("%f %f %f : ", PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2]);
                        if(!SV_PushEntity(&steptrace2, ent, push, false, false))
                        {
                                blocked |= 8;
                                break;
                        }
-                       //Con_Printf("%f %f %f : ", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
-                       VectorSet(steppush, 0, 0, org[2] - ent->fields.server->origin[2]);
+                       //Con_Printf("%f %f %f : ", PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2]);
+                       VectorSet(steppush, 0, 0, org[2] - PRVM_serveredictvector(ent, origin)[2]);
                        if(!SV_PushEntity(&steptrace3, ent, steppush, false, false))
                        {
                                blocked |= 8;
                                break;
                        }
-                       //Con_Printf("%f %f %f : ", ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2]);
+                       //Con_Printf("%f %f %f : ", PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2]);
                        // accept the new position if it made some progress...
-                       if (fabs(ent->fields.server->origin[0] - org[0]) >= 0.03125 || fabs(ent->fields.server->origin[1] - org[1]) >= 0.03125)
+                       if (fabs(PRVM_serveredictvector(ent, origin)[0] - org[0]) >= 0.03125 || fabs(PRVM_serveredictvector(ent, origin)[1] - org[1]) >= 0.03125)
                        {
-                               //Con_Printf("accepted (delta %f %f %f)\n", ent->fields.server->origin[0] - org[0], ent->fields.server->origin[1] - org[1], ent->fields.server->origin[2] - org[2]);
+                               //Con_Printf("accepted (delta %f %f %f)\n", PRVM_serveredictvector(ent, origin)[0] - org[0], PRVM_serveredictvector(ent, origin)[1] - org[1], PRVM_serveredictvector(ent, origin)[2] - org[2]);
                                trace = steptrace2;
-                               VectorCopy(ent->fields.server->origin, trace.endpos);
+                               VectorCopy(PRVM_serveredictvector(ent, origin), trace.endpos);
                                time_left *= 1 - trace.fraction;
                                numplanes = 0;
                                continue;
                        }
                        else
                        {
-                               //Con_Printf("REJECTED (delta %f %f %f)\n", ent->fields.server->origin[0] - org[0], ent->fields.server->origin[1] - org[1], ent->fields.server->origin[2] - org[2]);
-                               VectorCopy(org, ent->fields.server->origin);
+                               //Con_Printf("REJECTED (delta %f %f %f)\n", PRVM_serveredictvector(ent, origin)[0] - org[0], PRVM_serveredictvector(ent, origin)[1] - org[1], PRVM_serveredictvector(ent, origin)[2] - org[2]);
+                               VectorCopy(org, PRVM_serveredictvector(ent, origin));
                        }
                }
                else
@@ -1329,7 +1329,7 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
                if (trace.fraction >= 0.001)
                {
                        // actually covered some distance
-                       VectorCopy(ent->fields.server->velocity, original_velocity);
+                       VectorCopy(PRVM_serveredictvector(ent, velocity), original_velocity);
                        numplanes = 0;
                }
 
@@ -1339,7 +1339,7 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
                if (numplanes >= MAX_CLIP_PLANES)
                {
                        // this shouldn't really happen
-                       VectorClear(ent->fields.server->velocity);
+                       VectorClear(PRVM_serveredictvector(ent, velocity));
                        blocked = 3;
                        break;
                }
@@ -1350,7 +1350,7 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
                                break;
                if (i < numplanes)
                {
-                       VectorAdd(ent->fields.server->velocity, trace.plane.normal, ent->fields.server->velocity);
+                       VectorAdd(PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity));
                        continue;
                }
                */
@@ -1378,49 +1378,49 @@ static int SV_FlyMove (prvm_edict_t *ent, float time, qboolean applygravity, flo
                if (i != numplanes)
                {
                        // go along this plane
-                       VectorCopy(new_velocity, ent->fields.server->velocity);
+                       VectorCopy(new_velocity, PRVM_serveredictvector(ent, velocity));
                }
                else
                {
                        // go along the crease
                        if (numplanes != 2)
                        {
-                               VectorClear(ent->fields.server->velocity);
+                               VectorClear(PRVM_serveredictvector(ent, velocity));
                                blocked = 7;
                                break;
                        }
                        CrossProduct(planes[0], planes[1], dir);
                        // LordHavoc: thanks to taniwha of QuakeForge for pointing out this fix for slowed falling in corners
                        VectorNormalize(dir);
-                       d = DotProduct(dir, ent->fields.server->velocity);
-                       VectorScale(dir, d, ent->fields.server->velocity);
+                       d = DotProduct(dir, PRVM_serveredictvector(ent, velocity));
+                       VectorScale(dir, d, PRVM_serveredictvector(ent, velocity));
                }
 
                // if current velocity is against the original velocity,
                // stop dead to avoid tiny occilations in sloping corners
-               if (DotProduct(ent->fields.server->velocity, primal_velocity) <= 0)
+               if (DotProduct(PRVM_serveredictvector(ent, velocity), primal_velocity) <= 0)
                {
-                       VectorClear(ent->fields.server->velocity);
+                       VectorClear(PRVM_serveredictvector(ent, velocity));
                        break;
                }
        }
 
-       //Con_Printf("entity %i final: blocked %i velocity %f %f %f\n", ent - prog->edicts, blocked, ent->fields.server->velocity[0], ent->fields.server->velocity[1], ent->fields.server->velocity[2]);
+       //Con_Printf("entity %i final: blocked %i velocity %f %f %f\n", ent - prog->edicts, blocked, PRVM_serveredictvector(ent, velocity)[0], PRVM_serveredictvector(ent, velocity)[1], PRVM_serveredictvector(ent, velocity)[2]);
 
        /*
        if ((blocked & 1) == 0 && bumpcount > 1)
        {
                // LordHavoc: fix the 'fall to your death in a wedge corner' glitch
                // flag ONGROUND if there's ground under it
-               trace = SV_TraceBox(ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, end, MOVE_NORMAL, ent, hitsupercontentsmask);
+               trace = SV_TraceBox(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), end, MOVE_NORMAL, ent, hitsupercontentsmask);
        }
        */
 
        // LordHavoc: this came from QW and allows you to get out of water more easily
-       if (sv_gameplayfix_easierwaterjump.integer && ((int)ent->fields.server->flags & FL_WATERJUMP) && !(blocked & 8))
-               VectorCopy(primal_velocity, ent->fields.server->velocity);
-       if (applygravity && !((int)ent->fields.server->flags & FL_ONGROUND))
-               ent->fields.server->velocity[2] -= gravity;
+       if (sv_gameplayfix_easierwaterjump.integer && ((int)PRVM_serveredictfloat(ent, flags) & FL_WATERJUMP) && !(blocked & 8))
+               VectorCopy(primal_velocity, PRVM_serveredictvector(ent, velocity));
+       if (applygravity && !((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND))
+               PRVM_serveredictvector(ent, velocity)[2] -= gravity;
        return blocked;
 }
 
@@ -1469,10 +1469,10 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
        vec3_t start;
        vec3_t end;
 
-       solid = (int)ent->fields.server->solid;
-       movetype = (int)ent->fields.server->movetype;
-       VectorCopy(ent->fields.server->mins, mins);
-       VectorCopy(ent->fields.server->maxs, maxs);
+       solid = (int)PRVM_serveredictfloat(ent, solid);
+       movetype = (int)PRVM_serveredictfloat(ent, movetype);
+       VectorCopy(PRVM_serveredictvector(ent, mins), mins);
+       VectorCopy(PRVM_serveredictvector(ent, maxs), maxs);
 
        // move start position out of solids
        if (sv_gameplayfix_nudgeoutofsolid.integer && sv_gameplayfix_nudgeoutofsolid_separation.value >= 0)
@@ -1484,7 +1484,7 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
                vec_t separation = sv_gameplayfix_nudgeoutofsolid_separation.value;
                if (sv.worldmodel && sv.worldmodel->brushq1.numclipnodes)
                        separation = 0.0f; // when using hulls, it can not be enlarged
-               VectorCopy(ent->fields.server->origin, stuckorigin);
+               VectorCopy(PRVM_serveredictvector(ent, origin), stuckorigin);
                VectorCopy(mins, stuckmins);
                VectorCopy(maxs, stuckmaxs);
                stuckmins[0] -= separation;
@@ -1499,7 +1499,7 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
                        if (!stucktrace.bmodelstartsolid || stucktrace.startdepth >= 0)
                        {
                                // found a good location, use it
-                               VectorCopy(stuckorigin, ent->fields.server->origin);
+                               VectorCopy(stuckorigin, PRVM_serveredictvector(ent, origin));
                                break;
                        }
                        nudge = -stucktrace.startdepth;
@@ -1507,7 +1507,7 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
                }
        }
 
-       VectorCopy(ent->fields.server->origin, start);
+       VectorCopy(PRVM_serveredictvector(ent, origin), start);
        VectorAdd(start, push, end);
 
        if (movetype == MOVETYPE_FLYMISSILE)
@@ -1521,16 +1521,16 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
        if (trace->bmodelstartsolid && failonbmodelstartsolid)
                return true;
 
-       VectorCopy(trace->endpos, ent->fields.server->origin);
+       VectorCopy(trace->endpos, PRVM_serveredictvector(ent, origin));
 
-       VectorCopy(ent->fields.server->origin, original);
-       VectorCopy(ent->fields.server->velocity, original_velocity);
+       VectorCopy(PRVM_serveredictvector(ent, origin), original);
+       VectorCopy(PRVM_serveredictvector(ent, velocity), original_velocity);
 
        SV_LinkEdict(ent);
 
 #if 0
        if(!trace->startsolid)
-       if(SV_TraceBox(ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, ent->fields.server->origin, type, ent, SV_GenericHitSuperContentsMask(ent)).startsolid)
+       if(SV_TraceBox(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, origin), type, ent, SV_GenericHitSuperContentsMask(ent)).startsolid)
        {
                Con_Printf("something eeeeevil happened\n");
        }
@@ -1539,10 +1539,10 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
        if (dolink)
                SV_LinkEdict_TouchAreaGrid(ent);
 
-       if((ent->fields.server->solid >= SOLID_TRIGGER && trace->ent && (!((int)ent->fields.server->flags & FL_ONGROUND) || ent->fields.server->groundentity != PRVM_EDICT_TO_PROG(trace->ent))))
+       if((PRVM_serveredictfloat(ent, solid) >= SOLID_TRIGGER && trace->ent && (!((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND) || PRVM_serveredictedict(ent, groundentity) != PRVM_EDICT_TO_PROG(trace->ent))))
                SV_Impact (ent, trace);
 
-       return VectorCompare(ent->fields.server->origin, original) && VectorCompare(ent->fields.server->velocity, original_velocity);
+       return VectorCompare(PRVM_serveredictvector(ent, origin), original) && VectorCompare(PRVM_serveredictvector(ent, velocity), original_velocity);
 }
 
 
@@ -1568,13 +1568,13 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
        matrix4x4_t pusherfinalmatrix, pusherfinalimatrix;
        static unsigned short moved_edicts[MAX_EDICTS];
 
-       if (!pusher->fields.server->velocity[0] && !pusher->fields.server->velocity[1] && !pusher->fields.server->velocity[2] && !pusher->fields.server->avelocity[0] && !pusher->fields.server->avelocity[1] && !pusher->fields.server->avelocity[2])
+       if (!PRVM_serveredictvector(pusher, velocity)[0] && !PRVM_serveredictvector(pusher, velocity)[1] && !PRVM_serveredictvector(pusher, velocity)[2] && !PRVM_serveredictvector(pusher, avelocity)[0] && !PRVM_serveredictvector(pusher, avelocity)[1] && !PRVM_serveredictvector(pusher, avelocity)[2])
        {
-               pusher->fields.server->ltime += movetime;
+               PRVM_serveredictfloat(pusher, ltime) += movetime;
                return;
        }
 
-       switch ((int) pusher->fields.server->solid)
+       switch ((int) PRVM_serveredictfloat(pusher, solid))
        {
        // LordHavoc: valid pusher types
        case SOLID_BSP:
@@ -1585,46 +1585,46 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
        // LordHavoc: no collisions
        case SOLID_NOT:
        case SOLID_TRIGGER:
-               VectorMA (pusher->fields.server->origin, movetime, pusher->fields.server->velocity, pusher->fields.server->origin);
-               VectorMA (pusher->fields.server->angles, movetime, pusher->fields.server->avelocity, pusher->fields.server->angles);
-               pusher->fields.server->angles[0] -= 360.0 * floor(pusher->fields.server->angles[0] * (1.0 / 360.0));
-               pusher->fields.server->angles[1] -= 360.0 * floor(pusher->fields.server->angles[1] * (1.0 / 360.0));
-               pusher->fields.server->angles[2] -= 360.0 * floor(pusher->fields.server->angles[2] * (1.0 / 360.0));
-               pusher->fields.server->ltime += movetime;
+               VectorMA (PRVM_serveredictvector(pusher, origin), movetime, PRVM_serveredictvector(pusher, velocity), PRVM_serveredictvector(pusher, origin));
+               VectorMA (PRVM_serveredictvector(pusher, angles), movetime, PRVM_serveredictvector(pusher, avelocity), PRVM_serveredictvector(pusher, angles));
+               PRVM_serveredictvector(pusher, angles)[0] -= 360.0 * floor(PRVM_serveredictvector(pusher, angles)[0] * (1.0 / 360.0));
+               PRVM_serveredictvector(pusher, angles)[1] -= 360.0 * floor(PRVM_serveredictvector(pusher, angles)[1] * (1.0 / 360.0));
+               PRVM_serveredictvector(pusher, angles)[2] -= 360.0 * floor(PRVM_serveredictvector(pusher, angles)[2] * (1.0 / 360.0));
+               PRVM_serveredictfloat(pusher, ltime) += movetime;
                SV_LinkEdict(pusher);
                return;
        default:
-               Con_Printf("SV_PushMove: entity #%i, unrecognized solid type %f\n", PRVM_NUM_FOR_EDICT(pusher), pusher->fields.server->solid);
+               Con_Printf("SV_PushMove: entity #%i, unrecognized solid type %f\n", PRVM_NUM_FOR_EDICT(pusher), PRVM_serveredictfloat(pusher, solid));
                return;
        }
-       index = (int) pusher->fields.server->modelindex;
+       index = (int) PRVM_serveredictfloat(pusher, modelindex);
        if (index < 1 || index >= MAX_MODELS)
        {
-               Con_Printf("SV_PushMove: entity #%i has an invalid modelindex %f\n", PRVM_NUM_FOR_EDICT(pusher), pusher->fields.server->modelindex);
+               Con_Printf("SV_PushMove: entity #%i has an invalid modelindex %f\n", PRVM_NUM_FOR_EDICT(pusher), PRVM_serveredictfloat(pusher, modelindex));
                return;
        }
        pushermodel = SV_GetModelByIndex(index);
-       pusherowner = pusher->fields.server->owner;
+       pusherowner = PRVM_serveredictedict(pusher, owner);
        pusherprog = PRVM_EDICT_TO_PROG(pusher);
 
-       rotated = VectorLength2(pusher->fields.server->angles) + VectorLength2(pusher->fields.server->avelocity) > 0;
+       rotated = VectorLength2(PRVM_serveredictvector(pusher, angles)) + VectorLength2(PRVM_serveredictvector(pusher, avelocity)) > 0;
 
        movetime2 = movetime;
-       VectorScale(pusher->fields.server->velocity, movetime2, move1);
-       VectorScale(pusher->fields.server->avelocity, movetime2, moveangle);
+       VectorScale(PRVM_serveredictvector(pusher, velocity), movetime2, move1);
+       VectorScale(PRVM_serveredictvector(pusher, avelocity), movetime2, moveangle);
        if (moveangle[0] || moveangle[2])
        {
                for (i = 0;i < 3;i++)
                {
                        if (move1[i] > 0)
                        {
-                               mins[i] = pushermodel->rotatedmins[i] + pusher->fields.server->origin[i] - 1;
-                               maxs[i] = pushermodel->rotatedmaxs[i] + move1[i] + pusher->fields.server->origin[i] + 1;
+                               mins[i] = pushermodel->rotatedmins[i] + PRVM_serveredictvector(pusher, origin)[i] - 1;
+                               maxs[i] = pushermodel->rotatedmaxs[i] + move1[i] + PRVM_serveredictvector(pusher, origin)[i] + 1;
                        }
                        else
                        {
-                               mins[i] = pushermodel->rotatedmins[i] + move1[i] + pusher->fields.server->origin[i] - 1;
-                               maxs[i] = pushermodel->rotatedmaxs[i] + pusher->fields.server->origin[i] + 1;
+                               mins[i] = pushermodel->rotatedmins[i] + move1[i] + PRVM_serveredictvector(pusher, origin)[i] - 1;
+                               maxs[i] = pushermodel->rotatedmaxs[i] + PRVM_serveredictvector(pusher, origin)[i] + 1;
                        }
                }
        }
@@ -1634,13 +1634,13 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                {
                        if (move1[i] > 0)
                        {
-                               mins[i] = pushermodel->yawmins[i] + pusher->fields.server->origin[i] - 1;
-                               maxs[i] = pushermodel->yawmaxs[i] + move1[i] + pusher->fields.server->origin[i] + 1;
+                               mins[i] = pushermodel->yawmins[i] + PRVM_serveredictvector(pusher, origin)[i] - 1;
+                               maxs[i] = pushermodel->yawmaxs[i] + move1[i] + PRVM_serveredictvector(pusher, origin)[i] + 1;
                        }
                        else
                        {
-                               mins[i] = pushermodel->yawmins[i] + move1[i] + pusher->fields.server->origin[i] - 1;
-                               maxs[i] = pushermodel->yawmaxs[i] + pusher->fields.server->origin[i] + 1;
+                               mins[i] = pushermodel->yawmins[i] + move1[i] + PRVM_serveredictvector(pusher, origin)[i] - 1;
+                               maxs[i] = pushermodel->yawmaxs[i] + PRVM_serveredictvector(pusher, origin)[i] + 1;
                        }
                }
        }
@@ -1650,13 +1650,13 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                {
                        if (move1[i] > 0)
                        {
-                               mins[i] = pushermodel->normalmins[i] + pusher->fields.server->origin[i] - 1;
-                               maxs[i] = pushermodel->normalmaxs[i] + move1[i] + pusher->fields.server->origin[i] + 1;
+                               mins[i] = pushermodel->normalmins[i] + PRVM_serveredictvector(pusher, origin)[i] - 1;
+                               maxs[i] = pushermodel->normalmaxs[i] + move1[i] + PRVM_serveredictvector(pusher, origin)[i] + 1;
                        }
                        else
                        {
-                               mins[i] = pushermodel->normalmins[i] + move1[i] + pusher->fields.server->origin[i] - 1;
-                               maxs[i] = pushermodel->normalmaxs[i] + pusher->fields.server->origin[i] + 1;
+                               mins[i] = pushermodel->normalmins[i] + move1[i] + PRVM_serveredictvector(pusher, origin)[i] - 1;
+                               maxs[i] = pushermodel->normalmaxs[i] + PRVM_serveredictvector(pusher, origin)[i] + 1;
                        }
                }
        }
@@ -1664,22 +1664,22 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
        VectorNegate (moveangle, a);
        AngleVectorsFLU (a, forward, left, up);
 
-       VectorCopy (pusher->fields.server->origin, pushorig);
-       VectorCopy (pusher->fields.server->angles, pushang);
-       pushltime = pusher->fields.server->ltime;
+       VectorCopy (PRVM_serveredictvector(pusher, origin), pushorig);
+       VectorCopy (PRVM_serveredictvector(pusher, angles), pushang);
+       pushltime = PRVM_serveredictfloat(pusher, ltime);
 
 // move the pusher to its final position
 
-       VectorMA (pusher->fields.server->origin, movetime, pusher->fields.server->velocity, pusher->fields.server->origin);
-       VectorMA (pusher->fields.server->angles, movetime, pusher->fields.server->avelocity, pusher->fields.server->angles);
-       pusher->fields.server->ltime += movetime;
+       VectorMA (PRVM_serveredictvector(pusher, origin), movetime, PRVM_serveredictvector(pusher, velocity), PRVM_serveredictvector(pusher, origin));
+       VectorMA (PRVM_serveredictvector(pusher, angles), movetime, PRVM_serveredictvector(pusher, avelocity), PRVM_serveredictvector(pusher, angles));
+       PRVM_serveredictfloat(pusher, ltime) += movetime;
        SV_LinkEdict(pusher);
 
        pushermodel = SV_GetModelFromEdict(pusher);
-       Matrix4x4_CreateFromQuakeEntity(&pusherfinalmatrix, pusher->fields.server->origin[0], pusher->fields.server->origin[1], pusher->fields.server->origin[2], pusher->fields.server->angles[0], pusher->fields.server->angles[1], pusher->fields.server->angles[2], 1);
+       Matrix4x4_CreateFromQuakeEntity(&pusherfinalmatrix, PRVM_serveredictvector(pusher, origin)[0], PRVM_serveredictvector(pusher, origin)[1], PRVM_serveredictvector(pusher, origin)[2], PRVM_serveredictvector(pusher, angles)[0], PRVM_serveredictvector(pusher, angles)[1], PRVM_serveredictvector(pusher, angles)[2], 1);
        Matrix4x4_Invert_Simple(&pusherfinalimatrix, &pusherfinalmatrix);
 
-       savesolid = pusher->fields.server->solid;
+       savesolid = PRVM_serveredictfloat(pusher, solid);
 
 // see if any solid entities are inside the final position
        num_moved = 0;
@@ -1688,7 +1688,7 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
        for (e = 0;e < numcheckentities;e++)
        {
                prvm_edict_t *check = checkentities[e];
-               int movetype = (int)check->fields.server->movetype;
+               int movetype = (int)PRVM_serveredictfloat(check, movetype);
                switch(movetype)
                {
                case MOVETYPE_NONE:
@@ -1701,13 +1701,13 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                        break;
                }
 
-               if (check->fields.server->owner == pusherprog)
+               if (PRVM_serveredictedict(check, owner) == pusherprog)
                        continue;
 
                if (pusherowner == PRVM_EDICT_TO_PROG(check))
                        continue;
 
-               //Con_Printf("%i %s ", PRVM_NUM_FOR_EDICT(check), PRVM_GetString(check->fields.server->classname));
+               //Con_Printf("%i %s ", PRVM_NUM_FOR_EDICT(check), PRVM_GetString(PRVM_serveredictstring(check, classname)));
 
                // tell any MOVETYPE_STEP entity that it may need to check for water transitions
                check->priv.server->waterposition_forceupdate = true;
@@ -1717,10 +1717,10 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                // if the entity is standing on the pusher, it will definitely be moved
                // if the entity is not standing on the pusher, but is in the pusher's
                // final position, move it
-               if (!((int)check->fields.server->flags & FL_ONGROUND) || PRVM_PROG_TO_EDICT(check->fields.server->groundentity) != pusher)
+               if (!((int)PRVM_serveredictfloat(check, flags) & FL_ONGROUND) || PRVM_PROG_TO_EDICT(PRVM_serveredictedict(check, groundentity)) != pusher)
                {
-                       Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, pusher->fields.server->mins, pusher->fields.server->maxs, SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, check->fields.server->origin, check->fields.server->mins, check->fields.server->maxs, check->fields.server->origin, checkcontents);
-                       //trace = SV_TraceBox(check->fields.server->origin, check->fields.server->mins, check->fields.server->maxs, check->fields.server->origin, MOVE_NOMONSTERS, check, checkcontents);
+                       Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
+                       //trace = SV_TraceBox(PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), MOVE_NOMONSTERS, check, checkcontents);
                        if (!trace.startsolid)
                        {
                                //Con_Printf("- not in solid\n");
@@ -1731,7 +1731,7 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                if (rotated)
                {
                        vec3_t org2;
-                       VectorSubtract (check->fields.server->origin, pusher->fields.server->origin, org);
+                       VectorSubtract (PRVM_serveredictvector(check, origin), PRVM_serveredictvector(pusher, origin), org);
                        org2[0] = DotProduct (org, forward);
                        org2[1] = DotProduct (org, left);
                        org2[2] = DotProduct (org, up);
@@ -1743,114 +1743,114 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
 
                //Con_Printf("- pushing %f %f %f\n", move[0], move[1], move[2]);
 
-               VectorCopy (check->fields.server->origin, check->priv.server->moved_from);
-               VectorCopy (check->fields.server->angles, check->priv.server->moved_fromangles);
+               VectorCopy (PRVM_serveredictvector(check, origin), check->priv.server->moved_from);
+               VectorCopy (PRVM_serveredictvector(check, angles), check->priv.server->moved_fromangles);
                moved_edicts[num_moved++] = PRVM_NUM_FOR_EDICT(check);
 
                // physics objects need better collisions than this code can do
                if (movetype == MOVETYPE_PHYSICS)
                {
-                       VectorAdd(check->fields.server->origin, move, check->fields.server->origin);
+                       VectorAdd(PRVM_serveredictvector(check, origin), move, PRVM_serveredictvector(check, origin));
                        SV_LinkEdict(check);
                        SV_LinkEdict_TouchAreaGrid(check);
                        continue;
                }
 
                // try moving the contacted entity
-               pusher->fields.server->solid = SOLID_NOT;
+               PRVM_serveredictfloat(pusher, solid) = SOLID_NOT;
                if(!SV_PushEntity (&trace, check, move, true, true))
                {
                        // entity "check" got teleported
-                       check->fields.server->angles[1] += trace.fraction * moveangle[1];
-                       pusher->fields.server->solid = savesolid; // was SOLID_BSP
+                       PRVM_serveredictvector(check, angles)[1] += trace.fraction * moveangle[1];
+                       PRVM_serveredictfloat(pusher, solid) = savesolid; // was SOLID_BSP
                        continue; // pushed enough
                }
                // FIXME: turn players specially
-               check->fields.server->angles[1] += trace.fraction * moveangle[1];
-               pusher->fields.server->solid = savesolid; // was SOLID_BSP
+               PRVM_serveredictvector(check, angles)[1] += trace.fraction * moveangle[1];
+               PRVM_serveredictfloat(pusher, solid) = savesolid; // was SOLID_BSP
                //Con_Printf("%s:%d frac %f startsolid %d bmodelstartsolid %d allsolid %d\n", __FILE__, __LINE__, trace.fraction, trace.startsolid, trace.bmodelstartsolid, trace.allsolid);
 
                // this trace.fraction < 1 check causes items to fall off of pushers
                // if they pass under or through a wall
                // the groundentity check causes items to fall off of ledges
-               if (check->fields.server->movetype != MOVETYPE_WALK && (trace.fraction < 1 || PRVM_PROG_TO_EDICT(check->fields.server->groundentity) != pusher))
-                       check->fields.server->flags = (int)check->fields.server->flags & ~FL_ONGROUND;
+               if (PRVM_serveredictfloat(check, movetype) != MOVETYPE_WALK && (trace.fraction < 1 || PRVM_PROG_TO_EDICT(PRVM_serveredictedict(check, groundentity)) != pusher))
+                       PRVM_serveredictfloat(check, flags) = (int)PRVM_serveredictfloat(check, flags) & ~FL_ONGROUND;
 
                // if it is still inside the pusher, block
-               Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, pusher->fields.server->mins, pusher->fields.server->maxs, SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, check->fields.server->origin, check->fields.server->mins, check->fields.server->maxs, check->fields.server->origin, checkcontents);
+               Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
                if (trace.startsolid)
                {
                        // try moving the contacted entity a tiny bit further to account for precision errors
                        vec3_t move2;
-                       pusher->fields.server->solid = SOLID_NOT;
+                       PRVM_serveredictfloat(pusher, solid) = SOLID_NOT;
                        VectorScale(move, 1.1, move2);
-                       VectorCopy (check->priv.server->moved_from, check->fields.server->origin);
-                       VectorCopy (check->priv.server->moved_fromangles, check->fields.server->angles);
+                       VectorCopy (check->priv.server->moved_from, PRVM_serveredictvector(check, origin));
+                       VectorCopy (check->priv.server->moved_fromangles, PRVM_serveredictvector(check, angles));
                        if(!SV_PushEntity (&trace2, check, move2, true, true))
                        {
                                // entity "check" got teleported
                                continue;
                        }
-                       pusher->fields.server->solid = savesolid;
-                       Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, pusher->fields.server->mins, pusher->fields.server->maxs, SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, check->fields.server->origin, check->fields.server->mins, check->fields.server->maxs, check->fields.server->origin, checkcontents);
+                       PRVM_serveredictfloat(pusher, solid) = savesolid;
+                       Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
                        if (trace.startsolid)
                        {
                                // try moving the contacted entity a tiny bit less to account for precision errors
-                               pusher->fields.server->solid = SOLID_NOT;
+                               PRVM_serveredictfloat(pusher, solid) = SOLID_NOT;
                                VectorScale(move, 0.9, move2);
-                               VectorCopy (check->priv.server->moved_from, check->fields.server->origin);
-                               VectorCopy (check->priv.server->moved_fromangles, check->fields.server->angles);
+                               VectorCopy (check->priv.server->moved_from, PRVM_serveredictvector(check, origin));
+                               VectorCopy (check->priv.server->moved_fromangles, PRVM_serveredictvector(check, angles));
                                if(!SV_PushEntity (&trace2, check, move2, true, true))
                                {
                                        // entity "check" got teleported
                                        continue;
                                }
-                               pusher->fields.server->solid = savesolid;
-                               Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, pusher->fields.server->mins, pusher->fields.server->maxs, SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, check->fields.server->origin, check->fields.server->mins, check->fields.server->maxs, check->fields.server->origin, checkcontents);
+                               PRVM_serveredictfloat(pusher, solid) = savesolid;
+                               Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
                                if (trace.startsolid)
                                {
                                        // still inside pusher, so it's really blocked
 
                                        // fail the move
-                                       if (check->fields.server->mins[0] == check->fields.server->maxs[0])
+                                       if (PRVM_serveredictvector(check, mins)[0] == PRVM_serveredictvector(check, maxs)[0])
                                                continue;
-                                       if (check->fields.server->solid == SOLID_NOT || check->fields.server->solid == SOLID_TRIGGER)
+                                       if (PRVM_serveredictfloat(check, solid) == SOLID_NOT || PRVM_serveredictfloat(check, solid) == SOLID_TRIGGER)
                                        {
                                                // corpse
-                                               check->fields.server->mins[0] = check->fields.server->mins[1] = 0;
-                                               VectorCopy (check->fields.server->mins, check->fields.server->maxs);
+                                               PRVM_serveredictvector(check, mins)[0] = PRVM_serveredictvector(check, mins)[1] = 0;
+                                               VectorCopy (PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs));
                                                continue;
                                        }
 
-                                       VectorCopy (pushorig, pusher->fields.server->origin);
-                                       VectorCopy (pushang, pusher->fields.server->angles);
-                                       pusher->fields.server->ltime = pushltime;
+                                       VectorCopy (pushorig, PRVM_serveredictvector(pusher, origin));
+                                       VectorCopy (pushang, PRVM_serveredictvector(pusher, angles));
+                                       PRVM_serveredictfloat(pusher, ltime) = pushltime;
                                        SV_LinkEdict(pusher);
 
                                        // move back any entities we already moved
                                        for (i = 0;i < num_moved;i++)
                                        {
                                                prvm_edict_t *ed = PRVM_EDICT_NUM(moved_edicts[i]);
-                                               VectorCopy (ed->priv.server->moved_from, ed->fields.server->origin);
-                                               VectorCopy (ed->priv.server->moved_fromangles, ed->fields.server->angles);
+                                               VectorCopy (ed->priv.server->moved_from, PRVM_serveredictvector(ed, origin));
+                                               VectorCopy (ed->priv.server->moved_fromangles, PRVM_serveredictvector(ed, angles));
                                                SV_LinkEdict(ed);
                                        }
 
                                        // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone
-                                       if (pusher->fields.server->blocked)
+                                       if (PRVM_serveredictfunction(pusher, blocked))
                                        {
-                                               prog->globals.server->self = PRVM_EDICT_TO_PROG(pusher);
-                                               prog->globals.server->other = PRVM_EDICT_TO_PROG(check);
-                                               PRVM_ExecuteProgram (pusher->fields.server->blocked, "QC function self.blocked is missing");
+                                               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(pusher);
+                                               PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(check);
+                                               PRVM_ExecuteProgram (PRVM_serveredictfunction(pusher, blocked), "QC function self.blocked is missing");
                                        }
                                        break;
                                }
                        }
                }
        }
-       pusher->fields.server->angles[0] -= 360.0 * floor(pusher->fields.server->angles[0] * (1.0 / 360.0));
-       pusher->fields.server->angles[1] -= 360.0 * floor(pusher->fields.server->angles[1] * (1.0 / 360.0));
-       pusher->fields.server->angles[2] -= 360.0 * floor(pusher->fields.server->angles[2] * (1.0 / 360.0));
+       PRVM_serveredictvector(pusher, angles)[0] -= 360.0 * floor(PRVM_serveredictvector(pusher, angles)[0] * (1.0 / 360.0));
+       PRVM_serveredictvector(pusher, angles)[1] -= 360.0 * floor(PRVM_serveredictvector(pusher, angles)[1] * (1.0 / 360.0));
+       PRVM_serveredictvector(pusher, angles)[2] -= 360.0 * floor(PRVM_serveredictvector(pusher, angles)[2] * (1.0 / 360.0));
 }
 
 /*
@@ -1863,12 +1863,12 @@ void SV_Physics_Pusher (prvm_edict_t *ent)
 {
        float thinktime, oldltime, movetime;
 
-       oldltime = ent->fields.server->ltime;
+       oldltime = PRVM_serveredictfloat(ent, ltime);
 
-       thinktime = ent->fields.server->nextthink;
-       if (thinktime < ent->fields.server->ltime + sv.frametime)
+       thinktime = PRVM_serveredictfloat(ent, nextthink);
+       if (thinktime < PRVM_serveredictfloat(ent, ltime) + sv.frametime)
        {
-               movetime = thinktime - ent->fields.server->ltime;
+               movetime = thinktime - PRVM_serveredictfloat(ent, ltime);
                if (movetime < 0)
                        movetime = 0;
        }
@@ -1876,16 +1876,16 @@ void SV_Physics_Pusher (prvm_edict_t *ent)
                movetime = sv.frametime;
 
        if (movetime)
-               // advances ent->fields.server->ltime if not blocked
+               // advances PRVM_serveredictfloat(ent, ltime) if not blocked
                SV_PushMove (ent, movetime);
 
-       if (thinktime > oldltime && thinktime <= ent->fields.server->ltime)
+       if (thinktime > oldltime && thinktime <= PRVM_serveredictfloat(ent, ltime))
        {
-               ent->fields.server->nextthink = 0;
-               prog->globals.server->time = sv.time;
-               prog->globals.server->self = PRVM_EDICT_TO_PROG(ent);
-               prog->globals.server->other = PRVM_EDICT_TO_PROG(prog->edicts);
-               PRVM_ExecuteProgram (ent->fields.server->think, "QC function self.think is missing");
+               PRVM_serveredictfloat(ent, nextthink) = 0;
+               PRVM_serverglobalfloat(time) = sv.time;
+               PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent);
+               PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(prog->edicts);
+               PRVM_ExecuteProgram (PRVM_serveredictfunction(ent, think), "QC function self.think is missing");
        }
 }
 
@@ -1942,7 +1942,7 @@ unstickresult_t SV_UnstickEntityReturnOffset (prvm_edict_t *ent, vec3_t offset)
                }
        }
 
-       maxunstick = (int) ((ent->fields.server->maxs[2] - ent->fields.server->mins[2]) * 0.36);
+       maxunstick = (int) ((PRVM_serveredictvector(ent, maxs)[2] - PRVM_serveredictvector(ent, mins)[2]) * 0.36);
        // magic number 0.36 allows unsticking by up to 17 units with the largest supported bbox
 
        for(i = 2; i <= maxunstick; ++i)
@@ -1975,11 +1975,11 @@ qboolean SV_UnstickEntity (prvm_edict_t *ent)
                case UNSTICK_GOOD:
                        return true;
                case UNSTICK_UNSTUCK:
-                       Con_DPrintf("Unstuck entity %i (classname \"%s\") with offset %f %f %f.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname), offset[0], offset[1], offset[2]);
+                       Con_DPrintf("Unstuck entity %i (classname \"%s\") with offset %f %f %f.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(PRVM_serveredictstring(ent, classname)), offset[0], offset[1], offset[2]);
                        return true;
                case UNSTICK_STUCK:
                        if (developer_extra.integer)
-                               Con_DPrintf("Stuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname));
+                               Con_DPrintf("Stuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(PRVM_serveredictstring(ent, classname)));
                        return false;
                default:
                        Con_Printf("SV_UnstickEntityReturnOffset returned a value outside its enum.\n");
@@ -2002,21 +2002,21 @@ void SV_CheckStuck (prvm_edict_t *ent)
        switch(SV_UnstickEntityReturnOffset(ent, offset))
        {
                case UNSTICK_GOOD:
-                       VectorCopy (ent->fields.server->origin, ent->fields.server->oldorigin);
+                       VectorCopy (PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, oldorigin));
                        break;
                case UNSTICK_UNSTUCK:
-                       Con_DPrintf("Unstuck player entity %i (classname \"%s\") with offset %f %f %f.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname), offset[0], offset[1], offset[2]);
+                       Con_DPrintf("Unstuck player entity %i (classname \"%s\") with offset %f %f %f.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(PRVM_serveredictstring(ent, classname)), offset[0], offset[1], offset[2]);
                        break;
                case UNSTICK_STUCK:
-                       VectorSubtract(ent->fields.server->oldorigin, ent->fields.server->origin, offset);
+                       VectorSubtract(PRVM_serveredictvector(ent, oldorigin), PRVM_serveredictvector(ent, origin), offset);
                        if (!SV_TestEntityPosition(ent, offset))
                        {
-                               Con_DPrintf("Unstuck player entity %i (classname \"%s\") by restoring oldorigin.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname));
+                               Con_DPrintf("Unstuck player entity %i (classname \"%s\") by restoring oldorigin.\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(PRVM_serveredictstring(ent, classname)));
                                SV_LinkEdict(ent);
                                //SV_LinkEdict_TouchAreaGrid(ent);
                        }
                        else
-                               Con_DPrintf("Stuck player entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname));
+                               Con_DPrintf("Stuck player entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(PRVM_serveredictstring(ent, classname)));
                        break;
                default:
                        Con_Printf("SV_UnstickEntityReturnOffset returned a value outside its enum.\n");
@@ -2035,9 +2035,9 @@ qboolean SV_CheckWater (prvm_edict_t *ent)
        int nNativeContents;
        vec3_t point;
 
-       point[0] = ent->fields.server->origin[0];
-       point[1] = ent->fields.server->origin[1];
-       point[2] = ent->fields.server->origin[2] + ent->fields.server->mins[2] + 1;
+       point[0] = PRVM_serveredictvector(ent, origin)[0];
+       point[1] = PRVM_serveredictvector(ent, origin)[1];
+       point[2] = PRVM_serveredictvector(ent, origin)[2] + PRVM_serveredictvector(ent, mins)[2] + 1;
 
        // DRESK - Support for Entity Contents Transition Event
        // NOTE: Some logic needed to be slightly re-ordered
@@ -2049,29 +2049,29 @@ qboolean SV_CheckWater (prvm_edict_t *ent)
        nNativeContents = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, cont);
 
        // DRESK - Support for Entity Contents Transition Event
-       if(ent->fields.server->watertype)
+       if(PRVM_serveredictfloat(ent, watertype))
                // Entity did NOT Spawn; Check
                SV_CheckContentsTransition(ent, nNativeContents);
 
 
-       ent->fields.server->waterlevel = 0;
-       ent->fields.server->watertype = CONTENTS_EMPTY;
+       PRVM_serveredictfloat(ent, waterlevel) = 0;
+       PRVM_serveredictfloat(ent, watertype) = CONTENTS_EMPTY;
        cont = SV_PointSuperContents(point);
        if (cont & (SUPERCONTENTS_LIQUIDSMASK))
        {
-               ent->fields.server->watertype = nNativeContents;
-               ent->fields.server->waterlevel = 1;
-               point[2] = ent->fields.server->origin[2] + (ent->fields.server->mins[2] + ent->fields.server->maxs[2])*0.5;
+               PRVM_serveredictfloat(ent, watertype) = nNativeContents;
+               PRVM_serveredictfloat(ent, waterlevel) = 1;
+               point[2] = PRVM_serveredictvector(ent, origin)[2] + (PRVM_serveredictvector(ent, mins)[2] + PRVM_serveredictvector(ent, maxs)[2])*0.5;
                if (SV_PointSuperContents(point) & (SUPERCONTENTS_LIQUIDSMASK))
                {
-                       ent->fields.server->waterlevel = 2;
-                       point[2] = ent->fields.server->origin[2] + ent->fields.server->view_ofs[2];
+                       PRVM_serveredictfloat(ent, waterlevel) = 2;
+                       point[2] = PRVM_serveredictvector(ent, origin)[2] + PRVM_serveredictvector(ent, view_ofs)[2];
                        if (SV_PointSuperContents(point) & (SUPERCONTENTS_LIQUIDSMASK))
-                               ent->fields.server->waterlevel = 3;
+                               PRVM_serveredictfloat(ent, waterlevel) = 3;
                }
        }
 
-       return ent->fields.server->waterlevel > 1;
+       return PRVM_serveredictfloat(ent, waterlevel) > 1;
 }
 
 /*
@@ -2085,15 +2085,15 @@ void SV_WallFriction (prvm_edict_t *ent, float *stepnormal)
        float d, i;
        vec3_t forward, into, side;
 
-       AngleVectors (ent->fields.server->v_angle, forward, NULL, NULL);
+       AngleVectors (PRVM_serveredictvector(ent, v_angle), forward, NULL, NULL);
        if ((d = DotProduct (stepnormal, forward) + 0.5) < 0)
        {
                // cut the tangential velocity
-               i = DotProduct (stepnormal, ent->fields.server->velocity);
+               i = DotProduct (stepnormal, PRVM_serveredictvector(ent, velocity));
                VectorScale (stepnormal, i, into);
-               VectorSubtract (ent->fields.server->velocity, into, side);
-               ent->fields.server->velocity[0] = side[0] * (1 + d);
-               ent->fields.server->velocity[1] = side[1] * (1 + d);
+               VectorSubtract (PRVM_serveredictvector(ent, velocity), into, side);
+               PRVM_serveredictvector(ent, velocity)[0] = side[0] * (1 + d);
+               PRVM_serveredictvector(ent, velocity)[1] = side[1] * (1 + d);
        }
 }
 
@@ -2115,7 +2115,7 @@ int SV_TryUnstick (prvm_edict_t *ent, vec3_t oldvel)
        int i, clip;
        vec3_t oldorg, dir;
 
-       VectorCopy (ent->fields.server->origin, oldorg);
+       VectorCopy (PRVM_serveredictvector(ent, origin), oldorg);
        VectorClear (dir);
 
        for (i=0 ; i<8 ; i++)
@@ -2136,24 +2136,24 @@ int SV_TryUnstick (prvm_edict_t *ent, vec3_t oldvel)
                SV_PushEntity (&trace, ent, dir, false, true);
 
                // retry the original move
-               ent->fields.server->velocity[0] = oldvel[0];
-               ent->fields.server->velocity[1] = oldvel[1];
-               ent->fields.server->velocity[2] = 0;
+               PRVM_serveredictvector(ent, velocity)[0] = oldvel[0];
+               PRVM_serveredictvector(ent, velocity)[1] = oldvel[1];
+               PRVM_serveredictvector(ent, velocity)[2] = 0;
                clip = SV_FlyMove (ent, 0.1, NULL, SV_GenericHitSuperContentsMask(ent));
 
-               if (fabs(oldorg[1] - ent->fields.server->origin[1]) > 4
-                || fabs(oldorg[0] - ent->fields.server->origin[0]) > 4)
+               if (fabs(oldorg[1] - PRVM_serveredictvector(ent, origin)[1]) > 4
+                || fabs(oldorg[0] - PRVM_serveredictvector(ent, origin)[0]) > 4)
                {
                        Con_DPrint("TryUnstick - success.\n");
                        return clip;
                }
 
                // go back to the original pos and try again
-               VectorCopy (oldorg, ent->fields.server->origin);
+               VectorCopy (oldorg, PRVM_serveredictvector(ent, origin));
        }
 
        // still not moving
-       VectorClear (ent->fields.server->velocity);
+       VectorClear (PRVM_serveredictvector(ent, velocity));
        Con_DPrint("TryUnstick - failure.\n");
        return 7;
 }
@@ -2186,17 +2186,17 @@ void SV_WalkMove (prvm_edict_t *ent)
 
        SV_CheckStuck (ent);
 
-       applygravity = !SV_CheckWater (ent) && ent->fields.server->movetype == MOVETYPE_WALK && ! ((int)ent->fields.server->flags & FL_WATERJUMP);
+       applygravity = !SV_CheckWater (ent) && PRVM_serveredictfloat(ent, movetype) == MOVETYPE_WALK && ! ((int)PRVM_serveredictfloat(ent, flags) & FL_WATERJUMP);
 
        hitsupercontentsmask = SV_GenericHitSuperContentsMask(ent);
 
        SV_CheckVelocity(ent);
 
        // do a regular slide move unless it looks like you ran into a step
-       oldonground = (int)ent->fields.server->flags & FL_ONGROUND;
+       oldonground = (int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND;
 
-       VectorCopy (ent->fields.server->origin, start_origin);
-       VectorCopy (ent->fields.server->velocity, start_velocity);
+       VectorCopy (PRVM_serveredictvector(ent, origin), start_origin);
+       VectorCopy (PRVM_serveredictvector(ent, velocity), start_velocity);
 
        clip = SV_FlyMove (ent, sv.frametime, applygravity, NULL, hitsupercontentsmask, sv_gameplayfix_stepmultipletimes.integer ? sv_stepheight.value : 0);
 
@@ -2206,22 +2206,22 @@ void SV_WalkMove (prvm_edict_t *ent)
                // only try this if there was no floor in the way in the trace (no,
                // this check seems to be not REALLY necessary, because if clip & 1,
                // our trace will hit that thing too)
-               VectorSet(upmove, ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2] + 1);
-               VectorSet(downmove, ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2] - 1);
-               if (ent->fields.server->movetype == MOVETYPE_FLYMISSILE)
+               VectorSet(upmove, PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2] + 1);
+               VectorSet(downmove, PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2] - 1);
+               if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLYMISSILE)
                        type = MOVE_MISSILE;
-               else if (ent->fields.server->solid == SOLID_TRIGGER || ent->fields.server->solid == SOLID_NOT)
+               else if (PRVM_serveredictfloat(ent, solid) == SOLID_TRIGGER || PRVM_serveredictfloat(ent, solid) == SOLID_NOT)
                        type = MOVE_NOMONSTERS; // only clip against bmodels
                else
                        type = MOVE_NORMAL;
-               trace = SV_TraceBox(upmove, ent->fields.server->mins, ent->fields.server->maxs, downmove, type, ent, SV_GenericHitSuperContentsMask(ent));
+               trace = SV_TraceBox(upmove, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), downmove, type, ent, SV_GenericHitSuperContentsMask(ent));
                if(trace.fraction < 1 && trace.plane.normal[2] > 0.7)
                        clip |= 1; // but we HAVE found a floor
        }
 
        // if the move did not hit the ground at any point, we're not on ground
        if(!(clip & 1))
-               ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND;
+               PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
 
        SV_CheckVelocity(ent);
        SV_LinkEdict(ent);
@@ -2230,17 +2230,17 @@ void SV_WalkMove (prvm_edict_t *ent)
        if(clip & 8) // teleport
                return;
 
-       if ((int)ent->fields.server->flags & FL_WATERJUMP)
+       if ((int)PRVM_serveredictfloat(ent, flags) & FL_WATERJUMP)
                return;
 
        if (sv_nostep.integer)
                return;
 
-       VectorCopy(ent->fields.server->origin, originalmove_origin);
-       VectorCopy(ent->fields.server->velocity, originalmove_velocity);
+       VectorCopy(PRVM_serveredictvector(ent, origin), originalmove_origin);
+       VectorCopy(PRVM_serveredictvector(ent, velocity), originalmove_velocity);
        //originalmove_clip = clip;
-       originalmove_flags = (int)ent->fields.server->flags;
-       originalmove_groundentity = ent->fields.server->groundentity;
+       originalmove_flags = (int)PRVM_serveredictfloat(ent, flags);
+       originalmove_groundentity = PRVM_serveredictedict(ent, groundentity);
 
        // if move didn't block on a step, return
        if (clip & 2)
@@ -2249,22 +2249,22 @@ void SV_WalkMove (prvm_edict_t *ent)
                if (fabs(start_velocity[0]) < 0.03125 && fabs(start_velocity[1]) < 0.03125)
                        return;
 
-               if (ent->fields.server->movetype != MOVETYPE_FLY)
+               if (PRVM_serveredictfloat(ent, movetype) != MOVETYPE_FLY)
                {
                        // return if gibbed by a trigger
-                       if (ent->fields.server->movetype != MOVETYPE_WALK)
+                       if (PRVM_serveredictfloat(ent, movetype) != MOVETYPE_WALK)
                                return;
 
                        // only step up while jumping if that is enabled
                        if (!(sv_jumpstep.integer && sv_gameplayfix_stepwhilejumping.integer))
-                               if (!oldonground && ent->fields.server->waterlevel == 0)
+                               if (!oldonground && PRVM_serveredictfloat(ent, waterlevel) == 0)
                                        return;
                }
 
                // try moving up and forward to go up a step
                // back to start pos
-               VectorCopy (start_origin, ent->fields.server->origin);
-               VectorCopy (start_velocity, ent->fields.server->velocity);
+               VectorCopy (start_origin, PRVM_serveredictvector(ent, origin));
+               VectorCopy (start_velocity, PRVM_serveredictvector(ent, velocity));
 
                // move up
                VectorClear (upmove);
@@ -2276,9 +2276,9 @@ void SV_WalkMove (prvm_edict_t *ent)
                }
 
                // move forward
-               ent->fields.server->velocity[2] = 0;
+               PRVM_serveredictvector(ent, velocity)[2] = 0;
                clip = SV_FlyMove (ent, sv.frametime, applygravity, stepnormal, hitsupercontentsmask, 0);
-               ent->fields.server->velocity[2] += start_velocity[2];
+               PRVM_serveredictvector(ent, velocity)[2] += start_velocity[2];
                if(clip & 8)
                {
                        // we got teleported when upstepping... must abort the move
@@ -2293,16 +2293,16 @@ void SV_WalkMove (prvm_edict_t *ent)
                // check for stuckness, possibly due to the limited precision of floats
                // in the clipping hulls
                if (clip
-                && fabs(originalmove_origin[1] - ent->fields.server->origin[1]) < 0.03125
-                && fabs(originalmove_origin[0] - ent->fields.server->origin[0]) < 0.03125)
+                && fabs(originalmove_origin[1] - PRVM_serveredictvector(ent, origin)[1]) < 0.03125
+                && fabs(originalmove_origin[0] - PRVM_serveredictvector(ent, origin)[0]) < 0.03125)
                {
                        //Con_Printf("wall\n");
                        // stepping up didn't make any progress, revert to original move
-                       VectorCopy(originalmove_origin, ent->fields.server->origin);
-                       VectorCopy(originalmove_velocity, ent->fields.server->velocity);
+                       VectorCopy(originalmove_origin, PRVM_serveredictvector(ent, origin));
+                       VectorCopy(originalmove_velocity, PRVM_serveredictvector(ent, velocity));
                        //clip = originalmove_clip;
-                       ent->fields.server->flags = originalmove_flags;
-                       ent->fields.server->groundentity = originalmove_groundentity;
+                       PRVM_serveredictfloat(ent, flags) = originalmove_flags;
+                       PRVM_serveredictedict(ent, groundentity) = originalmove_groundentity;
                        // now try to unstick if needed
                        //clip = SV_TryUnstick (ent, oldvel);
                        return;
@@ -2315,7 +2315,7 @@ void SV_WalkMove (prvm_edict_t *ent)
                        SV_WallFriction (ent, stepnormal);
        }
        // don't do the down move if stepdown is disabled, moving upward, not in water, or the move started offground or ended onground
-       else if (!sv_gameplayfix_stepdown.integer || ent->fields.server->waterlevel >= 3 || start_velocity[2] >= (1.0 / 32.0) || !oldonground || ((int)ent->fields.server->flags & FL_ONGROUND))
+       else if (!sv_gameplayfix_stepdown.integer || PRVM_serveredictfloat(ent, waterlevel) >= 3 || start_velocity[2] >= (1.0 / 32.0) || !oldonground || ((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND))
                return;
 
        // move down
@@ -2333,11 +2333,11 @@ void SV_WalkMove (prvm_edict_t *ent)
                // up while already jumping (also known as the Quake2 double jump bug)
 #if 0
                // LordHavoc: disabled this check so you can walk on monsters/players
-               //if (ent->fields.server->solid == SOLID_BSP)
+               //if (PRVM_serveredictfloat(ent, solid) == SOLID_BSP)
                {
                        //Con_Printf("onground\n");
-                       ent->fields.server->flags =     (int)ent->fields.server->flags | FL_ONGROUND;
-                       ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(downtrace.ent);
+                       PRVM_serveredictfloat(ent, flags) =     (int)PRVM_serveredictfloat(ent, flags) | FL_ONGROUND;
+                       PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(downtrace.ent);
                }
 #endif
        }
@@ -2347,11 +2347,11 @@ void SV_WalkMove (prvm_edict_t *ent)
                // if the push down didn't end up on good ground, use the move without
                // the step up.  This happens near wall / slope combinations, and can
                // cause the player to hop up higher on a slope too steep to climb
-               VectorCopy(originalmove_origin, ent->fields.server->origin);
-               VectorCopy(originalmove_velocity, ent->fields.server->velocity);
+               VectorCopy(originalmove_origin, PRVM_serveredictvector(ent, origin));
+               VectorCopy(originalmove_velocity, PRVM_serveredictvector(ent, velocity));
                //clip = originalmove_clip;
-               ent->fields.server->flags = originalmove_flags;
-               ent->fields.server->groundentity = originalmove_groundentity;
+               PRVM_serveredictfloat(ent, flags) = originalmove_flags;
+               PRVM_serveredictedict(ent, groundentity) = originalmove_groundentity;
        }
 
        SV_CheckVelocity(ent);
@@ -2378,30 +2378,30 @@ void SV_Physics_Follow (prvm_edict_t *ent)
                return;
 
        // LordHavoc: implemented rotation on MOVETYPE_FOLLOW objects
-       e = PRVM_PROG_TO_EDICT(ent->fields.server->aiment);
-       if (e->fields.server->angles[0] == ent->fields.server->punchangle[0] && e->fields.server->angles[1] == ent->fields.server->punchangle[1] && e->fields.server->angles[2] == ent->fields.server->punchangle[2])
+       e = PRVM_PROG_TO_EDICT(PRVM_serveredictedict(ent, aiment));
+       if (PRVM_serveredictvector(e, angles)[0] == PRVM_serveredictvector(ent, punchangle)[0] && PRVM_serveredictvector(e, angles)[1] == PRVM_serveredictvector(ent, punchangle)[1] && PRVM_serveredictvector(e, angles)[2] == PRVM_serveredictvector(ent, punchangle)[2])
        {
                // quick case for no rotation
-               VectorAdd(e->fields.server->origin, ent->fields.server->view_ofs, ent->fields.server->origin);
+               VectorAdd(PRVM_serveredictvector(e, origin), PRVM_serveredictvector(ent, view_ofs), PRVM_serveredictvector(ent, origin));
        }
        else
        {
-               angles[0] = -ent->fields.server->punchangle[0];
-               angles[1] =  ent->fields.server->punchangle[1];
-               angles[2] =  ent->fields.server->punchangle[2];
+               angles[0] = -PRVM_serveredictvector(ent, punchangle)[0];
+               angles[1] =  PRVM_serveredictvector(ent, punchangle)[1];
+               angles[2] =  PRVM_serveredictvector(ent, punchangle)[2];
                AngleVectors (angles, vf, vr, vu);
-               v[0] = ent->fields.server->view_ofs[0] * vf[0] + ent->fields.server->view_ofs[1] * vr[0] + ent->fields.server->view_ofs[2] * vu[0];
-               v[1] = ent->fields.server->view_ofs[0] * vf[1] + ent->fields.server->view_ofs[1] * vr[1] + ent->fields.server->view_ofs[2] * vu[1];
-               v[2] = ent->fields.server->view_ofs[0] * vf[2] + ent->fields.server->view_ofs[1] * vr[2] + ent->fields.server->view_ofs[2] * vu[2];
-               angles[0] = -e->fields.server->angles[0];
-               angles[1] =  e->fields.server->angles[1];
-               angles[2] =  e->fields.server->angles[2];
+               v[0] = PRVM_serveredictvector(ent, view_ofs)[0] * vf[0] + PRVM_serveredictvector(ent, view_ofs)[1] * vr[0] + PRVM_serveredictvector(ent, view_ofs)[2] * vu[0];
+               v[1] = PRVM_serveredictvector(ent, view_ofs)[0] * vf[1] + PRVM_serveredictvector(ent, view_ofs)[1] * vr[1] + PRVM_serveredictvector(ent, view_ofs)[2] * vu[1];
+               v[2] = PRVM_serveredictvector(ent, view_ofs)[0] * vf[2] + PRVM_serveredictvector(ent, view_ofs)[1] * vr[2] + PRVM_serveredictvector(ent, view_ofs)[2] * vu[2];
+               angles[0] = -PRVM_serveredictvector(e, angles)[0];
+               angles[1] =  PRVM_serveredictvector(e, angles)[1];
+               angles[2] =  PRVM_serveredictvector(e, angles)[2];
                AngleVectors (angles, vf, vr, vu);
-               ent->fields.server->origin[0] = v[0] * vf[0] + v[1] * vf[1] + v[2] * vf[2] + e->fields.server->origin[0];
-               ent->fields.server->origin[1] = v[0] * vr[0] + v[1] * vr[1] + v[2] * vr[2] + e->fields.server->origin[1];
-               ent->fields.server->origin[2] = v[0] * vu[0] + v[1] * vu[1] + v[2] * vu[2] + e->fields.server->origin[2];
+               PRVM_serveredictvector(ent, origin)[0] = v[0] * vf[0] + v[1] * vf[1] + v[2] * vf[2] + PRVM_serveredictvector(e, origin)[0];
+               PRVM_serveredictvector(ent, origin)[1] = v[0] * vr[0] + v[1] * vr[1] + v[2] * vr[2] + PRVM_serveredictvector(e, origin)[1];
+               PRVM_serveredictvector(ent, origin)[2] = v[0] * vu[0] + v[1] * vu[1] + v[2] * vu[2] + PRVM_serveredictvector(e, origin)[2];
        }
-       VectorAdd (e->fields.server->angles, ent->fields.server->v_angle, ent->fields.server->angles);
+       VectorAdd (PRVM_serveredictvector(e, angles), PRVM_serveredictvector(ent, v_angle), PRVM_serveredictvector(ent, angles));
        SV_LinkEdict(ent);
        //SV_LinkEdict_TouchAreaGrid(ent);
 }
@@ -2423,12 +2423,12 @@ SV_CheckWaterTransition
 void SV_CheckWaterTransition (prvm_edict_t *ent)
 {
        int cont;
-       cont = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, SV_PointSuperContents(ent->fields.server->origin));
-       if (!ent->fields.server->watertype)
+       cont = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, SV_PointSuperContents(PRVM_serveredictvector(ent, origin)));
+       if (!PRVM_serveredictfloat(ent, watertype))
        {
                // just spawned here
-               ent->fields.server->watertype = cont;
-               ent->fields.server->waterlevel = 1;
+               PRVM_serveredictfloat(ent, watertype) = cont;
+               PRVM_serveredictfloat(ent, waterlevel) = 1;
                return;
        }
 
@@ -2439,19 +2439,19 @@ void SV_CheckWaterTransition (prvm_edict_t *ent)
        if( !SV_CheckContentsTransition(ent, cont) )
        { // Contents Transition Function Invalid; Potentially Play Water Sound
                // check if the entity crossed into or out of water
-               if (sv_sound_watersplash.string && ((ent->fields.server->watertype == CONTENTS_WATER || ent->fields.server->watertype == CONTENTS_SLIME) != (cont == CONTENTS_WATER || cont == CONTENTS_SLIME)))
+               if (sv_sound_watersplash.string && ((PRVM_serveredictfloat(ent, watertype) == CONTENTS_WATER || PRVM_serveredictfloat(ent, watertype) == CONTENTS_SLIME) != (cont == CONTENTS_WATER || cont == CONTENTS_SLIME)))
                        SV_StartSound (ent, 0, sv_sound_watersplash.string, 255, 1);
        }
 
        if (cont <= CONTENTS_WATER)
        {
-               ent->fields.server->watertype = cont;
-               ent->fields.server->waterlevel = 1;
+               PRVM_serveredictfloat(ent, watertype) = cont;
+               PRVM_serveredictfloat(ent, waterlevel) = 1;
        }
        else
        {
-               ent->fields.server->watertype = CONTENTS_EMPTY;
-               ent->fields.server->waterlevel = 0;
+               PRVM_serveredictfloat(ent, watertype) = CONTENTS_EMPTY;
+               PRVM_serveredictfloat(ent, waterlevel) = 0;
        }
 }
 
@@ -2471,15 +2471,15 @@ void SV_Physics_Toss (prvm_edict_t *ent)
        prvm_edict_t *groundentity;
 
 // if onground, return without moving
-       if ((int)ent->fields.server->flags & FL_ONGROUND)
+       if ((int)PRVM_serveredictfloat(ent, flags) & FL_ONGROUND)
        {
-               groundentity = PRVM_PROG_TO_EDICT(ent->fields.server->groundentity);
-               if (ent->fields.server->velocity[2] >= (1.0 / 32.0) && sv_gameplayfix_upwardvelocityclearsongroundflag.integer)
+               groundentity = PRVM_PROG_TO_EDICT(PRVM_serveredictedict(ent, groundentity));
+               if (PRVM_serveredictvector(ent, velocity)[2] >= (1.0 / 32.0) && sv_gameplayfix_upwardvelocityclearsongroundflag.integer)
                {
                        // don't stick to ground if onground and moving upward
-                       ent->fields.server->flags -= FL_ONGROUND;
+                       PRVM_serveredictfloat(ent, flags) -= FL_ONGROUND;
                }
-               else if (!ent->fields.server->groundentity || !sv_gameplayfix_noairborncorpse.integer)
+               else if (!PRVM_serveredictedict(ent, groundentity) || !sv_gameplayfix_noairborncorpse.integer)
                {
                        // we can trust FL_ONGROUND if groundentity is world because it never moves
                        return;
@@ -2489,7 +2489,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        // if ent was supported by a brush model on previous frame,
                        // and groundentity is now freed, set groundentity to 0 (world)
                        // which leaves it suspended in the air
-                       ent->fields.server->groundentity = 0;
+                       PRVM_serveredictedict(ent, groundentity) = 0;
                        if (sv_gameplayfix_noairborncorpse_allowsuspendeditems.integer)
                                return;
                }
@@ -2504,17 +2504,17 @@ void SV_Physics_Toss (prvm_edict_t *ent)
        SV_CheckVelocity (ent);
 
 // add gravity
-       if (ent->fields.server->movetype == MOVETYPE_TOSS || ent->fields.server->movetype == MOVETYPE_BOUNCE)
-               ent->fields.server->velocity[2] -= SV_Gravity(ent);
+       if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_TOSS || PRVM_serveredictfloat(ent, movetype) == MOVETYPE_BOUNCE)
+               PRVM_serveredictvector(ent, velocity)[2] -= SV_Gravity(ent);
 
 // move angles
-       VectorMA (ent->fields.server->angles, sv.frametime, ent->fields.server->avelocity, ent->fields.server->angles);
+       VectorMA (PRVM_serveredictvector(ent, angles), sv.frametime, PRVM_serveredictvector(ent, avelocity), PRVM_serveredictvector(ent, angles));
 
        movetime = sv.frametime;
        for (bump = 0;bump < MAX_CLIP_PLANES && movetime > 0;bump++)
        {
        // move origin
-               VectorScale (ent->fields.server->velocity, movetime, move);
+               VectorScale (PRVM_serveredictvector(ent, velocity), movetime, move);
                if(!SV_PushEntity (&trace, ent, move, true, true))
                        return; // teleported
                if (ent->priv.server->free)
@@ -2531,17 +2531,17 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                if (trace.fraction == 1)
                        break;
                movetime *= 1 - min(1, trace.fraction);
-               if (ent->fields.server->movetype == MOVETYPE_BOUNCEMISSILE)
+               if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_BOUNCEMISSILE)
                {
                        float bouncefactor;
                        bouncefactor = PRVM_serveredictfloat(ent, bouncefactor);
                        if (!bouncefactor)
                                bouncefactor = 1.0f;
 
-                       ClipVelocity (ent->fields.server->velocity, trace.plane.normal, ent->fields.server->velocity, 1 + bouncefactor);
-                       ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND;
+                       ClipVelocity (PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity), 1 + bouncefactor);
+                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
                }
-               else if (ent->fields.server->movetype == MOVETYPE_BOUNCE)
+               else if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_BOUNCE)
                {
                        float d, ent_gravity;
                        float bouncefactor;
@@ -2555,53 +2555,53 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        if (!bouncestop)
                                bouncestop = 60.0f / 800.0f;
 
-                       ClipVelocity (ent->fields.server->velocity, trace.plane.normal, ent->fields.server->velocity, 1 + bouncefactor);
+                       ClipVelocity (PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity), 1 + bouncefactor);
                        ent_gravity = PRVM_serveredictfloat(ent, gravity);
                        if (!ent_gravity)
                                ent_gravity = 1.0f;
                        // LordHavoc: fixed grenades not bouncing when fired down a slope
                        if (sv_gameplayfix_grenadebouncedownslopes.integer)
                        {
-                               d = DotProduct(trace.plane.normal, ent->fields.server->velocity);
+                               d = DotProduct(trace.plane.normal, PRVM_serveredictvector(ent, velocity));
                                if (trace.plane.normal[2] > 0.7 && fabs(d) < sv_gravity.value * bouncestop * ent_gravity)
                                {
-                                       ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
-                                       ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
-                                       VectorClear (ent->fields.server->velocity);
-                                       VectorClear (ent->fields.server->avelocity);
+                                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) | FL_ONGROUND;
+                                       PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
+                                       VectorClear (PRVM_serveredictvector(ent, velocity));
+                                       VectorClear (PRVM_serveredictvector(ent, avelocity));
                                }
                                else
-                                       ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND;
+                                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
                        }
                        else
                        {
-                               if (trace.plane.normal[2] > 0.7 && ent->fields.server->velocity[2] < sv_gravity.value * bouncestop * ent_gravity)
+                               if (trace.plane.normal[2] > 0.7 && PRVM_serveredictvector(ent, velocity)[2] < sv_gravity.value * bouncestop * ent_gravity)
                                {
-                                       ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
-                                       ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
-                                       VectorClear (ent->fields.server->velocity);
-                                       VectorClear (ent->fields.server->avelocity);
+                                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) | FL_ONGROUND;
+                                       PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
+                                       VectorClear (PRVM_serveredictvector(ent, velocity));
+                                       VectorClear (PRVM_serveredictvector(ent, avelocity));
                                }
                                else
-                                       ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND;
+                                       PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) & ~FL_ONGROUND;
                        }
                }
                else
                {
-                       ClipVelocity (ent->fields.server->velocity, trace.plane.normal, ent->fields.server->velocity, 1.0);
+                       ClipVelocity (PRVM_serveredictvector(ent, velocity), trace.plane.normal, PRVM_serveredictvector(ent, velocity), 1.0);
                        if (trace.plane.normal[2] > 0.7)
                        {
-                               ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
-                               ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
-                               if (((prvm_edict_t *)trace.ent)->fields.server->solid == SOLID_BSP)
+                               PRVM_serveredictfloat(ent, flags) = (int)PRVM_serveredictfloat(ent, flags) | FL_ONGROUND;
+                               PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
+                               if (PRVM_serveredictfloat(((prvm_edict_t *)trace.ent), solid) == SOLID_BSP)
                                        ent->priv.server-&g