really clean up global and function access. Unfortunatly, frames are still

borked, at least for the view entity.
This commit is contained in:
Bill Currie 2001-03-01 08:34:30 +00:00
parent c2213f2366
commit ad18afaa3c
15 changed files with 286 additions and 115 deletions

View File

@ -226,12 +226,16 @@ struct progs_s {
void (*flush)(void);
// required globals
float *g_time;
int *g_self;
struct {
float *time;
int *self;
} globals;
// required fields (offsets into the edict)
int f_nextthink;
int f_frame;
int f_think;
struct {
int nextthink;
int frame;
int think;
} fields;
};
#endif // _PROGS_H

View File

@ -863,7 +863,7 @@ ED_LoadFromFile (progs_t * pr, char *data)
ent = NULL;
inhibit = 0;
*pr->g_time = *(pr)->time;
*pr->globals.time = *(pr)->time;
// parse ents
while (1) {
@ -907,7 +907,7 @@ ED_LoadFromFile (progs_t * pr, char *data)
continue;
}
*pr->g_self = EDICT_TO_PROG (pr, ent);
*pr->globals.self = EDICT_TO_PROG (pr, ent);
PR_ExecuteProgram (pr, func - pr->pr_functions);
if (pr->flush)
pr->flush ();
@ -1008,16 +1008,16 @@ PR_LoadProgs (progs_t * pr, char *progsname)
def = PR_FindGlobal (pr, "time");
if (!def)
PR_Error (pr, "%s: undefined symbol: time", progsname);
pr->g_time = &pr->pr_globals[def->ofs].float_var;
pr->globals.time = &pr->pr_globals[def->ofs].float_var;
def = PR_FindGlobal (pr, "self");
if (!def)
PR_Error (pr, "%s: undefined symbol: self", progsname);
pr->g_self = &pr->pr_globals[def->ofs].edict_var;
if (!(pr->f_nextthink = FindFieldOffset (pr, "nextthink")))
pr->globals.self = &pr->pr_globals[def->ofs].edict_var;
if (!(pr->fields.nextthink = FindFieldOffset (pr, "nextthink")))
PR_Error (pr, "%s: undefined field: nextthink", progsname);
if (!(pr->f_frame = FindFieldOffset (pr, "frame")))
if (!(pr->fields.frame = FindFieldOffset (pr, "frame")))
PR_Error (pr, "%s: undefined field: frame", progsname);
if (!(pr->f_think = FindFieldOffset (pr, "think")))
if (!(pr->fields.think = FindFieldOffset (pr, "think")))
PR_Error (pr, "%s: undefined field: think", progsname);
// LordHavoc: Ender added this

View File

