touch, think and blocked now support methods

also a little whitespace cleanup
This commit is contained in:
Bill Currie 2002-05-31 21:05:58 +00:00
parent 9e5f8c3bd9
commit e8026d9c76
10 changed files with 126 additions and 61 deletions

View file

@ -201,5 +201,56 @@ extern sv_fields_t sv_fields;
#define SVinteger(e,f) SVFIELD (e, f, integer)
extern func_t EndFrame;
extern progs_t sv_pr_state;
static inline void
sv_pr_touch (edict_t *self, edict_t *other)
{
int this;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
if ((this = sv_pr_state.fields.this) != -1) {
P_INT (&sv_pr_state, 0) = E_var (self, this, integer);
P_INT (&sv_pr_state, 1) = 0;
P_INT (&sv_pr_state, 2) = E_var (other, this, integer);
}
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, touch));
}
static inline void
sv_pr_use (edict_t *self, edict_t *other)
{
}
static inline void
sv_pr_think (edict_t *self)
{
int this;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
*sv_globals.other = 0;
if ((this = sv_pr_state.fields.this) != -1) {
P_INT (&sv_pr_state, 0) = E_var (self, this, integer);
P_INT (&sv_pr_state, 1) = 0;
P_INT (&sv_pr_state, 2) = 0;
}
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, think));
}
static inline void
sv_pr_blocked (edict_t *self, edict_t *other)
{
int this;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
if ((this = sv_pr_state.fields.this) != -1) {
P_INT (&sv_pr_state, 0) = E_var (self, this, integer);
P_INT (&sv_pr_state, 1) = 0;
P_INT (&sv_pr_state, 2) = E_var (other, this, integer);
}
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, blocked));
}
#endif // __sv_progs_h

View file

@ -384,8 +384,7 @@ SV_DropClient (qboolean crash)
saveSelf = *sv_globals.self;
*sv_globals.self =
EDICT_TO_PROG (&sv_pr_state, host_client->edict);
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.ClientDisconnect);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientDisconnect);
*sv_globals.self = saveSelf;
}

View file

@ -320,8 +320,7 @@ SV_Physics_Client (edict_t *ent, int num)
// call standard client pre-think
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.PlayerPreThink);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.PlayerPreThink);
// do a move
SV_CheckVelocity (ent);
@ -371,6 +370,5 @@ SV_Physics_Client (edict_t *ent, int num)
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, ent);
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.PlayerPostThink);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.PlayerPostThink);
}

View file

@ -274,8 +274,7 @@ SV_ConnectClient (int clientnum)
memcpy (client->spawn_parms, spawn_parms, sizeof (spawn_parms));
else {
// call the progs to get default spawn parms for the new client
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.SetNewParms);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.SetNewParms);
for (i = 0; i < NUM_SPAWN_PARMS; i++)
client->spawn_parms[i] = sv_globals.parms[i];
}
@ -889,8 +888,7 @@ SV_SaveSpawnparms (void)
// call the progs to get default spawn parms for the new client
*sv_globals.self =
EDICT_TO_PROG (&sv_pr_state, host_client->edict);
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.SetChangeParms);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.SetChangeParms);
for (j = 0; j < NUM_SPAWN_PARMS; j++)
host_client->spawn_parms[j] =
sv_globals.parms[j];

View file

@ -152,9 +152,7 @@ SV_RunThink (edict_t *ent)
// by a trigger with a local time.
SVfloat (ent, nextthink) = 0;
*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, SVfunc (ent, think));
sv_pr_think (ent);
if (ent->free)
return false;
@ -178,15 +176,11 @@ SV_Impact (edict_t *e1, edict_t *e2)
*sv_globals.time = sv.time;
if (SVfunc (e1, touch) && SVfloat (e1, solid) != SOLID_NOT) {
*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, SVfunc (e1, touch));
sv_pr_touch (e1, e2);
}
if (SVfunc (e2, touch) && SVfloat (e2, solid) != SOLID_NOT) {
*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, SVfunc (e2, touch));
sv_pr_touch (e2, e1);
}
*sv_globals.self = old_self;
@ -484,9 +478,7 @@ 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 (SVfunc (pusher, blocked)) {
*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, SVfunc (pusher, blocked));
sv_pr_blocked (pusher, check);
}
// move back any entities we already moved
for (i = 0; i < num_moved; i++) {
@ -537,9 +529,7 @@ SV_Physics_Pusher (edict_t *ent)
if (thinktime > oldltime && thinktime <= SVfloat (ent, ltime)) {
SVfloat (ent, nextthink) = 0;
*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, SVfunc (ent, think));
sv_pr_think (ent);
if (ent->free)
return;
}

