progsdef.h is now used only for the PROGHEADER_CRC def. Much of the protocol

still seems to be broken :(
This commit is contained in:
Bill Currie 2001-03-01 18:44:19 +00:00
parent ad18afaa3c
commit ef38fd2e79
13 changed files with 640 additions and 488 deletions

View file

@ -130,7 +130,7 @@ int NUM_FOR_EDICT(progs_t *pr, edict_t *e);
#define E_FLOAT(e,o) E_var (e, o, float) #define E_FLOAT(e,o) E_var (e, o, float)
#define E_INT(e,o) E_var (e, o, int) #define E_INT(e,o) E_var (e, o, int)
#define E_VECTOR(e,o) (&E_FLOAT (e, o)) #define E_VECTOR(e,o) E_var (e, o, vector)
#define E_STRING(p,e,o) (PR_GetString (p, E_var (e, o, string))) #define E_STRING(p,e,o) (PR_GetString (p, E_var (e, o, string)))
extern int type_size[8]; extern int type_size[8];

View file

@ -33,7 +33,6 @@
#define __sv_progs_h #define __sv_progs_h
#include "progs.h" #include "progs.h"
#include "progdefs.h"
typedef struct { typedef struct {
int *self; int *self;
@ -82,4 +81,90 @@ typedef struct {
extern sv_funcs_t sv_funcs; extern sv_funcs_t sv_funcs;
typedef struct
{
int modelindex; //float *
int absmin; //vec3_t * *
int absmax; //vec3_t *
int ltime; //float *
int lastruntime; //float *
int movetype; //float *
int solid; //float *
int origin; //vec3_t *
int oldorigin; //vec3_t *
int velocity; //vec3_t *
int angles; //vec3_t *
int avelocity; //vec3_t *
int classname; //string_t
int model; //string_t *
int frame; //float *
int skin; //float *
int effects; //float *
int mins; //vec3_t *
int maxs; //vec3_t *
int size; //vec3_t *
int touch; //func_t *
//int use; //func_t
int think; //func_t *
int blocked; //func_t *
int nextthink; //float *
int groundentity; //int *
int health; //float *
int frags; //float *
int weapon; //float *
int weaponmodel; //string_t *
int weaponframe; //float *
int currentammo; //float
int ammo_shells; //float *
int ammo_nails; //float *
int ammo_rockets; //float *
int ammo_cells; //float *
int items; //float *
int takedamage; //float
int chain; //int *
//int deadflag; //float
int view_ofs; //vec3_t *
int button0; //float *
int button1; //float *
int button2; //float *
int impulse; //float
int fixangle; //float *
int v_angle; //vec3_t *
int netname; //string_t *
int enemy; //int *
int flags; //float *
int colormap; //float *
int team; //float
//int max_health; //float
int teleport_time; //float *
//int armortype; //float
int armorvalue; //float *
int waterlevel; //float *
int watertype; //float *
int ideal_yaw; //float *
int yaw_speed; //float *
//int aiment; //int
int goalentity; //int *
int spawnflags; //float *
//int target; //string_t
//int targetname; //string_t
int dmg_take; //float *
int dmg_save; //float *
int dmg_inflictor; //int *
int owner; //int
//int movedir; //vec3_t
int message; //string_t
int sounds; //float
//int noise; //string_t
//int noise1; //string_t
//int noise2; //string_t
//int noise3; //string_t
} sv_fields_t;
extern sv_fields_t sv_fields;
#define SVFIELD(e,f,t) E_var (e, sv_fields.f, t)
#define PROGHEADER_CRC 54730
#endif // __sv_progs_h #endif // __sv_progs_h

View file

@ -217,8 +217,8 @@ SV_God_f (void)
if (!SV_SetPlayer ()) if (!SV_SetPlayer ())
return; return;
((entvars_t*)&sv_player->v)->flags = (int) ((entvars_t*)&sv_player->v)->flags ^ FL_GODMODE; SVFIELD (sv_player, flags, float) = (int) SVFIELD (sv_player, flags, float) ^ FL_GODMODE;
if (!((int) ((entvars_t*)&sv_player->v)->flags & FL_GODMODE)) if (!((int) SVFIELD (sv_player, flags, float) & FL_GODMODE))
SV_ClientPrintf (host_client, PRINT_HIGH, "godmode OFF\n"); SV_ClientPrintf (host_client, PRINT_HIGH, "godmode OFF\n");
else else
SV_ClientPrintf (host_client, PRINT_HIGH, "godmode ON\n"); SV_ClientPrintf (host_client, PRINT_HIGH, "godmode ON\n");
@ -237,11 +237,11 @@ SV_Noclip_f (void)
if (!SV_SetPlayer ()) if (!SV_SetPlayer ())
return; return;
if (((entvars_t*)&sv_player->v)->movetype != MOVETYPE_NOCLIP) { if (SVFIELD (sv_player, movetype, float) != MOVETYPE_NOCLIP) {
((entvars_t*)&sv_player->v)->movetype = MOVETYPE_NOCLIP; SVFIELD (sv_player, movetype, float) = MOVETYPE_NOCLIP;
SV_ClientPrintf (host_client, PRINT_HIGH, "noclip ON\n"); SV_ClientPrintf (host_client, PRINT_HIGH, "noclip ON\n");
} else { } else {
((entvars_t*)&sv_player->v)->movetype = MOVETYPE_WALK; SVFIELD (sv_player, movetype, float) = MOVETYPE_WALK;
SV_ClientPrintf (host_client, PRINT_HIGH, "noclip OFF\n"); SV_ClientPrintf (host_client, PRINT_HIGH, "noclip OFF\n");
} }
} }
@ -277,24 +277,24 @@ SV_Give_f (void)
case '7': case '7':
case '8': case '8':
case '9': case '9':
((entvars_t*)&sv_player->v)->items = SVFIELD (sv_player, items, float) =
(int) ((entvars_t*)&sv_player->v)->items | IT_SHOTGUN << (t[0] - '2'); (int) SVFIELD (sv_player, items, float) | IT_SHOTGUN << (t[0] - '2');
break; break;
case 's': case 's':
((entvars_t*)&sv_player->v)->ammo_shells = v; SVFIELD (sv_player, ammo_shells, float) = v;
break; break;
case 'n': case 'n':
((entvars_t*)&sv_player->v)->ammo_nails = v; SVFIELD (sv_player, ammo_nails, float) = v;
break; break;
case 'r': case 'r':
((entvars_t*)&sv_player->v)->ammo_rockets = v; SVFIELD (sv_player, ammo_rockets, float) = v;
break; break;
case 'h': case 'h':
((entvars_t*)&sv_player->v)->health = v; SVFIELD (sv_player, health, float) = v;
break; break;
case 'c': case 'c':
((entvars_t*)&sv_player->v)->ammo_cells = v; SVFIELD (sv_player, ammo_cells, float) = v;
break; break;
} }
} }
@ -415,7 +415,7 @@ SV_Status_f (void)
Con_Printf ("%-16.16s ", cl->name); Con_Printf ("%-16.16s ", cl->name);
Con_Printf ("%6i %5i", cl->userid, (int) ((entvars_t*)&cl->edict->v)->frags); Con_Printf ("%6i %5i", cl->userid, (int) SVFIELD (cl->edict, frags, float));
if (cl->spectator) if (cl->spectator)
Con_Printf (" (s)\n"); Con_Printf (" (s)\n");
else else
@ -445,7 +445,7 @@ SV_Status_f (void)
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
if (!cl->state) if (!cl->state)
continue; continue;
Con_Printf ("%5i %6i ", (int) ((entvars_t*)&cl->edict->v)->frags, cl->userid); Con_Printf ("%5i %6i ", (int) SVFIELD (cl->edict, frags, float), cl->userid);
s = NET_BaseAdrToString (cl->netchan.remote_address); s = NET_BaseAdrToString (cl->netchan.remote_address);

View file

