From: havoc Date: Tue, 16 Sep 2008 13:36:21 +0000 (+0000) Subject: patch from esteel making the findkeysforcommand builtin available in X-Git-Tag: xonotic-v0.1.0preview~2078 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=6e48dafd2f198e53ef8031379080656e9483e709;hp=ad0206e3d383e1f61887081b9dc80ba7a5a6cdb0 patch from esteel making the findkeysforcommand builtin available in csqc (formerly only available in menu qc) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8506 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/clvm_cmds.c b/clvm_cmds.c index f1d3b4ac..289e531e 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -3494,6 +3494,8 @@ NULL, // #516 NULL, // #517 NULL, // #518 NULL, // #519 +VM_keynumtostring, // #520 string keynumtostring(float keynum) +VM_findkeysforcommand, // #521 string findkeysforcommand(string command) }; const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t); diff --git a/mvm_cmds.c b/mvm_cmds.c index 5b507dd3..d4c447b1 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -229,40 +229,6 @@ void VM_M_getresolution(void) PRVM_G_VECTOR(OFS_RETURN)[2] = 0; } -/* -========= -VM_M_findkeysforcommand - -string findkeysforcommand(string command) - -the returned string is an altstring -========= -*/ -#define NUMKEYS 5 // TODO: merge the constant in keys.c with this one somewhen - -void M_FindKeysForCommand(const char *command, int *keys); -void VM_M_findkeysforcommand(void) -{ - const char *cmd; - char ret[VM_STRINGTEMP_LENGTH]; - int keys[NUMKEYS]; - int i; - - VM_SAFEPARMCOUNT(1, VM_M_findkeysforcommand); - - cmd = PRVM_G_STRING(OFS_PARM0); - - VM_CheckEmptyString(cmd); - - M_FindKeysForCommand(cmd, keys); - - ret[0] = 0; - for(i = 0; i < NUMKEYS; i++) - strlcat(ret, va(" \'%i\'", keys[i]), sizeof(ret)); - - PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(ret); -} - /* ========= VM_M_getserverliststat @@ -1454,7 +1420,7 @@ VM_writetofile, // #606 void writetofile(float fhandle, entity ent) VM_M_isfunction, // #607 float isfunction(string function_name) VM_M_getresolution, // #608 vector getresolution(float number) VM_keynumtostring, // #609 string keynumtostring(float keynum) -VM_M_findkeysforcommand, // #610 string findkeysforcommand(string command) +VM_findkeysforcommand, // #610 string findkeysforcommand(string command) VM_M_getserverliststat, // #611 float gethostcachevalue(float type) VM_M_getserverliststring, // #612 string gethostcachestring(float type, float hostnr) VM_parseentitydata, // #613 void parseentitydata(entity ent, string data) diff --git a/prvm_cmds.c b/prvm_cmds.c index 2a4ebc87..6d88a9d6 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -3173,6 +3173,40 @@ void VM_keynumtostring (void) PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(Key_KeynumToString((int)PRVM_G_FLOAT(OFS_PARM0))); } +/* +========= +VM_findkeysforcommand + +string findkeysforcommand(string command) + +the returned string is an altstring +========= +*/ +#define NUMKEYS 5 // TODO: merge the constant in keys.c with this one somewhen + +void M_FindKeysForCommand(const char *command, int *keys); +void VM_findkeysforcommand(void) +{ + const char *cmd; + char ret[VM_STRINGTEMP_LENGTH]; + int keys[NUMKEYS]; + int i; + + VM_SAFEPARMCOUNT(1, VM_findkeysforcommand); + + cmd = PRVM_G_STRING(OFS_PARM0); + + VM_CheckEmptyString(cmd); + + M_FindKeysForCommand(cmd, keys); + + ret[0] = 0; + for(i = 0; i < NUMKEYS; i++) + strlcat(ret, va(" \'%i\'", keys[i]), sizeof(ret)); + + PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(ret); +} + /* ========= VM_stringtokeynum diff --git a/prvm_cmds.h b/prvm_cmds.h index 54c8d7db..42cd5d7c 100644 --- a/prvm_cmds.h +++ b/prvm_cmds.h @@ -359,6 +359,7 @@ void VM_makevectors (void); void VM_vectorvectors (void); void VM_keynumtostring (void); +void VM_findkeysforcommand (void); void VM_stringtokeynum (void); void VM_cin_open( void );