@ -352,8 +352,8 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
int profile, startprofile;
if (!fnum || fnum >= pr->progs->numfunctions) {
if (*pr->g_self)
ED_Print (pr, PROG_TO_EDICT (pr, *pr->g_self));
if (*pr->globals.self)
ED_Print (pr, PROG_TO_EDICT (pr, *pr->globals.self));
PR_Error (pr, "PR_ExecuteProgram: NULL function");
}
@ -675,10 +675,10 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
return; // all done
break;
case OP_STATE:
ed = PROG_TO_EDICT (pr, *pr->g_self);
ed->v[pr->f_nextthink].float_var = *pr->time + 0.1;
ed->v[pr->f_frame].float_var = E_OPA->_float;
ed->v[pr->f_think].func_var = E_OPB->function;
ed = PROG_TO_EDICT (pr, *pr->globals.self);
ed->v[pr->fields.nextthink].float_var = *pr->time + 0.1;
ed->v[pr->fields.frame].float_var = E_OPA->_float;
ed->v[pr->fields.think].func_var = E_OPB->function;
break;
// LordHavoc: to be enabled when Progs version 7 (or whatever it will be numbered) is finalized
/*

85
qw/include/sv_progs.h Normal file
View File

@ -0,0 +1,85 @@
/*
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"
#include "progdefs.h"
typedef struct {
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 *parms; // an actual array
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;
} 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;
#endif // __sv_progs_h

View File

@ -41,11 +41,11 @@
#include "bothdefs.h"
#include "cmd.h"
#include "msg.h"
#include "progdefs.h"
#include "qargs.h"
#include "qendian.h"
#include "quakefs.h"
#include "server.h"
#include "sv_progs.h"
#include "sys.h"
#include "va.h"

View File

@ -38,8 +38,8 @@
#include "msg.h"
#include "msg_ucmd.h"
#include "progdefs.h"
#include "server.h"
#include "sv_progs.h"
#include "sys.h"
// LordHavoc: added and removed certain eval_ items

View File

@ -38,9 +38,9 @@
#include "crc.h"
#include "msg.h"
#include "progdefs.h"
#include "quakefs.h"
#include "server.h"
#include "sv_progs.h"
#include "world.h"
#include "va.h"
@ -176,7 +176,7 @@ SV_SaveSpawnparms (void)
return; // no progs loaded yet
// serverflags is the only game related thing maintained
svs.serverflags = ((globalvars_t*)sv_pr_state.pr_globals)->serverflags;
svs.serverflags = *sv_globals.serverflags;
for (i = 0, host_client = svs.clients; i < MAX_CLIENTS; i++, host_client++) {
if (host_client->state != cs_spawned)
@ -186,10 +186,10 @@ SV_SaveSpawnparms (void)
host_client->state = cs_connected;
// call the progs to get default spawn parms for the new client
((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);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, host_client->edict);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.SetChangeParms);
for (j = 0; j < NUM_SPAWN_PARMS; j++)
host_client->spawn_parms[j] = (&((globalvars_t*)sv_pr_state.pr_globals)->parm1)[j];
host_client->spawn_parms[j] = sv_globals.parms[j];
}
}
@ -402,9 +402,9 @@ SV_SpawnServer (char *server)
((entvars_t*)&ent->v)->solid = SOLID_BSP;
((entvars_t*)&ent->v)->movetype = MOVETYPE_PUSH;
((globalvars_t*)sv_pr_state.pr_globals)->mapname = PR_SetString (&sv_pr_state, sv.name);
*sv_globals.mapname = PR_SetString (&sv_pr_state, sv.name);
// serverflags are for cross level information (sigils)
((globalvars_t*)sv_pr_state.pr_globals)->serverflags = svs.serverflags;
*sv_globals.serverflags = svs.serverflags;
// run the frame start qc function to let progs check cvars
SV_ProgStartFrame ();

View File

@ -46,10 +46,10 @@
#include "net.h"
#include "msg.h"
#include "pmove.h"
#include "progdefs.h"
#include "qargs.h"
#include "quakefs.h"
#include "server.h"
#include "sv_progs.h"
#include "sys.h"
#include "va.h"
#include "ver_check.h"
@ -251,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
((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);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, drop->edict);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientDisconnect);
} else if (SpectatorDisconnect) {
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
((globalvars_t*)sv_pr_state.pr_globals)->self = EDICT_TO_PROG (&sv_pr_state, drop->edict);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, drop->edict);
PR_ExecuteProgram (&sv_pr_state, SpectatorDisconnect);
}
}
@ -842,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, ((globalvars_t*)sv_pr_state.pr_globals)->SetNewParms);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.SetNewParms);
for (i = 0; i < NUM_SPAWN_PARMS; i++)
newcl->spawn_parms[i] = (&((globalvars_t*)sv_pr_state.pr_globals)->parm1)[i];
newcl->spawn_parms[i] = sv_globals.parms[i];
if (newcl->spectator)
Con_Printf ("Spectator %s connected\n", newcl->name);

View File

@ -34,10 +34,10 @@
#include <math.h>
#include "qtypes.h"
#include "progdefs.h"
#include "pmove.h"
#include "server.h"
#include "sv_pr_cmds.h"
#include "sv_progs.h"
#include "world.h"
#define STEPSIZE 18
@ -384,7 +384,7 @@ SV_MoveToGoal (progs_t *pr)
edict_t *ent, *goal;
float dist;
ent = PROG_TO_EDICT (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->self);
ent = PROG_TO_EDICT (&sv_pr_state, *sv_globals.self);
goal = PROG_TO_EDICT (&sv_pr_state, ((entvars_t*)&ent->v)->goalentity);
dist = G_FLOAT (&sv_pr_state, OFS_PARM0);

View File

@ -31,9 +31,9 @@
#endif
#include "cvar.h"
#include "progdefs.h"
#include "pmove.h"
#include "server.h"
#include "sv_progs.h"
#include "world.h"
/*
@ -155,9 +155,9 @@ SV_RunThink (edict_t *ent)
// it is possible to start that way
// by a trigger with a local time.
((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);
*sv_globals.time = thinktime;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think);
if (ent->free)
@ -177,24 +177,24 @@ SV_Impact (edict_t *e1, edict_t *e2)
{
int old_self, old_other;
old_self = ((globalvars_t*)sv_pr_state.pr_globals)->self;
old_other = ((globalvars_t*)sv_pr_state.pr_globals)->other;
old_self = *sv_globals.self;
old_other = *sv_globals.other;
((globalvars_t*)sv_pr_state.pr_globals)->time = sv.time;
*sv_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);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, e1);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, e2);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&e1->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);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, e2);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, e1);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&e2->v)->touch);
}
((globalvars_t*)sv_pr_state.pr_globals)->self = old_self;
((globalvars_t*)sv_pr_state.pr_globals)->other = old_other;
*sv_globals.self = old_self;
*sv_globals.other = old_other;
}
@ -514,8 +514,8 @@ SV_Push (edict_t *pusher, vec3_t move)
// if the pusher has a "blocked" function, call it
// otherwise, just stay in place until the obstacle is gone
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);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, pusher);
*sv_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
@ -582,9 +582,9 @@ SV_Physics_Pusher (edict_t *ent)
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);
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think);
if (ent->free)
return;
@ -830,8 +830,8 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push
// Stage 4: Yes, it must be. Fail the move.
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);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, pusher);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, check);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&pusher->v)->blocked);
}
@ -866,9 +866,9 @@ SV_Physics_PPusher (edict_t *ent)
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);
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&ent->v)->think);
if (ent->free)
return;
@ -881,10 +881,10 @@ void
SV_ProgStartFrame (void)
{
// let the progs know that a new frame has started
((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);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
*sv_globals.time = sv.time;
PR_ExecuteProgram (&sv_pr_state, sv_funcs.StartFrame);
}
/*
@ -932,11 +932,11 @@ SV_RunNewmis (void)
{
edict_t *ent;
if (!((globalvars_t*)sv_pr_state.pr_globals)->newmis)
if (!*sv_globals.newmis)
return;
ent = PROG_TO_EDICT (&sv_pr_state, ((globalvars_t*)sv_pr_state.pr_globals)->newmis);
ent = PROG_TO_EDICT (&sv_pr_state, *sv_globals.newmis);
sv_frametime = 0.05;
((globalvars_t*)sv_pr_state.pr_globals)->newmis = 0;
*sv_globals.newmis = 0;
SV_RunEntity (ent);
}
@ -959,7 +959,7 @@ SV_Physics (void)
sv_frametime = sv_maxtic->value;
old_time = realtime;
((globalvars_t*)sv_pr_state.pr_globals)->frametime = sv_frametime;
*sv_globals.frametime = sv_frametime;
SV_ProgStartFrame ();
@ -972,7 +972,7 @@ SV_Physics (void)
if (ent->free)
continue;
if (((globalvars_t*)sv_pr_state.pr_globals)->force_retouch)
if (*sv_globals.force_retouch)
SV_LinkEdict (ent, true); // force retouch even for stationary
if (i > 0 && i <= MAX_CLIENTS)
@ -983,15 +983,15 @@ SV_Physics (void)
SV_RunNewmis ();
}
if (((globalvars_t*)sv_pr_state.pr_globals)->force_retouch)
((globalvars_t*)sv_pr_state.pr_globals)->force_retouch--;
if (*sv_globals.force_retouch)
(*sv_globals.force_retouch)--;
// 2000-01-02 EndFrame function by Maddes/FrikaC start
if (EndFrame) {
// let the progs know that the frame has ended
((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;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
*sv_globals.time = sv.time;
PR_ExecuteProgram (&sv_pr_state, EndFrame);
}
// 2000-01-02 EndFrame function by Maddes/FrikaC end

View File

@ -37,7 +37,7 @@
#include "msg.h"
#include "server.h"
#include "sv_pr_cmds.h"
#include "progdefs.h"
#include "sv_progs.h"
#include "world.h"
#include "va.h"

View File

@ -38,12 +38,19 @@
#endif
#include "cmd.h"
#include "progdefs.h"
#include "progs.h"
#include "server.h"
#include "sv_progs.h"
#include "world.h"
int eval_alpha, eval_scale, eval_glowsize, eval_glowcolor, eval_colormod;
sv_globals_t sv_globals;
sv_funcs_t sv_funcs;
int eval_alpha;
int eval_scale;
int eval_glowsize;
int eval_glowcolor;
int eval_colormod;
progs_t sv_pr_state;
cvar_t *r_skyname;
cvar_t *sv_progs;
@ -151,6 +158,81 @@ SV_LoadProgs (void)
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");
// progs engine needs these globals anyway
sv_globals.self = sv_pr_state.globals.self;
sv_globals.time = sv_pr_state.globals.time;
(void *) sv_globals.other =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "other")->ofs];
(void *) sv_globals.world =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "world")->ofs];
(void *) sv_globals.frametime =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "frametime")->ofs];
(void *) sv_globals.newmis =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "newmis")->ofs];
(void *) sv_globals.force_retouch =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "force_retouch")->ofs];
(void *) sv_globals.mapname =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "mapname")->ofs];
(void *) sv_globals.serverflags =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "serverflags")->ofs];
(void *) sv_globals.total_secrets =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "total_secrets")->ofs];
(void *) sv_globals.total_monsters =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "total_monsters")->ofs];
(void *) sv_globals.found_secrets =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "found_secrets")->ofs];
(void *) sv_globals.killed_monsters =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "killed_monsters")->ofs];
(void *) sv_globals.parms =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "parm1")->ofs];
(void *) sv_globals.v_forward =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "v_forward")->ofs];
(void *) sv_globals.v_up =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "v_up")->ofs];
(void *) sv_globals.v_right =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "v_right")->ofs];
(void *) sv_globals.trace_allsolid =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_allsolid")->ofs];
(void *) sv_globals.trace_startsolid =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_startsolid")->ofs];
(void *) sv_globals.trace_fraction =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_fraction")->ofs];
(void *) sv_globals.trace_endpos =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_endpos")->ofs];
(void *) sv_globals.trace_plane_normal =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_plane_normal")->ofs];
(void *) sv_globals.trace_plane_dist =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_plane_dist")->ofs];
(void *) sv_globals.trace_ent =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_ent")->ofs];
(void *) sv_globals.trace_inopen =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_inopen")->ofs];
(void *) sv_globals.trace_inwater =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "trace_inwater")->ofs];
(void *) sv_globals.msg_entity =
&sv_pr_state.pr_globals[PR_FindGlobal (&sv_pr_state, "msg_entity")->ofs];
sv_funcs.main =
ED_FindFunction (&sv_pr_state, "main") - sv_pr_state.pr_functions;
sv_funcs.StartFrame =
ED_FindFunction (&sv_pr_state, "StartFrame") - sv_pr_state.pr_functions;
sv_funcs.PlayerPreThink =
ED_FindFunction (&sv_pr_state, "PlayerPreThink") - sv_pr_state.pr_functions;
sv_funcs.PlayerPostThink =
ED_FindFunction (&sv_pr_state, "PlayerPostThink") - sv_pr_state.pr_functions;
sv_funcs.ClientKill =
ED_FindFunction (&sv_pr_state, "ClientKill") - sv_pr_state.pr_functions;
sv_funcs.ClientConnect =
ED_FindFunction (&sv_pr_state, "ClientConnect") - sv_pr_state.pr_functions;
sv_funcs.PutClientInServer =
ED_FindFunction (&sv_pr_state, "PutClientInServer") - sv_pr_state.pr_functions;
sv_funcs.ClientDisconnect =
ED_FindFunction (&sv_pr_state, "ClientDisconnect") - sv_pr_state.pr_functions;
sv_funcs.SetNewParms =
ED_FindFunction (&sv_pr_state, "SetNewParms") - sv_pr_state.pr_functions;
sv_funcs.SetChangeParms =
ED_FindFunction (&sv_pr_state, "SetChangeParms") - sv_pr_state.pr_functions;
}
void

View File

@ -39,8 +39,8 @@
#include "bothdefs.h"
#include "msg.h"
#include "progdefs.h"
#include "server.h"
#include "sv_progs.h"
#include "sys.h"
#define CHAN_AUTO 0
@ -558,7 +558,7 @@ SV_UpdateClientStats (client_t *client)
stats[STAT_ACTIVEWEAPON] = ((entvars_t*)&ent->v)->weapon;
// stuff the sigil bits into the high bits of items for sbar
stats[STAT_ITEMS] =
(int) ((entvars_t*)&ent->v)->items | ((int) ((globalvars_t*)sv_pr_state.pr_globals)->serverflags << 28);
(int) ((entvars_t*)&ent->v)->items | ((int) *sv_globals.serverflags << 28);
// Extensions to the QW 2.40 protocol for Mega2k --KB
stats[STAT_VIEWHEIGHT] = (int) ((entvars_t*)&ent->v)->view_ofs[2];

View File

@ -47,10 +47,10 @@
#include "cvar.h"
#include "msg.h"
#include "msg_ucmd.h"
#include "progdefs.h"
#include "pmove.h"
#include "quakefs.h"
#include "server.h"
#include "sv_progs.h"
#include "sys.h"
#include "va.h"
#include "world.h"
@ -399,19 +399,19 @@ SV_Spawn_f (void)
ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
ClientReliableWrite_Byte (host_client, STAT_TOTALSECRETS);
ClientReliableWrite_Long (host_client, ((globalvars_t*)sv_pr_state.pr_globals)->total_secrets);
ClientReliableWrite_Long (host_client, *sv_globals.total_secrets);
ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
ClientReliableWrite_Byte (host_client, STAT_TOTALMONSTERS);
ClientReliableWrite_Long (host_client, ((globalvars_t*)sv_pr_state.pr_globals)->total_monsters);
ClientReliableWrite_Long (host_client, *sv_globals.total_monsters);
ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
ClientReliableWrite_Byte (host_client, STAT_SECRETS);
ClientReliableWrite_Long (host_client, ((globalvars_t*)sv_pr_state.pr_globals)->found_secrets);
ClientReliableWrite_Long (host_client, *sv_globals.found_secrets);
ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
ClientReliableWrite_Byte (host_client, STAT_MONSTERS);
ClientReliableWrite_Long (host_client, ((globalvars_t*)sv_pr_state.pr_globals)->killed_monsters);
ClientReliableWrite_Long (host_client, *sv_globals.killed_monsters);
// get the client to check and download skins
// when that is completed, a begin command will be issued
@ -470,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++)
(&((globalvars_t*)sv_pr_state.pr_globals)->parm1)[i] = host_client->spawn_parms[i];
sv_globals.parms[i] = host_client->spawn_parms[i];
// call the spawn function
((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);
*sv_globals.time = sv.time;
*sv_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++)
(&((globalvars_t*)sv_pr_state.pr_globals)->parm1)[i] = host_client->spawn_parms[i];
sv_globals.parms[i] = host_client->spawn_parms[i];
// call the spawn function
((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);
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientConnect);
// actually spawn the 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, ((globalvars_t*)sv_pr_state.pr_globals)->PutClientInServer);
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.PutClientInServer);
}
// clear the net statistics, because connecting gives a bogus picture
@ -907,9 +907,9 @@ SV_Kill_f (void)
return;
}
((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);
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientKill);
}
/*
@ -1484,13 +1484,13 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
sv_frametime = min (0.1, ucmd->msec * 0.001);
if (!host_client->spectator) {
((globalvars_t*)sv_pr_state.pr_globals)->frametime = sv_frametime;
*sv_globals.frametime = sv_frametime;
((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_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state,
sv_player);
PR_ExecuteProgram (&sv_pr_state,
((globalvars_t*)sv_pr_state.pr_globals)->PlayerPreThink);
sv_funcs.PlayerPreThink);
SV_RunThink (sv_player);
}
@ -1576,8 +1576,8 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
ent = EDICT_NUM (&sv_pr_state, n);
if (!((entvars_t*)&ent->v)->touch || (playertouch[n / 8] & (1 << (n % 8))))
continue;
((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);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_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);
}
@ -1595,15 +1595,15 @@ SV_PostRunCmd (void)
// run post-think
if (!host_client->spectator) {
((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_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state,
sv_player);
PR_ExecuteProgram (&sv_pr_state,
((globalvars_t*)sv_pr_state.pr_globals)->PlayerPostThink);
sv_funcs.PlayerPostThink);
SV_RunNewmis ();
} else if (SpectatorThink) {
((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_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state,
sv_player);
PR_ExecuteProgram (&sv_pr_state, SpectatorThink);
}

View File

@ -41,8 +41,8 @@
#include "commdef.h"
#include "console.h"
#include "crc.h"
#include "progdefs.h"
#include "server.h"
#include "sv_progs.h"
#include "world.h"
/*
@ -289,16 +289,16 @@ SV_TouchLinks (edict_t *ent, areanode_t *node)
|| ((entvars_t*)&ent->v)->absmax[2] < ((entvars_t*)&touch->v)->absmin[2])
continue;
old_self = ((globalvars_t*)sv_pr_state.pr_globals)->self;
old_other = ((globalvars_t*)sv_pr_state.pr_globals)->other;
old_self = *sv_globals.self;
old_other = *sv_globals.other;
((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;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, touch);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, ent);
*sv_globals.time = sv.time;
PR_ExecuteProgram (&sv_pr_state, ((entvars_t*)&touch->v)->touch);
((globalvars_t*)sv_pr_state.pr_globals)->self = old_self;
((globalvars_t*)sv_pr_state.pr_globals)->other = old_other;
*sv_globals.self = old_self;
*sv_globals.other = old_other;
}
// recurse down both sides