@ -118,8 +118,8 @@ extern int sv_nailmodel, sv_supernailmodel, sv_playermodel;
qboolean qboolean
SV_AddNailUpdate (edict_t *ent) SV_AddNailUpdate (edict_t *ent)
{ {
if (((entvars_t*)&ent->v)->modelindex != sv_nailmodel if (SVFIELD (ent, modelindex, float) != sv_nailmodel
&& ((entvars_t*)&ent->v)->modelindex != sv_supernailmodel) return false; && SVFIELD (ent, modelindex, float) != sv_supernailmodel) return false;
if (numnails == MAX_NAILS) if (numnails == MAX_NAILS)
return true; return true;
nails[numnails] = ent; nails[numnails] = ent;
@ -143,11 +143,11 @@ SV_EmitNailUpdate (sizebuf_t *msg)
for (n = 0; n < numnails; n++) { for (n = 0; n < numnails; n++) {
ent = nails[n]; ent = nails[n];
x = (int) (((entvars_t*)&ent->v)->origin[0] + 4096) >> 1; x = (int) (SVFIELD (ent, origin, vector)[0] + 4096) >> 1;
y = (int) (((entvars_t*)&ent->v)->origin[1] + 4096) >> 1; y = (int) (SVFIELD (ent, origin, vector)[1] + 4096) >> 1;
z = (int) (((entvars_t*)&ent->v)->origin[2] + 4096) >> 1; z = (int) (SVFIELD (ent, origin, vector)[2] + 4096) >> 1;
p = (int) (16 * ((entvars_t*)&ent->v)->angles[0] / 360) & 15; p = (int) (16 * SVFIELD (ent, angles, vector)[0] / 360) & 15;
yaw = (int) (256 * ((entvars_t*)&ent->v)->angles[1] / 360) & 255; yaw = (int) (256 * SVFIELD (ent, angles, vector)[1] / 360) & 255;
bits[0] = x; bits[0] = x;
bits[1] = (x >> 8) | (y << 4); bits[1] = (x >> 8) | (y << 4);
@ -417,18 +417,18 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
pflags = PF_MSEC | PF_COMMAND; pflags = PF_MSEC | PF_COMMAND;
if (((entvars_t*)&ent->v)->modelindex != sv_playermodel) if (SVFIELD (ent, modelindex, float) != sv_playermodel)
pflags |= PF_MODEL; pflags |= PF_MODEL;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (((entvars_t*)&ent->v)->velocity[i]) if (SVFIELD (ent, velocity, vector)[i])
pflags |= PF_VELOCITY1 << i; pflags |= PF_VELOCITY1 << i;
if (((entvars_t*)&ent->v)->effects) if (SVFIELD (ent, effects, float))
pflags |= PF_EFFECTS; pflags |= PF_EFFECTS;
if (((entvars_t*)&ent->v)->skin) if (SVFIELD (ent, skin, float))
pflags |= PF_SKINNUM; pflags |= PF_SKINNUM;
if (((entvars_t*)&ent->v)->health <= 0) if (SVFIELD (ent, health, float) <= 0)
pflags |= PF_DEAD; pflags |= PF_DEAD;
if (((entvars_t*)&ent->v)->mins[2] != -24) if (SVFIELD (ent, mins, vector)[2] != -24)
pflags |= PF_GIB; pflags |= PF_GIB;
if (cl->spectator) { // only sent origin and velocity to if (cl->spectator) { // only sent origin and velocity to
@ -437,21 +437,21 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
} else if (ent == clent) { // don't send a lot of data on } else if (ent == clent) { // don't send a lot of data on
// personal entity // personal entity
pflags &= ~(PF_MSEC | PF_COMMAND); pflags &= ~(PF_MSEC | PF_COMMAND);
if (((entvars_t*)&ent->v)->weaponframe) if (SVFIELD (ent, weaponframe, float))
pflags |= PF_WEAPONFRAME; pflags |= PF_WEAPONFRAME;
} }
if (client->spec_track && client->spec_track - 1 == j && if (client->spec_track && client->spec_track - 1 == j &&
((entvars_t*)&ent->v)->weaponframe) pflags |= PF_WEAPONFRAME; SVFIELD (ent, weaponframe, float)) pflags |= PF_WEAPONFRAME;
MSG_WriteByte (msg, svc_playerinfo); MSG_WriteByte (msg, svc_playerinfo);
MSG_WriteByte (msg, j); MSG_WriteByte (msg, j);
MSG_WriteShort (msg, pflags); MSG_WriteShort (msg, pflags);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
MSG_WriteCoord (msg, ((entvars_t*)&ent->v)->origin[i]); MSG_WriteCoord (msg, SVFIELD (ent, origin, vector)[i]);
MSG_WriteByte (msg, ((entvars_t*)&ent->v)->frame); MSG_WriteByte (msg, SVFIELD (ent, frame, float));
if (pflags & PF_MSEC) { if (pflags & PF_MSEC) {
msec = 1000 * (sv.time - cl->localtime); msec = 1000 * (sv.time - cl->localtime);
@ -463,10 +463,10 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
if (pflags & PF_COMMAND) { if (pflags & PF_COMMAND) {
cmd = cl->lastcmd; cmd = cl->lastcmd;
if (((entvars_t*)&ent->v)->health <= 0) { // don't show the corpse looking if (SVFIELD (ent, health, float) <= 0) { // don't show the corpse looking
// around... // around...
cmd.angles[0] = 0; cmd.angles[0] = 0;
cmd.angles[1] = ((entvars_t*)&ent->v)->angles[1]; cmd.angles[1] = SVFIELD (ent, angles, vector)[1];
cmd.angles[0] = 0; cmd.angles[0] = 0;
} }
@ -478,19 +478,19 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (pflags & (PF_VELOCITY1 << i)) if (pflags & (PF_VELOCITY1 << i))
MSG_WriteShort (msg, ((entvars_t*)&ent->v)->velocity[i]); MSG_WriteShort (msg, SVFIELD (ent, velocity, vector)[i]);
if (pflags & PF_MODEL) if (pflags & PF_MODEL)
MSG_WriteByte (msg, ((entvars_t*)&ent->v)->modelindex); MSG_WriteByte (msg, SVFIELD (ent, modelindex, float));
if (pflags & PF_SKINNUM) if (pflags & PF_SKINNUM)
MSG_WriteByte (msg, ((entvars_t*)&ent->v)->skin); MSG_WriteByte (msg, SVFIELD (ent, skin, float));
if (pflags & PF_EFFECTS) if (pflags & PF_EFFECTS)
MSG_WriteByte (msg, ((entvars_t*)&ent->v)->effects); MSG_WriteByte (msg, SVFIELD (ent, effects, float));
if (pflags & PF_WEAPONFRAME) if (pflags & PF_WEAPONFRAME)
MSG_WriteByte (msg, ((entvars_t*)&ent->v)->weaponframe); MSG_WriteByte (msg, SVFIELD (ent, weaponframe, float));
} }
} }
@ -520,7 +520,7 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
// find the client's PVS // find the client's PVS
clent = client->edict; clent = client->edict;
VectorAdd (((entvars_t*)&clent->v)->origin, ((entvars_t*)&clent->v)->view_ofs, org); VectorAdd (SVFIELD (clent, origin, vector), SVFIELD (clent, view_ofs, vector), org);
pvs = SV_FatPVS (org); pvs = SV_FatPVS (org);
// send over the players in the PVS // send over the players in the PVS
@ -536,7 +536,7 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
for (e = MAX_CLIENTS + 1, ent = EDICT_NUM (&sv_pr_state, e); e < sv.num_edicts; for (e = MAX_CLIENTS + 1, ent = EDICT_NUM (&sv_pr_state, e); e < sv.num_edicts;
e++, ent = NEXT_EDICT (&sv_pr_state, ent)) { e++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
// ignore ents without visible models // ignore ents without visible models
if (!((entvars_t*)&ent->v)->modelindex || !*PR_GetString (&sv_pr_state, ((entvars_t*)&ent->v)->model)) if (!SVFIELD (ent, modelindex, float) || !*PR_GetString (&sv_pr_state, SVFIELD (ent, model, string)))
continue; continue;
// ignore if not touching a PV leaf // ignore if not touching a PV leaf
@ -559,13 +559,13 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
state->number = e; state->number = e;
state->flags = 0; state->flags = 0;
VectorCopy (((entvars_t*)&ent->v)->origin, state->origin); VectorCopy (SVFIELD (ent, origin, vector), state->origin);
VectorCopy (((entvars_t*)&ent->v)->angles, state->angles); VectorCopy (SVFIELD (ent, angles, vector), state->angles);
state->modelindex = ((entvars_t*)&ent->v)->modelindex; state->modelindex = SVFIELD (ent, modelindex, float);
state->frame = ((entvars_t*)&ent->v)->frame; state->frame = SVFIELD (ent, frame, float);
state->colormap = ((entvars_t*)&ent->v)->colormap; state->colormap = SVFIELD (ent, colormap, float);
state->skinnum = ((entvars_t*)&ent->v)->skin; state->skinnum = SVFIELD (ent, skin, float);
state->effects = ((entvars_t*)&ent->v)->effects; state->effects = SVFIELD (ent, effects, float);
// LordHavoc: cleaned up Endy's coding style, shortened the code, // LordHavoc: cleaned up Endy's coding style, shortened the code,
// and implemented missing effects // and implemented missing effects

View file

@ -111,23 +111,23 @@ SV_CreateBaseline (void)
continue; continue;
// create baselines for all player slots, // create baselines for all player slots,
// and any other edict that has a visible model // and any other edict that has a visible model
if (entnum > MAX_CLIENTS && !((entvars_t*)&svent->v)->modelindex) if (entnum > MAX_CLIENTS && !SVFIELD (svent, modelindex, float))
continue; continue;
// //
// create entity baseline // create entity baseline
// //
VectorCopy (((entvars_t*)&svent->v)->origin, ((entity_state_t*)svent->data)->origin); VectorCopy (SVFIELD (svent, origin, vector), ((entity_state_t*)svent->data)->origin);
VectorCopy (((entvars_t*)&svent->v)->angles, ((entity_state_t*)svent->data)->angles); VectorCopy (SVFIELD (svent, angles, vector), ((entity_state_t*)svent->data)->angles);
((entity_state_t*)svent->data)->frame = ((entvars_t*)&svent->v)->frame; ((entity_state_t*)svent->data)->frame = SVFIELD (svent, frame, float);
((entity_state_t*)svent->data)->skinnum = ((entvars_t*)&svent->v)->skin; ((entity_state_t*)svent->data)->skinnum = SVFIELD (svent, skin, float);
if (entnum > 0 && entnum <= MAX_CLIENTS) { if (entnum > 0 && entnum <= MAX_CLIENTS) {
((entity_state_t*)svent->data)->colormap = entnum; ((entity_state_t*)svent->data)->colormap = entnum;
((entity_state_t*)svent->data)->modelindex = SV_ModelIndex ("progs/player.mdl"); ((entity_state_t*)svent->data)->modelindex = SV_ModelIndex ("progs/player.mdl");
} else { } else {
((entity_state_t*)svent->data)->colormap = 0; ((entity_state_t*)svent->data)->colormap = 0;
((entity_state_t*)svent->data)->modelindex = ((entity_state_t*)svent->data)->modelindex =
SV_ModelIndex (PR_GetString (&sv_pr_state, ((entvars_t*)&svent->v)->model)); SV_ModelIndex (PR_GetString (&sv_pr_state, SVFIELD (svent, model, string)));
} }
// LordHavoc: setup baseline to include new effects // LordHavoc: setup baseline to include new effects
((entity_state_t*)svent->data)->alpha = 255; ((entity_state_t*)svent->data)->alpha = 255;
@ -397,10 +397,10 @@ SV_SpawnServer (char *server)
ent = EDICT_NUM (&sv_pr_state, 0); ent = EDICT_NUM (&sv_pr_state, 0);
ent->free = false; ent->free = false;
((entvars_t*)&ent->v)->model = PR_SetString (&sv_pr_state, sv.worldmodel->name); SVFIELD (ent, model, string) = PR_SetString (&sv_pr_state, sv.worldmodel->name);
((entvars_t*)&ent->v)->modelindex = 1; // world model SVFIELD (ent, modelindex, float) = 1; // world model
((entvars_t*)&ent->v)->solid = SOLID_BSP; SVFIELD (ent, solid, float) = SOLID_BSP;
((entvars_t*)&ent->v)->movetype = MOVETYPE_PUSH; SVFIELD (ent, movetype, float) = MOVETYPE_PUSH;
*sv_globals.mapname = PR_SetString (&sv_pr_state, sv.name); *sv_globals.mapname = PR_SetString (&sv_pr_state, sv.name);
// serverflags are for cross level information (sigils) // serverflags are for cross level information (sigils)

View file

@ -279,7 +279,7 @@ SV_DropClient (client_t *drop)
drop->connection_started = realtime; // for zombie timeout drop->connection_started = realtime; // for zombie timeout
drop->old_frags = 0; drop->old_frags = 0;
((entvars_t*)&drop->edict->v)->frags = 0; SVFIELD (drop->edict, frags, float) = 0;
drop->name[0] = 0; drop->name[0] = 0;
memset (drop->userinfo, 0, sizeof (drop->userinfo)); memset (drop->userinfo, 0, sizeof (drop->userinfo));

View file

@ -58,8 +58,8 @@ SV_CheckBottom (edict_t *ent)
int x, y; int x, y;
float mid, bottom; float mid, bottom;
VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, mins); VectorAdd (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), mins);
VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->maxs, maxs); VectorAdd (SVFIELD (ent, origin, vector), SVFIELD (ent, maxs, vector), maxs);
// if all of the points under the corners are solid world, don't bother // if all of the points under the corners are solid world, don't bother
// with the tougher checks // with the tougher checks
@ -130,34 +130,34 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
edict_t *enemy; edict_t *enemy;
// try the move // try the move
VectorCopy (((entvars_t*)&ent->v)->origin, oldorg); VectorCopy (SVFIELD (ent, origin, vector), oldorg);
VectorAdd (((entvars_t*)&ent->v)->origin, move, neworg); VectorAdd (SVFIELD (ent, origin, vector), move, neworg);
// flying monsters don't step up // flying monsters don't step up
if ((int) ((entvars_t*)&ent->v)->flags & (FL_SWIM | FL_FLY)) { if ((int) SVFIELD (ent, flags, float) & (FL_SWIM | FL_FLY)) {
// try one move with vertical motion, then one without // try one move with vertical motion, then one without
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
VectorAdd (((entvars_t*)&ent->v)->origin, move, neworg); VectorAdd (SVFIELD (ent, origin, vector), move, neworg);
enemy = PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->enemy); enemy = PROG_TO_EDICT (&sv_pr_state, SVFIELD (ent, enemy, int));
if (i == 0 && enemy != sv.edicts) { if (i == 0 && enemy != sv.edicts) {
dz = dz =
((entvars_t*)&ent->v)->origin[2] - SVFIELD (ent, origin, vector)[2] -
((entvars_t*)&PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->enemy)->v)->origin[2]; SVFIELD (PROG_TO_EDICT (&sv_pr_state, SVFIELD (ent, enemy, int)), origin, vector)[2];
if (dz > 40) if (dz > 40)
neworg[2] -= 8; neworg[2] -= 8;
if (dz < 30) if (dz < 30)
neworg[2] += 8; neworg[2] += 8;
} }
trace = trace =
SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, neworg, false, SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), neworg, false,
ent); ent);
if (trace.fraction == 1) { if (trace.fraction == 1) {
if (((int) ((entvars_t*)&ent->v)->flags & FL_SWIM) if (((int) SVFIELD (ent, flags, float) & FL_SWIM)
&& SV_PointContents (trace.endpos) == CONTENTS_EMPTY) && SV_PointContents (trace.endpos) == CONTENTS_EMPTY)
return false; // swim monster left water return false; // swim monster left water
VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); VectorCopy (trace.endpos, SVFIELD (ent, origin, vector));
if (relink) if (relink)
SV_LinkEdict (ent, true); SV_LinkEdict (ent, true);
return true; return true;
@ -174,24 +174,24 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
VectorCopy (neworg, end); VectorCopy (neworg, end);
end[2] -= STEPSIZE * 2; end[2] -= STEPSIZE * 2;
trace = SV_Move (neworg, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, false, ent); trace = SV_Move (neworg, SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), end, false, ent);
if (trace.allsolid) if (trace.allsolid)
return false; return false;
if (trace.startsolid) { if (trace.startsolid) {
neworg[2] -= STEPSIZE; neworg[2] -= STEPSIZE;
trace = SV_Move (neworg, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, false, ent); trace = SV_Move (neworg, SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), end, false, ent);
if (trace.allsolid || trace.startsolid) if (trace.allsolid || trace.startsolid)
return false; return false;
} }
if (trace.fraction == 1) { if (trace.fraction == 1) {
// if monster had the ground pulled out, go ahead and fall // if monster had the ground pulled out, go ahead and fall
if ((int) ((entvars_t*)&ent->v)->flags & FL_PARTIALGROUND) { if ((int) SVFIELD (ent, flags, float) & FL_PARTIALGROUND) {
VectorAdd (((entvars_t*)&ent->v)->origin, move, ((entvars_t*)&ent->v)->origin); VectorAdd (SVFIELD (ent, origin, vector), move, SVFIELD (ent, origin, vector));
if (relink) if (relink)
SV_LinkEdict (ent, true); SV_LinkEdict (ent, true);
((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags & ~FL_ONGROUND; SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) & ~FL_ONGROUND;
// Con_Printf ("fall down\n"); // Con_Printf ("fall down\n");
return true; return true;
} }
@ -199,10 +199,10 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
return false; // walked off an edge return false; // walked off an edge
} }
// check point traces down for dangling corners // check point traces down for dangling corners
VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); VectorCopy (trace.endpos, SVFIELD (ent, origin, vector));
if (!SV_CheckBottom (ent)) { if (!SV_CheckBottom (ent)) {
if ((int) ((entvars_t*)&ent->v)->flags & FL_PARTIALGROUND) { // entity had floor if ((int) SVFIELD (ent, flags, float) & FL_PARTIALGROUND) { // entity had floor
// mostly pulled out // mostly pulled out
// from underneath it // from underneath it
// and is trying to correct // and is trying to correct
@ -210,15 +210,15 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
SV_LinkEdict (ent, true); SV_LinkEdict (ent, true);
return true; return true;
} }
VectorCopy (oldorg, ((entvars_t*)&ent->v)->origin); VectorCopy (oldorg, SVFIELD (ent, origin, vector));
return false; return false;
} }
if ((int) ((entvars_t*)&ent->v)->flags & FL_PARTIALGROUND) { if ((int) SVFIELD (ent, flags, float) & FL_PARTIALGROUND) {
// Con_Printf ("back on ground\n"); // Con_Printf ("back on ground\n");
((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags & ~FL_PARTIALGROUND; SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) & ~FL_PARTIALGROUND;
} }
((entvars_t*)&ent->v)->groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); SVFIELD (ent, groundentity, int) = EDICT_TO_PROG (&sv_pr_state, trace.ent);
// the move is ok // the move is ok
if (relink) if (relink)
@ -241,7 +241,7 @@ SV_StepDirection (edict_t *ent, float yaw, float dist)
vec3_t move, oldorigin; vec3_t move, oldorigin;
float delta; float delta;
((entvars_t*)&ent->v)->ideal_yaw = yaw; SVFIELD (ent, ideal_yaw, float) = yaw;
PF_changeyaw (&sv_pr_state); PF_changeyaw (&sv_pr_state);
yaw = yaw * M_PI * 2 / 360; yaw = yaw * M_PI * 2 / 360;
@ -249,12 +249,12 @@ SV_StepDirection (edict_t *ent, float yaw, float dist)
move[1] = sin (yaw) * dist; move[1] = sin (yaw) * dist;
move[2] = 0; move[2] = 0;
VectorCopy (((entvars_t*)&ent->v)->origin, oldorigin); VectorCopy (SVFIELD (ent, origin, vector), oldorigin);
if (SV_movestep (ent, move, false)) { if (SV_movestep (ent, move, false)) {
delta = ((entvars_t*)&ent->v)->angles[YAW] - ((entvars_t*)&ent->v)->ideal_yaw; delta = SVFIELD (ent, angles, vector)[YAW] - SVFIELD (ent, ideal_yaw, float);
if (delta > 45 && delta < 315) { // not turned far enough, so if (delta > 45 && delta < 315) { // not turned far enough, so
// don't take the step // don't take the step
VectorCopy (oldorigin, ((entvars_t*)&ent->v)->origin); VectorCopy (oldorigin, SVFIELD (ent, origin, vector));
} }
SV_LinkEdict (ent, true); SV_LinkEdict (ent, true);
return true; return true;
@ -272,7 +272,7 @@ SV_FixCheckBottom (edict_t *ent)
{ {
// Con_Printf ("SV_FixCheckBottom\n"); // Con_Printf ("SV_FixCheckBottom\n");
((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags | FL_PARTIALGROUND; SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) | FL_PARTIALGROUND;
} }
@ -288,11 +288,11 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
float d[3]; float d[3];
float tdir, olddir, turnaround; float tdir, olddir, turnaround;
olddir = anglemod ((int) (((entvars_t*)&actor->v)->ideal_yaw / 45) * 45); olddir = anglemod ((int) (SVFIELD (actor, ideal_yaw, float) / 45) * 45);
turnaround = anglemod (olddir - 180); turnaround = anglemod (olddir - 180);
deltax = ((entvars_t*)&enemy->v)->origin[0] - ((entvars_t*)&actor->v)->origin[0]; deltax = SVFIELD (enemy, origin, vector)[0] - SVFIELD (actor, origin, vector)[0];
deltay = ((entvars_t*)&enemy->v)->origin[1] - ((entvars_t*)&actor->v)->origin[1]; deltay = SVFIELD (enemy, origin, vector)[1] - SVFIELD (actor, origin, vector)[1];
if (deltax > 10) if (deltax > 10)
d[1] = 0; d[1] = 0;
else if (deltax < -10) else if (deltax < -10)
@ -348,7 +348,7 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
if (turnaround != DI_NODIR && SV_StepDirection (actor, turnaround, dist)) if (turnaround != DI_NODIR && SV_StepDirection (actor, turnaround, dist))
return; return;
((entvars_t*)&actor->v)->ideal_yaw = olddir; // can't move SVFIELD (actor, ideal_yaw, float) = olddir; // can't move
// if a bridge was pulled out from underneath a monster, it may not have // if a bridge was pulled out from underneath a monster, it may not have
// a valid standing position at all // a valid standing position at all
@ -367,9 +367,9 @@ SV_CloseEnough (edict_t *ent, edict_t *goal, float dist)
int i; int i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (((entvars_t*)&goal->v)->absmin[i] > ((entvars_t*)&ent->v)->absmax[i] + dist) if (SVFIELD (goal, absmin, vector)[i] > SVFIELD (ent, absmax, vector)[i] + dist)
return false; return false;
if (((entvars_t*)&goal->v)->absmax[i] < ((entvars_t*)&ent->v)->absmin[i] - dist) if (SVFIELD (goal, absmax, vector)[i] < SVFIELD (ent, absmin, vector)[i] - dist)
return false; return false;
} }
return true; return true;
@ -385,19 +385,19 @@ SV_MoveToGoal (progs_t *pr)
float dist; float dist;
ent = PROG_TO_EDICT (&sv_pr_state, *sv_globals.self); ent = PROG_TO_EDICT (&sv_pr_state, *sv_globals.self);
goal = PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->goalentity); goal = PROG_TO_EDICT (&sv_pr_state, SVFIELD (ent, goalentity, int));
dist = G_FLOAT (&sv_pr_state, OFS_PARM0); dist = G_FLOAT (&sv_pr_state, OFS_PARM0);
if (!((int) ((entvars_t*)&ent->v)->flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { if (!((int) SVFIELD (ent, flags, float) & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
G_FLOAT (&sv_pr_state, OFS_RETURN) = 0; G_FLOAT (&sv_pr_state, OFS_RETURN) = 0;
return; return;
} }
// if the next step hits the enemy, return immediately // if the next step hits the enemy, return immediately
if (PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->enemy) != sv.edicts if (PROG_TO_EDICT (&sv_pr_state, SVFIELD (ent, enemy, int)) != sv.edicts
&& SV_CloseEnough (ent, goal, dist)) return; && SV_CloseEnough (ent, goal, dist)) return;
// bump around... // bump around...
if ((rand () & 3) == 1 || !SV_StepDirection (ent, ((entvars_t*)&ent->v)->ideal_yaw, dist)) { if ((rand () & 3) == 1 || !SV_StepDirection (ent, SVFIELD (ent, ideal_yaw, float), dist)) {
SV_NewChaseDir (ent, goal, dist); SV_NewChaseDir (ent, goal, dist);
} }
} }

View file

