From 53ee50655ca97867a024c3ce36c8add8c4b26f4e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 12 Nov 2004 11:15:00 +0000 Subject: [PATCH] allow the progs code to hook into the parsing processes This is an imperfect revision of history. --- libs/gamecode/builtins/pr_cmds.c | 86 ++++++++++++++++++++------------ nq/source/sv_pr_cmds.c | 3 ++ qw/source/sv_pr_cmds.c | 9 ++++ 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/libs/gamecode/builtins/pr_cmds.c b/libs/gamecode/builtins/pr_cmds.c index f44e4b570..5d47d61b5 100644 --- a/libs/gamecode/builtins/pr_cmds.c +++ b/libs/gamecode/builtins/pr_cmds.c @@ -599,42 +599,66 @@ PR_gametype (progs_t *pr) RETURN_STRING (pr, pr_gametype); } +static void +PF_PR_SetField (progs_t *pr) +{ + edict_t *ent = P_EDICT (pr, 0); + ddef_t *field = PR_FindField (pr, P_GSTRING (pr, 1)); + const char *value = P_GSTRING (pr, 2); + + R_INT (pr) = 0; + if (field) + R_INT (pr) = ED_ParseEpair (pr, ent->v, field, value); +} + +static void +PF_PR_FindFunction (progs_t *pr) +{ + dfunction_t *func = PR_FindFunction (pr, P_GSTRING (pr, 0)); + R_FUNCTION (pr) = 0; + if (func) + R_FUNCTION (pr) = func - pr->pr_functions; +} + #define QF (PR_RANGE_QF << PR_RANGE_SHIFT) | static builtin_t builtins[] = { - {"break", PF_break, 6}, - {"random", PF_random, 7}, - {"normalize", PF_normalize, 9}, - {"vlen", PF_vlen, 12}, - {"vectoyaw", PF_vectoyaw, 13}, - {"find", PF_Find, 18}, - {"dprint", PF_dprint, 25}, - {"ftos", PF_ftos, 26}, - {"vtos", PF_vtos, 27}, - {"coredump", PF_coredump, 28}, - {"traceon", PF_traceon, 29}, - {"traceoff", PF_traceoff, 30}, - {"eprint", PF_eprint, 31}, - {"rint", PF_rint, 36}, - {"floor", PF_floor, 37}, - {"ceil", PF_ceil, 38}, - {"fabs", PF_fabs, 43}, - {"cvar", PF_cvar, 45}, - {"nextent", PF_nextent, 47}, - {"vectoangles", PF_vectoangles, 51}, - {"cvar_set", PF_cvar_set, 72}, - {"stof", PF_stof, 81}, + {"break", PF_break, 6}, + {"random", PF_random, 7}, + {"normalize", PF_normalize, 9}, + {"vlen", PF_vlen, 12}, + {"vectoyaw", PF_vectoyaw, 13}, + {"find", PF_Find, 18}, + {"dprint", PF_dprint, 25}, + {"ftos", PF_ftos, 26}, + {"vtos", PF_vtos, 27}, + {"coredump", PF_coredump, 28}, + {"traceon", PF_traceon, 29}, + {"traceoff", PF_traceoff, 30}, + {"eprint", PF_eprint, 31}, + {"rint", PF_rint, 36}, + {"floor", PF_floor, 37}, + {"ceil", PF_ceil, 38}, + {"fabs", PF_fabs, 43}, + {"cvar", PF_cvar, 45}, + {"nextent", PF_nextent, 47}, + {"vectoangles", PF_vectoangles, 51}, + {"cvar_set", PF_cvar_set, 72}, + {"stof", PF_stof, 81}, - {"strlen", PF_strlen, QF 100}, - {"charcount", PF_charcount, QF 101}, - {"sprintf", PF_sprintf, QF 109}, - {"ftoi", PF_ftoi, QF 110}, - {"itof", PF_itof, QF 111}, - {"itos", PF_itos, QF 112}, - {"stoi", PF_stoi, QF 113}, - {"stov", PF_stov, QF 114}, - {"gametype", PR_gametype, QF 115}, + {"strlen", PF_strlen, QF 100}, + {"charcount", PF_charcount, QF 101}, + {"sprintf", PF_sprintf, QF 109}, + {"ftoi", PF_ftoi, QF 110}, + {"itof", PF_itof, QF 111}, + {"itos", PF_itos, QF 112}, + {"stoi", PF_stoi, QF 113}, + {"stov", PF_stov, QF 114}, + {"gametype", PR_gametype, QF 115}, + + {"PR_SetField", PF_PR_SetField, -1}, + {"PR_FindFunction", PF_PR_FindFunction, -1}, {0} }; diff --git a/nq/source/sv_pr_cmds.c b/nq/source/sv_pr_cmds.c index eeb98ab3b..da47422ed 100644 --- a/nq/source/sv_pr_cmds.c +++ b/nq/source/sv_pr_cmds.c @@ -1440,6 +1440,9 @@ static builtin_t builtins[] = { {"freeboxhull", PF_freeboxhull, QF 96}, {"rotate_bbox", PF_rotate_bbox, QF 97}, {"checkextension", PF_checkextension, QF 99}, + + {"EntityParseFunction", ED_EntityParseFunction, -1}, + {0} }; diff --git a/qw/source/sv_pr_cmds.c b/qw/source/sv_pr_cmds.c index 74d7e02c3..d1e3e21ed 100644 --- a/qw/source/sv_pr_cmds.c +++ b/qw/source/sv_pr_cmds.c @@ -699,6 +699,13 @@ PF_Remove (progs_t *pr) edict_t *ed; ed = P_EDICT (pr, 0); + if (NUM_FOR_EDICT (pr, ed) < *pr->reserved_edicts) { + if (pr_double_remove->int_val == 1) { + PR_DumpState (pr); + SV_Printf ("Reserved entity remove\n"); + } else // == 2 + PR_RunError (pr, "Reserved entity remove\n"); + } if (ed->free && pr_double_remove->int_val) { if (pr_double_remove->int_val == 1) { PR_DumpState (pr); @@ -2007,6 +2014,8 @@ static builtin_t builtins[] = { {"SV_SetPing", PR_SV_SetPing, -1}, {"SV_UserCmd", PR_SV_UserCmd, -1}, {"SV_Spawn", PR_SV_Spawn, -1}, + + {"EntityParseFunction", ED_EntityParseFunction, -1}, {0} };