View file

@ -291,10 +291,8 @@ SV_TouchLinks (edict_t *ent, areanode_t *node)
old_self = *sv_globals.self;
old_other = *sv_globals.other;
*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, SVfunc (touch, touch));
sv_pr_touch (touch, ent);
*sv_globals.self = old_self;
*sv_globals.other = old_other;

View file

@ -184,4 +184,54 @@ extern func_t SpectatorThink;
extern func_t SpectatorDisconnect;
extern func_t UserInfoCallback;
static inline void
sv_pr_touch (edict_t *self, edict_t *other)
{
int this;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
if ((this = sv_pr_state.fields.this) != -1) {
P_INT (&sv_pr_state, 0) = E_var (self, this, integer);
P_INT (&sv_pr_state, 1) = 0;
P_INT (&sv_pr_state, 2) = E_var (other, this, integer);
}
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, touch));
}
static inline void
sv_pr_use (edict_t *self, edict_t *other)
{
}
static inline void
sv_pr_think (edict_t *self)
{
int this;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
*sv_globals.other = 0;
if ((this = sv_pr_state.fields.this) != -1) {
P_INT (&sv_pr_state, 0) = E_var (self, this, integer);
P_INT (&sv_pr_state, 1) = 0;
P_INT (&sv_pr_state, 2) = 0;
}
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, think));
}
static inline void
sv_pr_blocked (edict_t *self, edict_t *other)
{
int this;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
if ((this = sv_pr_state.fields.this) != -1) {
P_INT (&sv_pr_state, 0) = E_var (self, this, integer);
P_INT (&sv_pr_state, 1) = 0;
P_INT (&sv_pr_state, 2) = E_var (other, this, integer);
}
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, blocked));
}
#endif // __sv_progs_h

View file

@ -155,9 +155,7 @@ SV_RunThink (edict_t *ent)
// by a trigger with a local time.
SVfloat (ent, nextthink) = 0;
*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, SVfunc (ent, think));
sv_pr_think (ent);
if (ent->free)
return false;
@ -181,15 +179,11 @@ SV_Impact (edict_t *e1, edict_t *e2)
*sv_globals.time = sv.time;
if (SVfunc (e1, touch) && SVfloat (e1, solid) != SOLID_NOT) {
*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, SVfunc (e1, touch));
sv_pr_touch (e1, e2);
}
if (SVfunc (e2, touch) && SVfloat (e2, solid) != SOLID_NOT) {
*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, SVfunc (e2, touch));
sv_pr_touch (e2, e1);
}
*sv_globals.self = old_self;
@ -491,11 +485,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 (SVfunc (pusher, blocked)) {
*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, SVfunc (pusher, blocked));
}
if (SVfunc (pusher, blocked))
sv_pr_blocked (pusher, check);
// move back any entities we already moved
for (i = 0; i < num_moved; i++) {
VectorCopy (moved_from[i], SVvector (moved_edict[i], origin));
@ -548,9 +540,7 @@ SV_Physics_Pusher (edict_t *ent)
VectorCopy (SVvector (ent, origin), oldorg);
SVfloat (ent, nextthink) = 0;
*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, SVfunc (ent, think));
sv_pr_think (ent);
if (ent->free)
return;
VectorSubtract (SVvector (ent, origin), oldorg, move);

View file

@ -1526,10 +1526,8 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
*sv_globals.frametime = sv_frametime;
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state,
sv_player);
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.PlayerPreThink);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.PlayerPreThink);
SV_RunThink (sv_player);
}
@ -1615,9 +1613,7 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
ent = EDICT_NUM (&sv_pr_state, n);
if (!SVfunc (ent, touch) || (playertouch[n / 8] & (1 << (n % 8))))
continue;
*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, SVfunc (ent, touch));
sv_pr_touch (ent, sv_player);
playertouch[n / 8] |= 1 << (n % 8);
}
}
@ -1635,15 +1631,12 @@ SV_PostRunCmd (void)
if (!host_client->spectator) {
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state,
sv_player);
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.PlayerPostThink);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.PlayerPostThink);
SV_RunNewmis ();
} else if (SpectatorThink) {
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state,
sv_player);
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, SpectatorThink);
}
}

View file

@ -291,10 +291,8 @@ SV_TouchLinks (edict_t *ent, areanode_t *node)
old_self = *sv_globals.self;
old_other = *sv_globals.other;
*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, SVfunc (touch, touch));
sv_pr_touch (touch, ent);
*sv_globals.self = old_self;
*sv_globals.other = old_other;