@ -87,9 +87,9 @@ SV_CheckAllEnts (void)
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
if (check->free) if (check->free)
continue; continue;
if (((entvars_t*)&check->v)->movetype == MOVETYPE_PUSH if (SVFIELD (check, movetype, float) == MOVETYPE_PUSH
|| ((entvars_t*)&check->v)->movetype == MOVETYPE_NONE || SVFIELD (check, movetype, float) == MOVETYPE_NONE
|| ((entvars_t*)&check->v)->movetype == MOVETYPE_NOCLIP) continue; || SVFIELD (check, movetype, float) == MOVETYPE_NOCLIP) continue;
if (SV_TestEntityPosition (check)) if (SV_TestEntityPosition (check))
Con_Printf ("entity in invalid position\n"); Con_Printf ("entity in invalid position\n");
@ -109,23 +109,23 @@ SV_CheckVelocity (edict_t *ent)
// bound velocity // bound velocity
// //
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (IS_NAN (((entvars_t*)&ent->v)->velocity[i])) { if (IS_NAN (SVFIELD (ent, velocity, vector)[i])) {
Con_Printf ("Got a NaN velocity on %s\n", Con_Printf ("Got a NaN velocity on %s\n",
PR_GetString (&sv_pr_state, ((entvars_t*)&ent->v)->classname)); PR_GetString (&sv_pr_state, SVFIELD (ent, classname, string)));
((entvars_t*)&ent->v)->velocity[i] = 0; SVFIELD (ent, velocity, vector)[i] = 0;
} }
if (IS_NAN (((entvars_t*)&ent->v)->origin[i])) { if (IS_NAN (SVFIELD (ent, origin, vector)[i])) {
Con_Printf ("Got a NaN origin on %s\n", Con_Printf ("Got a NaN origin on %s\n",
PR_GetString (&sv_pr_state, ((entvars_t*)&ent->v)->classname)); PR_GetString (&sv_pr_state, SVFIELD (ent, classname, string)));
((entvars_t*)&ent->v)->origin[i] = 0; SVFIELD (ent, origin, vector)[i] = 0;
} }
} }
// 1999-10-18 SV_MAXVELOCITY fix by Maddes start // 1999-10-18 SV_MAXVELOCITY fix by Maddes start
wishspeed = Length (((entvars_t*)&ent->v)->velocity); wishspeed = Length (SVFIELD (ent, velocity, vector));
if (wishspeed > sv_maxvelocity->value) { if (wishspeed > sv_maxvelocity->value) {
VectorScale (((entvars_t*)&ent->v)->velocity, sv_maxvelocity->value / wishspeed, VectorScale (SVFIELD (ent, velocity, vector), sv_maxvelocity->value / wishspeed,
((entvars_t*)&ent->v)->velocity); SVFIELD (ent, velocity, vector));
} }
// 1999-10-18 SV_MAXVELOCITY fix by Maddes end // 1999-10-18 SV_MAXVELOCITY fix by Maddes end
} }
@ -144,7 +144,7 @@ SV_RunThink (edict_t *ent)
float thinktime; float thinktime;
do { do {
thinktime = ((entvars_t*)&ent->v)->nextthink; thinktime = SVFIELD (ent, nextthink, float);
if (thinktime <= 0) if (thinktime <= 0)
return true; return true;
if (thinktime > sv.time + sv_frametime) if (thinktime > sv.time + sv_frametime)
@ -154,11 +154,11 @@ SV_RunThink (edict_t *ent)
thinktime = sv.time; // don't let things stay in the past. thinktime = sv.time; // don't let things stay in the past.
// it is possible to start that way // it is possible to start that way
// by a trigger with a local time. // by a trigger with a local time.
((entvars_t*)&ent->v)->nextthink = 0; SVFIELD (ent, nextthink, float) = 0;
*sv_globals.time = thinktime; *sv_globals.time = thinktime;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think); PR_ExecuteProgram (&sv_pr_state, SVFIELD (ent, think, func));
if (ent->free) if (ent->free)
return false; return false;
@ -181,16 +181,16 @@ SV_Impact (edict_t *e1, edict_t *e2)
old_other = *sv_globals.other; old_other = *sv_globals.other;
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
if (((entvars_t*)&e1->v)->touch && ((entvars_t*)&e1->v)->solid != SOLID_NOT) { if (SVFIELD (e1, touch, func) && SVFIELD (e1, solid, float) != SOLID_NOT) {
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, e1); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, e1);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, e2); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, e2);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&e1->v)->touch); PR_ExecuteProgram (&sv_pr_state, SVFIELD (e1, touch, func));
} }
if (((entvars_t*)&e2->v)->touch && ((entvars_t*)&e2->v)->solid != SOLID_NOT) { if (SVFIELD (e2, touch, func) && SVFIELD (e2, solid, float) != SOLID_NOT) {
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, e2); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, e2);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, e1); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, e1);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&e2->v)->touch); PR_ExecuteProgram (&sv_pr_state, SVFIELD (e2, touch, func));
} }
*sv_globals.self = old_self; *sv_globals.self = old_self;
@ -259,27 +259,27 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
numbumps = 4; numbumps = 4;
blocked = 0; blocked = 0;
VectorCopy (((entvars_t*)&ent->v)->velocity, original_velocity); VectorCopy (SVFIELD (ent, velocity, vector), original_velocity);
VectorCopy (((entvars_t*)&ent->v)->velocity, primal_velocity); VectorCopy (SVFIELD (ent, velocity, vector), primal_velocity);
numplanes = 0; numplanes = 0;
time_left = time; time_left = time;
for (bumpcount = 0; bumpcount < numbumps; bumpcount++) { for (bumpcount = 0; bumpcount < numbumps; bumpcount++) {
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
end[i] = ((entvars_t*)&ent->v)->origin[i] + time_left * ((entvars_t*)&ent->v)->velocity[i]; end[i] = SVFIELD (ent, origin, vector)[i] + time_left * SVFIELD (ent, velocity, vector)[i];
trace = trace =
SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, false, ent); SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), end, false, ent);
if (trace.allsolid) { // entity is trapped in another solid if (trace.allsolid) { // entity is trapped in another solid
VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); VectorCopy (vec3_origin, SVFIELD (ent, velocity, vector));
return 3; return 3;
} }
if (trace.fraction > 0) { // actually covered some distance if (trace.fraction > 0) { // actually covered some distance
VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); VectorCopy (trace.endpos, SVFIELD (ent, origin, vector));
VectorCopy (((entvars_t*)&ent->v)->velocity, original_velocity); VectorCopy (SVFIELD (ent, velocity, vector), original_velocity);
numplanes = 0; numplanes = 0;
} }
@ -291,10 +291,10 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
if (trace.plane.normal[2] > 0.7) { if (trace.plane.normal[2] > 0.7) {
blocked |= 1; // floor blocked |= 1; // floor
if ((((entvars_t*)&trace.ent->v)->solid == SOLID_BSP) if ((SVFIELD (trace.ent, solid, float) == SOLID_BSP)
|| (((entvars_t*)&trace.ent->v)->movetype == MOVETYPE_PPUSH)) { || (SVFIELD (trace.ent, movetype, float) == MOVETYPE_PPUSH)) {
((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags | FL_ONGROUND; SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) | FL_ONGROUND;
((entvars_t*)&ent->v)->groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); SVFIELD (ent, groundentity, int) = EDICT_TO_PROG (&sv_pr_state, trace.ent);
} }
} }
if (!trace.plane.normal[2]) { if (!trace.plane.normal[2]) {
@ -314,7 +314,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
// cliped to another plane // cliped to another plane
if (numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen if (numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen
VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); VectorCopy (vec3_origin, SVFIELD (ent, velocity, vector));
return 3; return 3;
} }
@ -336,24 +336,24 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
} }
if (i != numplanes) { // go along this plane if (i != numplanes) { // go along this plane
VectorCopy (new_velocity, ((entvars_t*)&ent->v)->velocity); VectorCopy (new_velocity, SVFIELD (ent, velocity, vector));
} else { // go along the crease } else { // go along the crease
if (numplanes != 2) { if (numplanes != 2) {
// Con_Printf ("clip velocity, numplanes == %i\n",numplanes); // Con_Printf ("clip velocity, numplanes == %i\n",numplanes);
VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); VectorCopy (vec3_origin, SVFIELD (ent, velocity, vector));
return 7; return 7;
} }
CrossProduct (planes[0], planes[1], dir); CrossProduct (planes[0], planes[1], dir);
d = DotProduct (dir, ((entvars_t*)&ent->v)->velocity); d = DotProduct (dir, SVFIELD (ent, velocity, vector));
VectorScale (dir, d, ((entvars_t*)&ent->v)->velocity); VectorScale (dir, d, SVFIELD (ent, velocity, vector));
} }
// //
// if original velocity is against the original velocity, stop dead // if original velocity is against the original velocity, stop dead
// to avoid tiny occilations in sloping corners // to avoid tiny occilations in sloping corners
// //
if (DotProduct (((entvars_t*)&ent->v)->velocity, primal_velocity) <= 0) { if (DotProduct (SVFIELD (ent, velocity, vector), primal_velocity) <= 0) {
VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); VectorCopy (vec3_origin, SVFIELD (ent, velocity, vector));
return blocked; return blocked;
} }
} }
@ -368,7 +368,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
void void
SV_AddGravity (edict_t *ent, float scale) SV_AddGravity (edict_t *ent, float scale)
{ {
((entvars_t*)&ent->v)->velocity[2] -= scale * movevars.gravity * sv_frametime; SVFIELD (ent, velocity, vector)[2] -= scale * movevars.gravity * sv_frametime;
} }
/* /*
@ -386,23 +386,23 @@ SV_PushEntity (edict_t *ent, vec3_t push)
trace_t trace; trace_t trace;
vec3_t end; vec3_t end;
VectorAdd (((entvars_t*)&ent->v)->origin, push, end); VectorAdd (SVFIELD (ent, origin, vector), push, end);
if (((entvars_t*)&ent->v)->movetype == MOVETYPE_FLYMISSILE) if (SVFIELD (ent, movetype, float) == MOVETYPE_FLYMISSILE)
trace = trace =
SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, MOVE_MISSILE, SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), end, MOVE_MISSILE,
ent); ent);
else if (((entvars_t*)&ent->v)->solid == SOLID_TRIGGER || ((entvars_t*)&ent->v)->solid == SOLID_NOT) else if (SVFIELD (ent, solid, float) == SOLID_TRIGGER || SVFIELD (ent, solid, float) == SOLID_NOT)
// only clip against bmodels // only clip against bmodels
trace = trace =
SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), end,
MOVE_NOMONSTERS, ent); MOVE_NOMONSTERS, ent);
else else
trace = trace =
SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, MOVE_NORMAL, SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), end, MOVE_NORMAL,
ent); ent);
VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); VectorCopy (trace.endpos, SVFIELD (ent, origin, vector));
SV_LinkEdict (ent, true); SV_LinkEdict (ent, true);
if (trace.ent) if (trace.ent)
@ -430,15 +430,15 @@ SV_Push (edict_t *pusher, vec3_t move)
// --KB // --KB
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
mins[i] = ((entvars_t*)&pusher->v)->absmin[i] + move[i]; mins[i] = SVFIELD (pusher, absmin, vector)[i] + move[i];
maxs[i] = ((entvars_t*)&pusher->v)->absmax[i] + move[i]; maxs[i] = SVFIELD (pusher, absmax, vector)[i] + move[i];
} }
VectorCopy (((entvars_t*)&pusher->v)->origin, pushorig); VectorCopy (SVFIELD (pusher, origin, vector), pushorig);
// move the pusher to it's final position // move the pusher to it's final position
VectorAdd (((entvars_t*)&pusher->v)->origin, move, ((entvars_t*)&pusher->v)->origin); VectorAdd (SVFIELD (pusher, origin, vector), move, SVFIELD (pusher, origin, vector));
SV_LinkEdict (pusher, false); SV_LinkEdict (pusher, false);
// see if any solid entities are inside the final position // see if any solid entities are inside the final position
@ -447,30 +447,30 @@ SV_Push (edict_t *pusher, vec3_t move)
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
if (check->free) if (check->free)
continue; continue;
if (((entvars_t*)&check->v)->movetype == MOVETYPE_PUSH if (SVFIELD (check, movetype, float) == MOVETYPE_PUSH
|| ((entvars_t*)&check->v)->movetype == MOVETYPE_NONE || SVFIELD (check, movetype, float) == MOVETYPE_NONE
|| ((entvars_t*)&check->v)->movetype == MOVETYPE_PPUSH || SVFIELD (check, movetype, float) == MOVETYPE_PPUSH
|| ((entvars_t*)&check->v)->movetype == MOVETYPE_NOCLIP) continue; || SVFIELD (check, movetype, float) == MOVETYPE_NOCLIP) continue;
// Don't assume SOLID_BSP ! --KB // Don't assume SOLID_BSP ! --KB
solid_save = ((entvars_t*)&pusher->v)->solid; solid_save = SVFIELD (pusher, solid, float);
((entvars_t*)&pusher->v)->solid = SOLID_NOT; SVFIELD (pusher, solid, float) = SOLID_NOT;
block = SV_TestEntityPosition (check); block = SV_TestEntityPosition (check);
// ((entvars_t*)&pusher->v)->solid = SOLID_BSP; // SVFIELD (pusher, solid, float) = SOLID_BSP;
((entvars_t*)&pusher->v)->solid = solid_save; SVFIELD (pusher, solid, float) = solid_save;
if (block) if (block)
continue; continue;
// if the entity is standing on the pusher, it will definately be // if the entity is standing on the pusher, it will definately be
// moved // moved
if (!(((int) ((entvars_t*)&check->v)->flags & FL_ONGROUND) if (!(((int) SVFIELD (check, flags, float) & FL_ONGROUND)
&& PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&check->v)->groundentity) == pusher)) { && PROG_TO_EDICT (&sv_pr_state, SVFIELD (check, groundentity, int)) == pusher)) {
if (((entvars_t*)&check->v)->absmin[0] >= maxs[0] if (SVFIELD (check, absmin, vector)[0] >= maxs[0]
|| ((entvars_t*)&check->v)->absmin[1] >= maxs[1] || SVFIELD (check, absmin, vector)[1] >= maxs[1]
|| ((entvars_t*)&check->v)->absmin[2] >= maxs[2] || SVFIELD (check, absmin, vector)[2] >= maxs[2]
|| ((entvars_t*)&check->v)->absmax[0] <= mins[0] || SVFIELD (check, absmax, vector)[0] <= mins[0]
|| ((entvars_t*)&check->v)->absmax[1] <= mins[1] || SVFIELD (check, absmax, vector)[1] <= mins[1]
|| ((entvars_t*)&check->v)->absmax[2] <= mins[2]) || SVFIELD (check, absmax, vector)[2] <= mins[2])
continue; continue;
// see if the ent's bbox is inside the pusher's final position // see if the ent's bbox is inside the pusher's final position
@ -478,49 +478,49 @@ SV_Push (edict_t *pusher, vec3_t move)
continue; continue;
} }
VectorCopy (((entvars_t*)&check->v)->origin, moved_from[num_moved]); VectorCopy (SVFIELD (check, origin, vector), moved_from[num_moved]);
moved_edict[num_moved] = check; moved_edict[num_moved] = check;
num_moved++; num_moved++;
// try moving the contacted entity // try moving the contacted entity
VectorAdd (((entvars_t*)&check->v)->origin, move, ((entvars_t*)&check->v)->origin); VectorAdd (SVFIELD (check, origin, vector), move, SVFIELD (check, origin, vector));
block = SV_TestEntityPosition (check); block = SV_TestEntityPosition (check);
if (!block) { // pushed ok if (!block) { // pushed ok
SV_LinkEdict (check, false); SV_LinkEdict (check, false);
continue; continue;
} }
// if it is ok to leave in the old position, do it // if it is ok to leave in the old position, do it
VectorSubtract (((entvars_t*)&check->v)->origin, move, ((entvars_t*)&check->v)->origin); VectorSubtract (SVFIELD (check, origin, vector), move, SVFIELD (check, origin, vector));
block = SV_TestEntityPosition (check); block = SV_TestEntityPosition (check);
if (!block) { if (!block) {
num_moved--; num_moved--;
continue; continue;
} }
// if it is still inside the pusher, block // if it is still inside the pusher, block
if (((entvars_t*)&check->v)->mins[0] == ((entvars_t*)&check->v)->maxs[0]) { if (SVFIELD (check, mins, vector)[0] == SVFIELD (check, maxs, vector)[0]) {
SV_LinkEdict (check, false); SV_LinkEdict (check, false);
continue; continue;
} }
if (((entvars_t*)&check->v)->solid == SOLID_NOT || ((entvars_t*)&check->v)->solid == SOLID_TRIGGER) { // corpse if (SVFIELD (check, solid, float) == SOLID_NOT || SVFIELD (check, solid, float) == SOLID_TRIGGER) { // corpse
((entvars_t*)&check->v)->mins[0] = ((entvars_t*)&check->v)->mins[1] = 0; SVFIELD (check, mins, vector)[0] = SVFIELD (check, mins, vector)[1] = 0;
VectorCopy (((entvars_t*)&check->v)->mins, ((entvars_t*)&check->v)->maxs); VectorCopy (SVFIELD (check, mins, vector), SVFIELD (check, maxs, vector));
SV_LinkEdict (check, false); SV_LinkEdict (check, false);
continue; continue;
} }
VectorCopy (pushorig, ((entvars_t*)&pusher->v)->origin); VectorCopy (pushorig, SVFIELD (pusher, origin, vector));
SV_LinkEdict (pusher, false); SV_LinkEdict (pusher, false);
// if the pusher has a "blocked" function, call it // if the pusher has a "blocked" function, call it
// otherwise, just stay in place until the obstacle is gone // otherwise, just stay in place until the obstacle is gone
if (((entvars_t*)&pusher->v)->blocked) { if (SVFIELD (pusher, blocked, func)) {
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, pusher); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, pusher);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, check); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, check);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&pusher->v)->blocked); PR_ExecuteProgram (&sv_pr_state, SVFIELD (pusher, blocked, func));
} }
// move back any entities we already moved // move back any entities we already moved
for (i = 0; i < num_moved; i++) { for (i = 0; i < num_moved; i++) {
VectorCopy (moved_from[i], ((entvars_t*)&moved_edict[i]->v)->origin); VectorCopy (moved_from[i], SVFIELD (moved_edict[i], origin, vector));
SV_LinkEdict (moved_edict[i], false); SV_LinkEdict (moved_edict[i], false);
} }
return false; return false;
@ -538,17 +538,17 @@ SV_PushMove (edict_t *pusher, float movetime)
int i; int i;
vec3_t move; vec3_t move;
if (!((entvars_t*)&pusher->v)->velocity[0] && !((entvars_t*)&pusher->v)->velocity[1] if (!SVFIELD (pusher, velocity, vector)[0] && !SVFIELD (pusher, velocity, vector)[1]
&& !((entvars_t*)&pusher->v)->velocity[2]) { && !SVFIELD (pusher, velocity, vector)[2]) {
((entvars_t*)&pusher->v)->ltime += movetime; SVFIELD (pusher, ltime, float) += movetime;
return; return;
} }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
move[i] = ((entvars_t*)&pusher->v)->velocity[i] * movetime; move[i] = SVFIELD (pusher, velocity, vector)[i] * movetime;
if (SV_Push (pusher, move)) if (SV_Push (pusher, move))
((entvars_t*)&pusher->v)->ltime += movetime; SVFIELD (pusher, ltime, float) += movetime;
} }
@ -564,36 +564,36 @@ SV_Physics_Pusher (edict_t *ent)
vec3_t oldorg, move; vec3_t oldorg, move;
float l; float l;
oldltime = ((entvars_t*)&ent->v)->ltime; oldltime = SVFIELD (ent, ltime, float);
thinktime = ((entvars_t*)&ent->v)->nextthink; thinktime = SVFIELD (ent, nextthink, float);
if (thinktime < ((entvars_t*)&ent->v)->ltime + sv_frametime) { if (thinktime < SVFIELD (ent, ltime, float) + sv_frametime) {
movetime = thinktime - ((entvars_t*)&ent->v)->ltime; movetime = thinktime - SVFIELD (ent, ltime, float);
if (movetime < 0) if (movetime < 0)
movetime = 0; movetime = 0;
} else } else
movetime = sv_frametime; movetime = sv_frametime;
if (movetime) { if (movetime) {
SV_PushMove (ent, movetime); // advances ((entvars_t*)&ent->v)->ltime if not SV_PushMove (ent, movetime); // advances SVFIELD (ent, ltime, float) if not
// blocked // blocked
} }
if (thinktime > oldltime && thinktime <= ((entvars_t*)&ent->v)->ltime) { if (thinktime > oldltime && thinktime <= SVFIELD (ent, ltime, float)) {
VectorCopy (((entvars_t*)&ent->v)->origin, oldorg); VectorCopy (SVFIELD (ent, origin, vector), oldorg);
((entvars_t*)&ent->v)->nextthink = 0; SVFIELD (ent, nextthink, float) = 0;
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think); PR_ExecuteProgram (&sv_pr_state, SVFIELD (ent, think, func));
if (ent->free) if (ent->free)
return; return;
VectorSubtract (((entvars_t*)&ent->v)->origin, oldorg, move); VectorSubtract (SVFIELD (ent, origin, vector), oldorg, move);
l = Length (move); l = Length (move);
if (l > 1.0 / 64) { if (l > 1.0 / 64) {
// Con_Printf ("**** snap: %f\n", Length (l)); // Con_Printf ("**** snap: %f\n", Length (l));
VectorCopy (oldorg, ((entvars_t*)&ent->v)->origin); VectorCopy (oldorg, SVFIELD (ent, origin, vector));
SV_Push (ent, move); SV_Push (ent, move);
} }
} }
@ -625,8 +625,8 @@ SV_Physics_Noclip (edict_t *ent)
if (!SV_RunThink (ent)) if (!SV_RunThink (ent))
return; return;
VectorMA (((entvars_t*)&ent->v)->angles, sv_frametime, ((entvars_t*)&ent->v)->avelocity, ((entvars_t*)&ent->v)->angles); VectorMA (SVFIELD (ent, angles, vector), sv_frametime, SVFIELD (ent, avelocity, vector), SVFIELD (ent, angles, vector));
VectorMA (((entvars_t*)&ent->v)->origin, sv_frametime, ((entvars_t*)&ent->v)->velocity, ((entvars_t*)&ent->v)->origin); VectorMA (SVFIELD (ent, origin, vector), sv_frametime, SVFIELD (ent, velocity, vector), SVFIELD (ent, origin, vector));
SV_LinkEdict (ent, false); SV_LinkEdict (ent, false);
} }
@ -643,27 +643,27 @@ SV_CheckWaterTransition (edict_t *ent)
{ {
int cont; int cont;
cont = SV_PointContents (((entvars_t*)&ent->v)->origin); cont = SV_PointContents (SVFIELD (ent, origin, vector));
if (!((entvars_t*)&ent->v)->watertype) { // just spawned here if (!SVFIELD (ent, watertype, float)) { // just spawned here
((entvars_t*)&ent->v)->watertype = cont; SVFIELD (ent, watertype, float) = cont;
((entvars_t*)&ent->v)->waterlevel = 1; SVFIELD (ent, waterlevel, float) = 1;
return; return;
} }
if (cont <= CONTENTS_WATER) { if (cont <= CONTENTS_WATER) {
if (((entvars_t*)&ent->v)->watertype == CONTENTS_EMPTY) { // just crossed into if (SVFIELD (ent, watertype, float) == CONTENTS_EMPTY) { // just crossed into
// water // water
SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1);
} }
((entvars_t*)&ent->v)->watertype = cont; SVFIELD (ent, watertype, float) = cont;
((entvars_t*)&ent->v)->waterlevel = 1; SVFIELD (ent, waterlevel, float) = 1;
} else { } else {
if (((entvars_t*)&ent->v)->watertype != CONTENTS_EMPTY) { // just crossed into if (SVFIELD (ent, watertype, float) != CONTENTS_EMPTY) { // just crossed into
// water // water
SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1);
} }
((entvars_t*)&ent->v)->watertype = CONTENTS_EMPTY; SVFIELD (ent, watertype, float) = CONTENTS_EMPTY;
((entvars_t*)&ent->v)->waterlevel = cont; SVFIELD (ent, waterlevel, float) = cont;
} }
} }
@ -683,45 +683,45 @@ SV_Physics_Toss (edict_t *ent)
if (!SV_RunThink (ent)) if (!SV_RunThink (ent))
return; return;
if (((entvars_t*)&ent->v)->velocity[2] > 0) if (SVFIELD (ent, velocity, vector)[2] > 0)
((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags & ~FL_ONGROUND; SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) & ~FL_ONGROUND;
// if onground, return without moving // if onground, return without moving
if (((int) ((entvars_t*)&ent->v)->flags & FL_ONGROUND)) if (((int) SVFIELD (ent, flags, float) & FL_ONGROUND))
return; return;
SV_CheckVelocity (ent); SV_CheckVelocity (ent);
// add gravity // add gravity
if (((entvars_t*)&ent->v)->movetype != MOVETYPE_FLY if (SVFIELD (ent, movetype, float) != MOVETYPE_FLY
&& ((entvars_t*)&ent->v)->movetype != MOVETYPE_FLYMISSILE) SV_AddGravity (ent, 1.0); && SVFIELD (ent, movetype, float) != MOVETYPE_FLYMISSILE) SV_AddGravity (ent, 1.0);
// move angles // move angles
VectorMA (((entvars_t*)&ent->v)->angles, sv_frametime, ((entvars_t*)&ent->v)->avelocity, ((entvars_t*)&ent->v)->angles); VectorMA (SVFIELD (ent, angles, vector), sv_frametime, SVFIELD (ent, avelocity, vector), SVFIELD (ent, angles, vector));
// move origin // move origin
VectorScale (((entvars_t*)&ent->v)->velocity, sv_frametime, move); VectorScale (SVFIELD (ent, velocity, vector), sv_frametime, move);
trace = SV_PushEntity (ent, move); trace = SV_PushEntity (ent, move);
if (trace.fraction == 1) if (trace.fraction == 1)
return; return;
if (ent->free) if (ent->free)
return; return;
if (((entvars_t*)&ent->v)->movetype == MOVETYPE_BOUNCE) if (SVFIELD (ent, movetype, float) == MOVETYPE_BOUNCE)
backoff = 1.5; backoff = 1.5;
else else
backoff = 1; backoff = 1;
ClipVelocity (((entvars_t*)&ent->v)->velocity, trace.plane.normal, ((entvars_t*)&ent->v)->velocity, ClipVelocity (SVFIELD (ent, velocity, vector), trace.plane.normal, SVFIELD (ent, velocity, vector),
backoff); backoff);
// stop if on ground // stop if on ground
if (trace.plane.normal[2] > 0.7) { if (trace.plane.normal[2] > 0.7) {
if (((entvars_t*)&ent->v)->velocity[2] < 60 || ((entvars_t*)&ent->v)->movetype != MOVETYPE_BOUNCE) { if (SVFIELD (ent, velocity, vector)[2] < 60 || SVFIELD (ent, movetype, float) != MOVETYPE_BOUNCE) {
((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags | FL_ONGROUND; SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) | FL_ONGROUND;
((entvars_t*)&ent->v)->groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); SVFIELD (ent, groundentity, int) = EDICT_TO_PROG (&sv_pr_state, trace.ent);
VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); VectorCopy (vec3_origin, SVFIELD (ent, velocity, vector));
VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->avelocity); VectorCopy (vec3_origin, SVFIELD (ent, avelocity, vector));
} }
} }
// check for in water // check for in water
@ -748,8 +748,8 @@ SV_Physics_Step (edict_t *ent)
qboolean hitsound; qboolean hitsound;
// freefall if not on ground // freefall if not on ground
if (!((int) ((entvars_t*)&ent->v)->flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { if (!((int) SVFIELD (ent, flags, float) & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
if (((entvars_t*)&ent->v)->velocity[2] < movevars.gravity * -0.1) if (SVFIELD (ent, velocity, vector)[2] < movevars.gravity * -0.1)
hitsound = true; hitsound = true;
else else
hitsound = false; hitsound = false;
@ -759,7 +759,7 @@ SV_Physics_Step (edict_t *ent)
SV_FlyMove (ent, sv_frametime, NULL); SV_FlyMove (ent, sv_frametime, NULL);
SV_LinkEdict (ent, true); SV_LinkEdict (ent, true);
if ((int) ((entvars_t*)&ent->v)->flags & FL_ONGROUND) // just hit ground if ((int) SVFIELD (ent, flags, float) & FL_ONGROUND) // just hit ground
{ {
if (hitsound) if (hitsound)
SV_StartSound (ent, 0, "demon/dland2.wav", 255, 1); SV_StartSound (ent, 0, "demon/dland2.wav", 255, 1);
@ -782,27 +782,27 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push
SV_CheckVelocity (pusher); SV_CheckVelocity (pusher);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
move[i] = ((entvars_t*)&pusher->v)->velocity[i] * movetime; move[i] = SVFIELD (pusher, velocity, vector)[i] * movetime;
mins[i] = ((entvars_t*)&pusher->v)->absmin[i] + move[i]; mins[i] = SVFIELD (pusher, absmin, vector)[i] + move[i];
maxs[i] = ((entvars_t*)&pusher->v)->absmax[i] + move[i]; maxs[i] = SVFIELD (pusher, absmax, vector)[i] + move[i];
} }
VectorCopy (((entvars_t*)&pusher->v)->origin, ((entvars_t*)&pusher->v)->oldorigin); // Backup origin VectorCopy (SVFIELD (pusher, origin, vector), SVFIELD (pusher, oldorigin, vector)); // Backup origin
trace = trace =
SV_Move (((entvars_t*)&pusher->v)->origin, ((entvars_t*)&pusher->v)->mins, ((entvars_t*)&pusher->v)->maxs, move, SV_Move (SVFIELD (pusher, origin, vector), SVFIELD (pusher, mins, vector), SVFIELD (pusher, maxs, vector), move,
MOVE_NOMONSTERS, pusher); MOVE_NOMONSTERS, pusher);
if (trace.fraction == 1) { if (trace.fraction == 1) {
VectorCopy (((entvars_t*)&pusher->v)->origin, ((entvars_t*)&pusher->v)->oldorigin); // Revert VectorCopy (SVFIELD (pusher, origin, vector), SVFIELD (pusher, oldorigin, vector)); // Revert
return; return;
} }
VectorAdd (((entvars_t*)&pusher->v)->origin, move, ((entvars_t*)&pusher->v)->origin); // Move VectorAdd (SVFIELD (pusher, origin, vector), move, SVFIELD (pusher, origin, vector)); // Move
SV_LinkEdict (pusher, false); SV_LinkEdict (pusher, false);
((entvars_t*)&pusher->v)->ltime += movetime; SVFIELD (pusher, ltime, float) += movetime;
oldsolid = ((entvars_t*)&pusher->v)->solid; oldsolid = SVFIELD (pusher, solid, float);
check = NEXT_EDICT (&sv_pr_state, sv.edicts); check = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
@ -814,25 +814,25 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push
continue; continue;
// Stage 2: Is it a player we can push? // Stage 2: Is it a player we can push?
if (((entvars_t*)&check->v)->movetype == MOVETYPE_WALK) { if (SVFIELD (check, movetype, float) == MOVETYPE_WALK) {
Con_Printf ("Pusher encountered a player\n"); // Yes!@#!@ Con_Printf ("Pusher encountered a player\n"); // Yes!@#!@
((entvars_t*)&pusher->v)->solid = SOLID_NOT; SVFIELD (pusher, solid, float) = SOLID_NOT;
SV_PushEntity (check, move); SV_PushEntity (check, move);
((entvars_t*)&pusher->v)->solid = oldsolid; SVFIELD (pusher, solid, float) = oldsolid;
continue; continue;
} }
// Stage 3: No.. Is it something that blocks us? // Stage 3: No.. Is it something that blocks us?
if (((entvars_t*)&check->v)->mins[0] == ((entvars_t*)&check->v)->maxs[0]) if (SVFIELD (check, mins, vector)[0] == SVFIELD (check, maxs, vector)[0])
continue; continue;
if (((entvars_t*)&check->v)->solid == SOLID_NOT || ((entvars_t*)&check->v)->solid == SOLID_TRIGGER) if (SVFIELD (check, solid, float) == SOLID_NOT || SVFIELD (check, solid, float) == SOLID_TRIGGER)
continue; continue;
// Stage 4: Yes, it must be. Fail the move. // Stage 4: Yes, it must be. Fail the move.
VectorCopy (((entvars_t*)&pusher->v)->origin, ((entvars_t*)&pusher->v)->oldorigin); // Revert VectorCopy (SVFIELD (pusher, origin, vector), SVFIELD (pusher, oldorigin, vector)); // Revert
if (((entvars_t*)&pusher->v)->blocked) { // Blocked func? if (SVFIELD (pusher, blocked, func)) { // Blocked func?
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, pusher); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, pusher);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, check); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, check);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&pusher->v)->blocked); PR_ExecuteProgram (&sv_pr_state, SVFIELD (pusher, blocked, func));
} }
return; return;
@ -848,11 +848,11 @@ SV_Physics_PPusher (edict_t *ent)
// float l; // float l;
oldltime = ((entvars_t*)&ent->v)->ltime; oldltime = SVFIELD (ent, ltime, float);
thinktime = ((entvars_t*)&ent->v)->nextthink; thinktime = SVFIELD (ent, nextthink, float);
if (thinktime < ((entvars_t*)&ent->v)->ltime + sv_frametime) { if (thinktime < SVFIELD (ent, ltime, float) + sv_frametime) {
movetime = thinktime - ((entvars_t*)&ent->v)->ltime; movetime = thinktime - SVFIELD (ent, ltime, float);
if (movetime < 0) if (movetime < 0)
movetime = 0; movetime = 0;
} else } else
@ -860,16 +860,16 @@ SV_Physics_PPusher (edict_t *ent)
// if (movetime) // if (movetime)
// { // {
SV_PPushMove (ent, 0.0009); // advances ((entvars_t*)&ent->v)->ltime if not SV_PPushMove (ent, 0.0009); // advances SVFIELD (ent, ltime, float) if not
// blocked // blocked
// } // }
if (thinktime > oldltime && thinktime <= ((entvars_t*)&ent->v)->ltime) { if (thinktime > oldltime && thinktime <= SVFIELD (ent, ltime, float)) {
((entvars_t*)&ent->v)->nextthink = 0; SVFIELD (ent, nextthink, float) = 0;
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think); PR_ExecuteProgram (&sv_pr_state, SVFIELD (ent, think, func));
if (ent->free) if (ent->free)
return; return;
} }
@ -893,11 +893,11 @@ SV_ProgStartFrame (void)
void void
SV_RunEntity (edict_t *ent) SV_RunEntity (edict_t *ent)
{ {
if (((entvars_t*)&ent->v)->lastruntime == (float) realtime) if (SVFIELD (ent, lastruntime, float) == (float) realtime)
return; return;
((entvars_t*)&ent->v)->lastruntime = (float) realtime; SVFIELD (ent, lastruntime, float) = (float) realtime;
switch ((int) ((entvars_t*)&ent->v)->movetype) { switch ((int) SVFIELD (ent, movetype, float)) {
case MOVETYPE_PUSH: case MOVETYPE_PUSH:
SV_Physics_Pusher (ent); SV_Physics_Pusher (ent);
break; break;
@ -920,7 +920,7 @@ SV_RunEntity (edict_t *ent)
SV_Physics_Toss (ent); SV_Physics_Toss (ent);
break; break;
default: default:
SV_Error ("SV_Physics: bad movetype %i", (int) ((entvars_t*)&ent->v)->movetype); SV_Error ("SV_Physics: bad movetype %i", (int) SVFIELD (ent, movetype, float));
} }
} }

View file

@ -80,7 +80,7 @@ PF_error (progs_t *pr)
s = PF_VarString (pr, 0); s = PF_VarString (pr, 0);
Con_Printf ("======SERVER ERROR in %s:\n%s\n", Con_Printf ("======SERVER ERROR in %s:\n%s\n",
PR_GetString (pr, pr->pr_xfunction->s_name), s); PR_GetString (pr, pr->pr_xfunction->s_name), s);
ed = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); ed = PROG_TO_EDICT (pr, *sv_globals.self);
ED_Print (pr, ed); ED_Print (pr, ed);
SV_Error ("Program error"); SV_Error ("Program error");
@ -103,7 +103,7 @@ PF_objerror (progs_t *pr)
s = PF_VarString (pr, 0); s = PF_VarString (pr, 0);
Con_Printf ("======OBJECT ERROR in %s:\n%s\n", Con_Printf ("======OBJECT ERROR in %s:\n%s\n",
PR_GetString (pr, pr->pr_xfunction->s_name), s); PR_GetString (pr, pr->pr_xfunction->s_name), s);
ed = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); ed = PROG_TO_EDICT (pr, *sv_globals.self);
ED_Print (pr, ed); ED_Print (pr, ed);
ED_Free (pr, ed); ED_Free (pr, ed);
@ -121,8 +121,8 @@ PF_objerror (progs_t *pr)
void void
PF_makevectors (progs_t *pr) PF_makevectors (progs_t *pr)
{ {
AngleVectors (G_VECTOR (pr, OFS_PARM0), ((globalvars_t*)pr->pr_globals)->v_forward, AngleVectors (G_VECTOR (pr, OFS_PARM0), *sv_globals.v_forward,
((globalvars_t*)pr->pr_globals)->v_right, ((globalvars_t*)pr->pr_globals)->v_up); *sv_globals.v_right, *sv_globals.v_up);
} }
/* /*
@ -140,7 +140,7 @@ PF_setorigin (progs_t *pr)
e = G_EDICT (pr, OFS_PARM0); e = G_EDICT (pr, OFS_PARM0);
org = G_VECTOR (pr, OFS_PARM1); org = G_VECTOR (pr, OFS_PARM1);
VectorCopy (org, ((entvars_t*)&e->v)->origin); VectorCopy (org, SVFIELD (e, origin, vector));
SV_LinkEdict (e, false); SV_LinkEdict (e, false);
} }
@ -161,9 +161,9 @@ PF_setsize (progs_t *pr)
e = G_EDICT (pr, OFS_PARM0); e = G_EDICT (pr, OFS_PARM0);
min = G_VECTOR (pr, OFS_PARM1); min = G_VECTOR (pr, OFS_PARM1);
max = G_VECTOR (pr, OFS_PARM2); max = G_VECTOR (pr, OFS_PARM2);
VectorCopy (min, ((entvars_t*)&e->v)->mins); VectorCopy (min, SVFIELD (e, mins, vector));
VectorCopy (max, ((entvars_t*)&e->v)->maxs); VectorCopy (max, SVFIELD (e, maxs, vector));
VectorSubtract (max, min, ((entvars_t*)&e->v)->size); VectorSubtract (max, min, SVFIELD (e, size, vector));
SV_LinkEdict (e, false); SV_LinkEdict (e, false);
} }
@ -193,15 +193,15 @@ PF_setmodel (progs_t *pr)
if (!*check) if (!*check)
PR_RunError (pr, "no precache: %s\n", m); PR_RunError (pr, "no precache: %s\n", m);
((entvars_t*)&e->v)->model = PR_SetString (pr, m); SVFIELD (e, model, string) = PR_SetString (pr, m);
((entvars_t*)&e->v)->modelindex = i; SVFIELD (e, modelindex, float) = i;
// if it is an inline model, get the size information for it // if it is an inline model, get the size information for it
if (m[0] == '*') { if (m[0] == '*') {
mod = Mod_ForName (m, true); mod = Mod_ForName (m, true);
VectorCopy (mod->mins, ((entvars_t*)&e->v)->mins); VectorCopy (mod->mins, SVFIELD (e, mins, vector));
VectorCopy (mod->maxs, ((entvars_t*)&e->v)->maxs); VectorCopy (mod->maxs, SVFIELD (e, maxs, vector));
VectorSubtract (mod->maxs, mod->mins, ((entvars_t*)&e->v)->size); VectorSubtract (mod->maxs, mod->mins, SVFIELD (e, size, vector));
SV_LinkEdict (e, false); SV_LinkEdict (e, false);
} }
@ -519,18 +519,18 @@ PF_traceline (progs_t *pr)
trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent); trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent);
((globalvars_t*)pr->pr_globals)->trace_allsolid = trace.allsolid; *sv_globals.trace_allsolid = trace.allsolid;
((globalvars_t*)pr->pr_globals)->trace_startsolid = trace.startsolid; *sv_globals.trace_startsolid = trace.startsolid;
((globalvars_t*)pr->pr_globals)->trace_fraction = trace.fraction; *sv_globals.trace_fraction = trace.fraction;
((globalvars_t*)pr->pr_globals)->trace_inwater = trace.inwater; *sv_globals.trace_inwater = trace.inwater;
((globalvars_t*)pr->pr_globals)->trace_inopen = trace.inopen; *sv_globals.trace_inopen = trace.inopen;
VectorCopy (trace.endpos, ((globalvars_t*)pr->pr_globals)->trace_endpos); VectorCopy (trace.endpos, *sv_globals.trace_endpos);
VectorCopy (trace.plane.normal, ((globalvars_t*)pr->pr_globals)->trace_plane_normal); VectorCopy (trace.plane.normal, *sv_globals.trace_plane_normal);
((globalvars_t*)pr->pr_globals)->trace_plane_dist = trace.plane.dist; *sv_globals.trace_plane_dist = trace.plane.dist;
if (trace.ent) if (trace.ent)
((globalvars_t*)pr->pr_globals)->trace_ent = EDICT_TO_PROG (pr, trace.ent); *sv_globals.trace_ent = EDICT_TO_PROG (pr, trace.ent);
else else
((globalvars_t*)pr->pr_globals)->trace_ent = EDICT_TO_PROG (pr, sv.edicts); *sv_globals.trace_ent = EDICT_TO_PROG (pr, sv.edicts);
} }
/* /*
@ -582,9 +582,9 @@ PF_newcheckclient (progs_t *pr, int check)
if (ent->free) if (ent->free)
continue; continue;
if (((entvars_t*)&ent->v)->health <= 0) if (SVFIELD (ent, health, float) <= 0)
continue; continue;
if ((int) ((entvars_t*)&ent->v)->flags & FL_NOTARGET) if ((int) SVFIELD (ent, flags, float) & FL_NOTARGET)
continue; continue;
// anything that is a client, or has a client as an enemy // anything that is a client, or has a client as an enemy
@ -592,7 +592,7 @@ PF_newcheckclient (progs_t *pr, int check)
} }
// get the PVS for the entity // get the PVS for the entity
VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->view_ofs, org); VectorAdd (SVFIELD (ent, origin, vector), SVFIELD (ent, view_ofs, vector), org);
leaf = Mod_PointInLeaf (org, sv.worldmodel); leaf = Mod_PointInLeaf (org, sv.worldmodel);
pvs = Mod_LeafPVS (leaf, sv.worldmodel); pvs = Mod_LeafPVS (leaf, sv.worldmodel);
memcpy (checkpvs, pvs, (sv.worldmodel->numleafs + 7) >> 3); memcpy (checkpvs, pvs, (sv.worldmodel->numleafs + 7) >> 3);
@ -630,13 +630,13 @@ PF_checkclient (progs_t *pr)
} }
// return check if it might be visible // return check if it might be visible
ent = EDICT_NUM (pr, sv.lastcheck); ent = EDICT_NUM (pr, sv.lastcheck);
if (ent->free || ((entvars_t*)&ent->v)->health <= 0) { if (ent->free || SVFIELD (ent, health, float) <= 0) {
RETURN_EDICT (pr, sv.edicts); RETURN_EDICT (pr, sv.edicts);
return; return;
} }
// if current entity can't possibly see the check entity, return 0 // if current entity can't possibly see the check entity, return 0
self = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); self = PROG_TO_EDICT (pr, *sv_globals.self);
VectorAdd (((entvars_t*)&self->v)->origin, ((entvars_t*)&self->v)->view_ofs, view); VectorAdd (SVFIELD (self, origin, vector), SVFIELD (self, view_ofs, vector), view);
leaf = Mod_PointInLeaf (view, sv.worldmodel); leaf = Mod_PointInLeaf (view, sv.worldmodel);
l = (leaf - sv.worldmodel->leafs) - 1; l = (leaf - sv.worldmodel->leafs) - 1;
if ((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) { if ((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) {
@ -780,16 +780,16 @@ PF_findradius (progs_t *pr)
for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) { for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) {
if (ent->free) if (ent->free)
continue; continue;
if (((entvars_t*)&ent->v)->solid == SOLID_NOT) if (SVFIELD (ent, solid, float) == SOLID_NOT)
continue; continue;
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
eorg[j] = eorg[j] =
org[j] - (((entvars_t*)&ent->v)->origin[j] + org[j] - (SVFIELD (ent, origin, vector)[j] +
(((entvars_t*)&ent->v)->mins[j] + ((entvars_t*)&ent->v)->maxs[j]) * 0.5); (SVFIELD (ent, mins, vector)[j] + SVFIELD (ent, maxs, vector)[j]) * 0.5);
if (Length (eorg) > rad) if (Length (eorg) > rad)
continue; continue;
((entvars_t*)&ent->v)->chain = EDICT_TO_PROG (pr, chain); SVFIELD (ent, chain, int) = EDICT_TO_PROG (pr, chain);
chain = ent; chain = ent;
} }
@ -1003,11 +1003,11 @@ PF_walkmove (progs_t *pr)
dfunction_t *oldf; dfunction_t *oldf;
int oldself; int oldself;
ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); ent = PROG_TO_EDICT (pr, *sv_globals.self);
yaw = G_FLOAT (pr, OFS_PARM0); yaw = G_FLOAT (pr, OFS_PARM0);
dist = G_FLOAT (pr, OFS_PARM1); dist = G_FLOAT (pr, OFS_PARM1);
if (!((int) ((entvars_t*)&ent->v)->flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { if (!((int) SVFIELD (ent, flags, float) & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
G_FLOAT (pr, OFS_RETURN) = 0; G_FLOAT (pr, OFS_RETURN) = 0;
return; return;
} }
@ -1020,14 +1020,14 @@ PF_walkmove (progs_t *pr)
// save program state, because SV_movestep may call other progs // save program state, because SV_movestep may call other progs
oldf = pr->pr_xfunction; oldf = pr->pr_xfunction;
oldself = ((globalvars_t*)pr->pr_globals)->self; oldself = *sv_globals.self;
G_FLOAT (pr, OFS_RETURN) = SV_movestep (ent, move, true); G_FLOAT (pr, OFS_RETURN) = SV_movestep (ent, move, true);
// restore program state // restore program state
pr->pr_xfunction = oldf; pr->pr_xfunction = oldf;
((globalvars_t*)pr->pr_globals)->self = oldself; *sv_globals.self = oldself;
} }
/* /*
@ -1042,20 +1042,20 @@ PF_droptofloor (progs_t *pr)
vec3_t end; vec3_t end;
trace_t trace; trace_t trace;
ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); ent = PROG_TO_EDICT (pr, *sv_globals.self);
VectorCopy (((entvars_t*)&ent->v)->origin, end); VectorCopy (SVFIELD (ent, origin, vector), end);
end[2] -= 256; end[2] -= 256;
trace = SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, false, ent); trace = SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), end, false, ent);
if (trace.fraction == 1 || trace.allsolid) if (trace.fraction == 1 || trace.allsolid)
G_FLOAT (pr, OFS_RETURN) = 0; G_FLOAT (pr, OFS_RETURN) = 0;
else { else {
VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); VectorCopy (trace.endpos, SVFIELD (ent, origin, vector));
SV_LinkEdict (ent, false); SV_LinkEdict (ent, false);
((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags | FL_ONGROUND; SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) | FL_ONGROUND;
((entvars_t*)&ent->v)->groundentity = EDICT_TO_PROG (pr, trace.ent); SVFIELD (ent, groundentity, int) = EDICT_TO_PROG (pr, trace.ent);
G_FLOAT (pr, OFS_RETURN) = 1; G_FLOAT (pr, OFS_RETURN) = 1;
} }
} }
@ -1190,7 +1190,7 @@ PF_aim (progs_t *pr)
ent = G_EDICT (pr, OFS_PARM0); ent = G_EDICT (pr, OFS_PARM0);
speed = G_FLOAT (pr, OFS_PARM1); speed = G_FLOAT (pr, OFS_PARM1);
VectorCopy (((entvars_t*)&ent->v)->origin, start); VectorCopy (SVFIELD (ent, origin, vector), start);
start[2] += 20; start[2] += 20;
// noaim option // noaim option
@ -1198,18 +1198,18 @@ PF_aim (progs_t *pr)
if (i > 0 && i < MAX_CLIENTS) { if (i > 0 && i < MAX_CLIENTS) {
noaim = Info_ValueForKey (svs.clients[i - 1].userinfo, "noaim"); noaim = Info_ValueForKey (svs.clients[i - 1].userinfo, "noaim");
if (atoi (noaim) > 0) { if (atoi (noaim) > 0) {
VectorCopy (((globalvars_t*)pr->pr_globals)->v_forward, G_VECTOR (pr, OFS_RETURN)); VectorCopy (*sv_globals.v_forward, G_VECTOR (pr, OFS_RETURN));
return; return;
} }
} }
// try sending a trace straight // try sending a trace straight
VectorCopy (((globalvars_t*)pr->pr_globals)->v_forward, dir); VectorCopy (*sv_globals.v_forward, dir);
VectorMA (start, 2048, dir, end); VectorMA (start, 2048, dir, end);
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent); tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
if (tr.ent && ((entvars_t*)&tr.ent->v)->takedamage == DAMAGE_AIM if (tr.ent && SVFIELD (tr.ent, takedamage, float) == DAMAGE_AIM
&& (!teamplay->int_val || ((entvars_t*)&ent->v)->team <= 0 && (!teamplay->int_val || SVFIELD (ent, team, float) <= 0
|| ((entvars_t*)&ent->v)->team != ((entvars_t*)&tr.ent->v)->team)) { || SVFIELD (ent, team, float) != SVFIELD (tr.ent, team, float))) {
VectorCopy (((globalvars_t*)pr->pr_globals)->v_forward, G_VECTOR (pr, OFS_RETURN)); VectorCopy (*sv_globals.v_forward, G_VECTOR (pr, OFS_RETURN));
return; return;
} }
@ -1220,19 +1220,19 @@ PF_aim (progs_t *pr)
check = NEXT_EDICT (pr, sv.edicts); check = NEXT_EDICT (pr, sv.edicts);
for (i = 1; i < sv.num_edicts; i++, check = NEXT_EDICT (pr, check)) { for (i = 1; i < sv.num_edicts; i++, check = NEXT_EDICT (pr, check)) {
if (((entvars_t*)&check->v)->takedamage != DAMAGE_AIM) if (SVFIELD (check, takedamage, float) != DAMAGE_AIM)
continue; continue;
if (check == ent) if (check == ent)
continue; continue;
if (teamplay->int_val && ((entvars_t*)&ent->v)->team > 0 if (teamplay->int_val && SVFIELD (ent, team, float) > 0
&& ((entvars_t*)&ent->v)->team == ((entvars_t*)&check->v)->team) continue; // don't aim at && SVFIELD (ent, team, float) == SVFIELD (check, team, float)) continue; // don't aim at
// teammate // teammate
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
end[j] = ((entvars_t*)&check->v)->origin[j] end[j] = SVFIELD (check, origin, vector)[j]
+ 0.5 * (((entvars_t*)&check->v)->mins[j] + ((entvars_t*)&check->v)->maxs[j]); + 0.5 * (SVFIELD (check, mins, vector)[j] + SVFIELD (check, maxs, vector)[j]);
VectorSubtract (end, start, dir); VectorSubtract (end, start, dir);
VectorNormalize (dir); VectorNormalize (dir);
dist = DotProduct (dir, ((globalvars_t*)pr->pr_globals)->v_forward); dist = DotProduct (dir, *sv_globals.v_forward);
if (dist < bestdist) if (dist < bestdist)
continue; // to far to turn continue; // to far to turn
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent); tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
@ -1243,9 +1243,9 @@ PF_aim (progs_t *pr)
} }
if (bestent) { if (bestent) {
VectorSubtract (((entvars_t*)&bestent->v)->origin, ((entvars_t*)&ent->v)->origin, dir); VectorSubtract (SVFIELD (bestent, origin, vector), SVFIELD (ent, origin, vector), dir);
dist = DotProduct (dir, ((globalvars_t*)pr->pr_globals)->v_forward); dist = DotProduct (dir, *sv_globals.v_forward);
VectorScale (((globalvars_t*)pr->pr_globals)->v_forward, dist, end); VectorScale (*sv_globals.v_forward, dist, end);
end[2] = dir[2]; end[2] = dir[2];
VectorNormalize (end); VectorNormalize (end);
VectorCopy (end, G_VECTOR (pr, OFS_RETURN)); VectorCopy (end, G_VECTOR (pr, OFS_RETURN));
@ -1265,10 +1265,10 @@ PF_changeyaw (progs_t *pr)
edict_t *ent; edict_t *ent;
float ideal, current, move, speed; float ideal, current, move, speed;
ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); ent = PROG_TO_EDICT (pr, *sv_globals.self);
current = anglemod (((entvars_t*)&ent->v)->angles[1]); current = anglemod (SVFIELD (ent, angles, vector)[1]);
ideal = ((entvars_t*)&ent->v)->ideal_yaw; ideal = SVFIELD (ent, ideal_yaw, float);
speed = ((entvars_t*)&ent->v)->yaw_speed; speed = SVFIELD (ent, yaw_speed, float);
if (current == ideal) if (current == ideal)
return; return;
@ -1288,7 +1288,7 @@ PF_changeyaw (progs_t *pr)
move = -speed; move = -speed;
} }
((entvars_t*)&ent->v)->angles[1] = anglemod (current + move); SVFIELD (ent, angles, vector)[1] = anglemod (current + move);
} }
/* /*
@ -1314,7 +1314,7 @@ WriteDest (progs_t *pr)
case MSG_ONE: case MSG_ONE:
SV_Error ("Shouldn't be at MSG_ONE"); SV_Error ("Shouldn't be at MSG_ONE");
#if 0 #if 0
ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->msg_entity); ent = PROG_TO_EDICT (pr, *sv_globals.msg_entity);
entnum = NUM_FOR_EDICT (pr, ent); entnum = NUM_FOR_EDICT (pr, ent);
if (entnum < 1 || entnum > MAX_CLIENTS) if (entnum < 1 || entnum > MAX_CLIENTS)
PR_RunError (pr, "WriteDest: not a client"); PR_RunError (pr, "WriteDest: not a client");
@ -1347,7 +1347,7 @@ Write_GetClient (progs_t *pr)
int entnum; int entnum;
edict_t *ent; edict_t *ent;
ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->msg_entity); ent = PROG_TO_EDICT (pr, *sv_globals.msg_entity);
entnum = NUM_FOR_EDICT (pr, ent); entnum = NUM_FOR_EDICT (pr, ent);
if (entnum < 1 || entnum > MAX_CLIENTS) if (entnum < 1 || entnum > MAX_CLIENTS)
PR_RunError (pr, "Write_GetClient: not a client"); PR_RunError (pr, "Write_GetClient: not a client");
@ -1466,14 +1466,14 @@ PF_makestatic (progs_t *pr)
MSG_WriteByte (&sv.signon, svc_spawnstatic); MSG_WriteByte (&sv.signon, svc_spawnstatic);
MSG_WriteByte (&sv.signon, SV_ModelIndex (PR_GetString (pr, ((entvars_t*)&ent->v)->model))); MSG_WriteByte (&sv.signon, SV_ModelIndex (PR_GetString (pr, SVFIELD (ent, model, float))));
MSG_WriteByte (&sv.signon, ((entvars_t*)&ent->v)->frame); MSG_WriteByte (&sv.signon, SVFIELD (ent, frame, float));
MSG_WriteByte (&sv.signon, ((entvars_t*)&ent->v)->colormap); MSG_WriteByte (&sv.signon, SVFIELD (ent, colormap, float));
MSG_WriteByte (&sv.signon, ((entvars_t*)&ent->v)->skin); MSG_WriteByte (&sv.signon, SVFIELD (ent, skin, float));
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
MSG_WriteCoord (&sv.signon, ((entvars_t*)&ent->v)->origin[i]); MSG_WriteCoord (&sv.signon, SVFIELD (ent, origin, vector)[i]);
MSG_WriteAngle (&sv.signon, ((entvars_t*)&ent->v)->angles[i]); MSG_WriteAngle (&sv.signon, SVFIELD (ent, angles, vector)[i]);
} }
// throw the entity away now // throw the entity away now
@ -1501,7 +1501,7 @@ PF_setspawnparms (progs_t *pr)
client = svs.clients + (i - 1); client = svs.clients + (i - 1);
for (i = 0; i < NUM_SPAWN_PARMS; i++) for (i = 0; i < NUM_SPAWN_PARMS; i++)
(&((globalvars_t*)pr->pr_globals)->parm1)[i] = client->spawn_parms[i]; sv_globals.parms[i] = client->spawn_parms[i];
} }
/* /*

View file

@ -39,11 +39,13 @@
#include "cmd.h" #include "cmd.h"
#include "server.h" #include "server.h"
#include "progdefs.h"
#include "sv_progs.h" #include "sv_progs.h"
#include "world.h" #include "world.h"
sv_globals_t sv_globals; sv_globals_t sv_globals;
sv_funcs_t sv_funcs; sv_funcs_t sv_funcs;
sv_fields_t sv_fields;
int eval_alpha; int eval_alpha;
int eval_scale; int eval_scale;
@ -94,7 +96,7 @@ FindEdictFieldOffsets (progs_t *pr)
int int
ED_Prune_Edict (progs_t *pr, edict_t *ent) ED_Prune_Edict (progs_t *pr, edict_t *ent)
{ {
if (((int) ((entvars_t*)&ent->v)->spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) if (((int) SVFIELD (ent, spawnflags, float) & SPAWNFLAG_NOT_DEATHMATCH))
return 1; return 1;
return 0; return 0;
} }
@ -233,6 +235,71 @@ SV_LoadProgs (void)
ED_FindFunction (&sv_pr_state, "SetNewParms") - sv_pr_state.pr_functions; ED_FindFunction (&sv_pr_state, "SetNewParms") - sv_pr_state.pr_functions;
sv_funcs.SetChangeParms = sv_funcs.SetChangeParms =
ED_FindFunction (&sv_pr_state, "SetChangeParms") - sv_pr_state.pr_functions; ED_FindFunction (&sv_pr_state, "SetChangeParms") - sv_pr_state.pr_functions;
sv_fields.modelindex = ED_FindField (&sv_pr_state, "modelindex")->ofs;
sv_fields.absmin = ED_FindField (&sv_pr_state, "absmin")->ofs;
sv_fields.absmax = ED_FindField (&sv_pr_state, "absmax")->ofs;
sv_fields.ltime = ED_FindField (&sv_pr_state, "ltime")->ofs;
sv_fields.lastruntime = ED_FindField (&sv_pr_state, "lastruntime")->ofs;
sv_fields.movetype = ED_FindField (&sv_pr_state, "movetype")->ofs;
sv_fields.solid = ED_FindField (&sv_pr_state, "solid")->ofs;
sv_fields.origin = ED_FindField (&sv_pr_state, "origin")->ofs;
sv_fields.oldorigin = ED_FindField (&sv_pr_state, "oldorigin")->ofs;
sv_fields.velocity = ED_FindField (&sv_pr_state, "velocity")->ofs;
sv_fields.angles = ED_FindField (&sv_pr_state, "angles")->ofs;
sv_fields.avelocity = ED_FindField (&sv_pr_state, "avelocity")->ofs;
sv_fields.classname = ED_FindField (&sv_pr_state, "classname")->ofs;
sv_fields.model = ED_FindField (&sv_pr_state, "model")->ofs;
sv_fields.frame = ED_FindField (&sv_pr_state, "frame")->ofs;
sv_fields.skin = ED_FindField (&sv_pr_state, "skin")->ofs;
sv_fields.effects = ED_FindField (&sv_pr_state, "effects")->ofs;
sv_fields.mins = ED_FindField (&sv_pr_state, "mins")->ofs;
sv_fields.maxs = ED_FindField (&sv_pr_state, "maxs")->ofs;
sv_fields.size = ED_FindField (&sv_pr_state, "size")->ofs;
sv_fields.touch = ED_FindField (&sv_pr_state, "touch")->ofs;
sv_fields.think = ED_FindField (&sv_pr_state, "think")->ofs;
sv_fields.blocked = ED_FindField (&sv_pr_state, "blocked")->ofs;
sv_fields.nextthink = ED_FindField (&sv_pr_state, "nextthink")->ofs;
sv_fields.groundentity = ED_FindField (&sv_pr_state, "groundentity")->ofs;
sv_fields.health = ED_FindField (&sv_pr_state, "health")->ofs;
sv_fields.frags = ED_FindField (&sv_pr_state, "frags")->ofs;
sv_fields.weapon = ED_FindField (&sv_pr_state, "weapon")->ofs;
sv_fields.weaponmodel = ED_FindField (&sv_pr_state, "weaponmodel")->ofs;
sv_fields.weaponframe = ED_FindField (&sv_pr_state, "weaponframe")->ofs;
sv_fields.currentammo = ED_FindField (&sv_pr_state, "currentammo")->ofs;
sv_fields.ammo_shells = ED_FindField (&sv_pr_state, "ammo_shells")->ofs;
sv_fields.ammo_nails = ED_FindField (&sv_pr_state, "ammo_nails")->ofs;
sv_fields.ammo_rockets = ED_FindField (&sv_pr_state, "ammo_rockets")->ofs;
sv_fields.ammo_cells = ED_FindField (&sv_pr_state, "ammo_cells")->ofs;
sv_fields.items = ED_FindField (&sv_pr_state, "items")->ofs;
sv_fields.takedamage = ED_FindField (&sv_pr_state, "takedamage")->ofs;
sv_fields.chain = ED_FindField (&sv_pr_state, "chain")->ofs;
sv_fields.view_ofs = ED_FindField (&sv_pr_state, "view_ofs")->ofs;
sv_fields.button0 = ED_FindField (&sv_pr_state, "button0")->ofs;
sv_fields.button1 = ED_FindField (&sv_pr_state, "button1")->ofs;
sv_fields.button2 = ED_FindField (&sv_pr_state, "button2")->ofs;
sv_fields.impulse = ED_FindField (&sv_pr_state, "impulse")->ofs;
sv_fields.fixangle = ED_FindField (&sv_pr_state, "fixangle")->ofs;
sv_fields.v_angle = ED_FindField (&sv_pr_state, "v_angle")->ofs;
sv_fields.netname = ED_FindField (&sv_pr_state, "netname")->ofs;
sv_fields.enemy = ED_FindField (&sv_pr_state, "enemy")->ofs;
sv_fields.flags = ED_FindField (&sv_pr_state, "flags")->ofs;
sv_fields.colormap = ED_FindField (&sv_pr_state, "colormap")->ofs;
sv_fields.team = ED_FindField (&sv_pr_state, "team")->ofs;
sv_fields.teleport_time = ED_FindField (&sv_pr_state, "teleport_time")->ofs;
sv_fields.armorvalue = ED_FindField (&sv_pr_state, "armorvalue")->ofs;
sv_fields.waterlevel = ED_FindField (&sv_pr_state, "waterlevel")->ofs;
sv_fields.watertype = ED_FindField (&sv_pr_state, "watertype")->ofs;
sv_fields.ideal_yaw = ED_FindField (&sv_pr_state, "ideal_yaw")->ofs;
sv_fields.yaw_speed = ED_FindField (&sv_pr_state, "yaw_speed")->ofs;
sv_fields.goalentity = ED_FindField (&sv_pr_state, "goalentity")->ofs;
sv_fields.spawnflags = ED_FindField (&sv_pr_state, "spawnflags")->ofs;
sv_fields.dmg_take = ED_FindField (&sv_pr_state, "dmg_take")->ofs;
sv_fields.dmg_save = ED_FindField (&sv_pr_state, "dmg_save")->ofs;
sv_fields.dmg_inflictor = ED_FindField (&sv_pr_state, "dmg_inflictor")->ofs;
sv_fields.owner = ED_FindField (&sv_pr_state, "owner")->ofs;
sv_fields.message = ED_FindField (&sv_pr_state, "message")->ofs;
sv_fields.sounds = ED_FindField (&sv_pr_state, "sounds")->ofs;
} }
void void

View file

@ -333,12 +333,12 @@ SV_Multicast (vec3_t origin, int to)
if (to == MULTICAST_PHS_R || to == MULTICAST_PHS) { if (to == MULTICAST_PHS_R || to == MULTICAST_PHS) {
vec3_t delta; vec3_t delta;
VectorSubtract (origin, ((entvars_t*)&client->edict->v)->origin, delta); VectorSubtract (origin, SVFIELD (client->edict, origin, vector), delta);
if (Length (delta) <= 1024) if (Length (delta) <= 1024)
goto inrange; goto inrange;
} }
leaf = Mod_PointInLeaf (((entvars_t*)&client->edict->v)->origin, sv.worldmodel); leaf = Mod_PointInLeaf (SVFIELD (client->edict, origin, vector), sv.worldmodel);
if (leaf) { if (leaf) {
// -1 is because pvs rows are 1 based, not 0 based like leafs // -1 is because pvs rows are 1 based, not 0 based like leafs
leafnum = leaf - sv.worldmodel->leafs - 1; leafnum = leaf - sv.worldmodel->leafs - 1;
@ -430,13 +430,13 @@ SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
channel |= SND_ATTENUATION; channel |= SND_ATTENUATION;
// use the entity origin unless it is a bmodel // use the entity origin unless it is a bmodel
if (((entvars_t*)&entity->v)->solid == SOLID_BSP) { if (SVFIELD (entity, solid, float) == SOLID_BSP) {
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
origin[i] = origin[i] =
((entvars_t*)&entity->v)->origin[i] + 0.5 * (((entvars_t*)&entity->v)->mins[i] + SVFIELD (entity, origin, vector)[i] + 0.5 * (SVFIELD (entity, mins, vector)[i] +
((entvars_t*)&entity->v)->maxs[i]); SVFIELD (entity, maxs, vector)[i]);
} else { } else {
VectorCopy (((entvars_t*)&entity->v)->origin, origin); VectorCopy (SVFIELD (entity, origin, vector), origin);
} }
MSG_WriteByte (&sv.multicast, svc_sound); MSG_WriteByte (&sv.multicast, svc_sound);
@ -503,25 +503,25 @@ SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg)
client->chokecount = 0; client->chokecount = 0;
} }
// send a damage message if the player got hit this frame // send a damage message if the player got hit this frame
if (((entvars_t*)&ent->v)->dmg_take || ((entvars_t*)&ent->v)->dmg_save) { if (SVFIELD (ent, dmg_take, float) || SVFIELD (ent, dmg_save, float)) {
other = PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->dmg_inflictor); other = PROG_TO_EDICT (&sv_pr_state, SVFIELD (ent, dmg_inflictor, int));
MSG_WriteByte (msg, svc_damage); MSG_WriteByte (msg, svc_damage);
MSG_WriteByte (msg, ((entvars_t*)&ent->v)->dmg_save); MSG_WriteByte (msg, SVFIELD (ent, dmg_save, float));
MSG_WriteByte (msg, ((entvars_t*)&ent->v)->dmg_take); MSG_WriteByte (msg, SVFIELD (ent, dmg_take, float));
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
MSG_WriteCoord (msg, MSG_WriteCoord (msg,
((entvars_t*)&other->v)->origin[i] + 0.5 * (((entvars_t*)&other->v)->mins[i] + SVFIELD (other, origin, vector)[i] + 0.5 * (SVFIELD (other, mins, vector)[i] +
((entvars_t*)&other->v)->maxs[i])); SVFIELD (other, maxs, vector)[i]));
((entvars_t*)&ent->v)->dmg_take = 0; SVFIELD (ent, dmg_take, float) = 0;
((entvars_t*)&ent->v)->dmg_save = 0; SVFIELD (ent, dmg_save, float) = 0;
} }
// a fixangle might get lost in a dropped packet. Oh well. // a fixangle might get lost in a dropped packet. Oh well.
if (((entvars_t*)&ent->v)->fixangle) { if (SVFIELD (ent, fixangle, float)) {
MSG_WriteByte (msg, svc_setangle); MSG_WriteByte (msg, svc_setangle);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
MSG_WriteAngle (msg, ((entvars_t*)&ent->v)->angles[i]); MSG_WriteAngle (msg, SVFIELD (ent, angles, vector)[i]);
((entvars_t*)&ent->v)->fixangle = 0; SVFIELD (ent, fixangle, float) = 0;
} }
} }
@ -546,29 +546,29 @@ SV_UpdateClientStats (client_t *client)
if (client->spectator && client->spec_track > 0) if (client->spectator && client->spec_track > 0)
ent = svs.clients[client->spec_track - 1].edict; ent = svs.clients[client->spec_track - 1].edict;
stats[STAT_HEALTH] = ((entvars_t*)&ent->v)->health; stats[STAT_HEALTH] = SVFIELD (ent, health, float);
stats[STAT_WEAPON] = SV_ModelIndex (PR_GetString (&sv_pr_state, ((entvars_t*)&ent->v)->weaponmodel)); stats[STAT_WEAPON] = SV_ModelIndex (PR_GetString (&sv_pr_state, SVFIELD (ent, weaponmodel, string)));
stats[STAT_AMMO] = ((entvars_t*)&ent->v)->currentammo; stats[STAT_AMMO] = SVFIELD (ent, currentammo, float);
stats[STAT_ARMOR] = ((entvars_t*)&ent->v)->armorvalue; stats[STAT_ARMOR] = SVFIELD (ent, armorvalue, float);
stats[STAT_SHELLS] = ((entvars_t*)&ent->v)->ammo_shells; stats[STAT_SHELLS] = SVFIELD (ent, ammo_shells, float);
stats[STAT_NAILS] = ((entvars_t*)&ent->v)->ammo_nails; stats[STAT_NAILS] = SVFIELD (ent, ammo_nails, float);
stats[STAT_ROCKETS] = ((entvars_t*)&ent->v)->ammo_rockets; stats[STAT_ROCKETS] = SVFIELD (ent, ammo_rockets, float);
stats[STAT_CELLS] = ((entvars_t*)&ent->v)->ammo_cells; stats[STAT_CELLS] = SVFIELD (ent, ammo_cells, float);
if (!client->spectator) if (!client->spectator)
stats[STAT_ACTIVEWEAPON] = ((entvars_t*)&ent->v)->weapon; stats[STAT_ACTIVEWEAPON] = SVFIELD (ent, weapon, float);
// stuff the sigil bits into the high bits of items for sbar // stuff the sigil bits into the high bits of items for sbar
stats[STAT_ITEMS] = stats[STAT_ITEMS] =
(int) ((entvars_t*)&ent->v)->items | ((int) *sv_globals.serverflags << 28); (int) SVFIELD (ent, items, float) | ((int) *sv_globals.serverflags << 28);
// Extensions to the QW 2.40 protocol for Mega2k --KB // Extensions to the QW 2.40 protocol for Mega2k --KB
stats[STAT_VIEWHEIGHT] = (int) ((entvars_t*)&ent->v)->view_ofs[2]; stats[STAT_VIEWHEIGHT] = (int) SVFIELD (ent, view_ofs, vector)[2];
// FIXME: this should become a * key! --KB // FIXME: this should become a * key! --KB
if (((entvars_t*)&ent->v)->movetype == MOVETYPE_FLY && !atoi (Info_ValueForKey if (SVFIELD (ent, movetype, float) == MOVETYPE_FLY && !atoi (Info_ValueForKey
(svs.info, "playerfly"))) (svs.info, "playerfly")))
((entvars_t*)&ent->v)->movetype = MOVETYPE_WALK; SVFIELD (ent, movetype, float) = MOVETYPE_WALK;
stats[STAT_FLYMODE] = (((entvars_t*)&ent->v)->movetype == MOVETYPE_FLY); stats[STAT_FLYMODE] = (SVFIELD (ent, movetype, float) == MOVETYPE_FLY);
for (i = 0; i < MAX_CL_STATS; i++) for (i = 0; i < MAX_CL_STATS; i++)
@ -650,16 +650,16 @@ SV_UpdateToReliableMessages (void)
host_client->sendinfo = false; host_client->sendinfo = false;
SV_FullClientUpdate (host_client, &sv.reliable_datagram); SV_FullClientUpdate (host_client, &sv.reliable_datagram);
} }
if (host_client->old_frags != ((entvars_t*)&host_client->edict->v)->frags) { if (host_client->old_frags != SVFIELD (host_client->edict, frags, float)) {
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) { for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
if (client->state < cs_connected) if (client->state < cs_connected)
continue; continue;
ClientReliableWrite_Begin (client, svc_updatefrags, 4); ClientReliableWrite_Begin (client, svc_updatefrags, 4);
ClientReliableWrite_Byte (client, i); ClientReliableWrite_Byte (client, i);
ClientReliableWrite_Short (client, ((entvars_t*)&host_client->edict->v)->frags); ClientReliableWrite_Short (client, SVFIELD (host_client->edict, frags, float));
} }
host_client->old_frags = ((entvars_t*)&host_client->edict->v)->frags; host_client->old_frags = SVFIELD (host_client->edict, frags, float);
} }
// maxspeed/entgravity changes // maxspeed/entgravity changes
ent = host_client->edict; ent = host_client->edict;

View file

@ -132,7 +132,7 @@ SV_New_f (void)
// send full levelname // send full levelname
MSG_WriteString (&host_client->netchan.message, MSG_WriteString (&host_client->netchan.message,
PR_GetString (&sv_pr_state, ((entvars_t*)&sv.edicts->v)->message)); PR_GetString (&sv_pr_state, SVFIELD (sv.edicts, message, string)));
// send the movevars // send the movevars
MSG_WriteFloat (&host_client->netchan.message, movevars.gravity); MSG_WriteFloat (&host_client->netchan.message, movevars.gravity);
@ -148,7 +148,7 @@ SV_New_f (void)
// send music // send music
MSG_WriteByte (&host_client->netchan.message, svc_cdtrack); MSG_WriteByte (&host_client->netchan.message, svc_cdtrack);
MSG_WriteByte (&host_client->netchan.message, ((entvars_t*)&sv.edicts->v)->sounds); MSG_WriteByte (&host_client->netchan.message, SVFIELD (sv.edicts, sounds, float));
// send server info string // send server info string
MSG_WriteByte (&host_client->netchan.message, svc_stufftext); MSG_WriteByte (&host_client->netchan.message, svc_stufftext);
@ -379,9 +379,9 @@ SV_Spawn_f (void)
ent = host_client->edict; ent = host_client->edict;
memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4); memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
((entvars_t*)&ent->v)->colormap = NUM_FOR_EDICT (&sv_pr_state, ent); SVFIELD (ent, colormap, float) = NUM_FOR_EDICT (&sv_pr_state, ent);
((entvars_t*)&ent->v)->team = 0; // FIXME SVFIELD (ent, team, float) = 0; // FIXME
((entvars_t*)&ent->v)->netname = PR_SetString (&sv_pr_state, host_client->name); SVFIELD (ent, netname, string) = PR_SetString (&sv_pr_state, host_client->name);
host_client->entgravity = 1.0; host_client->entgravity = 1.0;
val = GetEdictFieldValue (&sv_pr_state, ent, "gravity"); val = GetEdictFieldValue (&sv_pr_state, ent, "gravity");
@ -428,15 +428,15 @@ SV_SpawnSpectator (void)
int i; int i;
edict_t *e; edict_t *e;
VectorCopy (vec3_origin, ((entvars_t*)&sv_player->v)->origin); VectorCopy (vec3_origin, SVFIELD (sv_player, origin, vector));
VectorCopy (vec3_origin, ((entvars_t*)&sv_player->v)->view_ofs); VectorCopy (vec3_origin, SVFIELD (sv_player, view_ofs, vector));
((entvars_t*)&sv_player->v)->view_ofs[2] = 22; SVFIELD (sv_player, view_ofs, vector)[2] = 22;
// search for an info_playerstart to spawn the spectator at // search for an info_playerstart to spawn the spectator at
for (i = MAX_CLIENTS - 1; i < sv.num_edicts; i++) { for (i = MAX_CLIENTS - 1; i < sv.num_edicts; i++) {
e = EDICT_NUM (&sv_pr_state, i); e = EDICT_NUM (&sv_pr_state, i);
if (!strcmp (PR_GetString (&sv_pr_state, ((entvars_t*)&e->v)->classname), "info_player_start")) { if (!strcmp (PR_GetString (&sv_pr_state, SVFIELD (e, classname, string)), "info_player_start")) {
VectorCopy (((entvars_t*)&e->v)->origin, ((entvars_t*)&sv_player->v)->origin); VectorCopy (SVFIELD (e, origin, vector), SVFIELD (sv_player, origin, vector));
return; return;
} }
} }
@ -525,7 +525,7 @@ SV_Begin_f (void)
ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients)); ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients));
MSG_WriteByte (&host_client->netchan.message, svc_setangle); MSG_WriteByte (&host_client->netchan.message, svc_setangle);
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
MSG_WriteAngle (&host_client->netchan.message, ((entvars_t*)&ent->v)->angles[i]); MSG_WriteAngle (&host_client->netchan.message, SVFIELD (ent, angles, vector)[i]);
MSG_WriteAngle (&host_client->netchan.message, 0); MSG_WriteAngle (&host_client->netchan.message, 0);
#endif #endif
} }
@ -899,7 +899,7 @@ SV_Pings_f (void)
void void
SV_Kill_f (void) SV_Kill_f (void)
{ {
if (((entvars_t*)&sv_player->v)->health <= 0) { if (SVFIELD (sv_player, health, float) <= 0) {
SV_BeginRedirect (RD_CLIENT); SV_BeginRedirect (RD_CLIENT);
SV_ClientPrintf (host_client, PRINT_HIGH, SV_ClientPrintf (host_client, PRINT_HIGH,
"Can't suicide -- already dead!\n"); "Can't suicide -- already dead!\n");
@ -1008,7 +1008,7 @@ SV_PTrack_f (void)
host_client->spec_track = 0; host_client->spec_track = 0;
ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1); ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1);
tent = EDICT_NUM (&sv_pr_state, 0); tent = EDICT_NUM (&sv_pr_state, 0);
((entvars_t*)&ent->v)->goalentity = EDICT_TO_PROG (&sv_pr_state, tent); SVFIELD (ent, goalentity, int) = EDICT_TO_PROG (&sv_pr_state, tent);
return; return;
} }
@ -1019,14 +1019,14 @@ SV_PTrack_f (void)
host_client->spec_track = 0; host_client->spec_track = 0;
ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1); ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1);
tent = EDICT_NUM (&sv_pr_state, 0); tent = EDICT_NUM (&sv_pr_state, 0);
((entvars_t*)&ent->v)->goalentity = EDICT_TO_PROG (&sv_pr_state, tent); SVFIELD (ent, goalentity, int) = EDICT_TO_PROG (&sv_pr_state, tent);
return; return;
} }
host_client->spec_track = i + 1; // now tracking host_client->spec_track = i + 1; // now tracking
ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1); ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1);
tent = EDICT_NUM (&sv_pr_state, i + 1); tent = EDICT_NUM (&sv_pr_state, i + 1);
((entvars_t*)&ent->v)->goalentity = EDICT_TO_PROG (&sv_pr_state, tent); SVFIELD (ent, goalentity, int) = EDICT_TO_PROG (&sv_pr_state, tent);
} }
@ -1287,16 +1287,16 @@ AddLinksToPmove (areanode_t *node)
next = l->next; next = l->next;
check = EDICT_FROM_AREA (l); check = EDICT_FROM_AREA (l);
if (((entvars_t*)&check->v)->owner == pl) if (SVFIELD (check, owner, int) == pl)
continue; // player's own missile continue; // player's own missile
if (((entvars_t*)&check->v)->solid == SOLID_BSP if (SVFIELD (check, solid, float) == SOLID_BSP
|| ((entvars_t*)&check->v)->solid == SOLID_BBOX || ((entvars_t*)&check->v)->solid == SOLID_SLIDEBOX) { || SVFIELD (check, solid, float) == SOLID_BBOX || SVFIELD (check, solid, float) == SOLID_SLIDEBOX) {
if (check == sv_player) if (check == sv_player)
continue; continue;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (((entvars_t*)&check->v)->absmin[i] > pmove_maxs[i] if (SVFIELD (check, absmin, vector)[i] > pmove_maxs[i]
|| ((entvars_t*)&check->v)->absmax[i] < pmove_mins[i]) || SVFIELD (check, absmax, vector)[i] < pmove_mins[i])
break; break;
if (i != 3) if (i != 3)
continue; continue;
@ -1305,15 +1305,15 @@ AddLinksToPmove (areanode_t *node)
pe = &pmove.physents[pmove.numphysent]; pe = &pmove.physents[pmove.numphysent];
pmove.numphysent++; pmove.numphysent++;
VectorCopy (((entvars_t*)&check->v)->origin, pe->origin); VectorCopy (SVFIELD (check, origin, vector), pe->origin);
pe->info = NUM_FOR_EDICT (&sv_pr_state, check); pe->info = NUM_FOR_EDICT (&sv_pr_state, check);
if (((entvars_t*)&check->v)->solid == SOLID_BSP) { if (SVFIELD (check, solid, float) == SOLID_BSP) {
pe->model = sv.models[(int) (((entvars_t*)&check->v)->modelindex)]; pe->model = sv.models[(int) (SVFIELD (check, modelindex, float))];
} else { } else {
pe->model = NULL; pe->model = NULL;
VectorCopy (((entvars_t*)&check->v)->mins, pe->mins); VectorCopy (SVFIELD (check, mins, vector), pe->mins);
VectorCopy (((entvars_t*)&check->v)->maxs, pe->maxs); VectorCopy (SVFIELD (check, maxs, vector), pe->maxs);
} }
} }
} }
@ -1350,30 +1350,30 @@ AddAllEntsToPmove (void)
check = NEXT_EDICT (&sv_pr_state, check)) { check = NEXT_EDICT (&sv_pr_state, check)) {
if (check->free) if (check->free)
continue; continue;
if (((entvars_t*)&check->v)->owner == pl) if (SVFIELD (check, owner, int) == pl)
continue; continue;
if (((entvars_t*)&check->v)->solid == SOLID_BSP if (SVFIELD (check, solid, float) == SOLID_BSP
|| ((entvars_t*)&check->v)->solid == SOLID_BBOX || SVFIELD (check, solid, float) == SOLID_BBOX
|| ((entvars_t*)&check->v)->solid == SOLID_SLIDEBOX) { || SVFIELD (check, solid, float) == SOLID_SLIDEBOX) {
if (check == sv_player) if (check == sv_player)
continue; continue;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (((entvars_t*)&check->v)->absmin[i] > pmove_maxs[i] if (SVFIELD (check, absmin, vector)[i] > pmove_maxs[i]
|| ((entvars_t*)&check->v)->absmax[i] < pmove_mins[i]) || SVFIELD (check, absmax, vector)[i] < pmove_mins[i])
break; break;
if (i != 3) if (i != 3)
continue; continue;
pe = &pmove.physents[pmove.numphysent]; pe = &pmove.physents[pmove.numphysent];
VectorCopy (((entvars_t*)&check->v)->origin, pe->origin); VectorCopy (SVFIELD (check, origin, vector), pe->origin);
pmove.physents[pmove.numphysent].info = e; pmove.physents[pmove.numphysent].info = e;
if (((entvars_t*)&check->v)->solid == SOLID_BSP) if (SVFIELD (check, solid, float) == SOLID_BSP)
pe->model = sv.models[(int) (((entvars_t*)&check->v)->modelindex)]; pe->model = sv.models[(int) (SVFIELD (check, modelindex, float))];
else { else {
pe->model = NULL; pe->model = NULL;
VectorCopy (((entvars_t*)&check->v)->mins, pe->mins); VectorCopy (SVFIELD (check, mins, vector), pe->mins);
VectorCopy (((entvars_t*)&check->v)->maxs, pe->maxs); VectorCopy (SVFIELD (check, maxs, vector), pe->maxs);
} }
if (++pmove.numphysent == MAX_PHYSENTS) if (++pmove.numphysent == MAX_PHYSENTS)
@ -1456,29 +1456,29 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
return; return;
} }
if (!((entvars_t*)&sv_player->v)->fixangle) if (!SVFIELD (sv_player, fixangle, float))
VectorCopy (ucmd->angles, ((entvars_t*)&sv_player->v)->v_angle); VectorCopy (ucmd->angles, SVFIELD (sv_player, v_angle, vector));
((entvars_t*)&sv_player->v)->button0 = ucmd->buttons & 1; SVFIELD (sv_player, button0, float) = ucmd->buttons & 1;
// 1999-10-29 +USE fix by Maddes start // 1999-10-29 +USE fix by Maddes start
if (!nouse) { if (!nouse) {
((entvars_t*)&sv_player->v)->button1 = (ucmd->buttons & 4) >> 2; SVFIELD (sv_player, button1, float) = (ucmd->buttons & 4) >> 2;
} }
// 1999-10-29 +USE fix by Maddes end // 1999-10-29 +USE fix by Maddes end
((entvars_t*)&sv_player->v)->button2 = (ucmd->buttons & 2) >> 1; SVFIELD (sv_player, button2, float) = (ucmd->buttons & 2) >> 1;
if (ucmd->impulse) if (ucmd->impulse)
((entvars_t*)&sv_player->v)->impulse = ucmd->impulse; SVFIELD (sv_player, impulse, float) = ucmd->impulse;
// //
// angles // angles
// show 1/3 the pitch angle and all the roll angle // show 1/3 the pitch angle and all the roll angle
if (((entvars_t*)&sv_player->v)->health > 0) { if (SVFIELD (sv_player, health, float) > 0) {
if (!((entvars_t*)&sv_player->v)->fixangle) { if (!SVFIELD (sv_player, fixangle, float)) {
((entvars_t*)&sv_player->v)->angles[PITCH] = -((entvars_t*)&sv_player->v)->v_angle[PITCH] / 3; SVFIELD (sv_player, angles, vector)[PITCH] = -SVFIELD (sv_player, v_angle, vector)[PITCH] / 3;
((entvars_t*)&sv_player->v)->angles[YAW] = ((entvars_t*)&sv_player->v)->v_angle[YAW]; SVFIELD (sv_player, angles, vector)[YAW] = SVFIELD (sv_player, v_angle, vector)[YAW];
} }
((entvars_t*)&sv_player->v)->angles[ROLL] = SVFIELD (sv_player, angles, vector)[ROLL] =
SV_CalcRoll (((entvars_t*)&sv_player->v)->angles, ((entvars_t*)&sv_player->v)->velocity) * 4; SV_CalcRoll (SVFIELD (sv_player, angles, vector), SVFIELD (sv_player, velocity, vector)) * 4;
} }
sv_frametime = min (0.1, ucmd->msec * 0.001); sv_frametime = min (0.1, ucmd->msec * 0.001);
@ -1497,18 +1497,18 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
pmove.origin[i] = pmove.origin[i] =
((entvars_t*)&sv_player->v)->origin[i] SVFIELD (sv_player, origin, vector)[i]
+ (((entvars_t*)&sv_player->v)->mins[i] - player_mins[i]); + (SVFIELD (sv_player, mins, vector)[i] - player_mins[i]);
VectorCopy (((entvars_t*)&sv_player->v)->velocity, pmove.velocity); VectorCopy (SVFIELD (sv_player, velocity, vector), pmove.velocity);
VectorCopy (((entvars_t*)&sv_player->v)->v_angle, pmove.angles); VectorCopy (SVFIELD (sv_player, v_angle, vector), pmove.angles);
pmove.flying = ((entvars_t*)&sv_player->v)->movetype == MOVETYPE_FLY; pmove.flying = SVFIELD (sv_player, movetype, float) == MOVETYPE_FLY;
pmove.spectator = host_client->spectator; pmove.spectator = host_client->spectator;
pmove.waterjumptime = ((entvars_t*)&sv_player->v)->teleport_time; pmove.waterjumptime = SVFIELD (sv_player, teleport_time, float);
pmove.numphysent = 1; pmove.numphysent = 1;
pmove.physents[0].model = sv.worldmodel; pmove.physents[0].model = sv.worldmodel;
pmove.cmd = *ucmd; pmove.cmd = *ucmd;
pmove.dead = ((entvars_t*)&sv_player->v)->health <= 0; pmove.dead = SVFIELD (sv_player, health, float) <= 0;
pmove.oldbuttons = host_client->oldbuttons; pmove.oldbuttons = host_client->oldbuttons;
movevars.entgravity = host_client->entgravity; movevars.entgravity = host_client->entgravity;
@ -1533,7 +1533,7 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
PlayerMove (); PlayerMove ();
after = PM_TestPlayerPosition (pmove.origin); after = PM_TestPlayerPosition (pmove.origin);
if (((entvars_t*)&sv_player->v)->health > 0 && before && !after) if (SVFIELD (sv_player, health, float) > 0 && before && !after)
Con_Printf ("player %s got stuck in playermove!!!!\n", Con_Printf ("player %s got stuck in playermove!!!!\n",
host_client->name); host_client->name);
} }
@ -1542,29 +1542,29 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
#endif #endif
host_client->oldbuttons = pmove.oldbuttons; host_client->oldbuttons = pmove.oldbuttons;
((entvars_t*)&sv_player->v)->teleport_time = pmove.waterjumptime; SVFIELD (sv_player, teleport_time, float) = pmove.waterjumptime;
((entvars_t*)&sv_player->v)->waterlevel = waterlevel; SVFIELD (sv_player, waterlevel, float) = waterlevel;
((entvars_t*)&sv_player->v)->watertype = watertype; SVFIELD (sv_player, watertype, float) = watertype;
if (onground != -1) { if (onground != -1) {
((entvars_t*)&sv_player->v)->flags = (int) ((entvars_t*)&sv_player->v)->flags | FL_ONGROUND; SVFIELD (sv_player, flags, float) = (int) SVFIELD (sv_player, flags, float) | FL_ONGROUND;
((entvars_t*)&sv_player->v)->groundentity = SVFIELD (sv_player, groundentity, int) =
EDICT_TO_PROG (&sv_pr_state, EDICT_NUM (&sv_pr_state, pmove.physents[onground].info)); EDICT_TO_PROG (&sv_pr_state, EDICT_NUM (&sv_pr_state, pmove.physents[onground].info));
} else { } else {
((entvars_t*)&sv_player->v)->flags = (int) ((entvars_t*)&sv_player->v)->flags & ~FL_ONGROUND; SVFIELD (sv_player, flags, float) = (int) SVFIELD (sv_player, flags, float) & ~FL_ONGROUND;
} }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
((entvars_t*)&sv_player->v)->origin[i] = SVFIELD (sv_player, origin, vector)[i] =
pmove.origin[i] - (((entvars_t*)&sv_player->v)->mins[i] - player_mins[i]); pmove.origin[i] - (SVFIELD (sv_player, mins, vector)[i] - player_mins[i]);
#if 0 #if 0
// truncate velocity the same way the net protocol will // truncate velocity the same way the net protocol will
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
((entvars_t*)&sv_player->v)->velocity[i] = (int) pmove.velocity[i]; SVFIELD (sv_player, velocity, vector)[i] = (int) pmove.velocity[i];
#else #else
VectorCopy (pmove.velocity, ((entvars_t*)&sv_player->v)->velocity); VectorCopy (pmove.velocity, SVFIELD (sv_player, velocity, vector));
#endif #endif
VectorCopy (pmove.angles, ((entvars_t*)&sv_player->v)->v_angle); VectorCopy (pmove.angles, SVFIELD (sv_player, v_angle, vector));
if (!host_client->spectator) { if (!host_client->spectator) {
// link into place and touch triggers // link into place and touch triggers
@ -1574,11 +1574,11 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
for (i = 0; i < pmove.numtouch; i++) { for (i = 0; i < pmove.numtouch; i++) {
n = pmove.physents[pmove.touchindex[i]].info; n = pmove.physents[pmove.touchindex[i]].info;
ent = EDICT_NUM (&sv_pr_state, n); ent = EDICT_NUM (&sv_pr_state, n);
if (!((entvars_t*)&ent->v)->touch || (playertouch[n / 8] & (1 << (n % 8)))) if (!SVFIELD (ent, touch, func) || (playertouch[n / 8] & (1 << (n % 8))))
continue; continue;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv_player); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->touch); PR_ExecuteProgram (&sv_pr_state, SVFIELD (ent, touch, func));
playertouch[n / 8] |= 1 << (n % 8); playertouch[n / 8] |= 1 << (n % 8);
} }
} }
@ -1746,7 +1746,7 @@ SV_ExecuteClientMessage (client_t *cl)
o[2] = MSG_ReadCoord (net_message); o[2] = MSG_ReadCoord (net_message);
// only allowed by spectators // only allowed by spectators
if (host_client->spectator) { if (host_client->spectator) {
VectorCopy (o, ((entvars_t*)&sv_player->v)->origin); VectorCopy (o, SVFIELD (sv_player, origin, vector));
SV_LinkEdict (sv_player, false); SV_LinkEdict (sv_player, false);
} }
break; break;

View file

@ -151,12 +151,12 @@ SV_HullForEntity (edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset)
hull_t *hull; hull_t *hull;
// decide which clipping hull to use, based on the size // decide which clipping hull to use, based on the size
if (((entvars_t*)&ent->v)->solid == SOLID_BSP) { if (SVFIELD (ent, solid, float) == SOLID_BSP) {
// explicit hulls in the BSP model // explicit hulls in the BSP model
if (((entvars_t*)&ent->v)->movetype != MOVETYPE_PUSH) if (SVFIELD (ent, movetype, float) != MOVETYPE_PUSH)
SV_Error ("SOLID_BSP without MOVETYPE_PUSH"); SV_Error ("SOLID_BSP without MOVETYPE_PUSH");
model = sv.models[(int) ((entvars_t*)&ent->v)->modelindex]; model = sv.models[(int) SVFIELD (ent, modelindex, float)];
if (!model || model->type != mod_brush) if (!model || model->type != mod_brush)
SV_Error ("SOLID_BSP with a non bsp model"); SV_Error ("SOLID_BSP with a non bsp model");
@ -171,15 +171,15 @@ SV_HullForEntity (edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset)
// calculate an offset value to center the origin // calculate an offset value to center the origin
VectorSubtract (hull->clip_mins, mins, offset); VectorSubtract (hull->clip_mins, mins, offset);
VectorAdd (offset, ((entvars_t*)&ent->v)->origin, offset); VectorAdd (offset, SVFIELD (ent, origin, vector), offset);
} else { // create a temp hull from bounding } else { // create a temp hull from bounding
// box sizes // box sizes
VectorSubtract (((entvars_t*)&ent->v)->mins, maxs, hullmins); VectorSubtract (SVFIELD (ent, mins, vector), maxs, hullmins);
VectorSubtract (((entvars_t*)&ent->v)->maxs, mins, hullmaxs); VectorSubtract (SVFIELD (ent, maxs, vector), mins, hullmaxs);
hull = SV_HullForBox (hullmins, hullmaxs); hull = SV_HullForBox (hullmins, hullmaxs);
VectorCopy (((entvars_t*)&ent->v)->origin, offset); VectorCopy (SVFIELD (ent, origin, vector), offset);
} }
@ -279,14 +279,14 @@ SV_TouchLinks (edict_t *ent, areanode_t *node)
touch = EDICT_FROM_AREA (l); touch = EDICT_FROM_AREA (l);
if (touch == ent) if (touch == ent)
continue; continue;
if (!((entvars_t*)&touch->v)->touch || ((entvars_t*)&touch->v)->solid != SOLID_TRIGGER) if (!SVFIELD (touch, touch, func) || SVFIELD (touch, solid, float) != SOLID_TRIGGER)
continue; continue;
if (((entvars_t*)&ent->v)->absmin[0] > ((entvars_t*)&touch->v)->absmax[0] if (SVFIELD (ent, absmin, vector)[0] > SVFIELD (touch, absmax, vector)[0]
|| ((entvars_t*)&ent->v)->absmin[1] > ((entvars_t*)&touch->v)->absmax[1] || SVFIELD (ent, absmin, vector)[1] > SVFIELD (touch, absmax, vector)[1]
|| ((entvars_t*)&ent->v)->absmin[2] > ((entvars_t*)&touch->v)->absmax[2] || SVFIELD (ent, absmin, vector)[2] > SVFIELD (touch, absmax, vector)[2]
|| ((entvars_t*)&ent->v)->absmax[0] < ((entvars_t*)&touch->v)->absmin[0] || SVFIELD (ent, absmax, vector)[0] < SVFIELD (touch, absmin, vector)[0]
|| ((entvars_t*)&ent->v)->absmax[1] < ((entvars_t*)&touch->v)->absmin[1] || SVFIELD (ent, absmax, vector)[1] < SVFIELD (touch, absmin, vector)[1]
|| ((entvars_t*)&ent->v)->absmax[2] < ((entvars_t*)&touch->v)->absmin[2]) || SVFIELD (ent, absmax, vector)[2] < SVFIELD (touch, absmin, vector)[2])
continue; continue;
old_self = *sv_globals.self; old_self = *sv_globals.self;
@ -295,7 +295,7 @@ SV_TouchLinks (edict_t *ent, areanode_t *node)
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, touch); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, touch);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, ent); *sv_globals.other = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&touch->v)->touch); PR_ExecuteProgram (&sv_pr_state, SVFIELD (touch, touch, func));
*sv_globals.self = old_self; *sv_globals.self = old_self;
*sv_globals.other = old_other; *sv_globals.other = old_other;
@ -305,9 +305,9 @@ SV_TouchLinks (edict_t *ent, areanode_t *node)
if (node->axis == -1) if (node->axis == -1)
return; return;
if (((entvars_t*)&ent->v)->absmax[node->axis] > node->dist) if (SVFIELD (ent, absmax, vector)[node->axis] > node->dist)
SV_TouchLinks (ent, node->children[0]); SV_TouchLinks (ent, node->children[0]);
if (((entvars_t*)&ent->v)->absmin[node->axis] < node->dist) if (SVFIELD (ent, absmin, vector)[node->axis] < node->dist)
SV_TouchLinks (ent, node->children[1]); SV_TouchLinks (ent, node->children[1]);
} }
@ -342,7 +342,7 @@ SV_FindTouchedLeafs (edict_t *ent, mnode_t *node)
// NODE_MIXED // NODE_MIXED
splitplane = node->plane; splitplane = node->plane;
sides = BOX_ON_PLANE_SIDE (((entvars_t*)&ent->v)->absmin, ((entvars_t*)&ent->v)->absmax, splitplane); sides = BOX_ON_PLANE_SIDE (SVFIELD (ent, absmin, vector), SVFIELD (ent, absmax, vector), splitplane);
// recurse down the contacted sides // recurse down the contacted sides
if (sides & 1) if (sides & 1)
@ -370,35 +370,35 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
return; return;
// set the abs box // set the abs box
VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->absmin); VectorAdd (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, absmin, vector));
VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->maxs, ((entvars_t*)&ent->v)->absmax); VectorAdd (SVFIELD (ent, origin, vector), SVFIELD (ent, maxs, vector), SVFIELD (ent, absmax, vector));
// //
// to make items easier to pick up and allow them to be grabbed off // to make items easier to pick up and allow them to be grabbed off
// of shelves, the abs sizes are expanded // of shelves, the abs sizes are expanded
// //
if ((int) ((entvars_t*)&ent->v)->flags & FL_ITEM) { if ((int) SVFIELD (ent, flags, float) & FL_ITEM) {
((entvars_t*)&ent->v)->absmin[0] -= 15; SVFIELD (ent, absmin, vector)[0] -= 15;
((entvars_t*)&ent->v)->absmin[1] -= 15; SVFIELD (ent, absmin, vector)[1] -= 15;
((entvars_t*)&ent->v)->absmax[0] += 15; SVFIELD (ent, absmax, vector)[0] += 15;
((entvars_t*)&ent->v)->absmax[1] += 15; SVFIELD (ent, absmax, vector)[1] += 15;
} else { // because movement is clipped an } else { // because movement is clipped an
// epsilon away from an actual edge, // epsilon away from an actual edge,
// we must fully check even when bounding boxes don't quite touch // we must fully check even when bounding boxes don't quite touch
((entvars_t*)&ent->v)->absmin[0] -= 1; SVFIELD (ent, absmin, vector)[0] -= 1;
((entvars_t*)&ent->v)->absmin[1] -= 1; SVFIELD (ent, absmin, vector)[1] -= 1;
((entvars_t*)&ent->v)->absmin[2] -= 1; SVFIELD (ent, absmin, vector)[2] -= 1;
((entvars_t*)&ent->v)->absmax[0] += 1; SVFIELD (ent, absmax, vector)[0] += 1;
((entvars_t*)&ent->v)->absmax[1] += 1; SVFIELD (ent, absmax, vector)[1] += 1;
((entvars_t*)&ent->v)->absmax[2] += 1; SVFIELD (ent, absmax, vector)[2] += 1;
} }
// link to PVS leafs // link to PVS leafs
ent->num_leafs = 0; ent->num_leafs = 0;
if (((entvars_t*)&ent->v)->modelindex) if (SVFIELD (ent, modelindex, float))
SV_FindTouchedLeafs (ent, sv.worldmodel->nodes); SV_FindTouchedLeafs (ent, sv.worldmodel->nodes);
if (((entvars_t*)&ent->v)->solid == SOLID_NOT) if (SVFIELD (ent, solid, float) == SOLID_NOT)
return; return;
// find the first node that the ent's box crosses // find the first node that the ent's box crosses
@ -406,9 +406,9 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
while (1) { while (1) {
if (node->axis == -1) if (node->axis == -1)
break; break;
if (((entvars_t*)&ent->v)->absmin[node->axis] > node->dist) if (SVFIELD (ent, absmin, vector)[node->axis] > node->dist)
node = node->children[0]; node = node->children[0];
else if (((entvars_t*)&ent->v)->absmax[node->axis] < node->dist) else if (SVFIELD (ent, absmax, vector)[node->axis] < node->dist)
node = node->children[1]; node = node->children[1];
else else
break; // crosses the node break; // crosses the node
@ -416,7 +416,7 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
// link it in // link it in
if (((entvars_t*)&ent->v)->solid == SOLID_TRIGGER) if (SVFIELD (ent, solid, float) == SOLID_TRIGGER)
InsertLinkBefore (&ent->area, &node->trigger_edicts); InsertLinkBefore (&ent->area, &node->trigger_edicts);
else else
InsertLinkBefore (&ent->area, &node->solid_edicts); InsertLinkBefore (&ent->area, &node->solid_edicts);
@ -490,7 +490,7 @@ SV_TestEntityPosition (edict_t *ent)
trace_t trace; trace_t trace;
trace = trace =
SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, ((entvars_t*)&ent->v)->origin, 0, SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), SVFIELD (ent, origin, vector), 0,
ent); ent);
if (trace.startsolid) if (trace.startsolid)
@ -699,38 +699,38 @@ SV_ClipToLinks (areanode_t *node, moveclip_t * clip)
for (l = node->solid_edicts.next; l != &node->solid_edicts; l = next) { for (l = node->solid_edicts.next; l != &node->solid_edicts; l = next) {
next = l->next; next = l->next;
touch = EDICT_FROM_AREA (l); touch = EDICT_FROM_AREA (l);
if (((entvars_t*)&touch->v)->solid == SOLID_NOT) if (SVFIELD (touch, solid, float) == SOLID_NOT)
continue; continue;
if (touch == clip->passedict) if (touch == clip->passedict)
continue; continue;
if (((entvars_t*)&touch->v)->solid == SOLID_TRIGGER) if (SVFIELD (touch, solid, float) == SOLID_TRIGGER)
SV_Error ("Trigger in clipping list"); SV_Error ("Trigger in clipping list");
if (clip->type == MOVE_NOMONSTERS && ((entvars_t*)&touch->v)->solid != SOLID_BSP) if (clip->type == MOVE_NOMONSTERS && SVFIELD (touch, solid, float) != SOLID_BSP)
continue; continue;
if (clip->boxmins[0] > ((entvars_t*)&touch->v)->absmax[0] if (clip->boxmins[0] > SVFIELD (touch, absmax, vector)[0]
|| clip->boxmins[1] > ((entvars_t*)&touch->v)->absmax[1] || clip->boxmins[1] > SVFIELD (touch, absmax, vector)[1]
|| clip->boxmins[2] > ((entvars_t*)&touch->v)->absmax[2] || clip->boxmins[2] > SVFIELD (touch, absmax, vector)[2]
|| clip->boxmaxs[0] < ((entvars_t*)&touch->v)->absmin[0] || clip->boxmaxs[0] < SVFIELD (touch, absmin, vector)[0]
|| clip->boxmaxs[1] < ((entvars_t*)&touch->v)->absmin[1] || clip->boxmaxs[1] < SVFIELD (touch, absmin, vector)[1]
|| clip->boxmaxs[2] < ((entvars_t*)&touch->v)->absmin[2]) || clip->boxmaxs[2] < SVFIELD (touch, absmin, vector)[2])
continue; continue;
if (clip->passedict != 0 && ((entvars_t*)&clip->passedict->v)->size[0] if (clip->passedict != 0 && SVFIELD (clip->passedict, size, vector)[0]
&& !((entvars_t*)&touch->v)->size[0]) continue; // points never interact && !SVFIELD (touch, size, vector)[0]) continue; // points never interact
// might intersect, so do an exact clip // might intersect, so do an exact clip
if (clip->trace.allsolid) if (clip->trace.allsolid)
return; return;
if (clip->passedict) { if (clip->passedict) {
if (PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&touch->v)->owner) == clip->passedict) if (PROG_TO_EDICT (&sv_pr_state, SVFIELD (touch, owner, int)) == clip->passedict)
continue; // don't clip against own missiles continue; // don't clip against own missiles
if (PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&clip->passedict->v)->owner) == touch) if (PROG_TO_EDICT (&sv_pr_state, SVFIELD (clip->passedict, owner, int)) == touch)
continue; // don't clip against owner continue; // don't clip against owner
} }
if ((int) ((entvars_t*)&touch->v)->flags & FL_MONSTER) if ((int) SVFIELD (touch, flags, float) & FL_MONSTER)
trace = trace =
SV_ClipMoveToEntity (touch, clip->start, clip->mins2, SV_ClipMoveToEntity (touch, clip->start, clip->mins2,
clip->maxs2, clip->end); clip->maxs2, clip->end);
@ -849,30 +849,30 @@ SV_TestPlayerPosition (edict_t *ent, vec3_t origin)
CONTENTS_EMPTY) return sv.edicts; CONTENTS_EMPTY) return sv.edicts;
// check all entities // check all entities
VectorAdd (origin, ((entvars_t*)&ent->v)->mins, boxmins); VectorAdd (origin, SVFIELD (ent, mins, vector), boxmins);
VectorAdd (origin, ((entvars_t*)&ent->v)->maxs, boxmaxs); VectorAdd (origin, SVFIELD (ent, maxs, vector), boxmaxs);
check = NEXT_EDICT (&sv_pr_state, sv.edicts); check = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
if (check->free) if (check->free)
continue; continue;
if (((entvars_t*)&check->v)->solid != SOLID_BSP && if (SVFIELD (check, solid, float) != SOLID_BSP &&
((entvars_t*)&check->v)->solid != SOLID_BBOX && ((entvars_t*)&check->v)->solid != SOLID_SLIDEBOX) SVFIELD (check, solid, float) != SOLID_BBOX && SVFIELD (check, solid, float) != SOLID_SLIDEBOX)
continue; continue;
if (boxmins[0] > ((entvars_t*)&check->v)->absmax[0] if (boxmins[0] > SVFIELD (check, absmax, vector)[0]
|| boxmins[1] > ((entvars_t*)&check->v)->absmax[1] || boxmins[1] > SVFIELD (check, absmax, vector)[1]
|| boxmins[2] > ((entvars_t*)&check->v)->absmax[2] || boxmins[2] > SVFIELD (check, absmax, vector)[2]
|| boxmaxs[0] < ((entvars_t*)&check->v)->absmin[0] || boxmaxs[0] < SVFIELD (check, absmin, vector)[0]
|| boxmaxs[1] < ((entvars_t*)&check->v)->absmin[1] || boxmaxs[1] < SVFIELD (check, absmin, vector)[1]
|| boxmaxs[2] < ((entvars_t*)&check->v)->absmin[2]) || boxmaxs[2] < SVFIELD (check, absmin, vector)[2])
continue; continue;
if (check == ent) if (check == ent)
continue; continue;
// get the clipping hull // get the clipping hull
hull = SV_HullForEntity (check, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, offset); hull = SV_HullForEntity (check, SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), offset);
VectorSubtract (origin, offset, offset); VectorSubtract (origin, offset, offset);