From 484edfde551587740bd10c047d2998df1026c471 Mon Sep 17 00:00:00 2001 From: Adam Olsen Date: Fri, 3 Aug 2001 07:37:21 +0000 Subject: [PATCH] Some of an aforementioned function to search for functions by name. Guess it's not as trivial as I thought. --- qw/source/sv_pr_cmds.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qw/source/sv_pr_cmds.c b/qw/source/sv_pr_cmds.c index 61fca72d9..9be53acce 100644 --- a/qw/source/sv_pr_cmds.c +++ b/qw/source/sv_pr_cmds.c @@ -1998,6 +1998,21 @@ PF_Checkextension (progs_t *pr) G_FLOAT(pr, OFS_RETURN) = 0; //FIXME make this function actually useful :P } +void +PF_checkfunction (progs_t *pr) +{ + char *name = G_STRING (pr, OFS_PARM0); + int i; + + for (i = 0; i < pr->numbuiltins; i++) { + if (pr->builtins[i].name && strequal (pr->builtins[i].name, name)) { + G_FUNCTION (pr, OFS_RETURN) = i; + return; + } + } + G_FUNCTION (pr, OFS_RETURN) = 0; +} + void SV_PR_Cmds_Init () { @@ -2120,4 +2135,5 @@ SV_PR_Cmds_Init () PR_AddBuiltin (&sv_pr_state, "cfwrite", PF_cfwrite, 106); // float (float desc, string buf) cfwrite = #106 PR_AddBuiltin (&sv_pr_state, "cfeof", PF_cfeof, 107); // float (float desc) cfeof = #107 PR_AddBuiltin (&sv_pr_state, "cfquota", PF_cfquota, 108); // float () cfquota = #108 + PR_AddBuiltin (&sv_pr_state, "checkfunction", PF_checkfunction, 109); // function (string name) checkfunction = #109 };