From 63b990cd309f3ed19d5bfe34d2cf6bf41205edfb Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 28 Feb 2001 22:44:38 +0000 Subject: [PATCH] qw-server builds, but dies a sad death. I REALLY REALLY NEED to clean up my progs globals and edict fields accessors, but I'm not so sure that's the cause of the run-time error: SV_Error: SV_ModelIndex: model progs/player.mdl not precached Fatal error: SV_Error: SV_ModelIndex: model progs/player.mdl not precached I suspect I failed to find the spawn function. --- include/.gitignore | 1 + include/progs.h | 15 +- libs/gamecode/pr_edict.c | 20 ++- qw/include/progdefs.h | 234 ++++++++++++------------ qw/source/Makefile.am | 10 +- qw/source/sv_ccmds.c | 29 +-- qw/source/sv_ents.c | 69 ++++---- qw/source/sv_init.c | 69 ++++---- qw/source/sv_main.c | 13 +- qw/source/sv_move.c | 80 +++++---- qw/source/sv_phys.c | 373 ++++++++++++++++++++------------------- qw/source/sv_pr_cmds.c | 147 +++++++-------- qw/source/sv_progs.c | 7 +- qw/source/sv_send.c | 69 ++++---- qw/source/sv_user.c | 197 +++++++++++---------- qw/source/world.c | 139 +++++++-------- 16 files changed, 753 insertions(+), 719 deletions(-) diff --git a/include/.gitignore b/include/.gitignore index 43f409a16..e3622e6f2 100644 --- a/include/.gitignore +++ b/include/.gitignore @@ -1,3 +1,4 @@ +.vimrc Makefile.in Makefile config.h.in diff --git a/include/progs.h b/include/progs.h index ef4d503e0..7cac1f66f 100644 --- a/include/progs.h +++ b/include/progs.h @@ -62,6 +62,7 @@ typedef struct edict_s short leafnums[MAX_ENT_LEAFS]; float freetime; // sv.time when the object was freed + void *data; // external per-edict data pr_type_t v[1]; // fields from progs } edict_t; #define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area) @@ -122,15 +123,15 @@ int NUM_FOR_EDICT(progs_t *pr, edict_t *e); #define G_EDICT(p,o) ((edict_t *)(PR_edicts (p) + G_INT (p, o))) #define G_EDICTNUM(p,o) NUM_FOR_EDICT(p, G_EDICT(p, o)) #define G_VECTOR(p,o) (&G_FLOAT (p, o)) -#define G_STRING(p,o) PR_GetString (p, G_var (p, o, string_t)) -#define G_FUNCTION(p,o) G_var (p, o, func_t) +#define G_STRING(p,o) PR_GetString (p, G_var (p, o, string)) +#define G_FUNCTION(p,o) G_var (p, o, func) -#define E_var(e,o,t) ((e)->v.vv[o].t##_var) +#define E_var(e,o,t) ((e)->v[o].t##_var) #define E_FLOAT(e,o) E_var (e, o, float) #define E_INT(e,o) E_var (e, o, int) #define E_VECTOR(e,o) (&E_FLOAT (e, o)) -#define E_STRING(p,e,o) (PR_GetString (p, E_var (e, o, string_t))) +#define E_STRING(p,e,o) (PR_GetString (p, E_var (e, o, string))) extern int type_size[8]; @@ -148,7 +149,7 @@ extern func_t SpectatorConnect; extern func_t SpectatorThink; extern func_t SpectatorDisconnect; -void PR_Error (progs_t *pr, char *error, ...) __attribute__((format(printf,2,3))); +void PR_Error (progs_t *pr, const char *error, ...) __attribute__((format(printf,2,3))); void PR_RunError (progs_t *pr, char *error, ...) __attribute__((format(printf,2,3))); void ED_PrintEdicts (progs_t *pr); @@ -196,7 +197,7 @@ struct progs_s { pr_type_t *pr_globals; // same as pr_global_struct int pr_edict_size; // in bytes - int pr_edictareasize; // LordHavoc: for bounds checking + int pr_edictareasize; // for bounds checking, starts at 0 int pr_argc; @@ -215,7 +216,7 @@ struct progs_s { edict_t **edicts; int *num_edicts; - int *reserved_edicts; + int *reserved_edicts; //alloc will start at reserved_edicts+1 double *time; int null_bad; diff --git a/libs/gamecode/pr_edict.c b/libs/gamecode/pr_edict.c index 5bdfa51ce..b7223db79 100644 --- a/libs/gamecode/pr_edict.c +++ b/libs/gamecode/pr_edict.c @@ -44,6 +44,7 @@ #include "qdefs.h" #include "qendian.h" #include "quakefs.h" +#include "sys.h" //XXX #include "zone.h" #include "va.h" @@ -963,7 +964,7 @@ PR_LoadProgs (progs_t * pr, char *progsname) pr->progs->entityfields * 4 + sizeof (edict_t) - sizeof (pr_type_t); - pr->pr_edictareasize = pr->pr_edict_size * MAX_EDICTS; + pr->pr_edictareasize = 0; // byte swap the lumps for (i = 0; i < pr->progs->numstatements; i++) { @@ -1014,8 +1015,8 @@ PR_LoadProgs (progs_t * pr, char *progsname) PR_Error (pr, "%s: undefined field: nextthink", progsname); if (!(pr->f_frame = FindFieldOffset (pr, "frame"))) PR_Error (pr, "%s: undefined field: frame", progsname); - if (!(pr->f_think = FindFieldOffset (pr, "function"))) - PR_Error (pr, "%s: undefined field: function", progsname); + if (!(pr->f_think = FindFieldOffset (pr, "think"))) + PR_Error (pr, "%s: undefined field: think", progsname); // LordHavoc: Ender added this FindEdictFieldOffsets (pr); @@ -1172,3 +1173,16 @@ NUM_FOR_EDICT (progs_t * pr, edict_t *e) PR_Error (pr, "NUM_FOR_EDICT: bad pointer"); return b; } + +void +PR_Error (progs_t *pr, const char *error, ...) +{ + va_list argptr; + char string[1024]; + + va_start (argptr, error); + vsnprintf (string, sizeof (string), error, argptr); + va_end (argptr); + + Sys_Error ("%s", string); +} diff --git a/qw/include/progdefs.h b/qw/include/progdefs.h index 031416fe3..7269ad3fe 100644 --- a/qw/include/progdefs.h +++ b/qw/include/progdefs.h @@ -29,135 +29,135 @@ /* file generated by qcc, do not modify */ typedef struct -{ int pad[28]; - int self; - int other; - int world; - float time; - float frametime; - int newmis; - float force_retouch; +{ int pad[28]; + int self; + int other; + int world; + float time; + float frametime; + int newmis; + float force_retouch; string_t mapname; - float serverflags; - float total_secrets; - float total_monsters; - float found_secrets; - float killed_monsters; - float parm1; - float parm2; - float parm3; - float parm4; - float parm5; - float parm6; - float parm7; - float parm8; - float parm9; - float parm10; - float parm11; - float parm12; - float parm13; - float parm14; - float parm15; - float parm16; - vec3_t v_forward; - vec3_t v_up; - vec3_t v_right; - float trace_allsolid; - float trace_startsolid; - float trace_fraction; - vec3_t trace_endpos; - vec3_t trace_plane_normal; - float trace_plane_dist; - int trace_ent; - float trace_inopen; - float trace_inwater; - int msg_entity; - func_t main; - func_t StartFrame; - func_t PlayerPreThink; - func_t PlayerPostThink; - func_t ClientKill; - func_t ClientConnect; - func_t PutClientInServer; - func_t ClientDisconnect; - func_t SetNewParms; - func_t SetChangeParms; + float serverflags; + float total_secrets; + float total_monsters; + float found_secrets; + float killed_monsters; + float parm1; + float parm2; + float parm3; + float parm4; + float parm5; + float parm6; + float parm7; + float parm8; + float parm9; + float parm10; + float parm11; + float parm12; + float parm13; + float parm14; + float parm15; + float parm16; + vec3_t v_forward; + vec3_t v_up; + vec3_t v_right; + float trace_allsolid; + float trace_startsolid; + float trace_fraction; + vec3_t trace_endpos; + vec3_t trace_plane_normal; + float trace_plane_dist; + int trace_ent; + float trace_inopen; + float trace_inwater; + int msg_entity; + func_t main; + func_t StartFrame; + func_t PlayerPreThink; + func_t PlayerPostThink; + func_t ClientKill; + func_t ClientConnect; + func_t PutClientInServer; + func_t ClientDisconnect; + func_t SetNewParms; + func_t SetChangeParms; } globalvars_t; typedef struct { - float modelindex; - vec3_t absmin; - vec3_t absmax; - float ltime; - float lastruntime; - float movetype; - float solid; - vec3_t origin; - vec3_t oldorigin; - vec3_t velocity; - vec3_t angles; - vec3_t avelocity; + float modelindex; + vec3_t absmin; + vec3_t absmax; + float ltime; + float lastruntime; + float movetype; + float solid; + vec3_t origin; + vec3_t oldorigin; + vec3_t velocity; + vec3_t angles; + vec3_t avelocity; string_t classname; string_t model; - float frame; - float skin; - float effects; - vec3_t mins; - vec3_t maxs; - vec3_t size; - func_t touch; - func_t use; - func_t think; - func_t blocked; - float nextthink; - int groundentity; - float health; - float frags; - float weapon; + float frame; + float skin; + float effects; + vec3_t mins; + vec3_t maxs; + vec3_t size; + func_t touch; + func_t use; + func_t think; + func_t blocked; + float nextthink; + int groundentity; + float health; + float frags; + float weapon; string_t weaponmodel; - float weaponframe; - float currentammo; - float ammo_shells; - float ammo_nails; - float ammo_rockets; - float ammo_cells; - float items; - float takedamage; - int chain; - float deadflag; - vec3_t view_ofs; - float button0; - float button1; - float button2; - float impulse; - float fixangle; - vec3_t v_angle; + float weaponframe; + float currentammo; + float ammo_shells; + float ammo_nails; + float ammo_rockets; + float ammo_cells; + float items; + float takedamage; + int chain; + float deadflag; + vec3_t view_ofs; + float button0; + float button1; + float button2; + float impulse; + float fixangle; + vec3_t v_angle; string_t netname; - int enemy; - float flags; - float colormap; - float team; - float max_health; - float teleport_time; - float armortype; - float armorvalue; - float waterlevel; - float watertype; - float ideal_yaw; - float yaw_speed; - int aiment; - int goalentity; - float spawnflags; + int enemy; + float flags; + float colormap; + float team; + float max_health; + float teleport_time; + float armortype; + float armorvalue; + float waterlevel; + float watertype; + float ideal_yaw; + float yaw_speed; + int aiment; + int goalentity; + float spawnflags; string_t target; string_t targetname; - float dmg_take; - float dmg_save; - int dmg_inflictor; - int owner; - vec3_t movedir; + float dmg_take; + float dmg_save; + int dmg_inflictor; + int owner; + vec3_t movedir; string_t message; - float sounds; + float sounds; string_t noise; string_t noise1; string_t noise2; diff --git a/qw/source/Makefile.am b/qw/source/Makefile.am index 867d8844d..c3b6914bc 100644 --- a/qw/source/Makefile.am +++ b/qw/source/Makefile.am @@ -80,14 +80,14 @@ if ASM_ARCH world_ASM= worlda.S endif -server_SOURCES= pr_edict.c pr_exec.c pr_offs.c sv_ccmds.c sv_cvar.c \ +server_SOURCES= sv_ccmds.c sv_cvar.c \ sv_ents.c sv_init.c sv_main.c sv_misc.c sv_model.c \ sv_move.c sv_nchan.c sv_phys.c sv_pr_cmds.c sv_progs.c sv_send.c \ sv_user.c ver_check.c world.c $(world_ASM) qw_server_SOURCES= $(common_SOURCES) $(server_SOURCES) -qw_server_LDADD= -L. -L../../libs -lqfnet -lqfsys_sv -lqfutil $(NET_LIBS) $(Z_LIBS) $(DL_LIBS) -qw_server_DEPENDENCIES= libqfnet.a libqfsys_sv.a ../../libs/libqfutil.a +qw_server_LDADD= -L. -L../../libs -lqfnet -lqfsys_sv -lqfgamecode -lqfutil $(NET_LIBS) $(Z_LIBS) $(DL_LIBS) +qw_server_DEPENDENCIES= libqfnet.a libqfsys_sv.a ../../libs/libqfgamecode.a ../../libs/libqfutil.a # # Client builds @@ -170,8 +170,8 @@ endif libqfjs_a_CFLAGS= $(JOY_CFLAGS) EXTRA_libqfjs_a_SOURCES= joy_linux.c joy_win.c joy_null.c -CLIENT_LIBS= -L. -L../../libs -lqfnet -lqfsys_cl -lqfsnd -lqfcd -lqfjs -lqfutil $(SOUND_LIBS) $(NET_LIBS) $(CD_LIBS) $(JOY_LIBS) $(Z_LIBS) -CLIENT_LIB_DEPS= libqfnet.a libqfsys_cl.a libqfsnd.a libqfcd.a libqfjs.a ../../libs/libqfutil.a +CLIENT_LIBS= -L. -L../../libs -lqfnet -lqfsys_cl -lqfsnd -lqfcd -lqfjs -lqfgamecode -lqfutil $(SOUND_LIBS) $(NET_LIBS) $(CD_LIBS) $(JOY_LIBS) $(Z_LIBS) +CLIENT_LIB_DEPS= libqfnet.a libqfsys_cl.a libqfsnd.a libqfcd.a libqfjs.a ../../libs/libqfgamecode.a ../../libs/libqfutil.a if ASM_ARCH client_ASM= snd_mixa.S cl_math.S diff --git a/qw/source/sv_ccmds.c b/qw/source/sv_ccmds.c index cf53c69c0..87523d4f8 100644 --- a/qw/source/sv_ccmds.c +++ b/qw/source/sv_ccmds.c @@ -41,6 +41,7 @@ #include "bothdefs.h" #include "cmd.h" #include "msg.h" +#include "progdefs.h" #include "qargs.h" #include "qendian.h" #include "quakefs.h" @@ -216,8 +217,8 @@ SV_God_f (void) if (!SV_SetPlayer ()) return; - sv_player->v.v.flags = (int) sv_player->v.v.flags ^ FL_GODMODE; - if (!((int) sv_player->v.v.flags & FL_GODMODE)) + ((entvars_t*)&sv_player->v)->flags = (int) ((entvars_t*)&sv_player->v)->flags ^ FL_GODMODE; + if (!((int) ((entvars_t*)&sv_player->v)->flags & FL_GODMODE)) SV_ClientPrintf (host_client, PRINT_HIGH, "godmode OFF\n"); else SV_ClientPrintf (host_client, PRINT_HIGH, "godmode ON\n"); @@ -236,11 +237,11 @@ SV_Noclip_f (void) if (!SV_SetPlayer ()) return; - if (sv_player->v.v.movetype != MOVETYPE_NOCLIP) { - sv_player->v.v.movetype = MOVETYPE_NOCLIP; + if (((entvars_t*)&sv_player->v)->movetype != MOVETYPE_NOCLIP) { + ((entvars_t*)&sv_player->v)->movetype = MOVETYPE_NOCLIP; SV_ClientPrintf (host_client, PRINT_HIGH, "noclip ON\n"); } else { - sv_player->v.v.movetype = MOVETYPE_WALK; + ((entvars_t*)&sv_player->v)->movetype = MOVETYPE_WALK; SV_ClientPrintf (host_client, PRINT_HIGH, "noclip OFF\n"); } } @@ -276,24 +277,24 @@ SV_Give_f (void) case '7': case '8': case '9': - sv_player->v.v.items = - (int) sv_player->v.v.items | IT_SHOTGUN << (t[0] - '2'); + ((entvars_t*)&sv_player->v)->items = + (int) ((entvars_t*)&sv_player->v)->items | IT_SHOTGUN << (t[0] - '2'); break; case 's': - sv_player->v.v.ammo_shells = v; + ((entvars_t*)&sv_player->v)->ammo_shells = v; break; case 'n': - sv_player->v.v.ammo_nails = v; + ((entvars_t*)&sv_player->v)->ammo_nails = v; break; case 'r': - sv_player->v.v.ammo_rockets = v; + ((entvars_t*)&sv_player->v)->ammo_rockets = v; break; case 'h': - sv_player->v.v.health = v; + ((entvars_t*)&sv_player->v)->health = v; break; case 'c': - sv_player->v.v.ammo_cells = v; + ((entvars_t*)&sv_player->v)->ammo_cells = v; break; } } @@ -414,7 +415,7 @@ SV_Status_f (void) Con_Printf ("%-16.16s ", cl->name); - Con_Printf ("%6i %5i", cl->userid, (int) cl->edict->v.v.frags); + Con_Printf ("%6i %5i", cl->userid, (int) ((entvars_t*)&cl->edict->v)->frags); if (cl->spectator) Con_Printf (" (s)\n"); else @@ -444,7 +445,7 @@ SV_Status_f (void) for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { if (!cl->state) continue; - Con_Printf ("%5i %6i ", (int) cl->edict->v.v.frags, cl->userid); + Con_Printf ("%5i %6i ", (int) ((entvars_t*)&cl->edict->v)->frags, cl->userid); s = NET_BaseAdrToString (cl->netchan.remote_address); diff --git a/qw/source/sv_ents.c b/qw/source/sv_ents.c index ab8c3628e..7b45ec645 100644 --- a/qw/source/sv_ents.c +++ b/qw/source/sv_ents.c @@ -38,6 +38,7 @@ #include "msg.h" #include "msg_ucmd.h" +#include "progdefs.h" #include "server.h" #include "sys.h" @@ -117,8 +118,8 @@ extern int sv_nailmodel, sv_supernailmodel, sv_playermodel; qboolean SV_AddNailUpdate (edict_t *ent) { - if (ent->v.v.modelindex != sv_nailmodel - && ent->v.v.modelindex != sv_supernailmodel) return false; + if (((entvars_t*)&ent->v)->modelindex != sv_nailmodel + && ((entvars_t*)&ent->v)->modelindex != sv_supernailmodel) return false; if (numnails == MAX_NAILS) return true; nails[numnails] = ent; @@ -142,11 +143,11 @@ SV_EmitNailUpdate (sizebuf_t *msg) for (n = 0; n < numnails; n++) { ent = nails[n]; - x = (int) (ent->v.v.origin[0] + 4096) >> 1; - y = (int) (ent->v.v.origin[1] + 4096) >> 1; - z = (int) (ent->v.v.origin[2] + 4096) >> 1; - p = (int) (16 * ent->v.v.angles[0] / 360) & 15; - yaw = (int) (256 * ent->v.v.angles[1] / 360) & 255; + x = (int) (((entvars_t*)&ent->v)->origin[0] + 4096) >> 1; + y = (int) (((entvars_t*)&ent->v)->origin[1] + 4096) >> 1; + z = (int) (((entvars_t*)&ent->v)->origin[2] + 4096) >> 1; + p = (int) (16 * ((entvars_t*)&ent->v)->angles[0] / 360) & 15; + yaw = (int) (256 * ((entvars_t*)&ent->v)->angles[1] / 360) & 255; bits[0] = x; bits[1] = (x >> 8) | (y << 4); @@ -362,7 +363,7 @@ SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *msg) // the baseline ent = EDICT_NUM (&sv_pr_state, newnum); //Con_Printf ("baseline %i\n", newnum); - SV_WriteDelta (&ent->baseline, &to->entities[newindex], msg, true, + SV_WriteDelta (ent->data, &to->entities[newindex], msg, true, client->stdver); newindex++; continue; @@ -416,18 +417,18 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs, pflags = PF_MSEC | PF_COMMAND; - if (ent->v.v.modelindex != sv_playermodel) + if (((entvars_t*)&ent->v)->modelindex != sv_playermodel) pflags |= PF_MODEL; for (i = 0; i < 3; i++) - if (ent->v.v.velocity[i]) + if (((entvars_t*)&ent->v)->velocity[i]) pflags |= PF_VELOCITY1 << i; - if (ent->v.v.effects) + if (((entvars_t*)&ent->v)->effects) pflags |= PF_EFFECTS; - if (ent->v.v.skin) + if (((entvars_t*)&ent->v)->skin) pflags |= PF_SKINNUM; - if (ent->v.v.health <= 0) + if (((entvars_t*)&ent->v)->health <= 0) pflags |= PF_DEAD; - if (ent->v.v.mins[2] != -24) + if (((entvars_t*)&ent->v)->mins[2] != -24) pflags |= PF_GIB; if (cl->spectator) { // only sent origin and velocity to @@ -436,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 // personal entity pflags &= ~(PF_MSEC | PF_COMMAND); - if (ent->v.v.weaponframe) + if (((entvars_t*)&ent->v)->weaponframe) pflags |= PF_WEAPONFRAME; } if (client->spec_track && client->spec_track - 1 == j && - ent->v.v.weaponframe) pflags |= PF_WEAPONFRAME; + ((entvars_t*)&ent->v)->weaponframe) pflags |= PF_WEAPONFRAME; MSG_WriteByte (msg, svc_playerinfo); MSG_WriteByte (msg, j); MSG_WriteShort (msg, pflags); for (i = 0; i < 3; i++) - MSG_WriteCoord (msg, ent->v.v.origin[i]); + MSG_WriteCoord (msg, ((entvars_t*)&ent->v)->origin[i]); - MSG_WriteByte (msg, ent->v.v.frame); + MSG_WriteByte (msg, ((entvars_t*)&ent->v)->frame); if (pflags & PF_MSEC) { msec = 1000 * (sv.time - cl->localtime); @@ -462,10 +463,10 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs, if (pflags & PF_COMMAND) { cmd = cl->lastcmd; - if (ent->v.v.health <= 0) { // don't show the corpse looking + if (((entvars_t*)&ent->v)->health <= 0) { // don't show the corpse looking // around... cmd.angles[0] = 0; - cmd.angles[1] = ent->v.v.angles[1]; + cmd.angles[1] = ((entvars_t*)&ent->v)->angles[1]; cmd.angles[0] = 0; } @@ -477,19 +478,19 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs, for (i = 0; i < 3; i++) if (pflags & (PF_VELOCITY1 << i)) - MSG_WriteShort (msg, ent->v.v.velocity[i]); + MSG_WriteShort (msg, ((entvars_t*)&ent->v)->velocity[i]); if (pflags & PF_MODEL) - MSG_WriteByte (msg, ent->v.v.modelindex); + MSG_WriteByte (msg, ((entvars_t*)&ent->v)->modelindex); if (pflags & PF_SKINNUM) - MSG_WriteByte (msg, ent->v.v.skin); + MSG_WriteByte (msg, ((entvars_t*)&ent->v)->skin); if (pflags & PF_EFFECTS) - MSG_WriteByte (msg, ent->v.v.effects); + MSG_WriteByte (msg, ((entvars_t*)&ent->v)->effects); if (pflags & PF_WEAPONFRAME) - MSG_WriteByte (msg, ent->v.v.weaponframe); + MSG_WriteByte (msg, ((entvars_t*)&ent->v)->weaponframe); } } @@ -519,7 +520,7 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg) // find the client's PVS clent = client->edict; - VectorAdd (clent->v.v.origin, clent->v.v.view_ofs, org); + VectorAdd (((entvars_t*)&clent->v)->origin, ((entvars_t*)&clent->v)->view_ofs, org); pvs = SV_FatPVS (org); // send over the players in the PVS @@ -535,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; e++, ent = NEXT_EDICT (&sv_pr_state, ent)) { // ignore ents without visible models - if (!ent->v.v.modelindex || !*PR_GetString (&sv_pr_state, ent->v.v.model)) + if (!((entvars_t*)&ent->v)->modelindex || !*PR_GetString (&sv_pr_state, ((entvars_t*)&ent->v)->model)) continue; // ignore if not touching a PV leaf @@ -558,13 +559,13 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg) state->number = e; state->flags = 0; - VectorCopy (ent->v.v.origin, state->origin); - VectorCopy (ent->v.v.angles, state->angles); - state->modelindex = ent->v.v.modelindex; - state->frame = ent->v.v.frame; - state->colormap = ent->v.v.colormap; - state->skinnum = ent->v.v.skin; - state->effects = ent->v.v.effects; + VectorCopy (((entvars_t*)&ent->v)->origin, state->origin); + VectorCopy (((entvars_t*)&ent->v)->angles, state->angles); + state->modelindex = ((entvars_t*)&ent->v)->modelindex; + state->frame = ((entvars_t*)&ent->v)->frame; + state->colormap = ((entvars_t*)&ent->v)->colormap; + state->skinnum = ((entvars_t*)&ent->v)->skin; + state->effects = ((entvars_t*)&ent->v)->effects; // LordHavoc: cleaned up Endy's coding style, shortened the code, // and implemented missing effects diff --git a/qw/source/sv_init.c b/qw/source/sv_init.c index 5e56ef161..f5ecbb89d 100644 --- a/qw/source/sv_init.c +++ b/qw/source/sv_init.c @@ -38,6 +38,7 @@ #include "crc.h" #include "msg.h" +#include "progdefs.h" #include "quakefs.h" #include "server.h" #include "world.h" @@ -49,6 +50,8 @@ char localmodels[MAX_MODELS][5]; // inline model names for precache char localinfo[MAX_LOCALINFO_STRING + 1]; // local game info +entity_state_t baselines[MAX_EDICTS]; + /* SV_ModelIndex */ @@ -108,30 +111,30 @@ SV_CreateBaseline (void) continue; // create baselines for all player slots, // and any other edict that has a visible model - if (entnum > MAX_CLIENTS && !svent->v.v.modelindex) + if (entnum > MAX_CLIENTS && !((entvars_t*)&svent->v)->modelindex) continue; // // create entity baseline // - VectorCopy (svent->v.v.origin, svent->baseline.origin); - VectorCopy (svent->v.v.angles, svent->baseline.angles); - svent->baseline.frame = svent->v.v.frame; - svent->baseline.skinnum = svent->v.v.skin; + VectorCopy (((entvars_t*)&svent->v)->origin, ((entity_state_t*)svent->data)->origin); + VectorCopy (((entvars_t*)&svent->v)->angles, ((entity_state_t*)svent->data)->angles); + ((entity_state_t*)svent->data)->frame = ((entvars_t*)&svent->v)->frame; + ((entity_state_t*)svent->data)->skinnum = ((entvars_t*)&svent->v)->skin; if (entnum > 0 && entnum <= MAX_CLIENTS) { - svent->baseline.colormap = entnum; - svent->baseline.modelindex = SV_ModelIndex ("progs/player.mdl"); + ((entity_state_t*)svent->data)->colormap = entnum; + ((entity_state_t*)svent->data)->modelindex = SV_ModelIndex ("progs/player.mdl"); } else { - svent->baseline.colormap = 0; - svent->baseline.modelindex = - SV_ModelIndex (PR_GetString (&sv_pr_state, svent->v.v.model)); + ((entity_state_t*)svent->data)->colormap = 0; + ((entity_state_t*)svent->data)->modelindex = + SV_ModelIndex (PR_GetString (&sv_pr_state, ((entvars_t*)&svent->v)->model)); } // LordHavoc: setup baseline to include new effects - svent->baseline.alpha = 255; - svent->baseline.scale = 16; - svent->baseline.glowsize = 0; - svent->baseline.glowcolor = 254; - svent->baseline.colormap = 255; + ((entity_state_t*)svent->data)->alpha = 255; + ((entity_state_t*)svent->data)->scale = 16; + ((entity_state_t*)svent->data)->glowsize = 0; + ((entity_state_t*)svent->data)->glowcolor = 254; + ((entity_state_t*)svent->data)->colormap = 255; // // flush the signon message out to a seperate buffer if @@ -145,13 +148,13 @@ SV_CreateBaseline (void) MSG_WriteByte (&sv.signon, svc_spawnbaseline); MSG_WriteShort (&sv.signon, entnum); - MSG_WriteByte (&sv.signon, svent->baseline.modelindex); - MSG_WriteByte (&sv.signon, svent->baseline.frame); - MSG_WriteByte (&sv.signon, svent->baseline.colormap); - MSG_WriteByte (&sv.signon, svent->baseline.skinnum); + MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->modelindex); + MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->frame); + MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->colormap); + MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->skinnum); for (i = 0; i < 3; i++) { - MSG_WriteCoord (&sv.signon, svent->baseline.origin[i]); - MSG_WriteAngle (&sv.signon, svent->baseline.angles[i]); + MSG_WriteCoord (&sv.signon, ((entity_state_t*)svent->data)->origin[i]); + MSG_WriteAngle (&sv.signon, ((entity_state_t*)svent->data)->angles[i]); } } } @@ -173,7 +176,7 @@ SV_SaveSpawnparms (void) return; // no progs loaded yet // serverflags is the only game related thing maintained - svs.serverflags = sv_pr_state.pr_global_struct->serverflags; + svs.serverflags = ((globalvars_t*)sv_pr_state.pr_globals)->serverflags; for (i = 0, host_client = svs.clients; i < MAX_CLIENTS; i++, host_client++) { if (host_client->state != cs_spawned) @@ -183,10 +186,10 @@ SV_SaveSpawnparms (void) host_client->state = cs_connected; // call the progs to get default spawn parms for the new client - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, host_client->edict); - PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->SetChangeParms); + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, host_client->edict); + PR_ExecuteProgram (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->SetChangeParms); for (j = 0; j < NUM_SPAWN_PARMS; j++) - host_client->spawn_parms[j] = (&sv_pr_state.pr_global_struct->parm1)[j]; + host_client->spawn_parms[j] = (&((globalvars_t*)sv_pr_state.pr_globals)->parm1)[j]; } } @@ -339,12 +342,14 @@ SV_SpawnServer (char *server) MAX_SERVERINFO_STRING); // allocate edicts - sv.edicts = Hunk_AllocName (MAX_EDICTS * sv_pr_state.pr_edict_size, "edicts"); + sv_pr_state.pr_edictareasize = sv_pr_state.pr_edict_size * MAX_EDICTS; + sv.edicts = Hunk_AllocName (sv_pr_state.pr_edictareasize, "edicts"); // leave slots at start for clients only sv.num_edicts = MAX_CLIENTS + 1; for (i = 0; i < MAX_CLIENTS; i++) { ent = EDICT_NUM (&sv_pr_state, i + 1); + ent->data = &baselines[i]; svs.clients[i].edict = ent; //ZOID - make sure we update frags right svs.clients[i].old_frags = 0; @@ -387,14 +392,14 @@ SV_SpawnServer (char *server) ent = EDICT_NUM (&sv_pr_state, 0); ent->free = false; - ent->v.v.model = PR_SetString (&sv_pr_state, sv.worldmodel->name); - ent->v.v.modelindex = 1; // world model - ent->v.v.solid = SOLID_BSP; - ent->v.v.movetype = MOVETYPE_PUSH; + ((entvars_t*)&ent->v)->model = PR_SetString (&sv_pr_state, sv.worldmodel->name); + ((entvars_t*)&ent->v)->modelindex = 1; // world model + ((entvars_t*)&ent->v)->solid = SOLID_BSP; + ((entvars_t*)&ent->v)->movetype = MOVETYPE_PUSH; - sv_pr_state.pr_global_struct->mapname = PR_SetString (&sv_pr_state, sv.name); + ((globalvars_t*)sv_pr_state.pr_globals)->mapname = PR_SetString (&sv_pr_state, sv.name); // serverflags are for cross level information (sigils) - sv_pr_state.pr_global_struct->serverflags = svs.serverflags; + ((globalvars_t*)sv_pr_state.pr_globals)->serverflags = svs.serverflags; // run the frame start qc function to let progs check cvars SV_ProgStartFrame (); diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index d0651f894..de81d31cb 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -46,6 +46,7 @@ #include "net.h" #include "msg.h" #include "pmove.h" +#include "progdefs.h" #include "qargs.h" #include "quakefs.h" #include "server.h" @@ -250,12 +251,12 @@ SV_DropClient (client_t *drop) if (!drop->spectator) { // call the prog function for removing a client // this will set the body to a dead frame, among other things - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, drop->edict); - PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->ClientDisconnect); + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, drop->edict); + PR_ExecuteProgram (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->ClientDisconnect); } else if (SpectatorDisconnect) { // call the prog function for removing a client // this will set the body to a dead frame, among other things - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, drop->edict); + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, drop->edict); PR_ExecuteProgram (&sv_pr_state, SpectatorDisconnect); } } @@ -278,7 +279,7 @@ SV_DropClient (client_t *drop) drop->connection_started = realtime; // for zombie timeout drop->old_frags = 0; - drop->edict->v.v.frags = 0; + ((entvars_t*)&drop->edict->v)->frags = 0; drop->name[0] = 0; memset (drop->userinfo, 0, sizeof (drop->userinfo)); @@ -841,9 +842,9 @@ SVC_DirectConnect (void) newcl->lockedtill = 0; // call the progs to get default spawn parms for the new client - PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->SetNewParms); + PR_ExecuteProgram (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->SetNewParms); for (i = 0; i < NUM_SPAWN_PARMS; i++) - newcl->spawn_parms[i] = (&sv_pr_state.pr_global_struct->parm1)[i]; + newcl->spawn_parms[i] = (&((globalvars_t*)sv_pr_state.pr_globals)->parm1)[i]; if (newcl->spectator) Con_Printf ("Spectator %s connected\n", newcl->name); diff --git a/qw/source/sv_move.c b/qw/source/sv_move.c index 258e965e4..7c1287e5a 100644 --- a/qw/source/sv_move.c +++ b/qw/source/sv_move.c @@ -33,6 +33,8 @@ #include #include +#include "qtypes.h" +#include "progdefs.h" #include "pmove.h" #include "server.h" #include "sv_pr_cmds.h" @@ -56,8 +58,8 @@ SV_CheckBottom (edict_t *ent) int x, y; float mid, bottom; - VectorAdd (ent->v.v.origin, ent->v.v.mins, mins); - VectorAdd (ent->v.v.origin, ent->v.v.maxs, maxs); + VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, mins); + VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->maxs, maxs); // if all of the points under the corners are solid world, don't bother // with the tougher checks @@ -128,34 +130,34 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) edict_t *enemy; // try the move - VectorCopy (ent->v.v.origin, oldorg); - VectorAdd (ent->v.v.origin, move, neworg); + VectorCopy (((entvars_t*)&ent->v)->origin, oldorg); + VectorAdd (((entvars_t*)&ent->v)->origin, move, neworg); // flying monsters don't step up - if ((int) ent->v.v.flags & (FL_SWIM | FL_FLY)) { + if ((int) ((entvars_t*)&ent->v)->flags & (FL_SWIM | FL_FLY)) { // try one move with vertical motion, then one without for (i = 0; i < 2; i++) { - VectorAdd (ent->v.v.origin, move, neworg); - enemy = PROG_TO_EDICT (&sv_pr_state, ent->v.v.enemy); + VectorAdd (((entvars_t*)&ent->v)->origin, move, neworg); + enemy = PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->enemy); if (i == 0 && enemy != sv.edicts) { dz = - ent->v.v.origin[2] - - PROG_TO_EDICT (&sv_pr_state, ent->v.v.enemy)->v.v.origin[2]; + ((entvars_t*)&ent->v)->origin[2] - + ((entvars_t*)&PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->enemy)->v)->origin[2]; if (dz > 40) neworg[2] -= 8; if (dz < 30) neworg[2] += 8; } trace = - SV_Move (ent->v.v.origin, ent->v.v.mins, ent->v.v.maxs, neworg, false, + SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, neworg, false, ent); if (trace.fraction == 1) { - if (((int) ent->v.v.flags & FL_SWIM) + if (((int) ((entvars_t*)&ent->v)->flags & FL_SWIM) && SV_PointContents (trace.endpos) == CONTENTS_EMPTY) return false; // swim monster left water - VectorCopy (trace.endpos, ent->v.v.origin); + VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); if (relink) SV_LinkEdict (ent, true); return true; @@ -172,24 +174,24 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) VectorCopy (neworg, end); end[2] -= STEPSIZE * 2; - trace = SV_Move (neworg, ent->v.v.mins, ent->v.v.maxs, end, false, ent); + trace = SV_Move (neworg, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, false, ent); if (trace.allsolid) return false; if (trace.startsolid) { neworg[2] -= STEPSIZE; - trace = SV_Move (neworg, ent->v.v.mins, ent->v.v.maxs, end, false, ent); + trace = SV_Move (neworg, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, false, ent); if (trace.allsolid || trace.startsolid) return false; } if (trace.fraction == 1) { // if monster had the ground pulled out, go ahead and fall - if ((int) ent->v.v.flags & FL_PARTIALGROUND) { - VectorAdd (ent->v.v.origin, move, ent->v.v.origin); + if ((int) ((entvars_t*)&ent->v)->flags & FL_PARTIALGROUND) { + VectorAdd (((entvars_t*)&ent->v)->origin, move, ((entvars_t*)&ent->v)->origin); if (relink) SV_LinkEdict (ent, true); - ent->v.v.flags = (int) ent->v.v.flags & ~FL_ONGROUND; + ((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags & ~FL_ONGROUND; // Con_Printf ("fall down\n"); return true; } @@ -197,10 +199,10 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) return false; // walked off an edge } // check point traces down for dangling corners - VectorCopy (trace.endpos, ent->v.v.origin); + VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); if (!SV_CheckBottom (ent)) { - if ((int) ent->v.v.flags & FL_PARTIALGROUND) { // entity had floor + if ((int) ((entvars_t*)&ent->v)->flags & FL_PARTIALGROUND) { // entity had floor // mostly pulled out // from underneath it // and is trying to correct @@ -208,15 +210,15 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink) SV_LinkEdict (ent, true); return true; } - VectorCopy (oldorg, ent->v.v.origin); + VectorCopy (oldorg, ((entvars_t*)&ent->v)->origin); return false; } - if ((int) ent->v.v.flags & FL_PARTIALGROUND) { + if ((int) ((entvars_t*)&ent->v)->flags & FL_PARTIALGROUND) { // Con_Printf ("back on ground\n"); - ent->v.v.flags = (int) ent->v.v.flags & ~FL_PARTIALGROUND; + ((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags & ~FL_PARTIALGROUND; } - ent->v.v.groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); + ((entvars_t*)&ent->v)->groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); // the move is ok if (relink) @@ -239,7 +241,7 @@ SV_StepDirection (edict_t *ent, float yaw, float dist) vec3_t move, oldorigin; float delta; - ent->v.v.ideal_yaw = yaw; + ((entvars_t*)&ent->v)->ideal_yaw = yaw; PF_changeyaw (&sv_pr_state); yaw = yaw * M_PI * 2 / 360; @@ -247,12 +249,12 @@ SV_StepDirection (edict_t *ent, float yaw, float dist) move[1] = sin (yaw) * dist; move[2] = 0; - VectorCopy (ent->v.v.origin, oldorigin); + VectorCopy (((entvars_t*)&ent->v)->origin, oldorigin); if (SV_movestep (ent, move, false)) { - delta = ent->v.v.angles[YAW] - ent->v.v.ideal_yaw; + delta = ((entvars_t*)&ent->v)->angles[YAW] - ((entvars_t*)&ent->v)->ideal_yaw; if (delta > 45 && delta < 315) { // not turned far enough, so // don't take the step - VectorCopy (oldorigin, ent->v.v.origin); + VectorCopy (oldorigin, ((entvars_t*)&ent->v)->origin); } SV_LinkEdict (ent, true); return true; @@ -270,7 +272,7 @@ SV_FixCheckBottom (edict_t *ent) { // Con_Printf ("SV_FixCheckBottom\n"); - ent->v.v.flags = (int) ent->v.v.flags | FL_PARTIALGROUND; + ((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags | FL_PARTIALGROUND; } @@ -286,11 +288,11 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) float d[3]; float tdir, olddir, turnaround; - olddir = anglemod ((int) (actor->v.v.ideal_yaw / 45) * 45); + olddir = anglemod ((int) (((entvars_t*)&actor->v)->ideal_yaw / 45) * 45); turnaround = anglemod (olddir - 180); - deltax = enemy->v.v.origin[0] - actor->v.v.origin[0]; - deltay = enemy->v.v.origin[1] - actor->v.v.origin[1]; + deltax = ((entvars_t*)&enemy->v)->origin[0] - ((entvars_t*)&actor->v)->origin[0]; + deltay = ((entvars_t*)&enemy->v)->origin[1] - ((entvars_t*)&actor->v)->origin[1]; if (deltax > 10) d[1] = 0; else if (deltax < -10) @@ -346,7 +348,7 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist) if (turnaround != DI_NODIR && SV_StepDirection (actor, turnaround, dist)) return; - actor->v.v.ideal_yaw = olddir; // can't move + ((entvars_t*)&actor->v)->ideal_yaw = olddir; // can't move // if a bridge was pulled out from underneath a monster, it may not have // a valid standing position at all @@ -365,9 +367,9 @@ SV_CloseEnough (edict_t *ent, edict_t *goal, float dist) int i; for (i = 0; i < 3; i++) { - if (goal->v.v.absmin[i] > ent->v.v.absmax[i] + dist) + if (((entvars_t*)&goal->v)->absmin[i] > ((entvars_t*)&ent->v)->absmax[i] + dist) return false; - if (goal->v.v.absmax[i] < ent->v.v.absmin[i] - dist) + if (((entvars_t*)&goal->v)->absmax[i] < ((entvars_t*)&ent->v)->absmin[i] - dist) return false; } return true; @@ -382,20 +384,20 @@ SV_MoveToGoal (progs_t *pr) edict_t *ent, *goal; float dist; - ent = PROG_TO_EDICT (&sv_pr_state, sv_pr_state.pr_global_struct->self); - goal = PROG_TO_EDICT (&sv_pr_state, ent->v.v.goalentity); + ent = PROG_TO_EDICT (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->self); + goal = PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->goalentity); dist = G_FLOAT (&sv_pr_state, OFS_PARM0); - if (!((int) ent->v.v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { + if (!((int) ((entvars_t*)&ent->v)->flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { G_FLOAT (&sv_pr_state, OFS_RETURN) = 0; return; } // if the next step hits the enemy, return immediately - if (PROG_TO_EDICT (&sv_pr_state, ent->v.v.enemy) != sv.edicts + if (PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->enemy) != sv.edicts && SV_CloseEnough (ent, goal, dist)) return; // bump around... - if ((rand () & 3) == 1 || !SV_StepDirection (ent, ent->v.v.ideal_yaw, dist)) { + if ((rand () & 3) == 1 || !SV_StepDirection (ent, ((entvars_t*)&ent->v)->ideal_yaw, dist)) { SV_NewChaseDir (ent, goal, dist); } } diff --git a/qw/source/sv_phys.c b/qw/source/sv_phys.c index 105e12ebf..06133ab8c 100644 --- a/qw/source/sv_phys.c +++ b/qw/source/sv_phys.c @@ -31,6 +31,7 @@ #endif #include "cvar.h" +#include "progdefs.h" #include "pmove.h" #include "server.h" #include "world.h" @@ -86,9 +87,9 @@ SV_CheckAllEnts (void) for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { if (check->free) continue; - if (check->v.v.movetype == MOVETYPE_PUSH - || check->v.v.movetype == MOVETYPE_NONE - || check->v.v.movetype == MOVETYPE_NOCLIP) continue; + if (((entvars_t*)&check->v)->movetype == MOVETYPE_PUSH + || ((entvars_t*)&check->v)->movetype == MOVETYPE_NONE + || ((entvars_t*)&check->v)->movetype == MOVETYPE_NOCLIP) continue; if (SV_TestEntityPosition (check)) Con_Printf ("entity in invalid position\n"); @@ -108,23 +109,23 @@ SV_CheckVelocity (edict_t *ent) // bound velocity // for (i = 0; i < 3; i++) { - if (IS_NAN (ent->v.v.velocity[i])) { + if (IS_NAN (((entvars_t*)&ent->v)->velocity[i])) { Con_Printf ("Got a NaN velocity on %s\n", - PR_GetString (&sv_pr_state, ent->v.v.classname)); - ent->v.v.velocity[i] = 0; + PR_GetString (&sv_pr_state, ((entvars_t*)&ent->v)->classname)); + ((entvars_t*)&ent->v)->velocity[i] = 0; } - if (IS_NAN (ent->v.v.origin[i])) { + if (IS_NAN (((entvars_t*)&ent->v)->origin[i])) { Con_Printf ("Got a NaN origin on %s\n", - PR_GetString (&sv_pr_state, ent->v.v.classname)); - ent->v.v.origin[i] = 0; + PR_GetString (&sv_pr_state, ((entvars_t*)&ent->v)->classname)); + ((entvars_t*)&ent->v)->origin[i] = 0; } } // 1999-10-18 SV_MAXVELOCITY fix by Maddes start - wishspeed = Length (ent->v.v.velocity); + wishspeed = Length (((entvars_t*)&ent->v)->velocity); if (wishspeed > sv_maxvelocity->value) { - VectorScale (ent->v.v.velocity, sv_maxvelocity->value / wishspeed, - ent->v.v.velocity); + VectorScale (((entvars_t*)&ent->v)->velocity, sv_maxvelocity->value / wishspeed, + ((entvars_t*)&ent->v)->velocity); } // 1999-10-18 SV_MAXVELOCITY fix by Maddes end } @@ -143,7 +144,7 @@ SV_RunThink (edict_t *ent) float thinktime; do { - thinktime = ent->v.v.nextthink; + thinktime = ((entvars_t*)&ent->v)->nextthink; if (thinktime <= 0) return true; if (thinktime > sv.time + sv_frametime) @@ -153,11 +154,11 @@ SV_RunThink (edict_t *ent) thinktime = sv.time; // don't let things stay in the past. // it is possible to start that way // by a trigger with a local time. - ent->v.v.nextthink = 0; - sv_pr_state.pr_global_struct->time = thinktime; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, ent); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); - PR_ExecuteProgram (&sv_pr_state, ent->v.v.think); + ((entvars_t*)&ent->v)->nextthink = 0; + ((globalvars_t*)sv_pr_state.pr_globals)->time = thinktime; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, ent); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think); if (ent->free) return false; @@ -176,24 +177,24 @@ SV_Impact (edict_t *e1, edict_t *e2) { int old_self, old_other; - old_self = sv_pr_state.pr_global_struct->self; - old_other = sv_pr_state.pr_global_struct->other; + old_self = ((globalvars_t*)sv_pr_state.pr_globals)->self; + old_other = ((globalvars_t*)sv_pr_state.pr_globals)->other; - sv_pr_state.pr_global_struct->time = sv.time; - if (e1->v.v.touch && e1->v.v.solid != SOLID_NOT) { - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, e1); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, e2); - PR_ExecuteProgram (&sv_pr_state, e1->v.v.touch); + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + if (((entvars_t*)&e1->v)->touch && ((entvars_t*)&e1->v)->solid != SOLID_NOT) { + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, e1); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, e2); + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&e1->v)->touch); } - if (e2->v.v.touch && e2->v.v.solid != SOLID_NOT) { - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, e2); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, e1); - PR_ExecuteProgram (&sv_pr_state, e2->v.v.touch); + if (((entvars_t*)&e2->v)->touch && ((entvars_t*)&e2->v)->solid != SOLID_NOT) { + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, e2); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, e1); + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&e2->v)->touch); } - sv_pr_state.pr_global_struct->self = old_self; - sv_pr_state.pr_global_struct->other = old_other; + ((globalvars_t*)sv_pr_state.pr_globals)->self = old_self; + ((globalvars_t*)sv_pr_state.pr_globals)->other = old_other; } @@ -258,27 +259,27 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) numbumps = 4; blocked = 0; - VectorCopy (ent->v.v.velocity, original_velocity); - VectorCopy (ent->v.v.velocity, primal_velocity); + VectorCopy (((entvars_t*)&ent->v)->velocity, original_velocity); + VectorCopy (((entvars_t*)&ent->v)->velocity, primal_velocity); numplanes = 0; time_left = time; for (bumpcount = 0; bumpcount < numbumps; bumpcount++) { for (i = 0; i < 3; i++) - end[i] = ent->v.v.origin[i] + time_left * ent->v.v.velocity[i]; + end[i] = ((entvars_t*)&ent->v)->origin[i] + time_left * ((entvars_t*)&ent->v)->velocity[i]; trace = - SV_Move (ent->v.v.origin, ent->v.v.mins, ent->v.v.maxs, end, false, ent); + SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, false, ent); if (trace.allsolid) { // entity is trapped in another solid - VectorCopy (vec3_origin, ent->v.v.velocity); + VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); return 3; } if (trace.fraction > 0) { // actually covered some distance - VectorCopy (trace.endpos, ent->v.v.origin); - VectorCopy (ent->v.v.velocity, original_velocity); + VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); + VectorCopy (((entvars_t*)&ent->v)->velocity, original_velocity); numplanes = 0; } @@ -290,10 +291,10 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) if (trace.plane.normal[2] > 0.7) { blocked |= 1; // floor - if ((trace.ent->v.v.solid == SOLID_BSP) - || (trace.ent->v.v.movetype == MOVETYPE_PPUSH)) { - ent->v.v.flags = (int) ent->v.v.flags | FL_ONGROUND; - ent->v.v.groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); + if ((((entvars_t*)&trace.ent->v)->solid == SOLID_BSP) + || (((entvars_t*)&trace.ent->v)->movetype == MOVETYPE_PPUSH)) { + ((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags | FL_ONGROUND; + ((entvars_t*)&ent->v)->groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); } } if (!trace.plane.normal[2]) { @@ -313,7 +314,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) // cliped to another plane if (numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen - VectorCopy (vec3_origin, ent->v.v.velocity); + VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); return 3; } @@ -335,24 +336,24 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) } if (i != numplanes) { // go along this plane - VectorCopy (new_velocity, ent->v.v.velocity); + VectorCopy (new_velocity, ((entvars_t*)&ent->v)->velocity); } else { // go along the crease if (numplanes != 2) { // Con_Printf ("clip velocity, numplanes == %i\n",numplanes); - VectorCopy (vec3_origin, ent->v.v.velocity); + VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); return 7; } CrossProduct (planes[0], planes[1], dir); - d = DotProduct (dir, ent->v.v.velocity); - VectorScale (dir, d, ent->v.v.velocity); + d = DotProduct (dir, ((entvars_t*)&ent->v)->velocity); + VectorScale (dir, d, ((entvars_t*)&ent->v)->velocity); } // // if original velocity is against the original velocity, stop dead // to avoid tiny occilations in sloping corners // - if (DotProduct (ent->v.v.velocity, primal_velocity) <= 0) { - VectorCopy (vec3_origin, ent->v.v.velocity); + if (DotProduct (((entvars_t*)&ent->v)->velocity, primal_velocity) <= 0) { + VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); return blocked; } } @@ -367,7 +368,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) void SV_AddGravity (edict_t *ent, float scale) { - ent->v.v.velocity[2] -= scale * movevars.gravity * sv_frametime; + ((entvars_t*)&ent->v)->velocity[2] -= scale * movevars.gravity * sv_frametime; } /* @@ -385,23 +386,23 @@ SV_PushEntity (edict_t *ent, vec3_t push) trace_t trace; vec3_t end; - VectorAdd (ent->v.v.origin, push, end); + VectorAdd (((entvars_t*)&ent->v)->origin, push, end); - if (ent->v.v.movetype == MOVETYPE_FLYMISSILE) + if (((entvars_t*)&ent->v)->movetype == MOVETYPE_FLYMISSILE) trace = - SV_Move (ent->v.v.origin, ent->v.v.mins, ent->v.v.maxs, end, MOVE_MISSILE, + SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, MOVE_MISSILE, ent); - else if (ent->v.v.solid == SOLID_TRIGGER || ent->v.v.solid == SOLID_NOT) + else if (((entvars_t*)&ent->v)->solid == SOLID_TRIGGER || ((entvars_t*)&ent->v)->solid == SOLID_NOT) // only clip against bmodels trace = - SV_Move (ent->v.v.origin, ent->v.v.mins, ent->v.v.maxs, end, + SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, MOVE_NOMONSTERS, ent); else trace = - SV_Move (ent->v.v.origin, ent->v.v.mins, ent->v.v.maxs, end, MOVE_NORMAL, + SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, MOVE_NORMAL, ent); - VectorCopy (trace.endpos, ent->v.v.origin); + VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); SV_LinkEdict (ent, true); if (trace.ent) @@ -429,15 +430,15 @@ SV_Push (edict_t *pusher, vec3_t move) // --KB for (i = 0; i < 3; i++) { - mins[i] = pusher->v.v.absmin[i] + move[i]; - maxs[i] = pusher->v.v.absmax[i] + move[i]; + mins[i] = ((entvars_t*)&pusher->v)->absmin[i] + move[i]; + maxs[i] = ((entvars_t*)&pusher->v)->absmax[i] + move[i]; } - VectorCopy (pusher->v.v.origin, pushorig); + VectorCopy (((entvars_t*)&pusher->v)->origin, pushorig); // move the pusher to it's final position - VectorAdd (pusher->v.v.origin, move, pusher->v.v.origin); + VectorAdd (((entvars_t*)&pusher->v)->origin, move, ((entvars_t*)&pusher->v)->origin); SV_LinkEdict (pusher, false); // see if any solid entities are inside the final position @@ -446,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)) { if (check->free) continue; - if (check->v.v.movetype == MOVETYPE_PUSH - || check->v.v.movetype == MOVETYPE_NONE - || check->v.v.movetype == MOVETYPE_PPUSH - || check->v.v.movetype == MOVETYPE_NOCLIP) continue; + if (((entvars_t*)&check->v)->movetype == MOVETYPE_PUSH + || ((entvars_t*)&check->v)->movetype == MOVETYPE_NONE + || ((entvars_t*)&check->v)->movetype == MOVETYPE_PPUSH + || ((entvars_t*)&check->v)->movetype == MOVETYPE_NOCLIP) continue; // Don't assume SOLID_BSP ! --KB - solid_save = pusher->v.v.solid; - pusher->v.v.solid = SOLID_NOT; + solid_save = ((entvars_t*)&pusher->v)->solid; + ((entvars_t*)&pusher->v)->solid = SOLID_NOT; block = SV_TestEntityPosition (check); - // pusher->v.v.solid = SOLID_BSP; - pusher->v.v.solid = solid_save; + // ((entvars_t*)&pusher->v)->solid = SOLID_BSP; + ((entvars_t*)&pusher->v)->solid = solid_save; if (block) continue; // if the entity is standing on the pusher, it will definately be // moved - if (!(((int) check->v.v.flags & FL_ONGROUND) - && PROG_TO_EDICT (&sv_pr_state, check->v.v.groundentity) == pusher)) { - if (check->v.v.absmin[0] >= maxs[0] - || check->v.v.absmin[1] >= maxs[1] - || check->v.v.absmin[2] >= maxs[2] - || check->v.v.absmax[0] <= mins[0] - || check->v.v.absmax[1] <= mins[1] - || check->v.v.absmax[2] <= mins[2]) + if (!(((int) ((entvars_t*)&check->v)->flags & FL_ONGROUND) + && PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&check->v)->groundentity) == pusher)) { + if (((entvars_t*)&check->v)->absmin[0] >= maxs[0] + || ((entvars_t*)&check->v)->absmin[1] >= maxs[1] + || ((entvars_t*)&check->v)->absmin[2] >= maxs[2] + || ((entvars_t*)&check->v)->absmax[0] <= mins[0] + || ((entvars_t*)&check->v)->absmax[1] <= mins[1] + || ((entvars_t*)&check->v)->absmax[2] <= mins[2]) continue; // see if the ent's bbox is inside the pusher's final position @@ -477,49 +478,49 @@ SV_Push (edict_t *pusher, vec3_t move) continue; } - VectorCopy (check->v.v.origin, moved_from[num_moved]); + VectorCopy (((entvars_t*)&check->v)->origin, moved_from[num_moved]); moved_edict[num_moved] = check; num_moved++; // try moving the contacted entity - VectorAdd (check->v.v.origin, move, check->v.v.origin); + VectorAdd (((entvars_t*)&check->v)->origin, move, ((entvars_t*)&check->v)->origin); block = SV_TestEntityPosition (check); if (!block) { // pushed ok SV_LinkEdict (check, false); continue; } // if it is ok to leave in the old position, do it - VectorSubtract (check->v.v.origin, move, check->v.v.origin); + VectorSubtract (((entvars_t*)&check->v)->origin, move, ((entvars_t*)&check->v)->origin); block = SV_TestEntityPosition (check); if (!block) { num_moved--; continue; } // if it is still inside the pusher, block - if (check->v.v.mins[0] == check->v.v.maxs[0]) { + if (((entvars_t*)&check->v)->mins[0] == ((entvars_t*)&check->v)->maxs[0]) { SV_LinkEdict (check, false); continue; } - if (check->v.v.solid == SOLID_NOT || check->v.v.solid == SOLID_TRIGGER) { // corpse - check->v.v.mins[0] = check->v.v.mins[1] = 0; - VectorCopy (check->v.v.mins, check->v.v.maxs); + if (((entvars_t*)&check->v)->solid == SOLID_NOT || ((entvars_t*)&check->v)->solid == SOLID_TRIGGER) { // corpse + ((entvars_t*)&check->v)->mins[0] = ((entvars_t*)&check->v)->mins[1] = 0; + VectorCopy (((entvars_t*)&check->v)->mins, ((entvars_t*)&check->v)->maxs); SV_LinkEdict (check, false); continue; } - VectorCopy (pushorig, pusher->v.v.origin); + VectorCopy (pushorig, ((entvars_t*)&pusher->v)->origin); SV_LinkEdict (pusher, false); // if the pusher has a "blocked" function, call it // otherwise, just stay in place until the obstacle is gone - if (pusher->v.v.blocked) { - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, pusher); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, check); - PR_ExecuteProgram (&sv_pr_state, pusher->v.v.blocked); + if (((entvars_t*)&pusher->v)->blocked) { + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, pusher); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, check); + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&pusher->v)->blocked); } // move back any entities we already moved for (i = 0; i < num_moved; i++) { - VectorCopy (moved_from[i], moved_edict[i]->v.v.origin); + VectorCopy (moved_from[i], ((entvars_t*)&moved_edict[i]->v)->origin); SV_LinkEdict (moved_edict[i], false); } return false; @@ -537,17 +538,17 @@ SV_PushMove (edict_t *pusher, float movetime) int i; vec3_t move; - if (!pusher->v.v.velocity[0] && !pusher->v.v.velocity[1] - && !pusher->v.v.velocity[2]) { - pusher->v.v.ltime += movetime; + if (!((entvars_t*)&pusher->v)->velocity[0] && !((entvars_t*)&pusher->v)->velocity[1] + && !((entvars_t*)&pusher->v)->velocity[2]) { + ((entvars_t*)&pusher->v)->ltime += movetime; return; } for (i = 0; i < 3; i++) - move[i] = pusher->v.v.velocity[i] * movetime; + move[i] = ((entvars_t*)&pusher->v)->velocity[i] * movetime; if (SV_Push (pusher, move)) - pusher->v.v.ltime += movetime; + ((entvars_t*)&pusher->v)->ltime += movetime; } @@ -563,36 +564,36 @@ SV_Physics_Pusher (edict_t *ent) vec3_t oldorg, move; float l; - oldltime = ent->v.v.ltime; + oldltime = ((entvars_t*)&ent->v)->ltime; - thinktime = ent->v.v.nextthink; - if (thinktime < ent->v.v.ltime + sv_frametime) { - movetime = thinktime - ent->v.v.ltime; + thinktime = ((entvars_t*)&ent->v)->nextthink; + if (thinktime < ((entvars_t*)&ent->v)->ltime + sv_frametime) { + movetime = thinktime - ((entvars_t*)&ent->v)->ltime; if (movetime < 0) movetime = 0; } else movetime = sv_frametime; if (movetime) { - SV_PushMove (ent, movetime); // advances ent->v.v.ltime if not + SV_PushMove (ent, movetime); // advances ((entvars_t*)&ent->v)->ltime if not // blocked } - if (thinktime > oldltime && thinktime <= ent->v.v.ltime) { - VectorCopy (ent->v.v.origin, oldorg); - ent->v.v.nextthink = 0; - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, ent); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); - PR_ExecuteProgram (&sv_pr_state, ent->v.v.think); + if (thinktime > oldltime && thinktime <= ((entvars_t*)&ent->v)->ltime) { + VectorCopy (((entvars_t*)&ent->v)->origin, oldorg); + ((entvars_t*)&ent->v)->nextthink = 0; + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, ent); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think); if (ent->free) return; - VectorSubtract (ent->v.v.origin, oldorg, move); + VectorSubtract (((entvars_t*)&ent->v)->origin, oldorg, move); l = Length (move); if (l > 1.0 / 64) { // Con_Printf ("**** snap: %f\n", Length (l)); - VectorCopy (oldorg, ent->v.v.origin); + VectorCopy (oldorg, ((entvars_t*)&ent->v)->origin); SV_Push (ent, move); } } @@ -624,8 +625,8 @@ SV_Physics_Noclip (edict_t *ent) if (!SV_RunThink (ent)) return; - VectorMA (ent->v.v.angles, sv_frametime, ent->v.v.avelocity, ent->v.v.angles); - VectorMA (ent->v.v.origin, sv_frametime, ent->v.v.velocity, ent->v.v.origin); + VectorMA (((entvars_t*)&ent->v)->angles, sv_frametime, ((entvars_t*)&ent->v)->avelocity, ((entvars_t*)&ent->v)->angles); + VectorMA (((entvars_t*)&ent->v)->origin, sv_frametime, ((entvars_t*)&ent->v)->velocity, ((entvars_t*)&ent->v)->origin); SV_LinkEdict (ent, false); } @@ -642,27 +643,27 @@ SV_CheckWaterTransition (edict_t *ent) { int cont; - cont = SV_PointContents (ent->v.v.origin); - if (!ent->v.v.watertype) { // just spawned here - ent->v.v.watertype = cont; - ent->v.v.waterlevel = 1; + cont = SV_PointContents (((entvars_t*)&ent->v)->origin); + if (!((entvars_t*)&ent->v)->watertype) { // just spawned here + ((entvars_t*)&ent->v)->watertype = cont; + ((entvars_t*)&ent->v)->waterlevel = 1; return; } if (cont <= CONTENTS_WATER) { - if (ent->v.v.watertype == CONTENTS_EMPTY) { // just crossed into + if (((entvars_t*)&ent->v)->watertype == CONTENTS_EMPTY) { // just crossed into // water SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); } - ent->v.v.watertype = cont; - ent->v.v.waterlevel = 1; + ((entvars_t*)&ent->v)->watertype = cont; + ((entvars_t*)&ent->v)->waterlevel = 1; } else { - if (ent->v.v.watertype != CONTENTS_EMPTY) { // just crossed into + if (((entvars_t*)&ent->v)->watertype != CONTENTS_EMPTY) { // just crossed into // water SV_StartSound (ent, 0, "misc/h2ohit1.wav", 255, 1); } - ent->v.v.watertype = CONTENTS_EMPTY; - ent->v.v.waterlevel = cont; + ((entvars_t*)&ent->v)->watertype = CONTENTS_EMPTY; + ((entvars_t*)&ent->v)->waterlevel = cont; } } @@ -682,45 +683,45 @@ SV_Physics_Toss (edict_t *ent) if (!SV_RunThink (ent)) return; - if (ent->v.v.velocity[2] > 0) - ent->v.v.flags = (int) ent->v.v.flags & ~FL_ONGROUND; + if (((entvars_t*)&ent->v)->velocity[2] > 0) + ((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags & ~FL_ONGROUND; // if onground, return without moving - if (((int) ent->v.v.flags & FL_ONGROUND)) + if (((int) ((entvars_t*)&ent->v)->flags & FL_ONGROUND)) return; SV_CheckVelocity (ent); // add gravity - if (ent->v.v.movetype != MOVETYPE_FLY - && ent->v.v.movetype != MOVETYPE_FLYMISSILE) SV_AddGravity (ent, 1.0); + if (((entvars_t*)&ent->v)->movetype != MOVETYPE_FLY + && ((entvars_t*)&ent->v)->movetype != MOVETYPE_FLYMISSILE) SV_AddGravity (ent, 1.0); // move angles - VectorMA (ent->v.v.angles, sv_frametime, ent->v.v.avelocity, ent->v.v.angles); + VectorMA (((entvars_t*)&ent->v)->angles, sv_frametime, ((entvars_t*)&ent->v)->avelocity, ((entvars_t*)&ent->v)->angles); // move origin - VectorScale (ent->v.v.velocity, sv_frametime, move); + VectorScale (((entvars_t*)&ent->v)->velocity, sv_frametime, move); trace = SV_PushEntity (ent, move); if (trace.fraction == 1) return; if (ent->free) return; - if (ent->v.v.movetype == MOVETYPE_BOUNCE) + if (((entvars_t*)&ent->v)->movetype == MOVETYPE_BOUNCE) backoff = 1.5; else backoff = 1; - ClipVelocity (ent->v.v.velocity, trace.plane.normal, ent->v.v.velocity, + ClipVelocity (((entvars_t*)&ent->v)->velocity, trace.plane.normal, ((entvars_t*)&ent->v)->velocity, backoff); // stop if on ground if (trace.plane.normal[2] > 0.7) { - if (ent->v.v.velocity[2] < 60 || ent->v.v.movetype != MOVETYPE_BOUNCE) { - ent->v.v.flags = (int) ent->v.v.flags | FL_ONGROUND; - ent->v.v.groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); - VectorCopy (vec3_origin, ent->v.v.velocity); - VectorCopy (vec3_origin, ent->v.v.avelocity); + if (((entvars_t*)&ent->v)->velocity[2] < 60 || ((entvars_t*)&ent->v)->movetype != MOVETYPE_BOUNCE) { + ((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags | FL_ONGROUND; + ((entvars_t*)&ent->v)->groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent); + VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->velocity); + VectorCopy (vec3_origin, ((entvars_t*)&ent->v)->avelocity); } } // check for in water @@ -747,8 +748,8 @@ SV_Physics_Step (edict_t *ent) qboolean hitsound; // freefall if not on ground - if (!((int) ent->v.v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { - if (ent->v.v.velocity[2] < movevars.gravity * -0.1) + if (!((int) ((entvars_t*)&ent->v)->flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { + if (((entvars_t*)&ent->v)->velocity[2] < movevars.gravity * -0.1) hitsound = true; else hitsound = false; @@ -758,7 +759,7 @@ SV_Physics_Step (edict_t *ent) SV_FlyMove (ent, sv_frametime, NULL); SV_LinkEdict (ent, true); - if ((int) ent->v.v.flags & FL_ONGROUND) // just hit ground + if ((int) ((entvars_t*)&ent->v)->flags & FL_ONGROUND) // just hit ground { if (hitsound) SV_StartSound (ent, 0, "demon/dland2.wav", 255, 1); @@ -781,27 +782,27 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push SV_CheckVelocity (pusher); for (i = 0; i < 3; i++) { - move[i] = pusher->v.v.velocity[i] * movetime; - mins[i] = pusher->v.v.absmin[i] + move[i]; - maxs[i] = pusher->v.v.absmax[i] + move[i]; + move[i] = ((entvars_t*)&pusher->v)->velocity[i] * movetime; + mins[i] = ((entvars_t*)&pusher->v)->absmin[i] + move[i]; + maxs[i] = ((entvars_t*)&pusher->v)->absmax[i] + move[i]; } - VectorCopy (pusher->v.v.origin, pusher->v.v.oldorigin); // Backup origin + VectorCopy (((entvars_t*)&pusher->v)->origin, ((entvars_t*)&pusher->v)->oldorigin); // Backup origin trace = - SV_Move (pusher->v.v.origin, pusher->v.v.mins, pusher->v.v.maxs, move, + SV_Move (((entvars_t*)&pusher->v)->origin, ((entvars_t*)&pusher->v)->mins, ((entvars_t*)&pusher->v)->maxs, move, MOVE_NOMONSTERS, pusher); if (trace.fraction == 1) { - VectorCopy (pusher->v.v.origin, pusher->v.v.oldorigin); // Revert + VectorCopy (((entvars_t*)&pusher->v)->origin, ((entvars_t*)&pusher->v)->oldorigin); // Revert return; } - VectorAdd (pusher->v.v.origin, move, pusher->v.v.origin); // Move + VectorAdd (((entvars_t*)&pusher->v)->origin, move, ((entvars_t*)&pusher->v)->origin); // Move SV_LinkEdict (pusher, false); - pusher->v.v.ltime += movetime; + ((entvars_t*)&pusher->v)->ltime += movetime; - oldsolid = pusher->v.v.solid; + oldsolid = ((entvars_t*)&pusher->v)->solid; check = NEXT_EDICT (&sv_pr_state, sv.edicts); for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { @@ -813,25 +814,25 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push continue; // Stage 2: Is it a player we can push? - if (check->v.v.movetype == MOVETYPE_WALK) { + if (((entvars_t*)&check->v)->movetype == MOVETYPE_WALK) { Con_Printf ("Pusher encountered a player\n"); // Yes!@#!@ - pusher->v.v.solid = SOLID_NOT; + ((entvars_t*)&pusher->v)->solid = SOLID_NOT; SV_PushEntity (check, move); - pusher->v.v.solid = oldsolid; + ((entvars_t*)&pusher->v)->solid = oldsolid; continue; } // Stage 3: No.. Is it something that blocks us? - if (check->v.v.mins[0] == check->v.v.maxs[0]) + if (((entvars_t*)&check->v)->mins[0] == ((entvars_t*)&check->v)->maxs[0]) continue; - if (check->v.v.solid == SOLID_NOT || check->v.v.solid == SOLID_TRIGGER) + if (((entvars_t*)&check->v)->solid == SOLID_NOT || ((entvars_t*)&check->v)->solid == SOLID_TRIGGER) continue; // Stage 4: Yes, it must be. Fail the move. - VectorCopy (pusher->v.v.origin, pusher->v.v.oldorigin); // Revert - if (pusher->v.v.blocked) { // Blocked func? - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, pusher); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, check); - PR_ExecuteProgram (&sv_pr_state, pusher->v.v.blocked); + VectorCopy (((entvars_t*)&pusher->v)->origin, ((entvars_t*)&pusher->v)->oldorigin); // Revert + if (((entvars_t*)&pusher->v)->blocked) { // Blocked func? + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, pusher); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, check); + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&pusher->v)->blocked); } return; @@ -847,11 +848,11 @@ SV_Physics_PPusher (edict_t *ent) // float l; - oldltime = ent->v.v.ltime; + oldltime = ((entvars_t*)&ent->v)->ltime; - thinktime = ent->v.v.nextthink; - if (thinktime < ent->v.v.ltime + sv_frametime) { - movetime = thinktime - ent->v.v.ltime; + thinktime = ((entvars_t*)&ent->v)->nextthink; + if (thinktime < ((entvars_t*)&ent->v)->ltime + sv_frametime) { + movetime = thinktime - ((entvars_t*)&ent->v)->ltime; if (movetime < 0) movetime = 0; } else @@ -859,16 +860,16 @@ SV_Physics_PPusher (edict_t *ent) // if (movetime) // { - SV_PPushMove (ent, 0.0009); // advances ent->v.v.ltime if not + SV_PPushMove (ent, 0.0009); // advances ((entvars_t*)&ent->v)->ltime if not // blocked // } - if (thinktime > oldltime && thinktime <= ent->v.v.ltime) { - ent->v.v.nextthink = 0; - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, ent); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); - PR_ExecuteProgram (&sv_pr_state, ent->v.v.think); + if (thinktime > oldltime && thinktime <= ((entvars_t*)&ent->v)->ltime) { + ((entvars_t*)&ent->v)->nextthink = 0; + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, ent); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think); if (ent->free) return; } @@ -880,10 +881,10 @@ void SV_ProgStartFrame (void) { // let the progs know that a new frame has started - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv.edicts); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); - sv_pr_state.pr_global_struct->time = sv.time; - PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->StartFrame); + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv.edicts); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + PR_ExecuteProgram (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->StartFrame); } /* @@ -892,11 +893,11 @@ SV_ProgStartFrame (void) void SV_RunEntity (edict_t *ent) { - if (ent->v.v.lastruntime == (float) realtime) + if (((entvars_t*)&ent->v)->lastruntime == (float) realtime) return; - ent->v.v.lastruntime = (float) realtime; + ((entvars_t*)&ent->v)->lastruntime = (float) realtime; - switch ((int) ent->v.v.movetype) { + switch ((int) ((entvars_t*)&ent->v)->movetype) { case MOVETYPE_PUSH: SV_Physics_Pusher (ent); break; @@ -919,7 +920,7 @@ SV_RunEntity (edict_t *ent) SV_Physics_Toss (ent); break; default: - SV_Error ("SV_Physics: bad movetype %i", (int) ent->v.v.movetype); + SV_Error ("SV_Physics: bad movetype %i", (int) ((entvars_t*)&ent->v)->movetype); } } @@ -931,11 +932,11 @@ SV_RunNewmis (void) { edict_t *ent; - if (!sv_pr_state.pr_global_struct->newmis) + if (!((globalvars_t*)sv_pr_state.pr_globals)->newmis) return; - ent = PROG_TO_EDICT (&sv_pr_state, sv_pr_state.pr_global_struct->newmis); + ent = PROG_TO_EDICT (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->newmis); sv_frametime = 0.05; - sv_pr_state.pr_global_struct->newmis = 0; + ((globalvars_t*)sv_pr_state.pr_globals)->newmis = 0; SV_RunEntity (ent); } @@ -958,7 +959,7 @@ SV_Physics (void) sv_frametime = sv_maxtic->value; old_time = realtime; - sv_pr_state.pr_global_struct->frametime = sv_frametime; + ((globalvars_t*)sv_pr_state.pr_globals)->frametime = sv_frametime; SV_ProgStartFrame (); @@ -971,7 +972,7 @@ SV_Physics (void) if (ent->free) continue; - if (sv_pr_state.pr_global_struct->force_retouch) + if (((globalvars_t*)sv_pr_state.pr_globals)->force_retouch) SV_LinkEdict (ent, true); // force retouch even for stationary if (i > 0 && i <= MAX_CLIENTS) @@ -982,15 +983,15 @@ SV_Physics (void) SV_RunNewmis (); } - if (sv_pr_state.pr_global_struct->force_retouch) - sv_pr_state.pr_global_struct->force_retouch--; + if (((globalvars_t*)sv_pr_state.pr_globals)->force_retouch) + ((globalvars_t*)sv_pr_state.pr_globals)->force_retouch--; // 2000-01-02 EndFrame function by Maddes/FrikaC start if (EndFrame) { // let the progs know that the frame has ended - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv.edicts); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); - sv_pr_state.pr_global_struct->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv.edicts); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts); + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; PR_ExecuteProgram (&sv_pr_state, EndFrame); } // 2000-01-02 EndFrame function by Maddes/FrikaC end diff --git a/qw/source/sv_pr_cmds.c b/qw/source/sv_pr_cmds.c index 89d01c1c5..2b1584135 100644 --- a/qw/source/sv_pr_cmds.c +++ b/qw/source/sv_pr_cmds.c @@ -37,6 +37,7 @@ #include "msg.h" #include "server.h" #include "sv_pr_cmds.h" +#include "progdefs.h" #include "world.h" #include "va.h" @@ -79,7 +80,7 @@ PF_error (progs_t *pr) s = PF_VarString (pr, 0); Con_Printf ("======SERVER ERROR in %s:\n%s\n", PR_GetString (pr, pr->pr_xfunction->s_name), s); - ed = PROG_TO_EDICT (pr, pr->pr_global_struct->self); + ed = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); ED_Print (pr, ed); SV_Error ("Program error"); @@ -102,7 +103,7 @@ PF_objerror (progs_t *pr) s = PF_VarString (pr, 0); Con_Printf ("======OBJECT ERROR in %s:\n%s\n", PR_GetString (pr, pr->pr_xfunction->s_name), s); - ed = PROG_TO_EDICT (pr, pr->pr_global_struct->self); + ed = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); ED_Print (pr, ed); ED_Free (pr, ed); @@ -120,8 +121,8 @@ PF_objerror (progs_t *pr) void PF_makevectors (progs_t *pr) { - AngleVectors (G_VECTOR (pr, OFS_PARM0), pr->pr_global_struct->v_forward, - pr->pr_global_struct->v_right, pr->pr_global_struct->v_up); + AngleVectors (G_VECTOR (pr, OFS_PARM0), ((globalvars_t*)pr->pr_globals)->v_forward, + ((globalvars_t*)pr->pr_globals)->v_right, ((globalvars_t*)pr->pr_globals)->v_up); } /* @@ -139,7 +140,7 @@ PF_setorigin (progs_t *pr) e = G_EDICT (pr, OFS_PARM0); org = G_VECTOR (pr, OFS_PARM1); - VectorCopy (org, e->v.v.origin); + VectorCopy (org, ((entvars_t*)&e->v)->origin); SV_LinkEdict (e, false); } @@ -160,9 +161,9 @@ PF_setsize (progs_t *pr) e = G_EDICT (pr, OFS_PARM0); min = G_VECTOR (pr, OFS_PARM1); max = G_VECTOR (pr, OFS_PARM2); - VectorCopy (min, e->v.v.mins); - VectorCopy (max, e->v.v.maxs); - VectorSubtract (max, min, e->v.v.size); + VectorCopy (min, ((entvars_t*)&e->v)->mins); + VectorCopy (max, ((entvars_t*)&e->v)->maxs); + VectorSubtract (max, min, ((entvars_t*)&e->v)->size); SV_LinkEdict (e, false); } @@ -192,15 +193,15 @@ PF_setmodel (progs_t *pr) if (!*check) PR_RunError (pr, "no precache: %s\n", m); - e->v.v.model = PR_SetString (pr, m); - e->v.v.modelindex = i; + ((entvars_t*)&e->v)->model = PR_SetString (pr, m); + ((entvars_t*)&e->v)->modelindex = i; // if it is an inline model, get the size information for it if (m[0] == '*') { mod = Mod_ForName (m, true); - VectorCopy (mod->mins, e->v.v.mins); - VectorCopy (mod->maxs, e->v.v.maxs); - VectorSubtract (mod->maxs, mod->mins, e->v.v.size); + VectorCopy (mod->mins, ((entvars_t*)&e->v)->mins); + VectorCopy (mod->maxs, ((entvars_t*)&e->v)->maxs); + VectorSubtract (mod->maxs, mod->mins, ((entvars_t*)&e->v)->size); SV_LinkEdict (e, false); } @@ -518,18 +519,18 @@ PF_traceline (progs_t *pr) trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent); - pr->pr_global_struct->trace_allsolid = trace.allsolid; - pr->pr_global_struct->trace_startsolid = trace.startsolid; - pr->pr_global_struct->trace_fraction = trace.fraction; - pr->pr_global_struct->trace_inwater = trace.inwater; - pr->pr_global_struct->trace_inopen = trace.inopen; - VectorCopy (trace.endpos, pr->pr_global_struct->trace_endpos); - VectorCopy (trace.plane.normal, pr->pr_global_struct->trace_plane_normal); - pr->pr_global_struct->trace_plane_dist = trace.plane.dist; + ((globalvars_t*)pr->pr_globals)->trace_allsolid = trace.allsolid; + ((globalvars_t*)pr->pr_globals)->trace_startsolid = trace.startsolid; + ((globalvars_t*)pr->pr_globals)->trace_fraction = trace.fraction; + ((globalvars_t*)pr->pr_globals)->trace_inwater = trace.inwater; + ((globalvars_t*)pr->pr_globals)->trace_inopen = trace.inopen; + VectorCopy (trace.endpos, ((globalvars_t*)pr->pr_globals)->trace_endpos); + VectorCopy (trace.plane.normal, ((globalvars_t*)pr->pr_globals)->trace_plane_normal); + ((globalvars_t*)pr->pr_globals)->trace_plane_dist = trace.plane.dist; if (trace.ent) - pr->pr_global_struct->trace_ent = EDICT_TO_PROG (pr, trace.ent); + ((globalvars_t*)pr->pr_globals)->trace_ent = EDICT_TO_PROG (pr, trace.ent); else - pr->pr_global_struct->trace_ent = EDICT_TO_PROG (pr, sv.edicts); + ((globalvars_t*)pr->pr_globals)->trace_ent = EDICT_TO_PROG (pr, sv.edicts); } /* @@ -581,9 +582,9 @@ PF_newcheckclient (progs_t *pr, int check) if (ent->free) continue; - if (ent->v.v.health <= 0) + if (((entvars_t*)&ent->v)->health <= 0) continue; - if ((int) ent->v.v.flags & FL_NOTARGET) + if ((int) ((entvars_t*)&ent->v)->flags & FL_NOTARGET) continue; // anything that is a client, or has a client as an enemy @@ -591,7 +592,7 @@ PF_newcheckclient (progs_t *pr, int check) } // get the PVS for the entity - VectorAdd (ent->v.v.origin, ent->v.v.view_ofs, org); + VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->view_ofs, org); leaf = Mod_PointInLeaf (org, sv.worldmodel); pvs = Mod_LeafPVS (leaf, sv.worldmodel); memcpy (checkpvs, pvs, (sv.worldmodel->numleafs + 7) >> 3); @@ -629,13 +630,13 @@ PF_checkclient (progs_t *pr) } // return check if it might be visible ent = EDICT_NUM (pr, sv.lastcheck); - if (ent->free || ent->v.v.health <= 0) { + if (ent->free || ((entvars_t*)&ent->v)->health <= 0) { RETURN_EDICT (pr, sv.edicts); return; } // if current entity can't possibly see the check entity, return 0 - self = PROG_TO_EDICT (pr, pr->pr_global_struct->self); - VectorAdd (self->v.v.origin, self->v.v.view_ofs, view); + self = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); + VectorAdd (((entvars_t*)&self->v)->origin, ((entvars_t*)&self->v)->view_ofs, view); leaf = Mod_PointInLeaf (view, sv.worldmodel); l = (leaf - sv.worldmodel->leafs) - 1; if ((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) { @@ -779,16 +780,16 @@ PF_findradius (progs_t *pr) for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) { if (ent->free) continue; - if (ent->v.v.solid == SOLID_NOT) + if (((entvars_t*)&ent->v)->solid == SOLID_NOT) continue; for (j = 0; j < 3; j++) eorg[j] = - org[j] - (ent->v.v.origin[j] + - (ent->v.v.mins[j] + ent->v.v.maxs[j]) * 0.5); + org[j] - (((entvars_t*)&ent->v)->origin[j] + + (((entvars_t*)&ent->v)->mins[j] + ((entvars_t*)&ent->v)->maxs[j]) * 0.5); if (Length (eorg) > rad) continue; - ent->v.v.chain = EDICT_TO_PROG (pr, chain); + ((entvars_t*)&ent->v)->chain = EDICT_TO_PROG (pr, chain); chain = ent; } @@ -1002,11 +1003,11 @@ PF_walkmove (progs_t *pr) dfunction_t *oldf; int oldself; - ent = PROG_TO_EDICT (pr, pr->pr_global_struct->self); + ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); yaw = G_FLOAT (pr, OFS_PARM0); dist = G_FLOAT (pr, OFS_PARM1); - if (!((int) ent->v.v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { + if (!((int) ((entvars_t*)&ent->v)->flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { G_FLOAT (pr, OFS_RETURN) = 0; return; } @@ -1019,14 +1020,14 @@ PF_walkmove (progs_t *pr) // save program state, because SV_movestep may call other progs oldf = pr->pr_xfunction; - oldself = pr->pr_global_struct->self; + oldself = ((globalvars_t*)pr->pr_globals)->self; G_FLOAT (pr, OFS_RETURN) = SV_movestep (ent, move, true); // restore program state pr->pr_xfunction = oldf; - pr->pr_global_struct->self = oldself; + ((globalvars_t*)pr->pr_globals)->self = oldself; } /* @@ -1041,20 +1042,20 @@ PF_droptofloor (progs_t *pr) vec3_t end; trace_t trace; - ent = PROG_TO_EDICT (pr, pr->pr_global_struct->self); + ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); - VectorCopy (ent->v.v.origin, end); + VectorCopy (((entvars_t*)&ent->v)->origin, end); end[2] -= 256; - trace = SV_Move (ent->v.v.origin, ent->v.v.mins, ent->v.v.maxs, end, false, ent); + trace = SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, end, false, ent); if (trace.fraction == 1 || trace.allsolid) G_FLOAT (pr, OFS_RETURN) = 0; else { - VectorCopy (trace.endpos, ent->v.v.origin); + VectorCopy (trace.endpos, ((entvars_t*)&ent->v)->origin); SV_LinkEdict (ent, false); - ent->v.v.flags = (int) ent->v.v.flags | FL_ONGROUND; - ent->v.v.groundentity = EDICT_TO_PROG (pr, trace.ent); + ((entvars_t*)&ent->v)->flags = (int) ((entvars_t*)&ent->v)->flags | FL_ONGROUND; + ((entvars_t*)&ent->v)->groundentity = EDICT_TO_PROG (pr, trace.ent); G_FLOAT (pr, OFS_RETURN) = 1; } } @@ -1189,7 +1190,7 @@ PF_aim (progs_t *pr) ent = G_EDICT (pr, OFS_PARM0); speed = G_FLOAT (pr, OFS_PARM1); - VectorCopy (ent->v.v.origin, start); + VectorCopy (((entvars_t*)&ent->v)->origin, start); start[2] += 20; // noaim option @@ -1197,18 +1198,18 @@ PF_aim (progs_t *pr) if (i > 0 && i < MAX_CLIENTS) { noaim = Info_ValueForKey (svs.clients[i - 1].userinfo, "noaim"); if (atoi (noaim) > 0) { - VectorCopy (pr->pr_global_struct->v_forward, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (((globalvars_t*)pr->pr_globals)->v_forward, G_VECTOR (pr, OFS_RETURN)); return; } } // try sending a trace straight - VectorCopy (pr->pr_global_struct->v_forward, dir); + VectorCopy (((globalvars_t*)pr->pr_globals)->v_forward, dir); VectorMA (start, 2048, dir, end); tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent); - if (tr.ent && tr.ent->v.v.takedamage == DAMAGE_AIM - && (!teamplay->int_val || ent->v.v.team <= 0 - || ent->v.v.team != tr.ent->v.v.team)) { - VectorCopy (pr->pr_global_struct->v_forward, G_VECTOR (pr, OFS_RETURN)); + if (tr.ent && ((entvars_t*)&tr.ent->v)->takedamage == DAMAGE_AIM + && (!teamplay->int_val || ((entvars_t*)&ent->v)->team <= 0 + || ((entvars_t*)&ent->v)->team != ((entvars_t*)&tr.ent->v)->team)) { + VectorCopy (((globalvars_t*)pr->pr_globals)->v_forward, G_VECTOR (pr, OFS_RETURN)); return; } @@ -1219,19 +1220,19 @@ PF_aim (progs_t *pr) check = NEXT_EDICT (pr, sv.edicts); for (i = 1; i < sv.num_edicts; i++, check = NEXT_EDICT (pr, check)) { - if (check->v.v.takedamage != DAMAGE_AIM) + if (((entvars_t*)&check->v)->takedamage != DAMAGE_AIM) continue; if (check == ent) continue; - if (teamplay->int_val && ent->v.v.team > 0 - && ent->v.v.team == check->v.v.team) continue; // don't aim at + if (teamplay->int_val && ((entvars_t*)&ent->v)->team > 0 + && ((entvars_t*)&ent->v)->team == ((entvars_t*)&check->v)->team) continue; // don't aim at // teammate for (j = 0; j < 3; j++) - end[j] = check->v.v.origin[j] - + 0.5 * (check->v.v.mins[j] + check->v.v.maxs[j]); + end[j] = ((entvars_t*)&check->v)->origin[j] + + 0.5 * (((entvars_t*)&check->v)->mins[j] + ((entvars_t*)&check->v)->maxs[j]); VectorSubtract (end, start, dir); VectorNormalize (dir); - dist = DotProduct (dir, pr->pr_global_struct->v_forward); + dist = DotProduct (dir, ((globalvars_t*)pr->pr_globals)->v_forward); if (dist < bestdist) continue; // to far to turn tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent); @@ -1242,9 +1243,9 @@ PF_aim (progs_t *pr) } if (bestent) { - VectorSubtract (bestent->v.v.origin, ent->v.v.origin, dir); - dist = DotProduct (dir, pr->pr_global_struct->v_forward); - VectorScale (pr->pr_global_struct->v_forward, dist, end); + VectorSubtract (((entvars_t*)&bestent->v)->origin, ((entvars_t*)&ent->v)->origin, dir); + dist = DotProduct (dir, ((globalvars_t*)pr->pr_globals)->v_forward); + VectorScale (((globalvars_t*)pr->pr_globals)->v_forward, dist, end); end[2] = dir[2]; VectorNormalize (end); VectorCopy (end, G_VECTOR (pr, OFS_RETURN)); @@ -1264,10 +1265,10 @@ PF_changeyaw (progs_t *pr) edict_t *ent; float ideal, current, move, speed; - ent = PROG_TO_EDICT (pr, pr->pr_global_struct->self); - current = anglemod (ent->v.v.angles[1]); - ideal = ent->v.v.ideal_yaw; - speed = ent->v.v.yaw_speed; + ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->self); + current = anglemod (((entvars_t*)&ent->v)->angles[1]); + ideal = ((entvars_t*)&ent->v)->ideal_yaw; + speed = ((entvars_t*)&ent->v)->yaw_speed; if (current == ideal) return; @@ -1287,7 +1288,7 @@ PF_changeyaw (progs_t *pr) move = -speed; } - ent->v.v.angles[1] = anglemod (current + move); + ((entvars_t*)&ent->v)->angles[1] = anglemod (current + move); } /* @@ -1313,7 +1314,7 @@ WriteDest (progs_t *pr) case MSG_ONE: SV_Error ("Shouldn't be at MSG_ONE"); #if 0 - ent = PROG_TO_EDICT (pr, pr->pr_global_struct->msg_entity); + ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->msg_entity); entnum = NUM_FOR_EDICT (pr, ent); if (entnum < 1 || entnum > MAX_CLIENTS) PR_RunError (pr, "WriteDest: not a client"); @@ -1346,7 +1347,7 @@ Write_GetClient (progs_t *pr) int entnum; edict_t *ent; - ent = PROG_TO_EDICT (pr, pr->pr_global_struct->msg_entity); + ent = PROG_TO_EDICT (pr, ((globalvars_t*)pr->pr_globals)->msg_entity); entnum = NUM_FOR_EDICT (pr, ent); if (entnum < 1 || entnum > MAX_CLIENTS) PR_RunError (pr, "Write_GetClient: not a client"); @@ -1465,14 +1466,14 @@ PF_makestatic (progs_t *pr) MSG_WriteByte (&sv.signon, svc_spawnstatic); - MSG_WriteByte (&sv.signon, SV_ModelIndex (PR_GetString (pr, ent->v.v.model))); + MSG_WriteByte (&sv.signon, SV_ModelIndex (PR_GetString (pr, ((entvars_t*)&ent->v)->model))); - MSG_WriteByte (&sv.signon, ent->v.v.frame); - MSG_WriteByte (&sv.signon, ent->v.v.colormap); - MSG_WriteByte (&sv.signon, ent->v.v.skin); + MSG_WriteByte (&sv.signon, ((entvars_t*)&ent->v)->frame); + MSG_WriteByte (&sv.signon, ((entvars_t*)&ent->v)->colormap); + MSG_WriteByte (&sv.signon, ((entvars_t*)&ent->v)->skin); for (i = 0; i < 3; i++) { - MSG_WriteCoord (&sv.signon, ent->v.v.origin[i]); - MSG_WriteAngle (&sv.signon, ent->v.v.angles[i]); + MSG_WriteCoord (&sv.signon, ((entvars_t*)&ent->v)->origin[i]); + MSG_WriteAngle (&sv.signon, ((entvars_t*)&ent->v)->angles[i]); } // throw the entity away now @@ -1500,7 +1501,7 @@ PF_setspawnparms (progs_t *pr) client = svs.clients + (i - 1); for (i = 0; i < NUM_SPAWN_PARMS; i++) - (&pr->pr_global_struct->parm1)[i] = client->spawn_parms[i]; + (&((globalvars_t*)pr->pr_globals)->parm1)[i] = client->spawn_parms[i]; } /* diff --git a/qw/source/sv_progs.c b/qw/source/sv_progs.c index 0fdb82c91..13d856698 100644 --- a/qw/source/sv_progs.c +++ b/qw/source/sv_progs.c @@ -38,6 +38,7 @@ #endif #include "cmd.h" +#include "progdefs.h" #include "progs.h" #include "server.h" #include "world.h" @@ -52,7 +53,7 @@ func_t SpectatorConnect; func_t SpectatorDisconnect; func_t SpectatorThink; -static reserved_edicts = MAX_CLIENTS; +static int reserved_edicts = MAX_CLIENTS; void FindEdictFieldOffsets (progs_t *pr) @@ -86,7 +87,7 @@ FindEdictFieldOffsets (progs_t *pr) int ED_Prune_Edict (progs_t *pr, edict_t *ent) { - if (((int) ent->v.v.spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) + if (((int) ((entvars_t*)&ent->v)->spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) return 1; return 0; } @@ -148,6 +149,8 @@ SV_LoadProgs (void) PR_LoadProgs (&sv_pr_state, sv_progs->string); if (!sv_pr_state.progs) SV_Error ("SV_LoadProgs: couldn't load %s", sv_progs->string); + if (sv_pr_state.progs->crc != PROGHEADER_CRC) + SV_Error ("You must have the qwprogs.dat from QuakeWorld installed"); } void diff --git a/qw/source/sv_send.c b/qw/source/sv_send.c index 599ae7261..4bbd9fccf 100644 --- a/qw/source/sv_send.c +++ b/qw/source/sv_send.c @@ -39,6 +39,7 @@ #include "bothdefs.h" #include "msg.h" +#include "progdefs.h" #include "server.h" #include "sys.h" @@ -332,12 +333,12 @@ SV_Multicast (vec3_t origin, int to) if (to == MULTICAST_PHS_R || to == MULTICAST_PHS) { vec3_t delta; - VectorSubtract (origin, client->edict->v.v.origin, delta); + VectorSubtract (origin, ((entvars_t*)&client->edict->v)->origin, delta); if (Length (delta) <= 1024) goto inrange; } - leaf = Mod_PointInLeaf (client->edict->v.v.origin, sv.worldmodel); + leaf = Mod_PointInLeaf (((entvars_t*)&client->edict->v)->origin, sv.worldmodel); if (leaf) { // -1 is because pvs rows are 1 based, not 0 based like leafs leafnum = leaf - sv.worldmodel->leafs - 1; @@ -429,13 +430,13 @@ SV_StartSound (edict_t *entity, int channel, char *sample, int volume, channel |= SND_ATTENUATION; // use the entity origin unless it is a bmodel - if (entity->v.v.solid == SOLID_BSP) { + if (((entvars_t*)&entity->v)->solid == SOLID_BSP) { for (i = 0; i < 3; i++) origin[i] = - entity->v.v.origin[i] + 0.5 * (entity->v.v.mins[i] + - entity->v.v.maxs[i]); + ((entvars_t*)&entity->v)->origin[i] + 0.5 * (((entvars_t*)&entity->v)->mins[i] + + ((entvars_t*)&entity->v)->maxs[i]); } else { - VectorCopy (entity->v.v.origin, origin); + VectorCopy (((entvars_t*)&entity->v)->origin, origin); } MSG_WriteByte (&sv.multicast, svc_sound); @@ -502,25 +503,25 @@ SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) client->chokecount = 0; } // send a damage message if the player got hit this frame - if (ent->v.v.dmg_take || ent->v.v.dmg_save) { - other = PROG_TO_EDICT (&sv_pr_state, ent->v.v.dmg_inflictor); + if (((entvars_t*)&ent->v)->dmg_take || ((entvars_t*)&ent->v)->dmg_save) { + other = PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->dmg_inflictor); MSG_WriteByte (msg, svc_damage); - MSG_WriteByte (msg, ent->v.v.dmg_save); - MSG_WriteByte (msg, ent->v.v.dmg_take); + MSG_WriteByte (msg, ((entvars_t*)&ent->v)->dmg_save); + MSG_WriteByte (msg, ((entvars_t*)&ent->v)->dmg_take); for (i = 0; i < 3; i++) MSG_WriteCoord (msg, - other->v.v.origin[i] + 0.5 * (other->v.v.mins[i] + - other->v.v.maxs[i])); + ((entvars_t*)&other->v)->origin[i] + 0.5 * (((entvars_t*)&other->v)->mins[i] + + ((entvars_t*)&other->v)->maxs[i])); - ent->v.v.dmg_take = 0; - ent->v.v.dmg_save = 0; + ((entvars_t*)&ent->v)->dmg_take = 0; + ((entvars_t*)&ent->v)->dmg_save = 0; } // a fixangle might get lost in a dropped packet. Oh well. - if (ent->v.v.fixangle) { + if (((entvars_t*)&ent->v)->fixangle) { MSG_WriteByte (msg, svc_setangle); for (i = 0; i < 3; i++) - MSG_WriteAngle (msg, ent->v.v.angles[i]); - ent->v.v.fixangle = 0; + MSG_WriteAngle (msg, ((entvars_t*)&ent->v)->angles[i]); + ((entvars_t*)&ent->v)->fixangle = 0; } } @@ -545,29 +546,29 @@ SV_UpdateClientStats (client_t *client) if (client->spectator && client->spec_track > 0) ent = svs.clients[client->spec_track - 1].edict; - stats[STAT_HEALTH] = ent->v.v.health; - stats[STAT_WEAPON] = SV_ModelIndex (PR_GetString (&sv_pr_state, ent->v.v.weaponmodel)); - stats[STAT_AMMO] = ent->v.v.currentammo; - stats[STAT_ARMOR] = ent->v.v.armorvalue; - stats[STAT_SHELLS] = ent->v.v.ammo_shells; - stats[STAT_NAILS] = ent->v.v.ammo_nails; - stats[STAT_ROCKETS] = ent->v.v.ammo_rockets; - stats[STAT_CELLS] = ent->v.v.ammo_cells; + stats[STAT_HEALTH] = ((entvars_t*)&ent->v)->health; + stats[STAT_WEAPON] = SV_ModelIndex (PR_GetString (&sv_pr_state, ((entvars_t*)&ent->v)->weaponmodel)); + stats[STAT_AMMO] = ((entvars_t*)&ent->v)->currentammo; + stats[STAT_ARMOR] = ((entvars_t*)&ent->v)->armorvalue; + stats[STAT_SHELLS] = ((entvars_t*)&ent->v)->ammo_shells; + stats[STAT_NAILS] = ((entvars_t*)&ent->v)->ammo_nails; + stats[STAT_ROCKETS] = ((entvars_t*)&ent->v)->ammo_rockets; + stats[STAT_CELLS] = ((entvars_t*)&ent->v)->ammo_cells; if (!client->spectator) - stats[STAT_ACTIVEWEAPON] = ent->v.v.weapon; + stats[STAT_ACTIVEWEAPON] = ((entvars_t*)&ent->v)->weapon; // stuff the sigil bits into the high bits of items for sbar stats[STAT_ITEMS] = - (int) ent->v.v.items | ((int) sv_pr_state.pr_global_struct->serverflags << 28); + (int) ((entvars_t*)&ent->v)->items | ((int) ((globalvars_t*)sv_pr_state.pr_globals)->serverflags << 28); // Extensions to the QW 2.40 protocol for Mega2k --KB - stats[STAT_VIEWHEIGHT] = (int) ent->v.v.view_ofs[2]; + stats[STAT_VIEWHEIGHT] = (int) ((entvars_t*)&ent->v)->view_ofs[2]; // FIXME: this should become a * key! --KB - if (ent->v.v.movetype == MOVETYPE_FLY && !atoi (Info_ValueForKey + if (((entvars_t*)&ent->v)->movetype == MOVETYPE_FLY && !atoi (Info_ValueForKey (svs.info, "playerfly"))) - ent->v.v.movetype = MOVETYPE_WALK; + ((entvars_t*)&ent->v)->movetype = MOVETYPE_WALK; - stats[STAT_FLYMODE] = (ent->v.v.movetype == MOVETYPE_FLY); + stats[STAT_FLYMODE] = (((entvars_t*)&ent->v)->movetype == MOVETYPE_FLY); for (i = 0; i < MAX_CL_STATS; i++) @@ -649,16 +650,16 @@ SV_UpdateToReliableMessages (void) host_client->sendinfo = false; SV_FullClientUpdate (host_client, &sv.reliable_datagram); } - if (host_client->old_frags != host_client->edict->v.v.frags) { + if (host_client->old_frags != ((entvars_t*)&host_client->edict->v)->frags) { for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) { if (client->state < cs_connected) continue; ClientReliableWrite_Begin (client, svc_updatefrags, 4); ClientReliableWrite_Byte (client, i); - ClientReliableWrite_Short (client, host_client->edict->v.v.frags); + ClientReliableWrite_Short (client, ((entvars_t*)&host_client->edict->v)->frags); } - host_client->old_frags = host_client->edict->v.v.frags; + host_client->old_frags = ((entvars_t*)&host_client->edict->v)->frags; } // maxspeed/entgravity changes ent = host_client->edict; diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index 3b1e4002a..f7d31e71e 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -47,6 +47,7 @@ #include "cvar.h" #include "msg.h" #include "msg_ucmd.h" +#include "progdefs.h" #include "pmove.h" #include "quakefs.h" #include "server.h" @@ -131,7 +132,7 @@ SV_New_f (void) // send full levelname MSG_WriteString (&host_client->netchan.message, - PR_GetString (&sv_pr_state, sv.edicts->v.v.message)); + PR_GetString (&sv_pr_state, ((entvars_t*)&sv.edicts->v)->message)); // send the movevars MSG_WriteFloat (&host_client->netchan.message, movevars.gravity); @@ -147,7 +148,7 @@ SV_New_f (void) // send music MSG_WriteByte (&host_client->netchan.message, svc_cdtrack); - MSG_WriteByte (&host_client->netchan.message, sv.edicts->v.v.sounds); + MSG_WriteByte (&host_client->netchan.message, ((entvars_t*)&sv.edicts->v)->sounds); // send server info string MSG_WriteByte (&host_client->netchan.message, svc_stufftext); @@ -378,9 +379,9 @@ SV_Spawn_f (void) ent = host_client->edict; memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4); - ent->v.v.colormap = NUM_FOR_EDICT (&sv_pr_state, ent); - ent->v.v.team = 0; // FIXME - ent->v.v.netname = PR_SetString (&sv_pr_state, host_client->name); + ((entvars_t*)&ent->v)->colormap = NUM_FOR_EDICT (&sv_pr_state, ent); + ((entvars_t*)&ent->v)->team = 0; // FIXME + ((entvars_t*)&ent->v)->netname = PR_SetString (&sv_pr_state, host_client->name); host_client->entgravity = 1.0; val = GetEdictFieldValue (&sv_pr_state, ent, "gravity"); @@ -398,19 +399,19 @@ SV_Spawn_f (void) ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6); ClientReliableWrite_Byte (host_client, STAT_TOTALSECRETS); - ClientReliableWrite_Long (host_client, sv_pr_state.pr_global_struct->total_secrets); + ClientReliableWrite_Long (host_client, ((globalvars_t*)sv_pr_state.pr_globals)->total_secrets); ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6); ClientReliableWrite_Byte (host_client, STAT_TOTALMONSTERS); - ClientReliableWrite_Long (host_client, sv_pr_state.pr_global_struct->total_monsters); + ClientReliableWrite_Long (host_client, ((globalvars_t*)sv_pr_state.pr_globals)->total_monsters); ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6); ClientReliableWrite_Byte (host_client, STAT_SECRETS); - ClientReliableWrite_Long (host_client, sv_pr_state.pr_global_struct->found_secrets); + ClientReliableWrite_Long (host_client, ((globalvars_t*)sv_pr_state.pr_globals)->found_secrets); ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6); ClientReliableWrite_Byte (host_client, STAT_MONSTERS); - ClientReliableWrite_Long (host_client, sv_pr_state.pr_global_struct->killed_monsters); + ClientReliableWrite_Long (host_client, ((globalvars_t*)sv_pr_state.pr_globals)->killed_monsters); // get the client to check and download skins // when that is completed, a begin command will be issued @@ -427,15 +428,15 @@ SV_SpawnSpectator (void) int i; edict_t *e; - VectorCopy (vec3_origin, sv_player->v.v.origin); - VectorCopy (vec3_origin, sv_player->v.v.view_ofs); - sv_player->v.v.view_ofs[2] = 22; + VectorCopy (vec3_origin, ((entvars_t*)&sv_player->v)->origin); + VectorCopy (vec3_origin, ((entvars_t*)&sv_player->v)->view_ofs); + ((entvars_t*)&sv_player->v)->view_ofs[2] = 22; // search for an info_playerstart to spawn the spectator at for (i = MAX_CLIENTS - 1; i < sv.num_edicts; i++) { e = EDICT_NUM (&sv_pr_state, i); - if (!strcmp (PR_GetString (&sv_pr_state, e->v.v.classname), "info_player_start")) { - VectorCopy (e->v.v.origin, sv_player->v.v.origin); + if (!strcmp (PR_GetString (&sv_pr_state, ((entvars_t*)&e->v)->classname), "info_player_start")) { + VectorCopy (((entvars_t*)&e->v)->origin, ((entvars_t*)&sv_player->v)->origin); return; } } @@ -469,27 +470,27 @@ SV_Begin_f (void) if (SpectatorConnect) { // copy spawn parms out of the client_t for (i = 0; i < NUM_SPAWN_PARMS; i++) - (&sv_pr_state.pr_global_struct->parm1)[i] = host_client->spawn_parms[i]; + (&((globalvars_t*)sv_pr_state.pr_globals)->parm1)[i] = host_client->spawn_parms[i]; // call the spawn function - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player); + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv_player); PR_ExecuteProgram (&sv_pr_state, SpectatorConnect); } } else { // copy spawn parms out of the client_t for (i = 0; i < NUM_SPAWN_PARMS; i++) - (&sv_pr_state.pr_global_struct->parm1)[i] = host_client->spawn_parms[i]; + (&((globalvars_t*)sv_pr_state.pr_globals)->parm1)[i] = host_client->spawn_parms[i]; // call the spawn function - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player); - PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->ClientConnect); + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv_player); + PR_ExecuteProgram (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->ClientConnect); // actually spawn the player - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player); - PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->PutClientInServer); + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv_player); + PR_ExecuteProgram (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->PutClientInServer); } // clear the net statistics, because connecting gives a bogus picture @@ -524,7 +525,7 @@ SV_Begin_f (void) ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients)); MSG_WriteByte (&host_client->netchan.message, svc_setangle); for (i = 0; i < 2; i++) - MSG_WriteAngle (&host_client->netchan.message, ent->v.v.angles[i]); + MSG_WriteAngle (&host_client->netchan.message, ((entvars_t*)&ent->v)->angles[i]); MSG_WriteAngle (&host_client->netchan.message, 0); #endif } @@ -898,7 +899,7 @@ SV_Pings_f (void) void SV_Kill_f (void) { - if (sv_player->v.v.health <= 0) { + if (((entvars_t*)&sv_player->v)->health <= 0) { SV_BeginRedirect (RD_CLIENT); SV_ClientPrintf (host_client, PRINT_HIGH, "Can't suicide -- already dead!\n"); @@ -906,9 +907,9 @@ SV_Kill_f (void) return; } - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player); - PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->ClientKill); + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv_player); + PR_ExecuteProgram (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->ClientKill); } /* @@ -1007,7 +1008,7 @@ SV_PTrack_f (void) host_client->spec_track = 0; ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1); tent = EDICT_NUM (&sv_pr_state, 0); - ent->v.v.goalentity = EDICT_TO_PROG (&sv_pr_state, tent); + ((entvars_t*)&ent->v)->goalentity = EDICT_TO_PROG (&sv_pr_state, tent); return; } @@ -1018,14 +1019,14 @@ SV_PTrack_f (void) host_client->spec_track = 0; ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1); tent = EDICT_NUM (&sv_pr_state, 0); - ent->v.v.goalentity = EDICT_TO_PROG (&sv_pr_state, tent); + ((entvars_t*)&ent->v)->goalentity = EDICT_TO_PROG (&sv_pr_state, tent); return; } host_client->spec_track = i + 1; // now tracking ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1); tent = EDICT_NUM (&sv_pr_state, i + 1); - ent->v.v.goalentity = EDICT_TO_PROG (&sv_pr_state, tent); + ((entvars_t*)&ent->v)->goalentity = EDICT_TO_PROG (&sv_pr_state, tent); } @@ -1286,16 +1287,16 @@ AddLinksToPmove (areanode_t *node) next = l->next; check = EDICT_FROM_AREA (l); - if (check->v.v.owner == pl) + if (((entvars_t*)&check->v)->owner == pl) continue; // player's own missile - if (check->v.v.solid == SOLID_BSP - || check->v.v.solid == SOLID_BBOX || check->v.v.solid == SOLID_SLIDEBOX) { + if (((entvars_t*)&check->v)->solid == SOLID_BSP + || ((entvars_t*)&check->v)->solid == SOLID_BBOX || ((entvars_t*)&check->v)->solid == SOLID_SLIDEBOX) { if (check == sv_player) continue; for (i = 0; i < 3; i++) - if (check->v.v.absmin[i] > pmove_maxs[i] - || check->v.v.absmax[i] < pmove_mins[i]) + if (((entvars_t*)&check->v)->absmin[i] > pmove_maxs[i] + || ((entvars_t*)&check->v)->absmax[i] < pmove_mins[i]) break; if (i != 3) continue; @@ -1304,15 +1305,15 @@ AddLinksToPmove (areanode_t *node) pe = &pmove.physents[pmove.numphysent]; pmove.numphysent++; - VectorCopy (check->v.v.origin, pe->origin); + VectorCopy (((entvars_t*)&check->v)->origin, pe->origin); pe->info = NUM_FOR_EDICT (&sv_pr_state, check); - if (check->v.v.solid == SOLID_BSP) { - pe->model = sv.models[(int) (check->v.v.modelindex)]; + if (((entvars_t*)&check->v)->solid == SOLID_BSP) { + pe->model = sv.models[(int) (((entvars_t*)&check->v)->modelindex)]; } else { pe->model = NULL; - VectorCopy (check->v.v.mins, pe->mins); - VectorCopy (check->v.v.maxs, pe->maxs); + VectorCopy (((entvars_t*)&check->v)->mins, pe->mins); + VectorCopy (((entvars_t*)&check->v)->maxs, pe->maxs); } } } @@ -1349,30 +1350,30 @@ AddAllEntsToPmove (void) check = NEXT_EDICT (&sv_pr_state, check)) { if (check->free) continue; - if (check->v.v.owner == pl) + if (((entvars_t*)&check->v)->owner == pl) continue; - if (check->v.v.solid == SOLID_BSP - || check->v.v.solid == SOLID_BBOX - || check->v.v.solid == SOLID_SLIDEBOX) { + if (((entvars_t*)&check->v)->solid == SOLID_BSP + || ((entvars_t*)&check->v)->solid == SOLID_BBOX + || ((entvars_t*)&check->v)->solid == SOLID_SLIDEBOX) { if (check == sv_player) continue; for (i = 0; i < 3; i++) - if (check->v.v.absmin[i] > pmove_maxs[i] - || check->v.v.absmax[i] < pmove_mins[i]) + if (((entvars_t*)&check->v)->absmin[i] > pmove_maxs[i] + || ((entvars_t*)&check->v)->absmax[i] < pmove_mins[i]) break; if (i != 3) continue; pe = &pmove.physents[pmove.numphysent]; - VectorCopy (check->v.v.origin, pe->origin); + VectorCopy (((entvars_t*)&check->v)->origin, pe->origin); pmove.physents[pmove.numphysent].info = e; - if (check->v.v.solid == SOLID_BSP) - pe->model = sv.models[(int) (check->v.v.modelindex)]; + if (((entvars_t*)&check->v)->solid == SOLID_BSP) + pe->model = sv.models[(int) (((entvars_t*)&check->v)->modelindex)]; else { pe->model = NULL; - VectorCopy (check->v.v.mins, pe->mins); - VectorCopy (check->v.v.maxs, pe->maxs); + VectorCopy (((entvars_t*)&check->v)->mins, pe->mins); + VectorCopy (((entvars_t*)&check->v)->maxs, pe->maxs); } if (++pmove.numphysent == MAX_PHYSENTS) @@ -1455,59 +1456,59 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside) return; } - if (!sv_player->v.v.fixangle) - VectorCopy (ucmd->angles, sv_player->v.v.v_angle); + if (!((entvars_t*)&sv_player->v)->fixangle) + VectorCopy (ucmd->angles, ((entvars_t*)&sv_player->v)->v_angle); - sv_player->v.v.button0 = ucmd->buttons & 1; + ((entvars_t*)&sv_player->v)->button0 = ucmd->buttons & 1; // 1999-10-29 +USE fix by Maddes start if (!nouse) { - sv_player->v.v.button1 = (ucmd->buttons & 4) >> 2; + ((entvars_t*)&sv_player->v)->button1 = (ucmd->buttons & 4) >> 2; } // 1999-10-29 +USE fix by Maddes end - sv_player->v.v.button2 = (ucmd->buttons & 2) >> 1; + ((entvars_t*)&sv_player->v)->button2 = (ucmd->buttons & 2) >> 1; if (ucmd->impulse) - sv_player->v.v.impulse = ucmd->impulse; + ((entvars_t*)&sv_player->v)->impulse = ucmd->impulse; // // angles // show 1/3 the pitch angle and all the roll angle - if (sv_player->v.v.health > 0) { - if (!sv_player->v.v.fixangle) { - sv_player->v.v.angles[PITCH] = -sv_player->v.v.v_angle[PITCH] / 3; - sv_player->v.v.angles[YAW] = sv_player->v.v.v_angle[YAW]; + if (((entvars_t*)&sv_player->v)->health > 0) { + if (!((entvars_t*)&sv_player->v)->fixangle) { + ((entvars_t*)&sv_player->v)->angles[PITCH] = -((entvars_t*)&sv_player->v)->v_angle[PITCH] / 3; + ((entvars_t*)&sv_player->v)->angles[YAW] = ((entvars_t*)&sv_player->v)->v_angle[YAW]; } - sv_player->v.v.angles[ROLL] = - SV_CalcRoll (sv_player->v.v.angles, sv_player->v.v.velocity) * 4; + ((entvars_t*)&sv_player->v)->angles[ROLL] = + SV_CalcRoll (((entvars_t*)&sv_player->v)->angles, ((entvars_t*)&sv_player->v)->velocity) * 4; } sv_frametime = min (0.1, ucmd->msec * 0.001); if (!host_client->spectator) { - sv_pr_state.pr_global_struct->frametime = sv_frametime; + ((globalvars_t*)sv_pr_state.pr_globals)->frametime = sv_frametime; - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv_player); PR_ExecuteProgram (&sv_pr_state, - sv_pr_state.pr_global_struct->PlayerPreThink); + ((globalvars_t*)sv_pr_state.pr_globals)->PlayerPreThink); SV_RunThink (sv_player); } for (i = 0; i < 3; i++) pmove.origin[i] = - sv_player->v.v.origin[i] - + (sv_player->v.v.mins[i] - player_mins[i]); - VectorCopy (sv_player->v.v.velocity, pmove.velocity); - VectorCopy (sv_player->v.v.v_angle, pmove.angles); + ((entvars_t*)&sv_player->v)->origin[i] + + (((entvars_t*)&sv_player->v)->mins[i] - player_mins[i]); + VectorCopy (((entvars_t*)&sv_player->v)->velocity, pmove.velocity); + VectorCopy (((entvars_t*)&sv_player->v)->v_angle, pmove.angles); - pmove.flying = sv_player->v.v.movetype == MOVETYPE_FLY; + pmove.flying = ((entvars_t*)&sv_player->v)->movetype == MOVETYPE_FLY; pmove.spectator = host_client->spectator; - pmove.waterjumptime = sv_player->v.v.teleport_time; + pmove.waterjumptime = ((entvars_t*)&sv_player->v)->teleport_time; pmove.numphysent = 1; pmove.physents[0].model = sv.worldmodel; pmove.cmd = *ucmd; - pmove.dead = sv_player->v.v.health <= 0; + pmove.dead = ((entvars_t*)&sv_player->v)->health <= 0; pmove.oldbuttons = host_client->oldbuttons; movevars.entgravity = host_client->entgravity; @@ -1532,7 +1533,7 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside) PlayerMove (); after = PM_TestPlayerPosition (pmove.origin); - if (sv_player->v.v.health > 0 && before && !after) + if (((entvars_t*)&sv_player->v)->health > 0 && before && !after) Con_Printf ("player %s got stuck in playermove!!!!\n", host_client->name); } @@ -1541,29 +1542,29 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside) #endif host_client->oldbuttons = pmove.oldbuttons; - sv_player->v.v.teleport_time = pmove.waterjumptime; - sv_player->v.v.waterlevel = waterlevel; - sv_player->v.v.watertype = watertype; + ((entvars_t*)&sv_player->v)->teleport_time = pmove.waterjumptime; + ((entvars_t*)&sv_player->v)->waterlevel = waterlevel; + ((entvars_t*)&sv_player->v)->watertype = watertype; if (onground != -1) { - sv_player->v.v.flags = (int) sv_player->v.v.flags | FL_ONGROUND; - sv_player->v.v.groundentity = + ((entvars_t*)&sv_player->v)->flags = (int) ((entvars_t*)&sv_player->v)->flags | FL_ONGROUND; + ((entvars_t*)&sv_player->v)->groundentity = EDICT_TO_PROG (&sv_pr_state, EDICT_NUM (&sv_pr_state, pmove.physents[onground].info)); } else { - sv_player->v.v.flags = (int) sv_player->v.v.flags & ~FL_ONGROUND; + ((entvars_t*)&sv_player->v)->flags = (int) ((entvars_t*)&sv_player->v)->flags & ~FL_ONGROUND; } for (i = 0; i < 3; i++) - sv_player->v.v.origin[i] = - pmove.origin[i] - (sv_player->v.v.mins[i] - player_mins[i]); + ((entvars_t*)&sv_player->v)->origin[i] = + pmove.origin[i] - (((entvars_t*)&sv_player->v)->mins[i] - player_mins[i]); #if 0 // truncate velocity the same way the net protocol will for (i = 0; i < 3; i++) - sv_player->v.v.velocity[i] = (int) pmove.velocity[i]; + ((entvars_t*)&sv_player->v)->velocity[i] = (int) pmove.velocity[i]; #else - VectorCopy (pmove.velocity, sv_player->v.v.velocity); + VectorCopy (pmove.velocity, ((entvars_t*)&sv_player->v)->velocity); #endif - VectorCopy (pmove.angles, sv_player->v.v.v_angle); + VectorCopy (pmove.angles, ((entvars_t*)&sv_player->v)->v_angle); if (!host_client->spectator) { // link into place and touch triggers @@ -1573,11 +1574,11 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside) for (i = 0; i < pmove.numtouch; i++) { n = pmove.physents[pmove.touchindex[i]].info; ent = EDICT_NUM (&sv_pr_state, n); - if (!ent->v.v.touch || (playertouch[n / 8] & (1 << (n % 8)))) + if (!((entvars_t*)&ent->v)->touch || (playertouch[n / 8] & (1 << (n % 8)))) continue; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, ent); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv_player); - PR_ExecuteProgram (&sv_pr_state, ent->v.v.touch); + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, ent); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, sv_player); + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->touch); playertouch[n / 8] |= 1 << (n % 8); } } @@ -1594,15 +1595,15 @@ SV_PostRunCmd (void) // run post-think if (!host_client->spectator) { - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv_player); PR_ExecuteProgram (&sv_pr_state, - sv_pr_state.pr_global_struct->PlayerPostThink); + ((globalvars_t*)sv_pr_state.pr_globals)->PlayerPostThink); SV_RunNewmis (); } else if (SpectatorThink) { - sv_pr_state.pr_global_struct->time = sv.time; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, sv_player); PR_ExecuteProgram (&sv_pr_state, SpectatorThink); } @@ -1745,7 +1746,7 @@ SV_ExecuteClientMessage (client_t *cl) o[2] = MSG_ReadCoord (net_message); // only allowed by spectators if (host_client->spectator) { - VectorCopy (o, sv_player->v.v.origin); + VectorCopy (o, ((entvars_t*)&sv_player->v)->origin); SV_LinkEdict (sv_player, false); } break; diff --git a/qw/source/world.c b/qw/source/world.c index f42b098f4..f835117f9 100644 --- a/qw/source/world.c +++ b/qw/source/world.c @@ -41,6 +41,7 @@ #include "commdef.h" #include "console.h" #include "crc.h" +#include "progdefs.h" #include "server.h" #include "world.h" @@ -150,12 +151,12 @@ SV_HullForEntity (edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset) hull_t *hull; // decide which clipping hull to use, based on the size - if (ent->v.v.solid == SOLID_BSP) { + if (((entvars_t*)&ent->v)->solid == SOLID_BSP) { // explicit hulls in the BSP model - if (ent->v.v.movetype != MOVETYPE_PUSH) + if (((entvars_t*)&ent->v)->movetype != MOVETYPE_PUSH) SV_Error ("SOLID_BSP without MOVETYPE_PUSH"); - model = sv.models[(int) ent->v.v.modelindex]; + model = sv.models[(int) ((entvars_t*)&ent->v)->modelindex]; if (!model || model->type != mod_brush) SV_Error ("SOLID_BSP with a non bsp model"); @@ -170,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 VectorSubtract (hull->clip_mins, mins, offset); - VectorAdd (offset, ent->v.v.origin, offset); + VectorAdd (offset, ((entvars_t*)&ent->v)->origin, offset); } else { // create a temp hull from bounding // box sizes - VectorSubtract (ent->v.v.mins, maxs, hullmins); - VectorSubtract (ent->v.v.maxs, mins, hullmaxs); + VectorSubtract (((entvars_t*)&ent->v)->mins, maxs, hullmins); + VectorSubtract (((entvars_t*)&ent->v)->maxs, mins, hullmaxs); hull = SV_HullForBox (hullmins, hullmaxs); - VectorCopy (ent->v.v.origin, offset); + VectorCopy (((entvars_t*)&ent->v)->origin, offset); } @@ -278,35 +279,35 @@ SV_TouchLinks (edict_t *ent, areanode_t *node) touch = EDICT_FROM_AREA (l); if (touch == ent) continue; - if (!touch->v.v.touch || touch->v.v.solid != SOLID_TRIGGER) + if (!((entvars_t*)&touch->v)->touch || ((entvars_t*)&touch->v)->solid != SOLID_TRIGGER) continue; - if (ent->v.v.absmin[0] > touch->v.v.absmax[0] - || ent->v.v.absmin[1] > touch->v.v.absmax[1] - || ent->v.v.absmin[2] > touch->v.v.absmax[2] - || ent->v.v.absmax[0] < touch->v.v.absmin[0] - || ent->v.v.absmax[1] < touch->v.v.absmin[1] - || ent->v.v.absmax[2] < touch->v.v.absmin[2]) + if (((entvars_t*)&ent->v)->absmin[0] > ((entvars_t*)&touch->v)->absmax[0] + || ((entvars_t*)&ent->v)->absmin[1] > ((entvars_t*)&touch->v)->absmax[1] + || ((entvars_t*)&ent->v)->absmin[2] > ((entvars_t*)&touch->v)->absmax[2] + || ((entvars_t*)&ent->v)->absmax[0] < ((entvars_t*)&touch->v)->absmin[0] + || ((entvars_t*)&ent->v)->absmax[1] < ((entvars_t*)&touch->v)->absmin[1] + || ((entvars_t*)&ent->v)->absmax[2] < ((entvars_t*)&touch->v)->absmin[2]) continue; - old_self = sv_pr_state.pr_global_struct->self; - old_other = sv_pr_state.pr_global_struct->other; + old_self = ((globalvars_t*)sv_pr_state.pr_globals)->self; + old_other = ((globalvars_t*)sv_pr_state.pr_globals)->other; - sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, touch); - sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, ent); - sv_pr_state.pr_global_struct->time = sv.time; - PR_ExecuteProgram (&sv_pr_state, touch->v.v.touch); + ((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, touch); + ((globalvars_t*)sv_pr_state.pr_globals)->other = EDICT_TO_PROG (&sv_pr_state, ent); + ((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time; + PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&touch->v)->touch); - sv_pr_state.pr_global_struct->self = old_self; - sv_pr_state.pr_global_struct->other = old_other; + ((globalvars_t*)sv_pr_state.pr_globals)->self = old_self; + ((globalvars_t*)sv_pr_state.pr_globals)->other = old_other; } // recurse down both sides if (node->axis == -1) return; - if (ent->v.v.absmax[node->axis] > node->dist) + if (((entvars_t*)&ent->v)->absmax[node->axis] > node->dist) SV_TouchLinks (ent, node->children[0]); - if (ent->v.v.absmin[node->axis] < node->dist) + if (((entvars_t*)&ent->v)->absmin[node->axis] < node->dist) SV_TouchLinks (ent, node->children[1]); } @@ -341,7 +342,7 @@ SV_FindTouchedLeafs (edict_t *ent, mnode_t *node) // NODE_MIXED splitplane = node->plane; - sides = BOX_ON_PLANE_SIDE (ent->v.v.absmin, ent->v.v.absmax, splitplane); + sides = BOX_ON_PLANE_SIDE (((entvars_t*)&ent->v)->absmin, ((entvars_t*)&ent->v)->absmax, splitplane); // recurse down the contacted sides if (sides & 1) @@ -369,35 +370,35 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers) return; // set the abs box - VectorAdd (ent->v.v.origin, ent->v.v.mins, ent->v.v.absmin); - VectorAdd (ent->v.v.origin, ent->v.v.maxs, ent->v.v.absmax); + VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->absmin); + VectorAdd (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->maxs, ((entvars_t*)&ent->v)->absmax); // // to make items easier to pick up and allow them to be grabbed off // of shelves, the abs sizes are expanded // - if ((int) ent->v.v.flags & FL_ITEM) { - ent->v.v.absmin[0] -= 15; - ent->v.v.absmin[1] -= 15; - ent->v.v.absmax[0] += 15; - ent->v.v.absmax[1] += 15; + if ((int) ((entvars_t*)&ent->v)->flags & FL_ITEM) { + ((entvars_t*)&ent->v)->absmin[0] -= 15; + ((entvars_t*)&ent->v)->absmin[1] -= 15; + ((entvars_t*)&ent->v)->absmax[0] += 15; + ((entvars_t*)&ent->v)->absmax[1] += 15; } else { // because movement is clipped an // epsilon away from an actual edge, // we must fully check even when bounding boxes don't quite touch - ent->v.v.absmin[0] -= 1; - ent->v.v.absmin[1] -= 1; - ent->v.v.absmin[2] -= 1; - ent->v.v.absmax[0] += 1; - ent->v.v.absmax[1] += 1; - ent->v.v.absmax[2] += 1; + ((entvars_t*)&ent->v)->absmin[0] -= 1; + ((entvars_t*)&ent->v)->absmin[1] -= 1; + ((entvars_t*)&ent->v)->absmin[2] -= 1; + ((entvars_t*)&ent->v)->absmax[0] += 1; + ((entvars_t*)&ent->v)->absmax[1] += 1; + ((entvars_t*)&ent->v)->absmax[2] += 1; } // link to PVS leafs ent->num_leafs = 0; - if (ent->v.v.modelindex) + if (((entvars_t*)&ent->v)->modelindex) SV_FindTouchedLeafs (ent, sv.worldmodel->nodes); - if (ent->v.v.solid == SOLID_NOT) + if (((entvars_t*)&ent->v)->solid == SOLID_NOT) return; // find the first node that the ent's box crosses @@ -405,9 +406,9 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers) while (1) { if (node->axis == -1) break; - if (ent->v.v.absmin[node->axis] > node->dist) + if (((entvars_t*)&ent->v)->absmin[node->axis] > node->dist) node = node->children[0]; - else if (ent->v.v.absmax[node->axis] < node->dist) + else if (((entvars_t*)&ent->v)->absmax[node->axis] < node->dist) node = node->children[1]; else break; // crosses the node @@ -415,7 +416,7 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers) // link it in - if (ent->v.v.solid == SOLID_TRIGGER) + if (((entvars_t*)&ent->v)->solid == SOLID_TRIGGER) InsertLinkBefore (&ent->area, &node->trigger_edicts); else InsertLinkBefore (&ent->area, &node->solid_edicts); @@ -489,7 +490,7 @@ SV_TestEntityPosition (edict_t *ent) trace_t trace; trace = - SV_Move (ent->v.v.origin, ent->v.v.mins, ent->v.v.maxs, ent->v.v.origin, 0, + SV_Move (((entvars_t*)&ent->v)->origin, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, ((entvars_t*)&ent->v)->origin, 0, ent); if (trace.startsolid) @@ -698,38 +699,38 @@ SV_ClipToLinks (areanode_t *node, moveclip_t * clip) for (l = node->solid_edicts.next; l != &node->solid_edicts; l = next) { next = l->next; touch = EDICT_FROM_AREA (l); - if (touch->v.v.solid == SOLID_NOT) + if (((entvars_t*)&touch->v)->solid == SOLID_NOT) continue; if (touch == clip->passedict) continue; - if (touch->v.v.solid == SOLID_TRIGGER) + if (((entvars_t*)&touch->v)->solid == SOLID_TRIGGER) SV_Error ("Trigger in clipping list"); - if (clip->type == MOVE_NOMONSTERS && touch->v.v.solid != SOLID_BSP) + if (clip->type == MOVE_NOMONSTERS && ((entvars_t*)&touch->v)->solid != SOLID_BSP) continue; - if (clip->boxmins[0] > touch->v.v.absmax[0] - || clip->boxmins[1] > touch->v.v.absmax[1] - || clip->boxmins[2] > touch->v.v.absmax[2] - || clip->boxmaxs[0] < touch->v.v.absmin[0] - || clip->boxmaxs[1] < touch->v.v.absmin[1] - || clip->boxmaxs[2] < touch->v.v.absmin[2]) + if (clip->boxmins[0] > ((entvars_t*)&touch->v)->absmax[0] + || clip->boxmins[1] > ((entvars_t*)&touch->v)->absmax[1] + || clip->boxmins[2] > ((entvars_t*)&touch->v)->absmax[2] + || clip->boxmaxs[0] < ((entvars_t*)&touch->v)->absmin[0] + || clip->boxmaxs[1] < ((entvars_t*)&touch->v)->absmin[1] + || clip->boxmaxs[2] < ((entvars_t*)&touch->v)->absmin[2]) continue; - if (clip->passedict != 0 && clip->passedict->v.v.size[0] - && !touch->v.v.size[0]) continue; // points never interact + if (clip->passedict != 0 && ((entvars_t*)&clip->passedict->v)->size[0] + && !((entvars_t*)&touch->v)->size[0]) continue; // points never interact // might intersect, so do an exact clip if (clip->trace.allsolid) return; if (clip->passedict) { - if (PROG_TO_EDICT (&sv_pr_state, touch->v.v.owner) == clip->passedict) + if (PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&touch->v)->owner) == clip->passedict) continue; // don't clip against own missiles - if (PROG_TO_EDICT (&sv_pr_state, clip->passedict->v.v.owner) == touch) + if (PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&clip->passedict->v)->owner) == touch) continue; // don't clip against owner } - if ((int) touch->v.v.flags & FL_MONSTER) + if ((int) ((entvars_t*)&touch->v)->flags & FL_MONSTER) trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end); @@ -848,30 +849,30 @@ SV_TestPlayerPosition (edict_t *ent, vec3_t origin) CONTENTS_EMPTY) return sv.edicts; // check all entities - VectorAdd (origin, ent->v.v.mins, boxmins); - VectorAdd (origin, ent->v.v.maxs, boxmaxs); + VectorAdd (origin, ((entvars_t*)&ent->v)->mins, boxmins); + VectorAdd (origin, ((entvars_t*)&ent->v)->maxs, boxmaxs); check = NEXT_EDICT (&sv_pr_state, sv.edicts); for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) { if (check->free) continue; - if (check->v.v.solid != SOLID_BSP && - check->v.v.solid != SOLID_BBOX && check->v.v.solid != SOLID_SLIDEBOX) + if (((entvars_t*)&check->v)->solid != SOLID_BSP && + ((entvars_t*)&check->v)->solid != SOLID_BBOX && ((entvars_t*)&check->v)->solid != SOLID_SLIDEBOX) continue; - if (boxmins[0] > check->v.v.absmax[0] - || boxmins[1] > check->v.v.absmax[1] - || boxmins[2] > check->v.v.absmax[2] - || boxmaxs[0] < check->v.v.absmin[0] - || boxmaxs[1] < check->v.v.absmin[1] - || boxmaxs[2] < check->v.v.absmin[2]) + if (boxmins[0] > ((entvars_t*)&check->v)->absmax[0] + || boxmins[1] > ((entvars_t*)&check->v)->absmax[1] + || boxmins[2] > ((entvars_t*)&check->v)->absmax[2] + || boxmaxs[0] < ((entvars_t*)&check->v)->absmin[0] + || boxmaxs[1] < ((entvars_t*)&check->v)->absmin[1] + || boxmaxs[2] < ((entvars_t*)&check->v)->absmin[2]) continue; if (check == ent) continue; // get the clipping hull - hull = SV_HullForEntity (check, ent->v.v.mins, ent->v.v.maxs, offset); + hull = SV_HullForEntity (check, ((entvars_t*)&ent->v)->mins, ((entvars_t*)&ent->v)->maxs, offset); VectorSubtract (origin, offset, offset);