mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-10 06:42:26 +00:00
progs modularity improvements. what WAS sv_progs is now sv_pr_state, qwprog is
now sv_progs and the progs loading code no longer falls back to qwprogs.dat or progs.dat. Also, call SV_Progs_Init_Cvars (forgot to do this earlier)
This commit is contained in:
parent
3c18a79299
commit
a24894dc70
13 changed files with 216 additions and 210 deletions
|
@ -71,9 +71,10 @@ typedef struct progs_s progs_t;
|
|||
//============================================================================
|
||||
|
||||
void PR_Init (void);
|
||||
void PR_Init_Cvars (void);
|
||||
|
||||
void PR_ExecuteProgram (progs_t *pr, func_t fnum);
|
||||
void PR_LoadProgs (progs_t *pr);
|
||||
void PR_LoadProgs (progs_t *pr, char *progsname);
|
||||
|
||||
void PR_Profile_f (void);
|
||||
|
||||
|
|
|
@ -397,7 +397,7 @@ extern QFile *sv_fraglogfile;
|
|||
|
||||
extern double sv_frametime;
|
||||
|
||||
extern progs_t sv_progs;
|
||||
extern progs_t sv_pr_state;
|
||||
|
||||
//===========================================================
|
||||
// FIXME: declare exported functions in their own relevant .h
|
||||
|
@ -405,6 +405,8 @@ extern progs_t sv_progs;
|
|||
void SV_Error (char *error, ...) __attribute__((format(printf,1,2)));
|
||||
void SV_Init (void);
|
||||
void SV_Progs_Init (void);
|
||||
void SV_Progs_Init_Cvars (void);
|
||||
void SV_LoadProgs (void);
|
||||
|
||||
void Con_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||
void Con_DPrintf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||
|
|
|
@ -48,9 +48,7 @@
|
|||
#include "server.h"
|
||||
#include "world.h"
|
||||
|
||||
cvar_t *r_skyname;
|
||||
cvar_t *pr_boundscheck;
|
||||
cvar_t *qwprog;
|
||||
|
||||
int type_size[8] = {
|
||||
1,
|
||||
|
@ -914,7 +912,7 @@ ED_LoadFromFile (progs_t *pr, char *data)
|
|||
PR_LoadProgs
|
||||
*/
|
||||
void
|
||||
PR_LoadProgs (progs_t *pr)
|
||||
PR_LoadProgs (progs_t *pr, char *progsname)
|
||||
{
|
||||
int i;
|
||||
dstatement_t *st;
|
||||
|
@ -923,13 +921,9 @@ PR_LoadProgs (progs_t *pr)
|
|||
for (i = 0; i < GEFV_CACHESIZE; i++)
|
||||
gefvCache[i].field[0] = 0;
|
||||
|
||||
pr->progs = (dprograms_t *) COM_LoadHunkFile (qwprog->string);
|
||||
if ((!pr->progs) && (!strcmp(qwprog->string,"qwprogs.dat")))
|
||||
pr->progs = (dprograms_t *) COM_LoadHunkFile ("qwprogs.dat");
|
||||
if ((!pr->progs) && (!strcmp(qwprog->string,"progs.dat")))
|
||||
pr->progs = (dprograms_t *) COM_LoadHunkFile ("progs.dat");
|
||||
pr->progs = (dprograms_t *) COM_LoadHunkFile (progsname);
|
||||
if (!pr->progs)
|
||||
SV_Error ("PR_LoadProgs: couldn't load progs.dat");
|
||||
return;
|
||||
|
||||
Con_DPrintf ("Programs occupy %iK.\n", com_filesize / 1024);
|
||||
|
||||
|
@ -1126,7 +1120,6 @@ PR_Init_Cvars (void)
|
|||
pr_boundscheck =
|
||||
Cvar_Get ("pr_boundscheck", "1", CVAR_NONE,
|
||||
"Server progs bounds checking");
|
||||
qwprog = Cvar_Get ("qwprog", "qwprogs.dat", CVAR_ROM, "Allows selectable qwprogs.dat if you have several of them in the gamedir");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -419,7 +419,7 @@ SV_Status_f (void)
|
|||
Con_Printf ("net address : %s\n", NET_AdrToString (net_local_adr));
|
||||
Con_Printf ("cpu utilization : %3i%%\n", (int) cpu);
|
||||
Con_Printf ("avg response time: %i ms\n", (int) avg);
|
||||
Con_Printf ("packets/frame : %5.2f (%d)\n", pak, sv_progs.num_prstr);
|
||||
Con_Printf ("packets/frame : %5.2f (%d)\n", pak, sv_pr_state.num_prstr);
|
||||
|
||||
// min fps lat drp
|
||||
if (sv_redirected != RD_NONE) {
|
||||
|
|
|
@ -373,7 +373,7 @@ SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *msg)
|
|||
|
||||
if (newnum < oldnum) { // this is a new entity, send it from
|
||||
// the baseline
|
||||
ent = EDICT_NUM (&sv_progs, newnum);
|
||||
ent = EDICT_NUM (&sv_pr_state, newnum);
|
||||
//Con_Printf ("baseline %i\n", newnum);
|
||||
SV_WriteDelta (&ent->baseline, &to->entities[newindex], msg, true,
|
||||
client->stdver);
|
||||
|
@ -550,10 +550,10 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
|
|||
|
||||
numnails = 0;
|
||||
|
||||
for (e = MAX_CLIENTS + 1, ent = EDICT_NUM (&sv_progs, e); e < sv.num_edicts;
|
||||
e++, ent = NEXT_EDICT (&sv_progs, ent)) {
|
||||
for (e = MAX_CLIENTS + 1, ent = EDICT_NUM (&sv_pr_state, e); e < sv.num_edicts;
|
||||
e++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
|
||||
// ignore ents without visible models
|
||||
if (!ent->v.modelindex || !*PR_GetString (&sv_progs, ent->v.model))
|
||||
if (!ent->v.modelindex || !*PR_GetString (&sv_pr_state, ent->v.model))
|
||||
continue;
|
||||
|
||||
// ignore if not touching a PV leaf
|
||||
|
|
|
@ -111,7 +111,7 @@ SV_CreateBaseline (void)
|
|||
int entnum;
|
||||
|
||||
for (entnum = 0; entnum < sv.num_edicts; entnum++) {
|
||||
svent = EDICT_NUM (&sv_progs, entnum);
|
||||
svent = EDICT_NUM (&sv_pr_state, entnum);
|
||||
if (svent->free)
|
||||
continue;
|
||||
// create baselines for all player slots,
|
||||
|
@ -132,7 +132,7 @@ SV_CreateBaseline (void)
|
|||
} else {
|
||||
svent->baseline.colormap = 0;
|
||||
svent->baseline.modelindex =
|
||||
SV_ModelIndex (PR_GetString (&sv_progs, svent->v.model));
|
||||
SV_ModelIndex (PR_GetString (&sv_pr_state, svent->v.model));
|
||||
}
|
||||
// LordHavoc: setup baseline to include new effects
|
||||
svent->baseline.alpha = 255;
|
||||
|
@ -183,7 +183,7 @@ SV_SaveSpawnparms (void)
|
|||
return; // no progs loaded yet
|
||||
|
||||
// serverflags is the only game related thing maintained
|
||||
svs.serverflags = sv_progs.pr_global_struct->serverflags;
|
||||
svs.serverflags = sv_pr_state.pr_global_struct->serverflags;
|
||||
|
||||
for (i = 0, host_client = svs.clients; i < MAX_CLIENTS; i++, host_client++) {
|
||||
if (host_client->state != cs_spawned)
|
||||
|
@ -193,10 +193,10 @@ SV_SaveSpawnparms (void)
|
|||
host_client->state = cs_connected;
|
||||
|
||||
// call the progs to get default spawn parms for the new client
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, host_client->edict);
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->SetChangeParms);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, host_client->edict);
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->SetChangeParms);
|
||||
for (j = 0; j < NUM_SPAWN_PARMS; j++)
|
||||
host_client->spawn_parms[j] = (&sv_progs.pr_global_struct->parm1)[j];
|
||||
host_client->spawn_parms[j] = (&sv_pr_state.pr_global_struct->parm1)[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ SV_SpawnServer (char *server)
|
|||
// restarted
|
||||
|
||||
sv.state = ss_dead;
|
||||
sv_progs.null_bad = 0;
|
||||
sv_pr_state.null_bad = 0;
|
||||
|
||||
Mod_ClearAll ();
|
||||
Hunk_FreeToLowMark (host_hunklevel);
|
||||
|
@ -348,17 +348,17 @@ SV_SpawnServer (char *server)
|
|||
|
||||
// load progs to get entity field count
|
||||
// which determines how big each edict is
|
||||
PR_LoadProgs (&sv_progs);
|
||||
Info_SetValueForStarKey (svs.info, "*progs", va ("%i", sv_progs.crc),
|
||||
SV_LoadProgs ();
|
||||
Info_SetValueForStarKey (svs.info, "*progs", va ("%i", sv_pr_state.crc),
|
||||
MAX_SERVERINFO_STRING);
|
||||
|
||||
// allocate edicts
|
||||
sv.edicts = Hunk_AllocName (MAX_EDICTS * sv_progs.pr_edict_size, "edicts");
|
||||
sv.edicts = Hunk_AllocName (MAX_EDICTS * sv_pr_state.pr_edict_size, "edicts");
|
||||
|
||||
// leave slots at start for clients only
|
||||
sv.num_edicts = MAX_CLIENTS + 1;
|
||||
for (i = 0; i < MAX_CLIENTS; i++) {
|
||||
ent = EDICT_NUM (&sv_progs, i + 1);
|
||||
ent = EDICT_NUM (&sv_pr_state, i + 1);
|
||||
svs.clients[i].edict = ent;
|
||||
//ZOID - make sure we update frags right
|
||||
svs.clients[i].old_frags = 0;
|
||||
|
@ -376,9 +376,9 @@ SV_SpawnServer (char *server)
|
|||
//
|
||||
SV_ClearWorld ();
|
||||
|
||||
sv.sound_precache[0] = sv_progs.pr_strings;
|
||||
sv.sound_precache[0] = sv_pr_state.pr_strings;
|
||||
|
||||
sv.model_precache[0] = sv_progs.pr_strings;
|
||||
sv.model_precache[0] = sv_pr_state.pr_strings;
|
||||
sv.model_precache[1] = sv.modelname;
|
||||
sv.models[1] = sv.worldmodel;
|
||||
for (i = 1; i < sv.worldmodel->numsubmodels; i++) {
|
||||
|
@ -397,24 +397,24 @@ SV_SpawnServer (char *server)
|
|||
// precache and static commands can be issued during
|
||||
// map initialization
|
||||
sv.state = ss_loading;
|
||||
sv_progs.null_bad = 0;
|
||||
sv_pr_state.null_bad = 0;
|
||||
|
||||
ent = EDICT_NUM (&sv_progs, 0);
|
||||
ent = EDICT_NUM (&sv_pr_state, 0);
|
||||
ent->free = false;
|
||||
ent->v.model = PR_SetString (&sv_progs, sv.worldmodel->name);
|
||||
ent->v.model = PR_SetString (&sv_pr_state, sv.worldmodel->name);
|
||||
ent->v.modelindex = 1; // world model
|
||||
ent->v.solid = SOLID_BSP;
|
||||
ent->v.movetype = MOVETYPE_PUSH;
|
||||
|
||||
sv_progs.pr_global_struct->mapname = PR_SetString (&sv_progs, sv.name);
|
||||
sv_pr_state.pr_global_struct->mapname = PR_SetString (&sv_pr_state, sv.name);
|
||||
// serverflags are for cross level information (sigils)
|
||||
sv_progs.pr_global_struct->serverflags = svs.serverflags;
|
||||
sv_pr_state.pr_global_struct->serverflags = svs.serverflags;
|
||||
|
||||
// run the frame start qc function to let progs check cvars
|
||||
SV_ProgStartFrame ();
|
||||
|
||||
// load and spawn all other entities
|
||||
ED_LoadFromFile (&sv_progs, sv.worldmodel->entities);
|
||||
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);
|
||||
|
||||
// look up some model indexes for specialized message compression
|
||||
SV_FindModelNumbers ();
|
||||
|
@ -422,7 +422,7 @@ SV_SpawnServer (char *server)
|
|||
// all spawning is completed, any further precache statements
|
||||
// or prog writes to the signon message are errors
|
||||
sv.state = ss_active;
|
||||
sv_progs.null_bad = 1;
|
||||
sv_pr_state.null_bad = 1;
|
||||
|
||||
// run two frames to allow everything to settle
|
||||
sv_frametime = 0.1;
|
||||
|
|
|
@ -146,8 +146,6 @@ QFile *sv_fraglogfile;
|
|||
|
||||
void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
||||
void Master_Shutdown (void);
|
||||
void SV_Progs_Init_Cvars (void);
|
||||
void PR_Init_Cvars (void);
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
@ -251,13 +249,13 @@ SV_DropClient (client_t *drop)
|
|||
if (!drop->spectator) {
|
||||
// call the prog function for removing a client
|
||||
// this will set the body to a dead frame, among other things
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, drop->edict);
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->ClientDisconnect);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, drop->edict);
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->ClientDisconnect);
|
||||
} else if (SpectatorDisconnect) {
|
||||
// call the prog function for removing a client
|
||||
// this will set the body to a dead frame, among other things
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, drop->edict);
|
||||
PR_ExecuteProgram (&sv_progs, SpectatorDisconnect);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, drop->edict);
|
||||
PR_ExecuteProgram (&sv_pr_state, SpectatorDisconnect);
|
||||
}
|
||||
}
|
||||
if (drop->spectator)
|
||||
|
@ -828,7 +826,7 @@ SVC_DirectConnect (void)
|
|||
// spectator mode can ONLY be set at join time
|
||||
newcl->spectator = spectator;
|
||||
|
||||
ent = EDICT_NUM (&sv_progs, edictnum);
|
||||
ent = EDICT_NUM (&sv_pr_state, edictnum);
|
||||
newcl->edict = ent;
|
||||
|
||||
// parse some info from the info strings
|
||||
|
@ -841,9 +839,9 @@ SVC_DirectConnect (void)
|
|||
newcl->lockedtill = 0;
|
||||
|
||||
// call the progs to get default spawn parms for the new client
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->SetNewParms);
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->SetNewParms);
|
||||
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
||||
newcl->spawn_parms[i] = (&sv_progs.pr_global_struct->parm1)[i];
|
||||
newcl->spawn_parms[i] = (&sv_pr_state.pr_global_struct->parm1)[i];
|
||||
|
||||
if (newcl->spectator)
|
||||
Con_Printf ("Spectator %s connected\n", newcl->name);
|
||||
|
|
|
@ -141,11 +141,11 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
|
|||
// try one move with vertical motion, then one without
|
||||
for (i = 0; i < 2; i++) {
|
||||
VectorAdd (ent->v.origin, move, neworg);
|
||||
enemy = PROG_TO_EDICT (&sv_progs, ent->v.enemy);
|
||||
enemy = PROG_TO_EDICT (&sv_pr_state, ent->v.enemy);
|
||||
if (i == 0 && enemy != sv.edicts) {
|
||||
dz =
|
||||
ent->v.origin[2] -
|
||||
PROG_TO_EDICT (&sv_progs, ent->v.enemy)->v.origin[2];
|
||||
PROG_TO_EDICT (&sv_pr_state, ent->v.enemy)->v.origin[2];
|
||||
if (dz > 40)
|
||||
neworg[2] -= 8;
|
||||
if (dz < 30)
|
||||
|
@ -221,7 +221,7 @@ SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
|
|||
// Con_Printf ("back on ground\n");
|
||||
ent->v.flags = (int) ent->v.flags & ~FL_PARTIALGROUND;
|
||||
}
|
||||
ent->v.groundentity = EDICT_TO_PROG (&sv_progs, trace.ent);
|
||||
ent->v.groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent);
|
||||
|
||||
// the move is ok
|
||||
if (relink)
|
||||
|
@ -248,7 +248,7 @@ SV_StepDirection (edict_t *ent, float yaw, float dist)
|
|||
float delta;
|
||||
|
||||
ent->v.ideal_yaw = yaw;
|
||||
PF_changeyaw (&sv_progs);
|
||||
PF_changeyaw (&sv_pr_state);
|
||||
|
||||
yaw = yaw * M_PI * 2 / 360;
|
||||
move[0] = cos (yaw) * dist;
|
||||
|
@ -402,16 +402,16 @@ SV_MoveToGoal (progs_t *pr)
|
|||
edict_t *ent, *goal;
|
||||
float dist;
|
||||
|
||||
ent = PROG_TO_EDICT (&sv_progs, sv_progs.pr_global_struct->self);
|
||||
goal = PROG_TO_EDICT (&sv_progs, ent->v.goalentity);
|
||||
dist = G_FLOAT (&sv_progs, OFS_PARM0);
|
||||
ent = PROG_TO_EDICT (&sv_pr_state, sv_pr_state.pr_global_struct->self);
|
||||
goal = PROG_TO_EDICT (&sv_pr_state, ent->v.goalentity);
|
||||
dist = G_FLOAT (&sv_pr_state, OFS_PARM0);
|
||||
|
||||
if (!((int) ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
|
||||
G_FLOAT (&sv_progs, OFS_RETURN) = 0;
|
||||
G_FLOAT (&sv_pr_state, OFS_RETURN) = 0;
|
||||
return;
|
||||
}
|
||||
// if the next step hits the enemy, return immediately
|
||||
if (PROG_TO_EDICT (&sv_progs, ent->v.enemy) != sv.edicts
|
||||
if (PROG_TO_EDICT (&sv_pr_state, ent->v.enemy) != sv.edicts
|
||||
&& SV_CloseEnough (ent, goal, dist)) return;
|
||||
|
||||
// bump around...
|
||||
|
|
112
source/sv_phys.c
112
source/sv_phys.c
|
@ -84,8 +84,8 @@ SV_CheckAllEnts (void)
|
|||
edict_t *check;
|
||||
|
||||
// see if any solid entities are inside the final position
|
||||
check = NEXT_EDICT (&sv_progs, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_progs, check)) {
|
||||
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
|
||||
if (check->free)
|
||||
continue;
|
||||
if (check->v.movetype == MOVETYPE_PUSH
|
||||
|
@ -114,12 +114,12 @@ SV_CheckVelocity (edict_t *ent)
|
|||
for (i = 0; i < 3; i++) {
|
||||
if (IS_NAN (ent->v.velocity[i])) {
|
||||
Con_Printf ("Got a NaN velocity on %s\n",
|
||||
PR_GetString (&sv_progs, ent->v.classname));
|
||||
PR_GetString (&sv_pr_state, ent->v.classname));
|
||||
ent->v.velocity[i] = 0;
|
||||
}
|
||||
if (IS_NAN (ent->v.origin[i])) {
|
||||
Con_Printf ("Got a NaN origin on %s\n",
|
||||
PR_GetString (&sv_progs, ent->v.classname));
|
||||
PR_GetString (&sv_pr_state, ent->v.classname));
|
||||
ent->v.origin[i] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -160,10 +160,10 @@ SV_RunThink (edict_t *ent)
|
|||
// it is possible to start that way
|
||||
// by a trigger with a local time.
|
||||
ent->v.nextthink = 0;
|
||||
sv_progs.pr_global_struct->time = thinktime;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, ent);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, sv.edicts);
|
||||
PR_ExecuteProgram (&sv_progs, ent->v.think);
|
||||
sv_pr_state.pr_global_struct->time = thinktime;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, ent);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
|
||||
PR_ExecuteProgram (&sv_pr_state, ent->v.think);
|
||||
|
||||
if (ent->free)
|
||||
return false;
|
||||
|
@ -184,24 +184,24 @@ SV_Impact (edict_t *e1, edict_t *e2)
|
|||
{
|
||||
int old_self, old_other;
|
||||
|
||||
old_self = sv_progs.pr_global_struct->self;
|
||||
old_other = sv_progs.pr_global_struct->other;
|
||||
old_self = sv_pr_state.pr_global_struct->self;
|
||||
old_other = sv_pr_state.pr_global_struct->other;
|
||||
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
if (e1->v.touch && e1->v.solid != SOLID_NOT) {
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, e1);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, e2);
|
||||
PR_ExecuteProgram (&sv_progs, e1->v.touch);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, e1);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, e2);
|
||||
PR_ExecuteProgram (&sv_pr_state, e1->v.touch);
|
||||
}
|
||||
|
||||
if (e2->v.touch && e2->v.solid != SOLID_NOT) {
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, e2);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, e1);
|
||||
PR_ExecuteProgram (&sv_progs, e2->v.touch);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, e2);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, e1);
|
||||
PR_ExecuteProgram (&sv_pr_state, e2->v.touch);
|
||||
}
|
||||
|
||||
sv_progs.pr_global_struct->self = old_self;
|
||||
sv_progs.pr_global_struct->other = old_other;
|
||||
sv_pr_state.pr_global_struct->self = old_self;
|
||||
sv_pr_state.pr_global_struct->other = old_other;
|
||||
}
|
||||
|
||||
|
||||
|
@ -305,7 +305,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
|
|||
if ((trace.ent->v.solid == SOLID_BSP)
|
||||
|| (trace.ent->v.movetype == MOVETYPE_PPUSH)) {
|
||||
ent->v.flags = (int) ent->v.flags | FL_ONGROUND;
|
||||
ent->v.groundentity = EDICT_TO_PROG (&sv_progs, trace.ent);
|
||||
ent->v.groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent);
|
||||
}
|
||||
}
|
||||
if (!trace.plane.normal[2]) {
|
||||
|
@ -466,8 +466,8 @@ SV_Push (edict_t *pusher, vec3_t move)
|
|||
|
||||
// see if any solid entities are inside the final position
|
||||
num_moved = 0;
|
||||
check = NEXT_EDICT (&sv_progs, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_progs, check)) {
|
||||
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
|
||||
if (check->free)
|
||||
continue;
|
||||
if (check->v.movetype == MOVETYPE_PUSH
|
||||
|
@ -487,7 +487,7 @@ SV_Push (edict_t *pusher, vec3_t move)
|
|||
// if the entity is standing on the pusher, it will definately be
|
||||
// moved
|
||||
if (!(((int) check->v.flags & FL_ONGROUND)
|
||||
&& PROG_TO_EDICT (&sv_progs, check->v.groundentity) == pusher)) {
|
||||
&& PROG_TO_EDICT (&sv_pr_state, check->v.groundentity) == pusher)) {
|
||||
if (check->v.absmin[0] >= maxs[0]
|
||||
|| check->v.absmin[1] >= maxs[1]
|
||||
|| check->v.absmin[2] >= maxs[2]
|
||||
|
@ -537,9 +537,9 @@ 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 (pusher->v.blocked) {
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, pusher);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, check);
|
||||
PR_ExecuteProgram (&sv_progs, pusher->v.blocked);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, pusher);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, check);
|
||||
PR_ExecuteProgram (&sv_pr_state, pusher->v.blocked);
|
||||
}
|
||||
// move back any entities we already moved
|
||||
for (i = 0; i < num_moved; i++) {
|
||||
|
@ -611,10 +611,10 @@ SV_Physics_Pusher (edict_t *ent)
|
|||
if (thinktime > oldltime && thinktime <= ent->v.ltime) {
|
||||
VectorCopy (ent->v.origin, oldorg);
|
||||
ent->v.nextthink = 0;
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, ent);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, sv.edicts);
|
||||
PR_ExecuteProgram (&sv_progs, ent->v.think);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, ent);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
|
||||
PR_ExecuteProgram (&sv_pr_state, ent->v.think);
|
||||
if (ent->free)
|
||||
return;
|
||||
VectorSubtract (ent->v.origin, oldorg, move);
|
||||
|
@ -760,7 +760,7 @@ SV_Physics_Toss (edict_t *ent)
|
|||
if (trace.plane.normal[2] > 0.7) {
|
||||
if (ent->v.velocity[2] < 60 || ent->v.movetype != MOVETYPE_BOUNCE) {
|
||||
ent->v.flags = (int) ent->v.flags | FL_ONGROUND;
|
||||
ent->v.groundentity = EDICT_TO_PROG (&sv_progs, trace.ent);
|
||||
ent->v.groundentity = EDICT_TO_PROG (&sv_pr_state, trace.ent);
|
||||
VectorCopy (vec3_origin, ent->v.velocity);
|
||||
VectorCopy (vec3_origin, ent->v.avelocity);
|
||||
}
|
||||
|
@ -851,8 +851,8 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push
|
|||
|
||||
oldsolid = pusher->v.solid;
|
||||
|
||||
check = NEXT_EDICT (&sv_progs, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_progs, check)) {
|
||||
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
|
||||
if (check->free) // What entity?
|
||||
continue;
|
||||
|
||||
|
@ -877,9 +877,9 @@ SV_PPushMove (edict_t *pusher, float movetime) // player push
|
|||
// Stage 4: Yes, it must be. Fail the move.
|
||||
VectorCopy (pusher->v.origin, pusher->v.oldorigin); // Revert
|
||||
if (pusher->v.blocked) { // Blocked func?
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, pusher);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, check);
|
||||
PR_ExecuteProgram (&sv_progs, pusher->v.blocked);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, pusher);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, check);
|
||||
PR_ExecuteProgram (&sv_pr_state, pusher->v.blocked);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -913,10 +913,10 @@ SV_Physics_PPusher (edict_t *ent)
|
|||
|
||||
if (thinktime > oldltime && thinktime <= ent->v.ltime) {
|
||||
ent->v.nextthink = 0;
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, ent);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, sv.edicts);
|
||||
PR_ExecuteProgram (&sv_progs, ent->v.think);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, ent);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
|
||||
PR_ExecuteProgram (&sv_pr_state, ent->v.think);
|
||||
if (ent->free)
|
||||
return;
|
||||
}
|
||||
|
@ -928,10 +928,10 @@ void
|
|||
SV_ProgStartFrame (void)
|
||||
{
|
||||
// let the progs know that a new frame has started
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv.edicts);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, sv.edicts);
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->StartFrame);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->StartFrame);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -985,11 +985,11 @@ SV_RunNewmis (void)
|
|||
{
|
||||
edict_t *ent;
|
||||
|
||||
if (!sv_progs.pr_global_struct->newmis)
|
||||
if (!sv_pr_state.pr_global_struct->newmis)
|
||||
return;
|
||||
ent = PROG_TO_EDICT (&sv_progs, sv_progs.pr_global_struct->newmis);
|
||||
ent = PROG_TO_EDICT (&sv_pr_state, sv_pr_state.pr_global_struct->newmis);
|
||||
sv_frametime = 0.05;
|
||||
sv_progs.pr_global_struct->newmis = 0;
|
||||
sv_pr_state.pr_global_struct->newmis = 0;
|
||||
|
||||
SV_RunEntity (ent);
|
||||
}
|
||||
|
@ -1015,7 +1015,7 @@ SV_Physics (void)
|
|||
sv_frametime = sv_maxtic->value;
|
||||
old_time = realtime;
|
||||
|
||||
sv_progs.pr_global_struct->frametime = sv_frametime;
|
||||
sv_pr_state.pr_global_struct->frametime = sv_frametime;
|
||||
|
||||
SV_ProgStartFrame ();
|
||||
|
||||
|
@ -1024,11 +1024,11 @@ SV_Physics (void)
|
|||
// even the world gets a chance to think
|
||||
//
|
||||
ent = sv.edicts;
|
||||
for (i = 0; i < sv.num_edicts; i++, ent = NEXT_EDICT (&sv_progs, ent)) {
|
||||
for (i = 0; i < sv.num_edicts; i++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
|
||||
if (ent->free)
|
||||
continue;
|
||||
|
||||
if (sv_progs.pr_global_struct->force_retouch)
|
||||
if (sv_pr_state.pr_global_struct->force_retouch)
|
||||
SV_LinkEdict (ent, true); // force retouch even for stationary
|
||||
|
||||
if (i > 0 && i <= MAX_CLIENTS)
|
||||
|
@ -1039,16 +1039,16 @@ SV_Physics (void)
|
|||
SV_RunNewmis ();
|
||||
}
|
||||
|
||||
if (sv_progs.pr_global_struct->force_retouch)
|
||||
sv_progs.pr_global_struct->force_retouch--;
|
||||
if (sv_pr_state.pr_global_struct->force_retouch)
|
||||
sv_pr_state.pr_global_struct->force_retouch--;
|
||||
|
||||
// 2000-01-02 EndFrame function by Maddes/FrikaC start
|
||||
if (EndFrame) {
|
||||
// let the progs know that the frame has ended
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv.edicts);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, sv.edicts);
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
PR_ExecuteProgram (&sv_progs, EndFrame);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv.edicts);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
PR_ExecuteProgram (&sv_pr_state, EndFrame);
|
||||
}
|
||||
// 2000-01-02 EndFrame function by Maddes/FrikaC end
|
||||
}
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
#include "world.h"
|
||||
|
||||
int eval_alpha, eval_scale, eval_glowsize, eval_glowcolor, eval_colormod;
|
||||
progs_t sv_progs;
|
||||
progs_t sv_pr_state;
|
||||
cvar_t *r_skyname;
|
||||
cvar_t *sv_progs;
|
||||
|
||||
func_t EndFrame;
|
||||
func_t SpectatorConnect;
|
||||
|
@ -56,34 +57,34 @@ FindEdictFieldOffsets (progs_t *pr)
|
|||
{
|
||||
dfunction_t *f;
|
||||
|
||||
if (pr == &sv_progs) {
|
||||
if (pr == &sv_pr_state) {
|
||||
// Zoid, find the spectator functions
|
||||
SpectatorConnect = SpectatorThink = SpectatorDisconnect = 0;
|
||||
|
||||
if ((f = ED_FindFunction (&sv_progs, "SpectatorConnect")) != NULL)
|
||||
SpectatorConnect = (func_t) (f - sv_progs.pr_functions);
|
||||
if ((f = ED_FindFunction (&sv_progs, "SpectatorThink")) != NULL)
|
||||
SpectatorThink = (func_t) (f - sv_progs.pr_functions);
|
||||
if ((f = ED_FindFunction (&sv_progs, "SpectatorDisconnect")) != NULL)
|
||||
SpectatorDisconnect = (func_t) (f - sv_progs.pr_functions);
|
||||
if ((f = ED_FindFunction (&sv_pr_state, "SpectatorConnect")) != NULL)
|
||||
SpectatorConnect = (func_t) (f - sv_pr_state.pr_functions);
|
||||
if ((f = ED_FindFunction (&sv_pr_state, "SpectatorThink")) != NULL)
|
||||
SpectatorThink = (func_t) (f - sv_pr_state.pr_functions);
|
||||
if ((f = ED_FindFunction (&sv_pr_state, "SpectatorDisconnect")) != NULL)
|
||||
SpectatorDisconnect = (func_t) (f - sv_pr_state.pr_functions);
|
||||
|
||||
// 2000-01-02 EndFrame function by Maddes/FrikaC
|
||||
EndFrame = 0;
|
||||
if ((f = ED_FindFunction (&sv_progs, "EndFrame")) != NULL)
|
||||
EndFrame = (func_t) (f - sv_progs.pr_functions);
|
||||
if ((f = ED_FindFunction (&sv_pr_state, "EndFrame")) != NULL)
|
||||
EndFrame = (func_t) (f - sv_pr_state.pr_functions);
|
||||
|
||||
eval_alpha = FindFieldOffset (&sv_progs, "alpha");
|
||||
eval_scale = FindFieldOffset (&sv_progs, "scale");
|
||||
eval_glowsize = FindFieldOffset (&sv_progs, "glow_size");
|
||||
eval_glowcolor = FindFieldOffset (&sv_progs, "glow_color");
|
||||
eval_colormod = FindFieldOffset (&sv_progs, "colormod");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ED_PrintEdicts_f (void)
|
||||
{
|
||||
ED_PrintEdicts (&sv_progs);
|
||||
ED_PrintEdicts (&sv_pr_state);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -98,19 +99,19 @@ ED_PrintEdict_f (void)
|
|||
|
||||
i = atoi (Cmd_Argv (1));
|
||||
Con_Printf ("\n EDICT %i:\n", i);
|
||||
ED_PrintNum (&sv_progs, i);
|
||||
ED_PrintNum (&sv_pr_state, i);
|
||||
}
|
||||
|
||||
void
|
||||
ED_Count_f (void)
|
||||
{
|
||||
ED_Count (&sv_progs);
|
||||
ED_Count (&sv_pr_state);
|
||||
}
|
||||
|
||||
void
|
||||
PR_Profile_f (void)
|
||||
{
|
||||
PR_Profile (&sv_progs);
|
||||
PR_Profile (&sv_pr_state);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -132,14 +133,22 @@ ED_Parse_Extra_Fields (progs_t *pr, char *key, char *value)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SV_LoadProgs (void)
|
||||
{
|
||||
PR_LoadProgs (&sv_pr_state, sv_progs->string);
|
||||
if (!sv_pr_state.progs)
|
||||
SV_Error ("SV_LoadProgs: couldn't load %s", sv_progs->string);
|
||||
}
|
||||
|
||||
void
|
||||
SV_Progs_Init (void)
|
||||
{
|
||||
sv_progs.edicts = &sv.edicts;
|
||||
sv_progs.num_edicts = &sv.num_edicts;
|
||||
sv_progs.time = &sv.time;
|
||||
sv_progs.unlink = SV_UnlinkEdict;
|
||||
sv_progs.flush = SV_FlushSignon;
|
||||
sv_pr_state.edicts = &sv.edicts;
|
||||
sv_pr_state.num_edicts = &sv.num_edicts;
|
||||
sv_pr_state.time = &sv.time;
|
||||
sv_pr_state.unlink = SV_UnlinkEdict;
|
||||
sv_pr_state.flush = SV_FlushSignon;
|
||||
|
||||
Cmd_AddCommand ("edict", ED_PrintEdict_f, "No Description");
|
||||
Cmd_AddCommand ("edicts", ED_PrintEdicts_f, "No Description");
|
||||
|
@ -152,4 +161,7 @@ SV_Progs_Init_Cvars (void)
|
|||
{
|
||||
r_skyname =
|
||||
Cvar_Get ("r_skyname", "", CVAR_SERVERINFO, "name of skybox");
|
||||
sv_progs = Cvar_Get ("sv_progs", "qwprogs.dat", CVAR_ROM,
|
||||
"Allows selectable game progs if you have several "
|
||||
"of them in the gamedir");
|
||||
}
|
||||
|
|
|
@ -430,7 +430,7 @@ SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
|
|||
return;
|
||||
}
|
||||
|
||||
ent = NUM_FOR_EDICT (&sv_progs, entity);
|
||||
ent = NUM_FOR_EDICT (&sv_pr_state, entity);
|
||||
|
||||
if ((channel & 8) || !sv_phs->int_val) // no PHS flag
|
||||
{
|
||||
|
@ -535,7 +535,7 @@ SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg)
|
|||
}
|
||||
// send a damage message if the player got hit this frame
|
||||
if (ent->v.dmg_take || ent->v.dmg_save) {
|
||||
other = PROG_TO_EDICT (&sv_progs, ent->v.dmg_inflictor);
|
||||
other = PROG_TO_EDICT (&sv_pr_state, ent->v.dmg_inflictor);
|
||||
MSG_WriteByte (msg, svc_damage);
|
||||
MSG_WriteByte (msg, ent->v.dmg_save);
|
||||
MSG_WriteByte (msg, ent->v.dmg_take);
|
||||
|
@ -580,7 +580,7 @@ SV_UpdateClientStats (client_t *client)
|
|||
ent = svs.clients[client->spec_track - 1].edict;
|
||||
|
||||
stats[STAT_HEALTH] = ent->v.health;
|
||||
stats[STAT_WEAPON] = SV_ModelIndex (PR_GetString (&sv_progs, ent->v.weaponmodel));
|
||||
stats[STAT_WEAPON] = SV_ModelIndex (PR_GetString (&sv_pr_state, ent->v.weaponmodel));
|
||||
stats[STAT_AMMO] = ent->v.currentammo;
|
||||
stats[STAT_ARMOR] = ent->v.armorvalue;
|
||||
stats[STAT_SHELLS] = ent->v.ammo_shells;
|
||||
|
@ -591,7 +591,7 @@ SV_UpdateClientStats (client_t *client)
|
|||
stats[STAT_ACTIVEWEAPON] = ent->v.weapon;
|
||||
// stuff the sigil bits into the high bits of items for sbar
|
||||
stats[STAT_ITEMS] =
|
||||
(int) ent->v.items | ((int) sv_progs.pr_global_struct->serverflags << 28);
|
||||
(int) ent->v.items | ((int) sv_pr_state.pr_global_struct->serverflags << 28);
|
||||
|
||||
// Extensions to the QW 2.40 protocol for Mega2k --KB
|
||||
stats[STAT_VIEWHEIGHT] = (int) ent->v.view_ofs[2];
|
||||
|
@ -701,13 +701,13 @@ SV_UpdateToReliableMessages (void)
|
|||
// maxspeed/entgravity changes
|
||||
ent = host_client->edict;
|
||||
|
||||
val = GetEdictFieldValue (&sv_progs, ent, "gravity");
|
||||
val = GetEdictFieldValue (&sv_pr_state, ent, "gravity");
|
||||
if (val && host_client->entgravity != val->_float) {
|
||||
host_client->entgravity = val->_float;
|
||||
ClientReliableWrite_Begin (host_client, svc_entgravity, 5);
|
||||
ClientReliableWrite_Float (host_client, host_client->entgravity);
|
||||
}
|
||||
val = GetEdictFieldValue (&sv_progs, ent, "maxspeed");
|
||||
val = GetEdictFieldValue (&sv_pr_state, ent, "maxspeed");
|
||||
if (val && host_client->maxspeed != val->_float) {
|
||||
host_client->maxspeed = val->_float;
|
||||
ClientReliableWrite_Begin (host_client, svc_maxspeed, 5);
|
||||
|
|
114
source/sv_user.c
114
source/sv_user.c
|
@ -128,14 +128,14 @@ SV_New_f (void)
|
|||
MSG_WriteLong (&host_client->netchan.message, svs.spawncount);
|
||||
MSG_WriteString (&host_client->netchan.message, gamedir);
|
||||
|
||||
playernum = NUM_FOR_EDICT (&sv_progs, host_client->edict) - 1;
|
||||
playernum = NUM_FOR_EDICT (&sv_pr_state, host_client->edict) - 1;
|
||||
if (host_client->spectator)
|
||||
playernum |= 128;
|
||||
MSG_WriteByte (&host_client->netchan.message, playernum);
|
||||
|
||||
// send full levelname
|
||||
MSG_WriteString (&host_client->netchan.message,
|
||||
PR_GetString (&sv_progs, sv.edicts->v.message));
|
||||
PR_GetString (&sv_pr_state, sv.edicts->v.message));
|
||||
|
||||
// send the movevars
|
||||
MSG_WriteFloat (&host_client->netchan.message, movevars.gravity);
|
||||
|
@ -389,17 +389,17 @@ SV_Spawn_f (void)
|
|||
// set up the edict
|
||||
ent = host_client->edict;
|
||||
|
||||
memset (&ent->v, 0, sv_progs.progs->entityfields * 4);
|
||||
ent->v.colormap = NUM_FOR_EDICT (&sv_progs, ent);
|
||||
memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
|
||||
ent->v.colormap = NUM_FOR_EDICT (&sv_pr_state, ent);
|
||||
ent->v.team = 0; // FIXME
|
||||
ent->v.netname = PR_SetString (&sv_progs, host_client->name);
|
||||
ent->v.netname = PR_SetString (&sv_pr_state, host_client->name);
|
||||
|
||||
host_client->entgravity = 1.0;
|
||||
val = GetEdictFieldValue (&sv_progs, ent, "gravity");
|
||||
val = GetEdictFieldValue (&sv_pr_state, ent, "gravity");
|
||||
if (val)
|
||||
val->_float = 1.0;
|
||||
host_client->maxspeed = sv_maxspeed->value;
|
||||
val = GetEdictFieldValue (&sv_progs, ent, "maxspeed");
|
||||
val = GetEdictFieldValue (&sv_pr_state, ent, "maxspeed");
|
||||
if (val)
|
||||
val->_float = sv_maxspeed->value;
|
||||
|
||||
|
@ -410,19 +410,19 @@ SV_Spawn_f (void)
|
|||
|
||||
ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
|
||||
ClientReliableWrite_Byte (host_client, STAT_TOTALSECRETS);
|
||||
ClientReliableWrite_Long (host_client, sv_progs.pr_global_struct->total_secrets);
|
||||
ClientReliableWrite_Long (host_client, sv_pr_state.pr_global_struct->total_secrets);
|
||||
|
||||
ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
|
||||
ClientReliableWrite_Byte (host_client, STAT_TOTALMONSTERS);
|
||||
ClientReliableWrite_Long (host_client, sv_progs.pr_global_struct->total_monsters);
|
||||
ClientReliableWrite_Long (host_client, sv_pr_state.pr_global_struct->total_monsters);
|
||||
|
||||
ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
|
||||
ClientReliableWrite_Byte (host_client, STAT_SECRETS);
|
||||
ClientReliableWrite_Long (host_client, sv_progs.pr_global_struct->found_secrets);
|
||||
ClientReliableWrite_Long (host_client, sv_pr_state.pr_global_struct->found_secrets);
|
||||
|
||||
ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
|
||||
ClientReliableWrite_Byte (host_client, STAT_MONSTERS);
|
||||
ClientReliableWrite_Long (host_client, sv_progs.pr_global_struct->killed_monsters);
|
||||
ClientReliableWrite_Long (host_client, sv_pr_state.pr_global_struct->killed_monsters);
|
||||
|
||||
// get the client to check and download skins
|
||||
// when that is completed, a begin command will be issued
|
||||
|
@ -447,8 +447,8 @@ SV_SpawnSpectator (void)
|
|||
|
||||
// search for an info_playerstart to spawn the spectator at
|
||||
for (i = MAX_CLIENTS - 1; i < sv.num_edicts; i++) {
|
||||
e = EDICT_NUM (&sv_progs, i);
|
||||
if (!strcmp (PR_GetString (&sv_progs, e->v.classname), "info_player_start")) {
|
||||
e = EDICT_NUM (&sv_pr_state, i);
|
||||
if (!strcmp (PR_GetString (&sv_pr_state, e->v.classname), "info_player_start")) {
|
||||
VectorCopy (e->v.origin, sv_player->v.origin);
|
||||
return;
|
||||
}
|
||||
|
@ -485,27 +485,27 @@ SV_Begin_f (void)
|
|||
if (SpectatorConnect) {
|
||||
// copy spawn parms out of the client_t
|
||||
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
||||
(&sv_progs.pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
|
||||
(&sv_pr_state.pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
|
||||
|
||||
// call the spawn function
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
PR_ExecuteProgram (&sv_progs, SpectatorConnect);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
PR_ExecuteProgram (&sv_pr_state, SpectatorConnect);
|
||||
}
|
||||
} else {
|
||||
// copy spawn parms out of the client_t
|
||||
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
||||
(&sv_progs.pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
|
||||
(&sv_pr_state.pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
|
||||
|
||||
// call the spawn function
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->ClientConnect);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->ClientConnect);
|
||||
|
||||
// actually spawn the player
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->PutClientInServer);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->PutClientInServer);
|
||||
}
|
||||
|
||||
// clear the net statistics, because connecting gives a bogus picture
|
||||
|
@ -537,7 +537,7 @@ SV_Begin_f (void)
|
|||
// in a state where it is expecting the client to correct the angle
|
||||
// and it won't happen if the game was just loaded, so you wind up
|
||||
// with a permanent head tilt
|
||||
ent = EDICT_NUM (&sv_progs, 1 + (host_client - svs.clients));
|
||||
ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients));
|
||||
MSG_WriteByte (&host_client->netchan.message, svc_setangle);
|
||||
for (i = 0; i < 2; i++)
|
||||
MSG_WriteAngle (&host_client->netchan.message, ent->v.angles[i]);
|
||||
|
@ -938,9 +938,9 @@ SV_Kill_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->ClientKill);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->ClientKill);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1045,9 +1045,9 @@ SV_PTrack_f (void)
|
|||
if (Cmd_Argc () != 2) {
|
||||
// turn off tracking
|
||||
host_client->spec_track = 0;
|
||||
ent = EDICT_NUM (&sv_progs, host_client - svs.clients + 1);
|
||||
tent = EDICT_NUM (&sv_progs, 0);
|
||||
ent->v.goalentity = EDICT_TO_PROG (&sv_progs, tent);
|
||||
ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1);
|
||||
tent = EDICT_NUM (&sv_pr_state, 0);
|
||||
ent->v.goalentity = EDICT_TO_PROG (&sv_pr_state, tent);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1056,16 +1056,16 @@ SV_PTrack_f (void)
|
|||
svs.clients[i].spectator) {
|
||||
SV_ClientPrintf (host_client, PRINT_HIGH, "Invalid client to track\n");
|
||||
host_client->spec_track = 0;
|
||||
ent = EDICT_NUM (&sv_progs, host_client - svs.clients + 1);
|
||||
tent = EDICT_NUM (&sv_progs, 0);
|
||||
ent->v.goalentity = EDICT_TO_PROG (&sv_progs, tent);
|
||||
ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1);
|
||||
tent = EDICT_NUM (&sv_pr_state, 0);
|
||||
ent->v.goalentity = EDICT_TO_PROG (&sv_pr_state, tent);
|
||||
return;
|
||||
}
|
||||
host_client->spec_track = i + 1; // now tracking
|
||||
|
||||
ent = EDICT_NUM (&sv_progs, host_client - svs.clients + 1);
|
||||
tent = EDICT_NUM (&sv_progs, i + 1);
|
||||
ent->v.goalentity = EDICT_TO_PROG (&sv_progs, tent);
|
||||
ent = EDICT_NUM (&sv_pr_state, host_client - svs.clients + 1);
|
||||
tent = EDICT_NUM (&sv_pr_state, i + 1);
|
||||
ent->v.goalentity = EDICT_TO_PROG (&sv_pr_state, tent);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1328,7 +1328,7 @@ AddLinksToPmove (areanode_t *node)
|
|||
int i;
|
||||
physent_t *pe;
|
||||
|
||||
pl = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
pl = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
|
||||
// touch linked edicts
|
||||
for (l = node->solid_edicts.next; l != &node->solid_edicts; l = next) {
|
||||
|
@ -1354,7 +1354,7 @@ AddLinksToPmove (areanode_t *node)
|
|||
pmove.numphysent++;
|
||||
|
||||
VectorCopy (check->v.origin, pe->origin);
|
||||
pe->info = NUM_FOR_EDICT (&sv_progs, check);
|
||||
pe->info = NUM_FOR_EDICT (&sv_pr_state, check);
|
||||
|
||||
if (check->v.solid == SOLID_BSP) {
|
||||
pe->model = sv.models[(int) (check->v.modelindex)];
|
||||
|
@ -1394,9 +1394,9 @@ AddAllEntsToPmove (void)
|
|||
physent_t *pe;
|
||||
int pl;
|
||||
|
||||
pl = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
check = NEXT_EDICT (&sv_progs, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_progs, check)) {
|
||||
pl = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
|
||||
if (check->free)
|
||||
continue;
|
||||
if (check->v.owner == pl)
|
||||
|
@ -1535,11 +1535,11 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
|||
sv_frametime = min (0.1, ucmd->msec * 0.001);
|
||||
|
||||
if (!host_client->spectator) {
|
||||
sv_progs.pr_global_struct->frametime = sv_frametime;
|
||||
sv_pr_state.pr_global_struct->frametime = sv_frametime;
|
||||
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->PlayerPreThink);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->PlayerPreThink);
|
||||
|
||||
SV_RunThink (sv_player);
|
||||
}
|
||||
|
@ -1596,7 +1596,7 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
|||
if (onground != -1) {
|
||||
sv_player->v.flags = (int) sv_player->v.flags | FL_ONGROUND;
|
||||
sv_player->v.groundentity =
|
||||
EDICT_TO_PROG (&sv_progs, EDICT_NUM (&sv_progs, pmove.physents[onground].info));
|
||||
EDICT_TO_PROG (&sv_pr_state, EDICT_NUM (&sv_pr_state, pmove.physents[onground].info));
|
||||
} else {
|
||||
sv_player->v.flags = (int) sv_player->v.flags & ~FL_ONGROUND;
|
||||
}
|
||||
|
@ -1621,12 +1621,12 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
|||
// touch other objects
|
||||
for (i = 0; i < pmove.numtouch; i++) {
|
||||
n = pmove.physents[pmove.touchindex[i]].info;
|
||||
ent = EDICT_NUM (&sv_progs, n);
|
||||
ent = EDICT_NUM (&sv_pr_state, n);
|
||||
if (!ent->v.touch || (playertouch[n / 8] & (1 << (n % 8))))
|
||||
continue;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, ent);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
PR_ExecuteProgram (&sv_progs, ent->v.touch);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, ent);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
PR_ExecuteProgram (&sv_pr_state, ent->v.touch);
|
||||
playertouch[n / 8] |= 1 << (n % 8);
|
||||
}
|
||||
}
|
||||
|
@ -1644,14 +1644,14 @@ SV_PostRunCmd (void)
|
|||
// run post-think
|
||||
|
||||
if (!host_client->spectator) {
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
PR_ExecuteProgram (&sv_progs, sv_progs.pr_global_struct->PlayerPostThink);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
PR_ExecuteProgram (&sv_pr_state, sv_pr_state.pr_global_struct->PlayerPostThink);
|
||||
SV_RunNewmis ();
|
||||
} else if (SpectatorThink) {
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, sv_player);
|
||||
PR_ExecuteProgram (&sv_progs, SpectatorThink);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
PR_ExecuteProgram (&sv_pr_state, SpectatorThink);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -314,16 +314,16 @@ SV_TouchLinks (edict_t *ent, areanode_t *node)
|
|||
|| ent->v.absmax[2] < touch->v.absmin[2])
|
||||
continue;
|
||||
|
||||
old_self = sv_progs.pr_global_struct->self;
|
||||
old_other = sv_progs.pr_global_struct->other;
|
||||
old_self = sv_pr_state.pr_global_struct->self;
|
||||
old_other = sv_pr_state.pr_global_struct->other;
|
||||
|
||||
sv_progs.pr_global_struct->self = EDICT_TO_PROG (&sv_progs, touch);
|
||||
sv_progs.pr_global_struct->other = EDICT_TO_PROG (&sv_progs, ent);
|
||||
sv_progs.pr_global_struct->time = sv.time;
|
||||
PR_ExecuteProgram (&sv_progs, touch->v.touch);
|
||||
sv_pr_state.pr_global_struct->self = EDICT_TO_PROG (&sv_pr_state, touch);
|
||||
sv_pr_state.pr_global_struct->other = EDICT_TO_PROG (&sv_pr_state, ent);
|
||||
sv_pr_state.pr_global_struct->time = sv.time;
|
||||
PR_ExecuteProgram (&sv_pr_state, touch->v.touch);
|
||||
|
||||
sv_progs.pr_global_struct->self = old_self;
|
||||
sv_progs.pr_global_struct->other = old_other;
|
||||
sv_pr_state.pr_global_struct->self = old_self;
|
||||
sv_pr_state.pr_global_struct->other = old_other;
|
||||
}
|
||||
|
||||
// recurse down both sides
|
||||
|
@ -778,9 +778,9 @@ SV_ClipToLinks (areanode_t *node, moveclip_t * clip)
|
|||
if (clip->trace.allsolid)
|
||||
return;
|
||||
if (clip->passedict) {
|
||||
if (PROG_TO_EDICT (&sv_progs, touch->v.owner) == clip->passedict)
|
||||
if (PROG_TO_EDICT (&sv_pr_state, touch->v.owner) == clip->passedict)
|
||||
continue; // don't clip against own missiles
|
||||
if (PROG_TO_EDICT (&sv_progs, clip->passedict->v.owner) == touch)
|
||||
if (PROG_TO_EDICT (&sv_pr_state, clip->passedict->v.owner) == touch)
|
||||
continue; // don't clip against owner
|
||||
}
|
||||
|
||||
|
@ -913,8 +913,8 @@ SV_TestPlayerPosition (edict_t *ent, vec3_t origin)
|
|||
VectorAdd (origin, ent->v.mins, boxmins);
|
||||
VectorAdd (origin, ent->v.maxs, boxmaxs);
|
||||
|
||||
check = NEXT_EDICT (&sv_progs, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_progs, check)) {
|
||||
check = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
||||
for (e = 1; e < sv.num_edicts; e++, check = NEXT_EDICT (&sv_pr_state, check)) {
|
||||
if (check->free)
|
||||
continue;
|
||||
if (check->v.solid != SOLID_BSP &&
|
||||
|
|
Loading…
Reference in a new issue