nq compiles with the new progs setup, but doesn't have a hope of running yet.

None of the globals etc structs are filled in and there will be a lot of type
errors in SVFIELD usage.
This commit is contained in:
Bill Currie 2001-03-03 08:31:58 +00:00
parent 26e2d545e4
commit 6d6c34320f
12 changed files with 1002 additions and 812 deletions

192
nq/include/sv_progs.h Normal file
View file

@ -0,0 +1,192 @@
/*
sv_progs.h
server specific progs definitions
Copyright (C) 2000 Bill Currie
Author: Bill Currie
Date: 28 Feb 2001
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __sv_progs_h
#define __sv_progs_h
#include "progs.h"
typedef struct {
int *self;
int *other;
int *world;
float *time;
float *frametime;
float *force_retouch;
string_t *mapname;
string_t *startspot;
float *deathmatch;
float *coop;
float *teamplay;
float *serverflags;
float *total_secrets;
float *total_monsters;
float *found_secrets;
float *killed_monsters;
float *parms;
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;
string_t *null;
} sv_globals_t;
extern sv_globals_t sv_globals;
typedef struct {
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;
} sv_funcs_t;
extern sv_funcs_t sv_funcs;
typedef struct
{
int modelindex; //float
int absmin; //vec3_t
int absmax; //vec3_t
int ltime; //float
int movetype; //float
int solid; //float
int origin; //vec3_t
int oldorigin; //vec3_t
int velocity; //vec3_t
int angles; //vec3_t
int avelocity; //vec3_t
int basevelocity; //vec3_t
int punchangle; //vec3_t
int classname; //string_t
int model; //string_t
int frame; //float
int skin; //float
int effects; //float
int drawPercent; //float
int gravity; //float
int mass; //float
int light_level; //float
int mins; //vec3_t
int maxs; //vec3_t
int size; //vec3_t
int touch; //func_t
int use; //func_t
int think; //func_t
int blocked; //func_t
int nextthink; //float
int groundentity; //int
int health; //float
int frags; //float
int weapon; //float
int weaponmodel; //string_t
int weaponframe; //float
int currentammo; //float
int ammo_shells; //float
int ammo_nails; //float
int ammo_rockets; //float
int ammo_cells; //float
int items; //float
int items2; //float
int takedamage; //float
int chain; //int
int deadflag; //float
int view_ofs; //vec3_t
int button0; //float
int button1; //float
int button2; //float
int impulse; //float
int fixangle; //float
int v_angle; //vec3_t
int idealpitch; //float
int pitch_speed; //float
int netname; //string_t
int enemy; //int
int flags; //float
int colormap; //float
int team; //float
int max_health; //float
int teleport_time; //float
int armortype; //float
int armorvalue; //float
int waterlevel; //float
int watertype; //float
int ideal_yaw; //float
int yaw_speed; //float
int aiment; //int
int goalentity; //int
int spawnflags; //float
int target; //string_t
int targetname; //string_t
int dmg_take; //float
int dmg_save; //float
int dmg_inflictor; //int
int owner; //int
int movedir; //vec3_t
int message; //string_t
int sounds; //float
int noise; //string_t
int noise1; //string_t
int noise2; //string_t
int noise3; //string_t
int dmg; //float
int dmgtime; //float
int air_finished; //float
int pain_finished; //float
int radsuit_finished; //float
int speed; //Float
} sv_fields_t;
extern sv_fields_t sv_fields;
#if 1
#define SVFIELD(e,f,t) ((ED_FindField (&sv_pr_state, #f)->type == ev_##t) ? E_var (e, sv_fields.f, t) : PR_Error (&sv_pr_state, "bad type access %s:%d", __FILE__, __LINE__), E_var (e, sv_fields.f, t))
#else
#define SVFIELD(e,f,t) E_var (e, sv_fields.f, t)
#endif
#define PROGHEADER_CRC 54730
#endif // __sv_progs_h

View file

@ -128,8 +128,8 @@ libqfnet_a_SOURCES= net_bsd.c net_dgrm.c net_loop.c \
EXTRA_libqfcd_a_SOURCES=net_dos.c net_bw.c net_ipx.c net_mp.c net_ser.c \
net_win.c net_wins.c net_wipx.c
client_LIBS= -L. -L../../libs -lqfsys -lqfsnd -lqfcd -lqfjs -lqfnet -lqfutil $(SOUND_LIBS) $(NET_LIBS) $(Z_LIBS)
client_LIB_DEPS= libqfsys.a libqfsnd.a libqfcd.a libqfjs.a libqfnet.a ../../libs/libqfutil.a
client_LIBS= -L. -L../../libs -lqfsys -lqfsnd -lqfcd -lqfjs -lqfnet -lqfgamecode -lqfutil $(SOUND_LIBS) $(NET_LIBS) $(Z_LIBS)
client_LIB_DEPS= libqfsys.a libqfsnd.a libqfcd.a libqfjs.a libqfnet.a ../../libs/libqfgamecode.a ../../libs/libqfutil.a
client_SOURCES= cl_cam.c cl_cmd.c cl_demo.c cl_input.c cl_main.c cl_parse.c \
cl_tent.c console.c keys.c menu.c sbar.c r_part.c r_view.c \
@ -137,7 +137,7 @@ client_SOURCES= cl_cam.c cl_cmd.c cl_demo.c cl_input.c cl_main.c cl_parse.c \
gib_interpret.c gib_modules.c gib_parse.c gib_stack.c vid.c
server_SOURCES= host.c host_cmd.c \
pr_cmds.c pr_edict.c pr_exec.c pr_offs.c \
pr_cmds.c \
sv_cvar.c sv_main.c sv_move.c sv_phys.c sv_progs.c sv_user.c
combined_SOURCES= $(common_SOURCES) $(client_SOURCES) $(server_SOURCES)

View file

@ -51,6 +51,7 @@
#include "sys.h"
#include "screen.h"
#include "gib.h"
#include "sv_progs.h"
/*
@ -394,12 +395,12 @@ SV_DropClient (qboolean crash)
if (host_client->edict && host_client->spawned) {
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
saveSelf = sv_pr_state.pr_global_struct->self;
sv_pr_state.pr_global_struct->self =
saveSelf = *sv_globals.self;
*sv_globals.self =
EDICT_TO_PROG (&sv_pr_state, host_client->edict);
PR_ExecuteProgram (&sv_pr_state,
sv_pr_state.pr_global_struct->ClientDisconnect);
sv_pr_state.pr_global_struct->self = saveSelf;
sv_funcs.ClientDisconnect);
*sv_globals.self = saveSelf;
}
Sys_Printf ("Client %s removed\n", host_client->name);
@ -592,7 +593,7 @@ void
_Host_ServerFrame (void)
{
// run the world state
sv_pr_state.pr_global_struct->frametime = host_frametime;
*sv_globals.frametime = host_frametime;
// read client messages
SV_RunClients ();
@ -610,7 +611,7 @@ Host_ServerFrame (void)
float temp_host_frametime;
// run the world state
sv_pr_state.pr_global_struct->frametime = host_frametime;
*sv_globals.frametime = host_frametime;
// set the time and clear the general datagram
SV_ClearDatagram ();
@ -639,7 +640,7 @@ void
Host_ServerFrame (void)
{
// run the world state
sv_pr_state.pr_global_struct->frametime = host_frametime;
*sv_globals.frametime = host_frametime;
// set the time and clear the general datagram
SV_ClearDatagram ();

View file

@ -43,6 +43,7 @@
#include "progs.h"
#include "keys.h"
#include "sys.h"
#include "sv_progs.h"
int current_skill;
@ -116,7 +117,7 @@ Host_Status_f (void)
} else
hours = 0;
print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j + 1, client->name,
(int) client->edict->v.v.frags, hours, minutes, seconds);
(int) SVFIELD (client->edict, frags, float), hours, minutes, seconds);
print (" %s\n", client->netconnection->address);
}
}
@ -137,11 +138,11 @@ Host_God_f (void)
return;
}
if (sv_pr_state.pr_global_struct->deathmatch && !host_client->privileged)
if (*sv_globals.deathmatch && !host_client->privileged)
return;
sv_player->v.v.flags = (int) sv_player->v.v.flags ^ FL_GODMODE;
if (!((int) sv_player->v.v.flags & FL_GODMODE))
SVFIELD (sv_player, flags, float) = (int) SVFIELD (sv_player, flags, float) ^ FL_GODMODE;
if (!((int) SVFIELD (sv_player, flags, float) & FL_GODMODE))
SV_ClientPrintf ("godmode OFF\n");
else
SV_ClientPrintf ("godmode ON\n");
@ -155,11 +156,11 @@ Host_Notarget_f (void)
return;
}
if (sv_pr_state.pr_global_struct->deathmatch && !host_client->privileged)
if (*sv_globals.deathmatch && !host_client->privileged)
return;
sv_player->v.v.flags = (int) sv_player->v.v.flags ^ FL_NOTARGET;
if (!((int) sv_player->v.v.flags & FL_NOTARGET))
SVFIELD (sv_player, flags, float) = (int) SVFIELD (sv_player, flags, float) ^ FL_NOTARGET;
if (!((int) SVFIELD (sv_player, flags, float) & FL_NOTARGET))
SV_ClientPrintf ("notarget OFF\n");
else
SV_ClientPrintf ("notarget ON\n");
@ -175,16 +176,16 @@ Host_Noclip_f (void)
return;
}
if (sv_pr_state.pr_global_struct->deathmatch && !host_client->privileged)
if (*sv_globals.deathmatch && !host_client->privileged)
return;
if (sv_player->v.v.movetype != MOVETYPE_NOCLIP) {
if (SVFIELD (sv_player, movetype, float) != MOVETYPE_NOCLIP) {
noclip_anglehack = true;
sv_player->v.v.movetype = MOVETYPE_NOCLIP;
SVFIELD (sv_player, movetype, float) = MOVETYPE_NOCLIP;
SV_ClientPrintf ("noclip ON\n");
} else {
noclip_anglehack = false;
sv_player->v.v.movetype = MOVETYPE_WALK;
SVFIELD (sv_player, movetype, float) = MOVETYPE_WALK;
SV_ClientPrintf ("noclip OFF\n");
}
}
@ -204,14 +205,14 @@ Host_Fly_f (void)
return;
}
if (sv_pr_state.pr_global_struct->deathmatch && !host_client->privileged)
if (*sv_globals.deathmatch && !host_client->privileged)
return;
if (sv_player->v.v.movetype != MOVETYPE_FLY) {
sv_player->v.v.movetype = MOVETYPE_FLY;
if (SVFIELD (sv_player, movetype, float) != MOVETYPE_FLY) {
SVFIELD (sv_player, movetype, float) = MOVETYPE_FLY;
SV_ClientPrintf ("flymode ON\n");
} else {
sv_player->v.v.movetype = MOVETYPE_WALK;
SVFIELD (sv_player, movetype, float) = MOVETYPE_WALK;
SV_ClientPrintf ("flymode OFF\n");
}
}
@ -511,7 +512,7 @@ Host_Savegame_f (void)
}
for (i = 0; i < svs.maxclients; i++) {
if (svs.clients[i].active && (svs.clients[i].edict->v.v.health <= 0)) {
if (svs.clients[i].active && (SVFIELD (svs.clients[i].edict, health, float) <= 0)) {
Con_Printf ("Can't savegame with a dead player\n");
return;
}
@ -748,7 +749,7 @@ SaveGamestate ()
for (i = svs.maxclients + 1; i < sv.num_edicts; i++) {
ent = EDICT_NUM (i);
if ((int) ent->v.v.flags & FL_ARCHIVE_OVERRIDE)
if ((int) SVFIELD (ent, flags, float) & FL_ARCHIVE_OVERRIDE)
continue;
Qprintf (f, "%i\n", i);
ED_Write (f, ent);
@ -936,7 +937,7 @@ Host_Name_f (void)
if (strcmp (host_client->name, newName) != 0)
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
strcpy (host_client->name, newName);
host_client->edict->v.v.netname =
SVFIELD (host_client->edict, netname, float) =
host_client->name - sv_pr_state.pr_strings;
// send notification to all clients
@ -1002,7 +1003,7 @@ Host_Say (qboolean teamonly)
if (!client || !client->active || !client->spawned)
continue;
if (teamplay->int_val && teamonly
&& client->edict->v.v.team != save->edict->v.v.team) continue;
&& SVFIELD (client->edict, team, float) != SVFIELD (save->edict, team, float)) continue;
host_client = client;
SV_ClientPrintf ("%s", text);
}
@ -1117,7 +1118,7 @@ Host_Color_f (void)
}
host_client->colors = playercolor;
host_client->edict->v.v.team = bottom + 1;
SVFIELD (host_client->edict, team, float) = bottom + 1;
// send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
@ -1138,15 +1139,15 @@ Host_Kill_f (void)
return;
}
if (sv_player->v.v.health <= 0) {
if (SVFIELD (sv_player, health, float) <= 0) {
SV_ClientPrintf ("Can't suicide -- already dead!\n");
return;
}
sv_pr_state.pr_global_struct->time = sv.time;
sv_pr_state.pr_global_struct->self =
*sv_globals.time = sv.time;
*sv_globals.self =
EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->ClientKill);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientKill);
}
@ -1171,11 +1172,11 @@ Host_Pause_f (void)
if (sv.paused) {
SV_BroadcastPrintf ("%s paused the game\n",
sv_pr_state.pr_strings +
sv_player->v.v.netname);
SVFIELD (sv_player, netname, string));
} else {
SV_BroadcastPrintf ("%s unpaused the game\n",
sv_pr_state.pr_strings +
sv_player->v.v.netname);
SVFIELD (sv_player, netname, string));
}
// send notification to all clients
@ -1242,28 +1243,28 @@ Host_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 = (host_client->colors & 15) + 1;
ent->v.v.netname = host_client->name - sv_pr_state.pr_strings;
SVFIELD (ent, colormap, float) = NUM_FOR_EDICT (&sv_pr_state, ent);
SVFIELD (ent, team, float) = (host_client->colors & 15) + 1;
SVFIELD (ent, netname, float) = host_client->name - sv_pr_state.pr_strings;
// 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];
sv_globals.parms[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 =
*sv_globals.time = sv.time;
*sv_globals.self =
EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state,
sv_pr_state.pr_global_struct->ClientConnect);
sv_funcs.ClientConnect);
if ((Sys_DoubleTime () - host_client->netconnection->connecttime) <=
sv.time) Sys_Printf ("%s entered the game\n", host_client->name);
PR_ExecuteProgram (&sv_pr_state,
sv_pr_state.pr_global_struct->PutClientInServer);
sv_funcs.PutClientInServer);
}
@ -1299,22 +1300,22 @@ Host_Spawn_f (void)
MSG_WriteByte (&host_client->message, svc_updatestat);
MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
MSG_WriteLong (&host_client->message,
sv_pr_state.pr_global_struct->total_secrets);
*sv_globals.total_secrets);
MSG_WriteByte (&host_client->message, svc_updatestat);
MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
MSG_WriteLong (&host_client->message,
sv_pr_state.pr_global_struct->total_monsters);
*sv_globals.total_monsters);
MSG_WriteByte (&host_client->message, svc_updatestat);
MSG_WriteByte (&host_client->message, STAT_SECRETS);
MSG_WriteLong (&host_client->message,
sv_pr_state.pr_global_struct->found_secrets);
*sv_globals.found_secrets);
MSG_WriteByte (&host_client->message, svc_updatestat);
MSG_WriteByte (&host_client->message, STAT_MONSTERS);
MSG_WriteLong (&host_client->message,
sv_pr_state.pr_global_struct->killed_monsters);
*sv_globals.killed_monsters);
//
@ -1326,7 +1327,7 @@ Host_Spawn_f (void)
ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients));
MSG_WriteByte (&host_client->message, svc_setangle);
for (i = 0; i < 2; i++)
MSG_WriteAngle (&host_client->message, ent->v.v.angles[i]);
MSG_WriteAngle (&host_client->message, SVFIELD (ent, angles, vector)[i]);
MSG_WriteAngle (&host_client->message, 0);
SV_WriteClientdataToMessage (sv_player, &host_client->message);
@ -1377,7 +1378,7 @@ Host_Kick_f (void)
return;
}
}
else if (sv_pr_state.pr_global_struct->deathmatch
else if (*sv_globals.deathmatch
&& !host_client->privileged) return;
save = host_client;
@ -1459,7 +1460,7 @@ Host_Give_f (void)
return;
}
if (sv_pr_state.pr_global_struct->deathmatch && !host_client->privileged)
if (*sv_globals.deathmatch && !host_client->privileged)
return;
t = Cmd_Argv (1);
@ -1480,23 +1481,23 @@ Host_Give_f (void)
if (hipnotic) {
if (t[0] == '6') {
if (t[1] == 'a')
sv_player->v.v.items =
(int) sv_player->v.v.items | HIT_PROXIMITY_GUN;
SVFIELD (sv_player, items, float) =
(int) SVFIELD (sv_player, items, float) | HIT_PROXIMITY_GUN;
else
sv_player->v.v.items =
(int) sv_player->v.v.items | IT_GRENADE_LAUNCHER;
SVFIELD (sv_player, items, float) =
(int) SVFIELD (sv_player, items, float) | IT_GRENADE_LAUNCHER;
} else if (t[0] == '9')
sv_player->v.v.items =
(int) sv_player->v.v.items | HIT_LASER_CANNON;
SVFIELD (sv_player, items, float) =
(int) SVFIELD (sv_player, items, float) | HIT_LASER_CANNON;
else if (t[0] == '0')
sv_player->v.v.items = (int) sv_player->v.v.items | HIT_MJOLNIR;
SVFIELD (sv_player, items, float) = (int) SVFIELD (sv_player, items, float) | HIT_MJOLNIR;
else if (t[0] >= '2')
sv_player->v.v.items =
(int) sv_player->v.v.items | (IT_SHOTGUN << (t[0] - '2'));
SVFIELD (sv_player, items, float) =
(int) SVFIELD (sv_player, items, float) | (IT_SHOTGUN << (t[0] - '2'));
} else {
if (t[0] >= '2')
sv_player->v.v.items =
(int) sv_player->v.v.items | (IT_SHOTGUN << (t[0] - '2'));
SVFIELD (sv_player, items, float) =
(int) SVFIELD (sv_player, items, float) | (IT_SHOTGUN << (t[0] - '2'));
}
break;
@ -1507,18 +1508,18 @@ Host_Give_f (void)
val->_float = v;
}
sv_player->v.v.ammo_shells = v;
SVFIELD (sv_player, ammo_shells, float) = v;
break;
case 'n':
if (rogue) {
val = GetEdictFieldValue (&sv_pr_state, sv_player, "ammo_nails1");
if (val) {
val->_float = v;
if (sv_player->v.v.weapon <= IT_LIGHTNING)
sv_player->v.v.ammo_nails = v;
if (SVFIELD (sv_player, weapon, float) <= IT_LIGHTNING)
SVFIELD (sv_player, ammo_nails, float) = v;
}
} else {
sv_player->v.v.ammo_nails = v;
SVFIELD (sv_player, ammo_nails, float) = v;
}
break;
case 'l':
@ -1527,8 +1528,8 @@ Host_Give_f (void)
GetEdictFieldValue (&sv_pr_state, sv_player, "ammo_lava_nails");
if (val) {
val->_float = v;
if (sv_player->v.v.weapon > IT_LIGHTNING)
sv_player->v.v.ammo_nails = v;
if (SVFIELD (sv_player, weapon, float) > IT_LIGHTNING)
SVFIELD (sv_player, ammo_nails, float) = v;
}
}
break;
@ -1537,11 +1538,11 @@ Host_Give_f (void)
val = GetEdictFieldValue (&sv_pr_state, sv_player, "ammo_rockets1");
if (val) {
val->_float = v;
if (sv_player->v.v.weapon <= IT_LIGHTNING)
sv_player->v.v.ammo_rockets = v;
if (SVFIELD (sv_player, weapon, float) <= IT_LIGHTNING)
SVFIELD (sv_player, ammo_rockets, float) = v;
}
} else {
sv_player->v.v.ammo_rockets = v;
SVFIELD (sv_player, ammo_rockets, float) = v;
}
break;
case 'm':
@ -1551,24 +1552,24 @@ Host_Give_f (void)
"ammo_multi_rockets");
if (val) {
val->_float = v;
if (sv_player->v.v.weapon > IT_LIGHTNING)
sv_player->v.v.ammo_rockets = v;
if (SVFIELD (sv_player, weapon, float) > IT_LIGHTNING)
SVFIELD (sv_player, ammo_rockets, float) = v;
}
}
break;
case 'h':
sv_player->v.v.health = v;
SVFIELD (sv_player, health, float) = v;
break;
case 'c':
if (rogue) {
val = GetEdictFieldValue (&sv_pr_state, sv_player, "ammo_cells1");
if (val) {
val->_float = v;
if (sv_player->v.v.weapon <= IT_LIGHTNING)
sv_player->v.v.ammo_cells = v;
if (SVFIELD (sv_player, weapon, float) <= IT_LIGHTNING)
SVFIELD (sv_player, ammo_cells, float) = v;
}
} else {
sv_player->v.v.ammo_cells = v;
SVFIELD (sv_player, ammo_cells, float) = v;
}
break;
case 'p':
@ -1576,8 +1577,8 @@ Host_Give_f (void)
val = GetEdictFieldValue (&sv_pr_state, sv_player, "ammo_plasma");
if (val) {
val->_float = v;
if (sv_player->v.v.weapon > IT_LIGHTNING)
sv_player->v.v.ammo_cells = v;
if (SVFIELD (sv_player, weapon, float) > IT_LIGHTNING)
SVFIELD (sv_player, ammo_cells, float) = v;
}
}
break;
@ -1592,7 +1593,7 @@ FindViewthing (void)
for (i = 0; i < sv.num_edicts; i++) {
e = EDICT_NUM (&sv_pr_state, i);
if (!strcmp (sv_pr_state.pr_strings + e->v.v.classname, "viewthing"))
if (!strcmp (sv_pr_state.pr_strings + SVFIELD (e, classname, string), "viewthing"))
return e;
}
Con_Printf ("No viewthing on map\n");
@ -1620,8 +1621,8 @@ Host_Viewmodel_f (void)
return;
}
e->v.v.frame = 0;
cl.model_precache[(int) e->v.v.modelindex] = m;
SVFIELD (e, frame, float) = 0;
cl.model_precache[(int) SVFIELD (e, modelindex, float)] = m;
}
/*
@ -1639,13 +1640,13 @@ Host_Viewframe_f (void)
e = FindViewthing ();
if (!e)
return;
m = cl.model_precache[(int) e->v.v.modelindex];
m = cl.model_precache[(int) SVFIELD (e, modelindex, float)];
f = atoi (Cmd_Argv (1));
if (f >= m->numframes)
f = m->numframes - 1;
e->v.v.frame = f;
SVFIELD (e, frame, float) = f;
}
@ -1677,13 +1678,13 @@ Host_Viewnext_f (void)
e = FindViewthing ();
if (!e)
return;
m = cl.model_precache[(int) e->v.v.modelindex];
m = cl.model_precache[(int) SVFIELD (e, modelindex, float)];
e->v.v.frame = e->v.v.frame + 1;
if (e->v.v.frame >= m->numframes)
e->v.v.frame = m->numframes - 1;
SVFIELD (e, frame, float) = SVFIELD (e, frame, float) + 1;
if (SVFIELD (e, frame, float) >= m->numframes)
SVFIELD (e, frame, float) = m->numframes - 1;
PrintFrameName (m, e->v.v.frame);
PrintFrameName (m, SVFIELD (e, frame, float));
}
/*
@ -1701,13 +1702,13 @@ Host_Viewprev_f (void)
if (!e)
return;
m = cl.model_precache[(int) e->v.v.modelindex];
m = cl.model_precache[(int) SVFIELD (e, modelindex, float)];
e->v.v.frame = e->v.v.frame - 1;
if (e->v.v.frame < 0)
e->v.v.frame = 0;
SVFIELD (e, frame, float) = SVFIELD (e, frame, float) - 1;
if (SVFIELD (e, frame, float) < 0)
SVFIELD (e, frame, float) = 0;
PrintFrameName (m, e->v.v.frame);
PrintFrameName (m, SVFIELD (e, frame, float));
}
/*

View file

@ -45,6 +45,7 @@
#include "console.h"
#include "net.h"
#include "game.h"
#include "sv_progs.h"
// This is enables a simple IP banning mechanism
#define BAN_TEST
@ -145,7 +146,7 @@ NET_Ban_f (void)
}
print = Con_Printf;
} else {
if (sv_pr_state.pr_global_struct->deathmatch
if (*sv_globals.deathmatch
&& !host_client->privileged) return;
print = SV_ClientPrintf;
}
@ -945,7 +946,7 @@ _Datagram_CheckNewConnections (void)
MSG_WriteByte (net_message->message, playerNumber);
MSG_WriteString (net_message->message, client->name);
MSG_WriteLong (net_message->message, client->colors);
MSG_WriteLong (net_message->message, (int) client->edict->v.v.frags);
MSG_WriteLong (net_message->message, SVFIELD (client->edict, frags, float));
MSG_WriteLong (net_message->message,
(int) (net_time - client->netconnection->connecttime));
MSG_WriteString (net_message->message, client->netconnection->address);

View file

@ -41,6 +41,7 @@
#include "world.h"
#include "msg.h"
#include "server.h"
#include "sv_progs.h"
#define RETURN_EDICT(p,e) (p->pr_globals[OFS_RETURN].int_var = EDICT_TO_PROG(p, e))
@ -85,7 +86,7 @@ PF_error (progs_t * pr)
s = PF_VarString (pr, 0);
Con_Printf ("======SERVER ERROR in %s:\n%s\n",
pr->pr_strings + pr->pr_xfunction->s_name, s);
ed = PROG_TO_EDICT (pr, pr->pr_global_struct->self);
ed = PROG_TO_EDICT (pr, *sv_globals.self);
ED_Print (pr, ed);
Host_Error ("Program error");
@ -110,7 +111,7 @@ PF_objerror (progs_t * pr)
s = PF_VarString (pr, 0);
Con_Printf ("======OBJECT ERROR in %s:\n%s\n",
pr->pr_strings + pr->pr_xfunction->s_name, s);
ed = PROG_TO_EDICT (pr, pr->pr_global_struct->self);
ed = PROG_TO_EDICT (pr, *sv_globals.self);
ED_Print (pr, ed);
ED_Free (pr, ed);
@ -130,8 +131,8 @@ makevectors(vector)
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), *sv_globals.v_forward,
*sv_globals.v_right, *sv_globals.v_up);
}
/*
@ -151,7 +152,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, SVFIELD (e, origin, vector));
SV_LinkEdict (e, false);
}
@ -182,7 +183,7 @@ SetMinMaxSize (progs_t * pr, edict_t *e, float *min, float *max,
VectorCopy (max, rmax);
} else {
// find min / max for rotations
angles = e->v.v.angles;
angles = SVFIELD (e, angles, vector);
a = angles[1] / 180 * M_PI;
@ -223,9 +224,9 @@ SetMinMaxSize (progs_t * pr, edict_t *e, float *min, float *max,
}
// set derived values
VectorCopy (rmin, e->v.v.mins);
VectorCopy (rmax, e->v.v.maxs);
VectorSubtract (max, min, e->v.v.size);
VectorCopy (rmin, SVFIELD (e, mins, vector));
VectorCopy (rmax, SVFIELD (e, maxs, vector));
VectorSubtract (max, min, SVFIELD (e, size, vector));
SV_LinkEdict (e, false);
}
@ -279,10 +280,10 @@ PF_setmodel (progs_t * pr)
PR_RunError (pr, "no precache: %s\n", m);
e->v.v.model = m - pr->pr_strings;
e->v.v.modelindex = i; // SV_ModelIndex (m);
SVFIELD (e, model, float) = m - pr->pr_strings;
SVFIELD (e, modelindex, float) = i; // SV_ModelIndex (m);
mod = sv.models[(int) e->v.v.modelindex]; // Mod_ForName (m, true);
mod = sv.models[(int) SVFIELD (e, modelindex, float)]; // Mod_ForName (m, true);
if (mod)
SetMinMaxSize (pr, e, mod->mins, mod->maxs, true);
@ -653,18 +654,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;
*sv_globals.trace_allsolid = trace.allsolid;
*sv_globals.trace_startsolid = trace.startsolid;
*sv_globals.trace_fraction = trace.fraction;
*sv_globals.trace_inwater = trace.inwater;
*sv_globals.trace_inopen = trace.inopen;
VectorCopy (trace.endpos, *sv_globals.trace_endpos);
VectorCopy (trace.plane.normal, *sv_globals.trace_plane_normal);
*sv_globals.trace_plane_dist = trace.plane.dist;
if (trace.ent)
pr->pr_global_struct->trace_ent = EDICT_TO_PROG (pr, trace.ent);
*sv_globals.trace_ent = EDICT_TO_PROG (pr, trace.ent);
else
pr->pr_global_struct->trace_ent = EDICT_TO_PROG (pr, sv.edicts);
*sv_globals.trace_ent = EDICT_TO_PROG (pr, sv.edicts);
}
@ -683,18 +684,18 @@ PF_TraceToss (progs_t * pr)
trace = SV_Trace_Toss (ent, ignore);
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;
*sv_globals.trace_allsolid = trace.allsolid;
*sv_globals.trace_startsolid = trace.startsolid;
*sv_globals.trace_fraction = trace.fraction;
*sv_globals.trace_inwater = trace.inwater;
*sv_globals.trace_inopen = trace.inopen;
VectorCopy (trace.endpos, *sv_globals.trace_endpos);
VectorCopy (trace.plane.normal, *sv_globals.trace_plane_normal);
*sv_globals.trace_plane_dist = trace.plane.dist;
if (trace.ent)
pr->pr_global_struct->trace_ent = EDICT_TO_PROG (pr, trace.ent);
*sv_globals.trace_ent = EDICT_TO_PROG (pr, trace.ent);
else
pr->pr_global_struct->trace_ent = EDICT_TO_PROG (pr, sv.edicts);
*sv_globals.trace_ent = EDICT_TO_PROG (pr, sv.edicts);
}
#endif
@ -750,9 +751,9 @@ PF_newcheckclient (progs_t * pr, int check)
if (ent->free)
continue;
if (ent->v.v.health <= 0)
if (SVFIELD (ent, health, float) <= 0)
continue;
if ((int) ent->v.v.flags & FL_NOTARGET)
if ((int) SVFIELD (ent, flags, float) & FL_NOTARGET)
continue;
// anything that is a client, or has a client as an enemy
@ -760,7 +761,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 (SVFIELD (ent, origin, vector), SVFIELD (ent, view_ofs, vector), org);
leaf = Mod_PointInLeaf (org, sv.worldmodel);
pvs = Mod_LeafPVS (leaf, sv.worldmodel);
memcpy (checkpvs, pvs, (sv.worldmodel->numleafs + 7) >> 3);
@ -800,13 +801,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 || SVFIELD (ent, health, float) <= 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, *sv_globals.self);
VectorAdd (SVFIELD (self, origin, vector), SVFIELD (self, view_ofs, vector), view);
leaf = Mod_PointInLeaf (view, sv.worldmodel);
l = (leaf - sv.worldmodel->leafs) - 1;
if ((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) {
@ -938,16 +939,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 (SVFIELD (ent, solid, float) == 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] - (SVFIELD (ent, origin, vector)[j] +
(SVFIELD (ent, mins, vector)[j] + SVFIELD (ent, maxs, vector)[j]) * 0.5);
if (Length (eorg) > rad)
continue;
ent->v.v.chain = EDICT_TO_PROG (pr, chain);
SVFIELD (ent, chain, float) = EDICT_TO_PROG (pr, chain);
chain = ent;
}
@ -1062,19 +1063,19 @@ PF_Find (progs_t * pr)
first = ed;
else if (second == (edict_t *) sv.edicts)
second = ed;
ed->v.v.chain = EDICT_TO_PROG (pr, last);
SVFIELD (ed, chain, float) = EDICT_TO_PROG (pr, last);
last = ed;
}
}
if (first != last) {
if (last != second)
first->v.v.chain = last->v.v.chain;
SVFIELD (first, chain, float) = SVFIELD (last, chain, float);
else
first->v.v.chain = EDICT_TO_PROG (pr, last);
last->v.v.chain = EDICT_TO_PROG (pr, (edict_t *) sv.edicts);
SVFIELD (first, chain, float) = EDICT_TO_PROG (pr, last);
SVFIELD (last, chain, float) = EDICT_TO_PROG (pr, (edict_t *) sv.edicts);
if (second && second != last)
second->v.v.chain = EDICT_TO_PROG (pr, last);
SVFIELD (second, chain, float) = EDICT_TO_PROG (pr, last);
}
RETURN_EDICT (pr, first);
}
@ -1216,11 +1217,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, *sv_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) SVFIELD (ent, flags, float) & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
G_FLOAT (pr, OFS_RETURN) = 0;
return;
}
@ -1233,14 +1234,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 = *sv_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;
*sv_globals.self = oldself;
}
/*
@ -1257,22 +1258,22 @@ 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, *sv_globals.self);
VectorCopy (ent->v.v.origin, end);
VectorCopy (SVFIELD (ent, origin, vector), end);
end[2] -= 256;
trace =
SV_Move (ent->v.v.origin, ent->v.v.mins, ent->v.v.maxs, end, false,
SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), 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, SVFIELD (ent, origin, vector));
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);
SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) | FL_ONGROUND;
SVFIELD (ent, groundentity, float) = EDICT_TO_PROG (pr, trace.ent);
G_FLOAT (pr, OFS_RETURN) = 1;
}
}
@ -1415,17 +1416,17 @@ PF_aim (progs_t * pr)
ent = G_EDICT (pr, OFS_PARM0);
speed = G_FLOAT (pr, OFS_PARM1);
VectorCopy (ent->v.v.origin, start);
VectorCopy (SVFIELD (ent, origin, vector), start);
start[2] += 20;
// try sending a trace straight
VectorCopy (pr->pr_global_struct->v_forward, dir);
VectorCopy (*sv_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 && SVFIELD (tr.ent, takedamage, float) == DAMAGE_AIM
&& (!teamplay->int_val || SVFIELD (ent, team, float) <= 0
|| SVFIELD (ent, team, float) != SVFIELD (tr.ent, team, float))) {
VectorCopy (*sv_globals.v_forward, G_VECTOR (pr, OFS_RETURN));
return;
}
// try all possible entities
@ -1435,19 +1436,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 (SVFIELD (check, takedamage, float) != 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 && SVFIELD (ent, team, float) > 0
&& SVFIELD (ent, team, float) == SVFIELD (check, team, float)) 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] = SVFIELD (check, origin, vector)[j]
+ 0.5 * (SVFIELD (check, mins, vector)[j] + SVFIELD (check, maxs, vector)[j]);
VectorSubtract (end, start, dir);
VectorNormalize (dir);
dist = DotProduct (dir, pr->pr_global_struct->v_forward);
dist = DotProduct (dir, *sv_globals.v_forward);
if (dist < bestdist)
continue; // to far to turn
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
@ -1458,9 +1459,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 (SVFIELD (bestent, origin, vector), SVFIELD (ent, origin, vector), dir);
dist = DotProduct (dir, *sv_globals.v_forward);
VectorScale (*sv_globals.v_forward, dist, end);
end[2] = dir[2];
VectorNormalize (end);
VectorCopy (end, G_VECTOR (pr, OFS_RETURN));
@ -1482,10 +1483,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, *sv_globals.self);
current = anglemod (SVFIELD (ent, angles, vector)[1]);
ideal = SVFIELD (ent, ideal_yaw, float);
speed = SVFIELD (ent, yaw_speed, float);
if (current == ideal)
return;
@ -1505,7 +1506,7 @@ PF_changeyaw (progs_t * pr)
move = -speed;
}
ent->v.v.angles[1] = anglemod (current + move);
SVFIELD (ent, angles, vector)[1] = anglemod (current + move);
}
#ifdef QUAKE2
@ -1521,9 +1522,9 @@ PF_changepitch (progs_t * pr)
float ideal, current, move, speed;
ent = G_EDICT (pr, OFS_PARM0);
current = anglemod (ent->v.v.angles[0]);
ideal = ent->v.v.idealpitch;
speed = ent->v.v.pitch_speed;
current = anglemod (SVFIELD (ent, angles, float)[0]);
ideal = SVFIELD (ent, idealpitch, float);
speed = SVFIELD (ent, pitch_speed, float);
if (current == ideal)
return;
@ -1543,7 +1544,7 @@ PF_changepitch (progs_t * pr)
move = -speed;
}
ent->v.v.angles[0] = anglemod (current + move);
SVFIELD (ent, angles, float)[0] = anglemod (current + move);
}
#endif
@ -1573,7 +1574,7 @@ WriteDest (progs_t * pr)
return &sv.datagram;
case MSG_ONE:
ent = PROG_TO_EDICT (pr, pr->pr_global_struct->msg_entity);
ent = PROG_TO_EDICT (pr, *sv_globals.msg_entity);
entnum = NUM_FOR_EDICT (pr, ent);
if (entnum < 1 || entnum > svs.maxclients)
PR_RunError (pr, "WriteDest: not a client");
@ -1656,14 +1657,14 @@ PF_makestatic (progs_t * pr)
MSG_WriteByte (&sv.signon, svc_spawnstatic);
MSG_WriteByte (&sv.signon, SV_ModelIndex (pr->pr_strings + ent->v.v.model));
MSG_WriteByte (&sv.signon, SV_ModelIndex (pr->pr_strings + SVFIELD (ent, model, string)));
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, SVFIELD (ent, frame, float));
MSG_WriteByte (&sv.signon, SVFIELD (ent, colormap, float));
MSG_WriteByte (&sv.signon, SVFIELD (ent, skin, float));
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, SVFIELD (ent, origin, vector)[i]);
MSG_WriteAngle (&sv.signon, SVFIELD (ent, angles, vector)[i]);
}
// throw the entity away now
@ -1693,7 +1694,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];
sv_globals.parms[i] = client->spawn_parms[i];
}
/*
@ -1714,7 +1715,7 @@ PF_changelevel (progs_t * pr)
s1 = G_STRING (pr, OFS_PARM0);
s2 = G_STRING (pr, OFS_PARM1);
if ((int) pr->pr_global_struct->
if ((int) *sv_globals.
serverflags & (SFL_NEW_UNIT | SFL_NEW_EPISODE))
Cbuf_AddText (va ("changelevel %s %s\n", s1, s2));
else
@ -1758,51 +1759,51 @@ PF_WaterMove (progs_t * pr)
float drownlevel;
float damage = 0.0;
self = PROG_TO_EDICT (pr, pr->pr_global_struct->self);
self = PROG_TO_EDICT (pr, *sv_globals.self);
if (self->v.v.movetype == MOVETYPE_NOCLIP) {
self->v.v.air_finished = sv.time + 12;
if (SVFIELD (self, movetype, float) == MOVETYPE_NOCLIP) {
SVFIELD (self, air_finished, float) = sv.time + 12;
G_FLOAT (pr, OFS_RETURN) = damage;
return;
}
if (self->v.v.health < 0) {
if (SVFIELD (self, health, float) < 0) {
G_FLOAT (pr, OFS_RETURN) = damage;
return;
}
if (self->v.v.deadflag == DEAD_NO)
if (SVFIELD (self, deadflag, float) == DEAD_NO)
drownlevel = 3;
else
drownlevel = 1;
flags = (int) self->v.v.flags;
waterlevel = (int) self->v.v.waterlevel;
watertype = (int) self->v.v.watertype;
flags = (int) SVFIELD (self, flags, float);
waterlevel = (int) SVFIELD (self, waterlevel, float);
watertype = (int) SVFIELD (self, watertype, float);
if (!(flags & (FL_IMMUNE_WATER + FL_GODMODE)))
if (((flags & FL_SWIM) && (waterlevel < drownlevel))
|| (waterlevel >= drownlevel)) {
if (self->v.v.air_finished < sv.time)
if (self->v.v.pain_finished < sv.time) {
self->v.v.dmg = self->v.v.dmg + 2;
if (self->v.v.dmg > 15)
self->v.v.dmg = 10;
if (SVFIELD (self, air_finished, float) < sv.time)
if (SVFIELD (self, pain_finished, float) < sv.time) {
SVFIELD (self, dmg, float) = SVFIELD (self, dmg, float) + 2;
if (SVFIELD (self, dmg, float) > 15)
SVFIELD (self, dmg, float) = 10;
// T_Damage (self, world, world, self.dmg, 0, FALSE);
damage = self->v.v.dmg;
self->v.v.pain_finished = sv.time + 1.0;
damage = SVFIELD (self, dmg, float);
SVFIELD (self, pain_finished, float) = sv.time + 1.0;
}
} else {
if (self->v.v.air_finished < sv.time)
if (SVFIELD (self, air_finished, float) < sv.time)
// sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
SV_StartSound (self, CHAN_VOICE, "player/gasp2.wav", 255,
ATTN_NORM);
else if (self->v.v.air_finished < sv.time + 9)
else if (SVFIELD (self, air_finished, float) < sv.time + 9)
// sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
SV_StartSound (self, CHAN_VOICE, "player/gasp1.wav", 255,
ATTN_NORM);
self->v.v.air_finished = sv.time + 12.0;
self->v.v.dmg = 2;
SVFIELD (self, air_finished, float) = sv.time + 12.0;
SVFIELD (self, dmg, float) = 2;
}
if (!waterlevel) {
@ -1811,28 +1812,28 @@ PF_WaterMove (progs_t * pr)
// sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
SV_StartSound (self, CHAN_BODY, "misc/outwater.wav", 255,
ATTN_NORM);
self->v.v.flags = (float) (flags & ~FL_INWATER);
SVFIELD (self, flags, float) = (float) (flags & ~FL_INWATER);
}
self->v.v.air_finished = sv.time + 12.0;
SVFIELD (self, air_finished, float) = sv.time + 12.0;
G_FLOAT (pr, OFS_RETURN) = damage;
return;
}
if (watertype == CONTENT_LAVA) { // do damage
if (!(flags & (FL_IMMUNE_LAVA + FL_GODMODE)))
if (self->v.v.dmgtime < sv.time) {
if (self->v.v.radsuit_finished < sv.time)
self->v.v.dmgtime = sv.time + 0.2;
if (SVFIELD (self, dmgtime, float) < sv.time) {
if (SVFIELD (self, radsuit_finished, float) < sv.time)
SVFIELD (self, dmgtime, float) = sv.time + 0.2;
else
self->v.v.dmgtime = sv.time + 1.0;
SVFIELD (self, dmgtime, float) = sv.time + 1.0;
// T_Damage (self, world, world, 10*self.waterlevel, 0, TRUE);
damage = (float) (10 * waterlevel);
}
} else if (watertype == CONTENT_SLIME) { // do damage
if (!(flags & (FL_IMMUNE_SLIME + FL_GODMODE)))
if (self->v.v.dmgtime < sv.time
&& self->v.v.radsuit_finished < sv.time) {
self->v.v.dmgtime = sv.time + 1.0;
if (SVFIELD (self, dmgtime, float) < sv.time
&& SVFIELD (self, radsuit_finished, float) < sv.time) {
SVFIELD (self, dmgtime, float) = sv.time + 1.0;
// T_Damage (self, world, world, 4*self.waterlevel, 0, TRUE);
damage = (float) (4 * waterlevel);
}
@ -1853,15 +1854,15 @@ PF_WaterMove (progs_t * pr)
SV_StartSound (self, CHAN_BODY, "player/slimbrn2.wav", 255,
ATTN_NORM);
self->v.v.flags = (float) (flags | FL_INWATER);
self->v.v.dmgtime = 0;
SVFIELD (self, flags, float) = (float) (flags | FL_INWATER);
SVFIELD (self, dmgtime, float) = 0;
}
if (!(flags & FL_WATERJUMP)) {
// self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
VectorMA (self->v.v.velocity,
-0.8 * self->v.v.waterlevel * host_frametime,
self->v.v.velocity, self->v.v.velocity);
VectorMA (SVFIELD (self, velocity, float),
-0.8 * SVFIELD (self, waterlevel, float) * host_frametime,
SVFIELD (self, velocity, float), SVFIELD (self, velocity, float));
}
G_FLOAT (pr, OFS_RETURN) = damage;

View file

@ -38,6 +38,7 @@
#include "cmd.h"
#include "host.h"
#include "world.h"
#include "sv_progs.h"
server_t sv;
server_static_t svs;
@ -178,8 +179,8 @@ SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
MSG_WriteByte (&sv.datagram, sound_num);
for (i = 0; i < 3; i++)
MSG_WriteCoord (&sv.datagram,
entity->v.v.origin[i] + 0.5 * (entity->v.v.mins[i] +
entity->v.v.maxs[i]));
SVFIELD (entity, origin, vector)[i] + 0.5 * (SVFIELD (entity, mins, vector)[i] +
SVFIELD (entity, maxs, vector)[i]));
}
/*
@ -219,7 +220,7 @@ SV_SendServerinfo (client_t *client)
MSG_WriteByte (&client->message, GAME_COOP);
snprintf (message, sizeof (message),
sv_pr_state.pr_strings + sv.edicts->v.v.message);
sv_pr_state.pr_strings + SVFIELD (sv.edicts, message, string));
MSG_WriteString (&client->message, message);
@ -233,8 +234,8 @@ SV_SendServerinfo (client_t *client)
// send music
MSG_WriteByte (&client->message, svc_cdtrack);
MSG_WriteByte (&client->message, sv.edicts->v.v.sounds);
MSG_WriteByte (&client->message, sv.edicts->v.v.sounds);
MSG_WriteByte (&client->message, SVFIELD (sv.edicts, sounds, float));
MSG_WriteByte (&client->message, SVFIELD (sv.edicts, sounds, float));
// set view
MSG_WriteByte (&client->message, svc_setview);
@ -297,9 +298,9 @@ SV_ConnectClient (int clientnum)
else {
// call the progs to get default spawn parms for the new client
PR_ExecuteProgram (&sv_pr_state,
sv_pr_state.pr_global_struct->SetNewParms);
sv_funcs.SetNewParms);
for (i = 0; i < NUM_SPAWN_PARMS; i++)
client->spawn_parms[i] = (&sv_pr_state.pr_global_struct->parm1)[i];
client->spawn_parms[i] = sv_globals.parms[i];
}
SV_SendServerinfo (client);
@ -447,7 +448,7 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
edict_t *ent;
// find the client's PVS
VectorAdd (clent->v.v.origin, clent->v.v.view_ofs, org);
VectorAdd (SVFIELD (clent, origin, vector), SVFIELD (clent, view_ofs, vector), org);
pvs = SV_FatPVS (org);
// send over all entities (excpet the client) that touch the pvs
@ -455,7 +456,7 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
for (e = 1; e < sv.num_edicts; e++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
#ifdef QUAKE2
// don't send if flagged for NODRAW and there are no lighting effects
if (ent->v.v.effects == EF_NODRAW)
if (SVFIELD (ent, effects, float) == EF_NODRAW)
continue;
#endif
@ -463,7 +464,7 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
if (ent != clent) // clent is ALLWAYS sent
{
// ignore ents without visible models
if (!ent->v.v.modelindex || !sv_pr_state.pr_strings[ent->v.v.model])
if (!SVFIELD (ent, modelindex, float) || !sv_pr_state.pr_strings[SVFIELD (ent, model, string)])
continue;
for (i = 0; i < ent->num_leafs; i++)
@ -482,36 +483,36 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
bits = 0;
for (i = 0; i < 3; i++) {
miss = ent->v.v.origin[i] - ent->baseline.origin[i];
miss = SVFIELD (ent, origin, vector)[i] - ((entity_state_t*)ent->data)->origin[i];
if (miss < -0.1 || miss > 0.1)
bits |= U_ORIGIN1 << i;
}
if (ent->v.v.angles[0] != ent->baseline.angles[0])
if (SVFIELD (ent, angles, vector)[0] != ((entity_state_t*)ent->data)->angles[0])
bits |= U_ANGLE1;
if (ent->v.v.angles[1] != ent->baseline.angles[1])
if (SVFIELD (ent, angles, vector)[1] != ((entity_state_t*)ent->data)->angles[1])
bits |= U_ANGLE2;
if (ent->v.v.angles[2] != ent->baseline.angles[2])
if (SVFIELD (ent, angles, vector)[2] != ((entity_state_t*)ent->data)->angles[2])
bits |= U_ANGLE3;
if (ent->v.v.movetype == MOVETYPE_STEP)
if (SVFIELD (ent, movetype, float) == MOVETYPE_STEP)
bits |= U_NOLERP; // don't mess up the step animation
if (ent->baseline.colormap != ent->v.v.colormap)
if (((entity_state_t*)ent->data)->colormap != SVFIELD (ent, colormap, float))
bits |= U_COLORMAP;
if (ent->baseline.skin != ent->v.v.skin)
if (((entity_state_t*)ent->data)->skin != SVFIELD (ent, skin, float))
bits |= U_SKIN;
if (ent->baseline.frame != ent->v.v.frame)
if (((entity_state_t*)ent->data)->frame != SVFIELD (ent, frame, float))
bits |= U_FRAME;
if (ent->baseline.effects != ent->v.v.effects)
if (((entity_state_t*)ent->data)->effects != SVFIELD (ent, effects, float))
bits |= U_EFFECTS;
if (ent->baseline.modelindex != ent->v.v.modelindex)
if (((entity_state_t*)ent->data)->modelindex != SVFIELD (ent, modelindex, float))
bits |= U_MODEL;
if (e >= 256)
@ -533,27 +534,27 @@ SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
MSG_WriteByte (msg, e);
if (bits & U_MODEL)
MSG_WriteByte (msg, ent->v.v.modelindex);
MSG_WriteByte (msg, SVFIELD (ent, modelindex, float));
if (bits & U_FRAME)
MSG_WriteByte (msg, ent->v.v.frame);
MSG_WriteByte (msg, SVFIELD (ent, frame, float));
if (bits & U_COLORMAP)
MSG_WriteByte (msg, ent->v.v.colormap);
MSG_WriteByte (msg, SVFIELD (ent, colormap, float));
if (bits & U_SKIN)
MSG_WriteByte (msg, ent->v.v.skin);
MSG_WriteByte (msg, SVFIELD (ent, skin, float));
if (bits & U_EFFECTS)
MSG_WriteByte (msg, ent->v.v.effects);
MSG_WriteByte (msg, SVFIELD (ent, effects, float));
if (bits & U_ORIGIN1)
MSG_WriteCoord (msg, ent->v.v.origin[0]);
MSG_WriteCoord (msg, SVFIELD (ent, origin, vector)[0]);
if (bits & U_ANGLE1)
MSG_WriteAngle (msg, ent->v.v.angles[0]);
MSG_WriteAngle (msg, SVFIELD (ent, angles, vector)[0]);
if (bits & U_ORIGIN2)
MSG_WriteCoord (msg, ent->v.v.origin[1]);
MSG_WriteCoord (msg, SVFIELD (ent, origin, vector)[1]);
if (bits & U_ANGLE2)
MSG_WriteAngle (msg, ent->v.v.angles[1]);
MSG_WriteAngle (msg, SVFIELD (ent, angles, vector)[1]);
if (bits & U_ORIGIN3)
MSG_WriteCoord (msg, ent->v.v.origin[2]);
MSG_WriteCoord (msg, SVFIELD (ent, origin, vector)[2]);
if (bits & U_ANGLE3)
MSG_WriteAngle (msg, ent->v.v.angles[2]);
MSG_WriteAngle (msg, SVFIELD (ent, angles, vector)[2]);
}
}
@ -571,7 +572,7 @@ SV_CleanupEnts (void)
ent = NEXT_EDICT (&sv_pr_state, sv.edicts);
for (e = 1; e < sv.num_edicts; e++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
ent->v.v.effects = (int) ent->v.v.effects & ~EF_MUZZLEFLASH;
SVFIELD (ent, effects, float) = (int) SVFIELD (ent, effects, float) & ~EF_MUZZLEFLASH;
}
}
@ -597,18 +598,18 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
//
// send a damage message
//
if (ent->v.v.dmg_take || ent->v.v.dmg_save) {
other = PROG_TO_EDICT (&sv_pr_state, ent->v.v.dmg_inflictor);
if (SVFIELD (ent, dmg_take, float) || SVFIELD (ent, dmg_save, float)) {
other = PROG_TO_EDICT (&sv_pr_state, SVFIELD (ent, dmg_inflictor, entity));
MSG_WriteByte (msg, svc_damage);
MSG_WriteByte (msg, ent->v.v.dmg_save);
MSG_WriteByte (msg, ent->v.v.dmg_take);
MSG_WriteByte (msg, SVFIELD (ent, dmg_save, float));
MSG_WriteByte (msg, SVFIELD (ent, dmg_take, float));
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]));
SVFIELD (other, origin, vector)[i] + 0.5 * (SVFIELD (other, mins, vector)[i] +
SVFIELD (other, maxs, vector)[i]));
ent->v.v.dmg_take = 0;
ent->v.v.dmg_save = 0;
SVFIELD (ent, dmg_take, float) = 0;
SVFIELD (ent, dmg_save, float) = 0;
}
//
// send the current viewpos offset from the view entity
@ -616,58 +617,57 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
SV_SetIdealPitch (); // how much to look up / down ideally
// a fixangle might get lost in a dropped packet. Oh well.
if (ent->v.v.fixangle) {
if (SVFIELD (ent, fixangle, float)) {
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, SVFIELD (ent, angles, vector)[i]);
SVFIELD (ent, fixangle, float) = 0;
}
bits = 0;
if (ent->v.v.view_ofs[2] != DEFAULT_VIEWHEIGHT)
if (SVFIELD (ent, view_ofs, vector)[2] != DEFAULT_VIEWHEIGHT)
bits |= SU_VIEWHEIGHT;
if (ent->v.v.idealpitch)
if (SVFIELD (ent, idealpitch, float))
bits |= SU_IDEALPITCH;
// stuff the sigil bits into the high bits of items for sbar, or else
// mix in items2
#ifdef QUAKE2
items = (int) ent->v.v.items | ((int) ent->v.v.items2 << 23);
items = (int) SVFIELD (ent, items, float) | ((int) SVFIELD (ent, items2, float) << 23);
#else
val = GetEdictFieldValue (&sv_pr_state, ent, "items2");
if (val)
items = (int) ent->v.v.items | ((int) val->_float << 23);
items = (int) SVFIELD (ent, items, float) | ((int) val->_float << 23);
else
items =
(int) ent->v.v.items | ((int) sv_pr_state.
pr_global_struct->serverflags << 28);
(int) SVFIELD (ent, items, float) | ((int) sv_globals.serverflags << 28);
#endif
bits |= SU_ITEMS;
if ((int) ent->v.v.flags & FL_ONGROUND)
if ((int) SVFIELD (ent, flags, float) & FL_ONGROUND)
bits |= SU_ONGROUND;
if (ent->v.v.waterlevel >= 2)
if (SVFIELD (ent, waterlevel, float) >= 2)
bits |= SU_INWATER;
for (i = 0; i < 3; i++) {
if (ent->v.v.punchangle[i])
if (SVFIELD (ent, punchangle, vector)[i])
bits |= (SU_PUNCH1 << i);
if (ent->v.v.velocity[i])
if (SVFIELD (ent, velocity, vector)[i])
bits |= (SU_VELOCITY1 << i);
}
if (ent->v.v.weaponframe)
if (SVFIELD (ent, weaponframe, float))
bits |= SU_WEAPONFRAME;
if (ent->v.v.armorvalue)
if (SVFIELD (ent, armorvalue, float))
bits |= SU_ARMOR;
// if (ent->v.v.weapon)
// if (SVFIELD (ent, weapon, float))
bits |= SU_WEAPON;
// send the data
@ -676,42 +676,42 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
MSG_WriteShort (msg, bits);
if (bits & SU_VIEWHEIGHT)
MSG_WriteChar (msg, ent->v.v.view_ofs[2]);
MSG_WriteChar (msg, SVFIELD (ent, view_ofs, vector)[2]);
if (bits & SU_IDEALPITCH)
MSG_WriteChar (msg, ent->v.v.idealpitch);
MSG_WriteChar (msg, SVFIELD (ent, idealpitch, float));
for (i = 0; i < 3; i++) {
if (bits & (SU_PUNCH1 << i))
MSG_WriteChar (msg, ent->v.v.punchangle[i]);
MSG_WriteChar (msg, SVFIELD (ent, punchangle, vector)[i]);
if (bits & (SU_VELOCITY1 << i))
MSG_WriteChar (msg, ent->v.v.velocity[i] / 16);
MSG_WriteChar (msg, SVFIELD (ent, velocity, vector)[i] / 16);
}
// [always sent] if (bits & SU_ITEMS)
MSG_WriteLong (msg, items);
if (bits & SU_WEAPONFRAME)
MSG_WriteByte (msg, ent->v.v.weaponframe);
MSG_WriteByte (msg, SVFIELD (ent, weaponframe, float));
if (bits & SU_ARMOR)
MSG_WriteByte (msg, ent->v.v.armorvalue);
MSG_WriteByte (msg, SVFIELD (ent, armorvalue, float));
if (bits & SU_WEAPON)
MSG_WriteByte (msg,
SV_ModelIndex (sv_pr_state.pr_strings +
ent->v.v.weaponmodel));
SVFIELD (ent, weaponmodel, string)));
MSG_WriteShort (msg, ent->v.v.health);
MSG_WriteByte (msg, ent->v.v.currentammo);
MSG_WriteByte (msg, ent->v.v.ammo_shells);
MSG_WriteByte (msg, ent->v.v.ammo_nails);
MSG_WriteByte (msg, ent->v.v.ammo_rockets);
MSG_WriteByte (msg, ent->v.v.ammo_cells);
MSG_WriteShort (msg, SVFIELD (ent, health, float));
MSG_WriteByte (msg, SVFIELD (ent, currentammo, float));
MSG_WriteByte (msg, SVFIELD (ent, ammo_shells, float));
MSG_WriteByte (msg, SVFIELD (ent, ammo_nails, float));
MSG_WriteByte (msg, SVFIELD (ent, ammo_rockets, float));
MSG_WriteByte (msg, SVFIELD (ent, ammo_cells, float));
if (standard_quake) {
MSG_WriteByte (msg, ent->v.v.weapon);
MSG_WriteByte (msg, SVFIELD (ent, weapon, float));
} else {
for (i = 0; i < 32; i++) {
if (((int) ent->v.v.weapon) & (1 << i)) {
if (((int) SVFIELD (ent, weapon, float)) & (1 << i)) {
MSG_WriteByte (msg, i);
break;
}
@ -771,17 +771,17 @@ SV_UpdateToReliableMessages (void)
// check for changes to be sent over the reliable streams
for (i = 0, host_client = svs.clients; i < svs.maxclients;
i++, host_client++) {
if (host_client->old_frags != host_client->edict->v.v.frags) {
if (host_client->old_frags != SVFIELD (host_client->edict, frags, float)) {
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) {
if (!client->active)
continue;
MSG_WriteByte (&client->message, svc_updatefrags);
MSG_WriteByte (&client->message, i);
MSG_WriteShort (&client->message,
host_client->edict->v.v.frags);
SVFIELD (host_client->edict, frags, float));
}
host_client->old_frags = host_client->edict->v.v.frags;
host_client->old_frags = SVFIELD (host_client->edict, frags, float);
}
}
@ -942,23 +942,23 @@ SV_CreateBaseline (void)
svent = EDICT_NUM (&sv_pr_state, entnum);
if (svent->free)
continue;
if (entnum > svs.maxclients && !svent->v.v.modelindex)
if (entnum > svs.maxclients && !SVFIELD (svent, modelindex, float))
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.skin = svent->v.v.skin;
VectorCopy (SVFIELD (svent, origin, vector), ((entity_state_t*)svent->data)->origin);
VectorCopy (SVFIELD (svent, angles, vector), ((entity_state_t*)svent->data)->angles);
((entity_state_t*)svent->data)->frame = SVFIELD (svent, frame, float);
((entity_state_t*)svent->data)->skin = SVFIELD (svent, skin, float);
if (entnum > 0 && entnum <= svs.maxclients) {
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 (sv_pr_state.pr_strings + svent->v.v.model);
((entity_state_t*)svent->data)->colormap = 0;
((entity_state_t*)svent->data)->modelindex =
SV_ModelIndex (sv_pr_state.pr_strings + SVFIELD (svent, model, string));
}
//
@ -967,13 +967,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.skin);
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)->skin);
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]);
}
}
}
@ -1022,7 +1022,7 @@ SV_SaveSpawnparms (void)
{
int i, j;
svs.serverflags = sv_pr_state.pr_global_struct->serverflags;
svs.serverflags = *sv_globals.serverflags;
for (i = 0, host_client = svs.clients; i < svs.maxclients;
i++, host_client++) {
@ -1030,13 +1030,13 @@ SV_SaveSpawnparms (void)
continue;
// call the progs to get default spawn parms for the new client
sv_pr_state.pr_global_struct->self =
*sv_globals.self =
EDICT_TO_PROG (&sv_pr_state, host_client->edict);
PR_ExecuteProgram (&sv_pr_state,
sv_pr_state.pr_global_struct->SetChangeParms);
sv_funcs.SetChangeParms);
for (j = 0; j < NUM_SPAWN_PARMS; j++)
host_client->spawn_parms[j] =
(&sv_pr_state.pr_global_struct->parm1)[j];
sv_globals.parms[j];
}
}
@ -1164,24 +1164,24 @@ SV_SpawnServer (char *server)
ent = EDICT_NUM (&sv_pr_state, 0);
memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
ent->free = false;
ent->v.v.model = sv.worldmodel->name - sv_pr_state.pr_strings;
ent->v.v.modelindex = 1; // world model
ent->v.v.solid = SOLID_BSP;
ent->v.v.movetype = MOVETYPE_PUSH;
SVFIELD (ent, model, float) = sv.worldmodel->name - sv_pr_state.pr_strings;
SVFIELD (ent, modelindex, float) = 1; // world model
SVFIELD (ent, solid, float) = SOLID_BSP;
SVFIELD (ent, movetype, float) = MOVETYPE_PUSH;
if (coop->int_val)
sv_pr_state.pr_global_struct->coop = coop->int_val;
*sv_globals.coop = coop->int_val;
else
sv_pr_state.pr_global_struct->deathmatch = deathmatch->int_val;
*sv_globals.deathmatch = deathmatch->int_val;
sv_pr_state.pr_global_struct->mapname = sv.name - sv_pr_state.pr_strings;
*sv_globals.mapname = sv.name - sv_pr_state.pr_strings;
#ifdef QUAKE2
sv_pr_state.pr_global_struct->startspot =
*sv_globals.startspot =
sv.startspot - sv_pr_state.pr_strings;
#endif
// serverflags are for cross level information (sigils)
sv_pr_state.pr_global_struct->serverflags = svs.serverflags;
*sv_globals.serverflags = svs.serverflags;
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);

View file

@ -31,6 +31,7 @@
#endif
#include "server.h"
#include "sv_progs.h"
#include "world.h"
#define STEPSIZE 18
@ -54,8 +55,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 (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), mins);
VectorAdd (SVFIELD (ent, origin, vector), SVFIELD (ent, maxs, vector), maxs);
// if all of the points under the corners are solid world, don't bother
// with the tougher checks
@ -128,35 +129,33 @@ 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 (SVFIELD (ent, origin, vector), oldorg);
VectorAdd (SVFIELD (ent, origin, vector), move, neworg);
// flying monsters don't step up
if ((int) ent->v.v.flags & (FL_SWIM | FL_FLY)) {
if ((int) SVFIELD (ent, flags, float) & (FL_SWIM | FL_FLY)) {
// try one move with vertical motion, then one without
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 (SVFIELD (ent, origin, vector), move, neworg);
enemy = PROG_TO_EDICT (&sv_pr_state, SVFIELD (ent, enemy, entity));
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];
SVFIELD (ent, origin, vector)[2] - SVFIELD (enemy, origin, vector)[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,
SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), neworg,
false, ent);
if (trace.fraction == 1) {
if (((int) ent->v.v.flags & FL_SWIM)
if (((int) SVFIELD (ent, flags, float) & FL_SWIM)
&& SV_PointContents (trace.endpos) == CONTENTS_EMPTY)
return false; // swim monster left water
VectorCopy (trace.endpos, ent->v.v.origin);
VectorCopy (trace.endpos, SVFIELD (ent, origin, vector));
if (relink)
SV_LinkEdict (ent, true);
return true;
@ -173,24 +172,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, SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), 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, SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), 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) SVFIELD (ent, flags, float) & FL_PARTIALGROUND) {
VectorAdd (SVFIELD (ent, origin, vector), move, SVFIELD (ent, origin, vector));
if (relink)
SV_LinkEdict (ent, true);
ent->v.v.flags = (int) ent->v.v.flags & ~FL_ONGROUND;
SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) & ~FL_ONGROUND;
// Con_Printf ("fall down\n");
return true;
}
@ -198,10 +197,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, SVFIELD (ent, origin, vector));
if (!SV_CheckBottom (ent)) {
if ((int) ent->v.v.flags & FL_PARTIALGROUND) { // entity had floor
if ((int) SVFIELD (ent, flags, float) & FL_PARTIALGROUND) { // entity had floor
// mostly pulled out
// from underneath it
// and is trying to correct
@ -209,15 +208,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, SVFIELD (ent, origin, vector));
return false;
}
if ((int) ent->v.v.flags & FL_PARTIALGROUND) {
if ((int) SVFIELD (ent, flags, float) & FL_PARTIALGROUND) {
// Con_Printf ("back on ground\n");
ent->v.v.flags = (int) ent->v.v.flags & ~FL_PARTIALGROUND;
SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) & ~FL_PARTIALGROUND;
}
ent->v.v.groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent);
SVFIELD (ent, groundentity, float) = EDICT_TO_PROG (&sv_pr_state, trace.ent);
// the move is ok
if (relink)
@ -244,7 +243,7 @@ SV_StepDirection (edict_t *ent, float yaw, float dist)
vec3_t move, oldorigin;
float delta;
ent->v.v.ideal_yaw = yaw;
SVFIELD (ent, ideal_yaw, float) = yaw;
PF_changeyaw ();
yaw = yaw * M_PI * 2 / 360;
@ -252,12 +251,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 (SVFIELD (ent, origin, vector), oldorigin);
if (SV_movestep (ent, move, false)) {
delta = ent->v.v.angles[YAW] - ent->v.v.ideal_yaw;
delta = SVFIELD (ent, angles, vector)[YAW] - SVFIELD (ent, ideal_yaw, float);
if (delta > 45 && delta < 315) { // not turned far enough, so
// don't take the step
VectorCopy (oldorigin, ent->v.v.origin);
VectorCopy (oldorigin, SVFIELD (ent, origin, vector));
}
SV_LinkEdict (ent, true);
return true;
@ -278,7 +277,7 @@ SV_FixCheckBottom (edict_t *ent)
{
// Con_Printf ("SV_FixCheckBottom\n");
ent->v.v.flags = (int) ent->v.v.flags | FL_PARTIALGROUND;
SVFIELD (ent, flags, float) = (int) SVFIELD (ent, flags, float) | FL_PARTIALGROUND;
}
@ -297,11 +296,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) (SVFIELD (actor, ideal_yaw, float) / 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 = SVFIELD (enemy, origin, vector)[0] - SVFIELD (actor, origin, vector)[0];
deltay = SVFIELD (enemy, origin, vector)[1] - SVFIELD (actor, origin, vector)[1];
if (deltax > 10)
d[1] = 0;
else if (deltax < -10)
@ -357,7 +356,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
SVFIELD (actor, ideal_yaw, float) = olddir; // can't move
// if a bridge was pulled out from underneath a monster, it may not have
// a valid standing position at all
@ -379,9 +378,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 (SVFIELD (goal, absmin, vector)[i] > SVFIELD (ent, absmax, vector)[i] + dist)
return false;
if (goal->v.v.absmax[i] < ent->v.v.absmin[i] - dist)
if (SVFIELD (goal, absmax, vector)[i] < SVFIELD (ent, absmin, vector)[i] - dist)
return false;
}
return true;
@ -403,26 +402,26 @@ SV_MoveToGoal (progs_t * pr)
edict_t *enemy;
#endif
ent = PROG_TO_EDICT (pr, pr->pr_global_struct->self);
goal = PROG_TO_EDICT (pr, ent->v.v.goalentity);
ent = PROG_TO_EDICT (pr, *pr->globals.self);
goal = PROG_TO_EDICT (pr, SVFIELD (ent, goalentity, entity));
dist = G_FLOAT (pr, OFS_PARM0);
if (!((int) ent->v.v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
if (!((int) SVFIELD (ent, flags, float) & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
G_FLOAT (pr, OFS_RETURN) = 0;
return;
}
// if the next step hits the enemy, return immediately
#ifdef QUAKE2
enemy = PROG_TO_EDICT (pr->, ent->v.v.enemy);
enemy = PROG_TO_EDICT (pr->, SVFIELD (ent, enemy, entity));
if (enemy != sv.edicts && SV_CloseEnough (ent, enemy, dist))
#else
if (PROG_TO_EDICT (pr, ent->v.v.enemy) != sv.edicts
if (PROG_TO_EDICT (pr, SVFIELD (ent, enemy, entity)) != sv.edicts
&& SV_CloseEnough (ent, goal, dist))
#endif
return;
// bump around...
if ((rand () & 3) == 1 || !SV_StepDirection (ent, ent->v.v.ideal_yaw, dist)) {
if ((rand () & 3) == 1 || !SV_StepDirection (ent, SVFIELD (ent, ideal_yaw, float), dist)) {
SV_NewChaseDir (ent, goal, dist);
}
}

File diff suppressed because it is too large Load diff

View file

@ -40,17 +40,14 @@
#include "cmd.h"
#include "console.h"
#include "host.h"
#include "progs.h"
#include "server.h"
#include "sv_progs.h"
#include "world.h"
int eval_alpha;
int eval_scale;
int eval_glowsize;
int eval_glowcolor;
int eval_colormod;
progs_t sv_pr_state;
sv_globals_t sv_globals;
sv_funcs_t sv_funcs;
sv_fields_t sv_fields;
cvar_t *r_skyname;
cvar_t *sv_progs;
@ -93,12 +90,6 @@ FindEdictFieldOffsets (progs_t * pr)
EndFrame = 0;
if ((f = ED_FindFunction (&sv_pr_state, "EndFrame")) != NULL)
EndFrame = (func_t) (f - sv_pr_state.pr_functions);
eval_alpha = FindFieldOffset (&sv_pr_state, "alpha");
eval_scale = FindFieldOffset (&sv_pr_state, "scale");
eval_glowsize = FindFieldOffset (&sv_pr_state, "glow_size");
eval_glowcolor = FindFieldOffset (&sv_pr_state, "glow_color");
eval_colormod = FindFieldOffset (&sv_pr_state, "colormod");
}
}
@ -107,16 +98,16 @@ ED_Prune_Edict (progs_t *pr, edict_t *ent)
{
// remove things from different skill levels or deathmatch
if (deathmatch->int_val) {
if (((int) ent->v.v.spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) {
if (((int) SVFIELD (ent, spawnflags, float) & SPAWNFLAG_NOT_DEATHMATCH)) {
return 1;
}
} else if (
(current_skill == 0
&& ((int) ent->v.v.spawnflags & SPAWNFLAG_NOT_EASY))
&& ((int) SVFIELD (ent, spawnflags, float) & SPAWNFLAG_NOT_EASY))
|| (current_skill == 1
&& ((int) ent->v.v.spawnflags & SPAWNFLAG_NOT_MEDIUM))
&& ((int) SVFIELD (ent, spawnflags, float) & SPAWNFLAG_NOT_MEDIUM))
|| (current_skill >= 2
&& ((int) ent->v.v.spawnflags & SPAWNFLAG_NOT_HARD))) {
&& ((int) SVFIELD (ent, spawnflags, float) & SPAWNFLAG_NOT_HARD))) {
return 1;
}
return 0;

View file

@ -39,7 +39,9 @@
#include "view.h"
#include "cmd.h"
#include "host.h"
#include "sv_progs.h"
#include "sys.h"
edict_t *sv_player;
cvar_t *sv_edgefriction;
@ -78,17 +80,17 @@ SV_SetIdealPitch (void)
int i, j;
int step, dir, steps;
if (!((int) sv_player->v.v.flags & FL_ONGROUND))
if (!((int) SVFIELD (sv_player, flags, float) & FL_ONGROUND))
return;
angleval = sv_player->v.v.angles[YAW] * M_PI * 2 / 360;
angleval = SVFIELD (sv_player, angles, vector)[YAW] * M_PI * 2 / 360;
sinval = sin (angleval);
cosval = cos (angleval);
for (i = 0; i < MAX_FORWARD; i++) {
top[0] = sv_player->v.v.origin[0] + cosval * (i + 3) * 12;
top[1] = sv_player->v.v.origin[1] + sinval * (i + 3) * 12;
top[2] = sv_player->v.v.origin[2] + sv_player->v.v.view_ofs[2];
top[0] = SVFIELD (sv_player, origin, vector)[0] + cosval * (i + 3) * 12;
top[1] = SVFIELD (sv_player, origin, vector)[1] + sinval * (i + 3) * 12;
top[2] = SVFIELD (sv_player, origin, vector)[2] + SVFIELD (sv_player, view_ofs, vector)[2];
bottom[0] = top[0];
bottom[1] = top[1];
@ -121,13 +123,13 @@ SV_SetIdealPitch (void)
}
if (!dir) {
sv_player->v.v.idealpitch = 0;
SVFIELD (sv_player, idealpitch, float) = 0;
return;
}
if (steps < 2)
return;
sv_player->v.v.idealpitch = -dir * sv_idealpitchscale->value;
SVFIELD (sv_player, idealpitch, float) = -dir * sv_idealpitchscale->value;
}
@ -155,7 +157,7 @@ SV_UserFriction (void)
// if the leading edge is over a dropoff, increase friction
start[0] = stop[0] = origin[0] + vel[0] / speed * 16;
start[1] = stop[1] = origin[1] + vel[1] / speed * 16;
start[2] = origin[2] + sv_player->v.v.mins[2];
start[2] = origin[2] + SVFIELD (sv_player, mins, vector)[2];
stop[2] = start[2] - 34;
trace = SV_Move (start, vec3_origin, vec3_origin, stop, true, sv_player);
@ -254,12 +256,12 @@ DropPunchAngle (void)
{
float len;
len = VectorNormalize (sv_player->v.v.punchangle);
len = VectorNormalize (SVFIELD (sv_player, punchangle, vector));
len -= 10 * host_frametime;
if (len < 0)
len = 0;
VectorScale (sv_player->v.v.punchangle, len, sv_player->v.v.punchangle);
VectorScale (SVFIELD (sv_player, punchangle, vector), len, SVFIELD (sv_player, punchangle, vector));
}
/*
@ -278,7 +280,7 @@ SV_WaterMove (void)
//
// user intentions
//
AngleVectors (sv_player->v.v.v_angle, forward, right, up);
AngleVectors (SVFIELD (sv_player, v_angle, vector), forward, right, up);
for (i = 0; i < 3; i++)
wishvel[i] = forward[i] * cmd.forwardmove + right[i] * cmd.sidemove;
@ -329,12 +331,12 @@ SV_WaterMove (void)
void
SV_WaterJump (void)
{
if (sv.time > sv_player->v.v.teleport_time || !sv_player->v.v.waterlevel) {
sv_player->v.v.flags = (int) sv_player->v.v.flags & ~FL_WATERJUMP;
sv_player->v.v.teleport_time = 0;
if (sv.time > SVFIELD (sv_player, teleport_time, float) || !SVFIELD (sv_player, waterlevel, float)) {
SVFIELD (sv_player, flags, float) = (int) SVFIELD (sv_player, flags, float) & ~FL_WATERJUMP;
SVFIELD (sv_player, teleport_time, float) = 0;
}
sv_player->v.v.velocity[0] = sv_player->v.v.movedir[0];
sv_player->v.v.velocity[1] = sv_player->v.v.movedir[1];
SVFIELD (sv_player, velocity, vector)[0] = SVFIELD (sv_player, movedir, vector)[0];
SVFIELD (sv_player, velocity, vector)[1] = SVFIELD (sv_player, movedir, vector)[1];
}
@ -351,19 +353,19 @@ SV_AirMove (void)
vec3_t wishvel;
float fmove, smove;
AngleVectors (sv_player->v.v.angles, forward, right, up);
AngleVectors (SVFIELD (sv_player, angles, vector), forward, right, up);
fmove = cmd.forwardmove;
smove = cmd.sidemove;
// hack to not let you back into teleporter
if (sv.time < sv_player->v.v.teleport_time && fmove < 0)
if (sv.time < SVFIELD (sv_player, teleport_time, float) && fmove < 0)
fmove = 0;
for (i = 0; i < 3; i++)
wishvel[i] = forward[i] * fmove + right[i] * smove;
if ((int) sv_player->v.v.movetype != MOVETYPE_WALK)
if ((int) SVFIELD (sv_player, movetype, float) != MOVETYPE_WALK)
wishvel[2] = cmd.upmove;
else
wishvel[2] = 0;
@ -375,7 +377,7 @@ SV_AirMove (void)
wishspeed = sv_maxspeed->value;
}
if (sv_player->v.v.movetype == MOVETYPE_NOCLIP) { // noclip
if (SVFIELD (sv_player, movetype, float) == MOVETYPE_NOCLIP) { // noclip
VectorCopy (wishvel, velocity);
} else if (onground) {
SV_UserFriction ();
@ -400,45 +402,45 @@ SV_ClientThink (void)
{
vec3_t v_angle;
if (sv_player->v.v.movetype == MOVETYPE_NONE)
if (SVFIELD (sv_player, movetype, float) == MOVETYPE_NONE)
return;
onground = (int) sv_player->v.v.flags & FL_ONGROUND;
onground = (int) SVFIELD (sv_player, flags, float) & FL_ONGROUND;
origin = sv_player->v.v.origin;
velocity = sv_player->v.v.velocity;
origin = SVFIELD (sv_player, origin, vector);
velocity = SVFIELD (sv_player, velocity, vector);
DropPunchAngle ();
//
// if dead, behave differently
//
if (sv_player->v.v.health <= 0)
if (SVFIELD (sv_player, health, float) <= 0)
return;
//
// angles
// show 1/3 the pitch angle and all the roll angle
cmd = host_client->cmd;
angles = sv_player->v.v.angles;
angles = SVFIELD (sv_player, angles, vector);
VectorAdd (sv_player->v.v.v_angle, sv_player->v.v.punchangle, v_angle);
VectorAdd (SVFIELD (sv_player, v_angle, vector), SVFIELD (sv_player, punchangle, vector), v_angle);
angles[ROLL] =
V_CalcRoll (sv_player->v.v.angles, sv_player->v.v.velocity) * 4;
if (!sv_player->v.v.fixangle) {
V_CalcRoll (SVFIELD (sv_player, angles, vector), SVFIELD (sv_player, velocity, vector)) * 4;
if (!SVFIELD (sv_player, fixangle, float)) {
angles[PITCH] = -v_angle[PITCH] / 3;
angles[YAW] = v_angle[YAW];
}
if ((int) sv_player->v.v.flags & FL_WATERJUMP) {
if ((int) SVFIELD (sv_player, flags, float) & FL_WATERJUMP) {
SV_WaterJump ();
return;
}
//
// walk
//
if ((sv_player->v.v.waterlevel >= 2)
&& (sv_player->v.v.movetype != MOVETYPE_NOCLIP)) {
if ((SVFIELD (sv_player, waterlevel, float) >= 2)
&& (SVFIELD (sv_player, movetype, float) != MOVETYPE_NOCLIP)) {
SV_WaterMove ();
return;
}
@ -468,7 +470,7 @@ SV_ReadClientMove (usercmd_t *move)
for (i = 0; i < 3; i++)
angle[i] = MSG_ReadAngle (net_message);
VectorCopy (angle, host_client->edict->v.v.v_angle);
VectorCopy (angle, SVFIELD (host_client->edict, v_angle, vector));
// read movement
move->forwardmove = MSG_ReadShort (net_message);
@ -477,16 +479,16 @@ SV_ReadClientMove (usercmd_t *move)
// read buttons
bits = MSG_ReadByte (net_message);
host_client->edict->v.v.button0 = bits & 1;
host_client->edict->v.v.button2 = (bits & 2) >> 1;
SVFIELD (host_client->edict, button0, float) = bits & 1;
SVFIELD (host_client->edict, button2, float) = (bits & 2) >> 1;
i = MSG_ReadByte (net_message);
if (i)
host_client->edict->v.v.impulse = i;
SVFIELD (host_client->edict, impulse, float) = i;
#ifdef QUAKE2
// read light level
host_client->edict->v.v.light_level = MSG_ReadByte (net_message);
SVFIELD (host_client->edict, light_level, float) = MSG_ReadByte (net_message);
#endif
}

View file

@ -36,6 +36,7 @@
#include "server.h"
#include "sys.h"
#include "console.h"
#include "sv_progs.h"
/*
@ -153,11 +154,11 @@ 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) { // explicit hulls in the BSP model
if (ent->v.v.movetype != MOVETYPE_PUSH)
if (SVFIELD (ent, solid, float) == SOLID_BSP) { // explicit hulls in the BSP model
if (SVFIELD (ent, movetype, float) != MOVETYPE_PUSH)
Sys_Error ("SOLID_BSP without MOVETYPE_PUSH");
model = sv.models[(int) ent->v.v.modelindex];
model = sv.models[(int) SVFIELD (ent, modelindex, float)];
if (!model || model->type != mod_brush)
Sys_Error ("MOVETYPE_PUSH with a non bsp model");
@ -172,15 +173,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, SVFIELD (ent, origin, vector), 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 (SVFIELD (ent, mins, vector), maxs, hullmins);
VectorSubtract (SVFIELD (ent, maxs, vector), mins, hullmaxs);
hull = SV_HullForBox (hullmins, hullmaxs);
VectorCopy (ent->v.v.origin, offset);
VectorCopy (SVFIELD (ent, origin, vector), offset);
}
@ -305,35 +306,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 (!SVFIELD (touch, touch, float) || SVFIELD (touch, solid, float) != 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 (SVFIELD (ent, absmin, vector)[0] > SVFIELD (touch, absmax, vector)[0]
|| SVFIELD (ent, absmin, vector)[1] > SVFIELD (touch, absmax, vector)[1]
|| SVFIELD (ent, absmin, vector)[2] > SVFIELD (touch, absmax, vector)[2]
|| SVFIELD (ent, absmax, vector)[0] < SVFIELD (touch, absmin, vector)[0]
|| SVFIELD (ent, absmax, vector)[1] < SVFIELD (touch, absmin, vector)[1]
|| SVFIELD (ent, absmax, vector)[2] < SVFIELD (touch, absmin, vector)[2])
continue;
old_self = sv_pr_state.pr_global_struct->self;
old_other = sv_pr_state.pr_global_struct->other;
old_self = *sv_globals.self;
old_other = *sv_globals.other;
sv_pr_state.pr_global_struct->self =
*sv_globals.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);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.time = sv.time;
PR_ExecuteProgram (&sv_pr_state, SVFIELD (touch, touch, float));
sv_pr_state.pr_global_struct->self = old_self;
sv_pr_state.pr_global_struct->other = old_other;
*sv_globals.self = old_self;
*sv_globals.other = old_other;
}
// recurse down both sides
if (node->axis == -1)
return;
if (ent->v.v.absmax[node->axis] > node->dist)
if (SVFIELD (ent, absmax, vector)[node->axis] > node->dist)
SV_TouchLinks (ent, node->children[0]);
if (ent->v.v.absmin[node->axis] < node->dist)
if (SVFIELD (ent, absmin, vector)[node->axis] < node->dist)
SV_TouchLinks (ent, node->children[1]);
}
@ -371,7 +372,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 (SVFIELD (ent, absmin, vector), SVFIELD (ent, absmax, vector), splitplane);
// recurse down the contacted sides
if (sides & 1)
@ -404,8 +405,8 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
// set the abs box
#ifdef QUAKE2
if (ent->v.v.solid == SOLID_BSP &&
(ent->v.v.angles[0] || ent->v.v.angles[1] || ent->v.v.angles[2])) { // expand
if (SVFIELD (ent, solid, float) == SOLID_BSP &&
(SVFIELD (ent, angles, float)[0] || SVFIELD (ent, angles, float)[1] || SVFIELD (ent, angles, float)[2])) { // expand
//
// for
// rotation
@ -414,50 +415,50 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
max = 0;
for (i = 0; i < 3; i++) {
v = fabs (ent->v.v.mins[i]);
v = fabs (SVFIELD (ent, mins, float)[i]);
if (v > max)
max = v;
v = fabs (ent->v.v.maxs[i]);
v = fabs (SVFIELD (ent, maxs, float)[i]);
if (v > max)
max = v;
}
for (i = 0; i < 3; i++) {
ent->v.v.absmin[i] = ent->v.v.origin[i] - max;
ent->v.v.absmax[i] = ent->v.v.origin[i] + max;
SVFIELD (ent, absmin, float)[i] = SVFIELD (ent, origin, float)[i] - max;
SVFIELD (ent, absmax, float)[i] = SVFIELD (ent, origin, float)[i] + max;
}
} else
#endif
{
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 (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, absmin, vector));
VectorAdd (SVFIELD (ent, origin, vector), SVFIELD (ent, maxs, vector), SVFIELD (ent, absmax, vector));
}
//
// to make items easier to pick up and allow them to be grabbed off
// 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) SVFIELD (ent, flags, float) & FL_ITEM) {
SVFIELD (ent, absmin, vector)[0] -= 15;
SVFIELD (ent, absmin, vector)[1] -= 15;
SVFIELD (ent, absmax, vector)[0] += 15;
SVFIELD (ent, absmax, vector)[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;
SVFIELD (ent, absmin, vector)[0] -= 1;
SVFIELD (ent, absmin, vector)[1] -= 1;
SVFIELD (ent, absmin, vector)[2] -= 1;
SVFIELD (ent, absmax, vector)[0] += 1;
SVFIELD (ent, absmax, vector)[1] += 1;
SVFIELD (ent, absmax, vector)[2] += 1;
}
// link to PVS leafs
ent->num_leafs = 0;
if (ent->v.v.modelindex)
if (SVFIELD (ent, modelindex, float))
SV_FindTouchedLeafs (ent, sv.worldmodel->nodes);
if (ent->v.v.solid == SOLID_NOT)
if (SVFIELD (ent, solid, float) == SOLID_NOT)
return;
// find the first node that the ent's box crosses
@ -465,9 +466,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 (SVFIELD (ent, absmin, vector)[node->axis] > node->dist)
node = node->children[0];
else if (ent->v.v.absmax[node->axis] < node->dist)
else if (SVFIELD (ent, absmax, vector)[node->axis] < node->dist)
node = node->children[1];
else
break; // crosses the node
@ -475,7 +476,7 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
// link it in
if (ent->v.v.solid == SOLID_TRIGGER)
if (SVFIELD (ent, solid, float) == SOLID_TRIGGER)
InsertLinkBefore (&ent->area, &node->trigger_edicts);
else
InsertLinkBefore (&ent->area, &node->solid_edicts);
@ -571,7 +572,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,
SV_Move (SVFIELD (ent, origin, vector), SVFIELD (ent, mins, vector), SVFIELD (ent, maxs, vector), SVFIELD (ent, origin, vector),
0, ent);
if (trace.startsolid)
@ -759,13 +760,13 @@ SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs,
#ifdef QUAKE2
// rotate start and end into the models frame of reference
if (ent->v.v.solid == SOLID_BSP &&
(ent->v.v.angles[0] || ent->v.v.angles[1] || ent->v.v.angles[2])) {
if (SVFIELD (ent, solid, float) == SOLID_BSP &&
(SVFIELD (ent, angles, float)[0] || SVFIELD (ent, angles, float)[1] || SVFIELD (ent, angles, float)[2])) {
vec3_t a;
vec3_t forward, right, up;
vec3_t temp;
AngleVectors (ent->v.v.angles, forward, right, up);
AngleVectors (SVFIELD (ent, angles, float), forward, right, up);
VectorCopy (start_l, temp);
start_l[0] = DotProduct (temp, forward);
@ -785,14 +786,14 @@ SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs,
#ifdef QUAKE2
// rotate endpos back to world frame of reference
if (ent->v.v.solid == SOLID_BSP &&
(ent->v.v.angles[0] || ent->v.v.angles[1] || ent->v.v.angles[2])) {
if (SVFIELD (ent, solid, float) == SOLID_BSP &&
(SVFIELD (ent, angles, float)[0] || SVFIELD (ent, angles, float)[1] || SVFIELD (ent, angles, float)[2])) {
vec3_t a;
vec3_t forward, right, up;
vec3_t temp;
if (trace.fraction != 1) {
VectorSubtract (vec3_origin, ent->v.v.angles, a);
VectorSubtract (vec3_origin, SVFIELD (ent, angles, float), a);
AngleVectors (a, forward, right, up);
VectorCopy (trace.endpos, temp);
@ -839,40 +840,40 @@ 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 (SVFIELD (touch, solid, float) == SOLID_NOT)
continue;
if (touch == clip->passedict)
continue;
if (touch->v.v.solid == SOLID_TRIGGER)
if (SVFIELD (touch, solid, float) == SOLID_TRIGGER)
Sys_Error ("Trigger in clipping list");
if (clip->type == MOVE_NOMONSTERS && touch->v.v.solid != SOLID_BSP)
if (clip->type == MOVE_NOMONSTERS && SVFIELD (touch, solid, float) != 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] > SVFIELD (touch, absmax, vector)[0]
|| clip->boxmins[1] > SVFIELD (touch, absmax, vector)[1]
|| clip->boxmins[2] > SVFIELD (touch, absmax, vector)[2]
|| clip->boxmaxs[0] < SVFIELD (touch, absmin, vector)[0]
|| clip->boxmaxs[1] < SVFIELD (touch, absmin, vector)[1]
|| clip->boxmaxs[2] < SVFIELD (touch, absmin, vector)[2])
continue;
if (clip->passedict && clip->passedict->v.v.size[0]
&& !touch->v.v.size[0])
if (clip->passedict && SVFIELD (clip->passedict, size, vector)[0]
&& !SVFIELD (touch, size, vector)[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) ==
if (PROG_TO_EDICT (&sv_pr_state, SVFIELD (touch, owner, entity)) ==
clip->passedict) continue; // don't clip against own
// missiles
if (PROG_TO_EDICT (&sv_pr_state, clip->passedict->v.v.owner) ==
if (PROG_TO_EDICT (&sv_pr_state, SVFIELD (clip->passedict, owner, entity)) ==
touch) continue; // don't clip against owner
}
if ((int) touch->v.v.flags & FL_MONSTER)
if ((int) SVFIELD (touch, flags, float) & FL_MONSTER)
trace =
SV_ClipMoveToEntity (touch, clip->start, clip->mins2,
clip->maxs2, clip->end);