make edict pruning, field parsing and the builtins part of progs_t like they

should have been
This commit is contained in:
Bill Currie 2001-03-27 22:39:21 +00:00
parent 31295c1f63
commit 067db089a2
7 changed files with 36 additions and 24 deletions

View file

@ -140,8 +140,6 @@ int NUM_FOR_EDICT(progs_t *pr, edict_t *e);
extern int type_size[8];
typedef void (*builtin_t) (progs_t *pr);
extern builtin_t *pr_builtins;
extern int pr_numbuiltins;
ddef_t *PR_FindGlobal (progs_t *pr, const char *name);
@ -169,10 +167,6 @@ eval_t *GetEdictFieldValue(progs_t *pr, edict_t *ed, char *field);
char *PR_GetString(progs_t *pr, int num);
int PR_SetString(progs_t *pr, char *s);
// externaly supplied functions
int ED_Parse_Extra_Fields (progs_t *pr, char *key, char *value);
int ED_Prune_Edict (progs_t *pr, edict_t *ent);
//============================================================================
@ -238,6 +232,12 @@ struct progs_s {
void (*unlink)(edict_t *ent);
void (*flush)(void);
int (*parse_field)(progs_t *pr, char *key, char *value);
int (*prune_edict)(progs_t *pr, edict_t *ent);
builtin_t *builtins;
int numbuiltins;
// required globals
struct {
float *time;

View file

@ -846,7 +846,7 @@ ED_ParseEdict (progs_t * pr, char *data, edict_t *ent)
key = ED_FindField (pr, keyname);
if (!key) {
if (!ED_Parse_Extra_Fields (pr, keyname, com_token)) {
if (!pr->parse_field || !pr->parse_field (pr, keyname, com_token)) {
Con_Printf ("'%s' is not a field\n", keyname);
continue;
}
@ -913,7 +913,7 @@ ED_LoadFromFile (progs_t * pr, char *data)
data = ED_ParseEdict (pr, data, ent);
// remove things from different skill levels or deathmatch
if (ED_Prune_Edict (pr, ent)) {
if (pr->prune_edict && pr->prune_edict (pr, ent)) {
ED_Free (pr, ent);
inhibit++;
continue;

View file

@ -661,9 +661,9 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
// built in functions
int i = -newf->first_statement;
if (i >= pr_numbuiltins)
if (i >= pr->numbuiltins)
PR_RunError (pr, "Bad builtin call number");
pr_builtins[i] (pr);
pr->builtins[i] (pr);
break;
}

View file

@ -1902,7 +1902,7 @@ PF_checkextension (progs_t *pr)
}
builtin_t pr_builtin[] = {
builtin_t sv_builtins[] = {
PF_Fixme,
PF_makevectors, // void(entity e) makevectors
// = #1;
@ -2065,5 +2065,4 @@ builtin_t pr_builtin[] = {
PF_checkextension,
};
builtin_t *pr_builtins = pr_builtin;
int pr_numbuiltins = sizeof (pr_builtin) / sizeof (pr_builtin[0]);
int sv_numbuiltins = sizeof (sv_builtins) / sizeof (sv_builtins[0]);

View file

@ -66,8 +66,8 @@ cvar_t *saved2;
cvar_t *saved3;
cvar_t *saved4;
int
ED_Prune_Edict (progs_t *pr, edict_t *ent)
static int
prune_edict (progs_t *pr, edict_t *ent)
{
// remove things from different skill levels or deathmatch
if (deathmatch->int_val) {
@ -119,8 +119,8 @@ PR_Profile_f (void)
PR_Profile (&sv_pr_state);
}
int
ED_Parse_Extra_Fields (progs_t * pr, char *key, char *value)
static int
parse_field (progs_t * pr, char *key, char *value)
{
return 0;
}
@ -275,6 +275,9 @@ sv_fields.radsuit_finished = ED_GetFieldIndex (&sv_pr_state, "radsuit_finished")
sv_fields.speed = ED_GetFieldIndex (&sv_pr_state, "speed");
}
extern builtin_t sv_builtins[];
extern int sv_numbuiltins;
void
SV_Progs_Init (void)
{
@ -283,6 +286,10 @@ SV_Progs_Init (void)
sv_pr_state.time = &sv.time;
sv_pr_state.reserved_edicts = &svs.maxclients;
sv_pr_state.unlink = SV_UnlinkEdict;
sv_pr_state.builtins = sv_builtins;
sv_pr_state.numbuiltins = sv_numbuiltins;
sv_pr_state.parse_field = parse_field;
sv_pr_state.prune_edict = prune_edict;
Cmd_AddCommand ("edict", ED_PrintEdict_f,
"Report information on a given edict in the game. (edict (edict number))");

View file

@ -1643,7 +1643,7 @@ PF_Checkextension (progs_t *pr)
G_FLOAT(pr, OFS_RETURN) = 0; //FIXME make this function actually useful :P
}
builtin_t pr_builtin[] = {
builtin_t sv_builtins[] = {
PF_Fixme,
PF_makevectors, // void(entity e) makevectors
// = #1;
@ -1788,5 +1788,4 @@ builtin_t pr_builtin[] = {
PF_Checkextension,
};
builtin_t *pr_builtins = pr_builtin;
int pr_numbuiltins = sizeof (pr_builtin) / sizeof (pr_builtin[0]);
int sv_numbuiltins = sizeof (sv_builtins) / sizeof (sv_builtins[0]);

View file

@ -59,8 +59,8 @@ func_t SpectatorThink;
static int reserved_edicts = MAX_CLIENTS;
int
ED_Prune_Edict (progs_t *pr, edict_t *ent)
static int
prune_edict (progs_t *pr, edict_t *ent)
{
if (((int) SVFIELD (ent, spawnflags, float) & SPAWNFLAG_NOT_DEATHMATCH))
return 1;
@ -100,8 +100,8 @@ PR_Profile_f (void)
PR_Profile (&sv_pr_state);
}
int
ED_Parse_Extra_Fields (progs_t *pr, char *key, char *value)
static int
parse_field (progs_t *pr, char *key, char *value)
{
/*
If skyname is set, we want to allow skyboxes and set what the skybox
@ -256,6 +256,9 @@ SV_LoadProgs (void)
sv_fields.colormod = ED_GetFieldIndex (&sv_pr_state, "colormod");
}
extern builtin_t sv_builtins[];
extern int sv_numbuiltins;
void
SV_Progs_Init (void)
{
@ -265,6 +268,10 @@ SV_Progs_Init (void)
sv_pr_state.reserved_edicts = &reserved_edicts;
sv_pr_state.unlink = SV_UnlinkEdict;
sv_pr_state.flush = SV_FlushSignon;
sv_pr_state.builtins = sv_builtins;
sv_pr_state.numbuiltins = sv_numbuiltins;
sv_pr_state.parse_field = parse_field;
sv_pr_state.prune_edict = prune_edict;
Cmd_AddCommand ("edict", ED_PrintEdict_f, "Report information on a given edict in the game. (edict (edict number))");
Cmd_AddCommand ("edicts", ED_PrintEdicts_f, "Display information on all edicts in the game.");