X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=prvm_cmds.c;h=f6a92d2b640bc5d47f782e4a3ffd32555c31e639;hb=10a2c31f2afb01affc8eacb388248fc787b09eb8;hp=fb68eea4cfd7ee1e1dff36590f3f0f2d3984ed41;hpb=3f570282ad9a4e7f53622026143e1be41619989b;p=xonotic%2Fdarkplaces.git diff --git a/prvm_cmds.c b/prvm_cmds.c index fb68eea4..f6a92d2b 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -94,6 +94,8 @@ float search_begin(string pattern, float caseinsensitive, float quiet) void search_end(float handle) float search_getsize(float handle) string search_getfilename(float handle, float num) + +string chr(float ascii) perhaps only : Menu : WriteMsg =============================== @@ -136,6 +138,8 @@ float getmousetarget(void) float isfunction(string function_name) vector getresolution(float number) string keynumtostring(float keynum) +string findkeysforcommand(string command) + */ @@ -2431,6 +2435,25 @@ void VM_search_getfilename(void) PRVM_G_INT(OFS_RETURN) = PRVM_SetString(tmp); } +/* +========= +VM_chr + +string chr(float ascii) +========= +*/ +void VM_chr(void) +{ + char *tmp; + VM_SAFEPARMCOUNT(1, VM_chr); + + tmp = VM_GetTempString(); + tmp[0] = (unsigned char) PRVM_G_FLOAT(OFS_PARM0); + tmp[1] = 0; + + PRVM_G_INT(OFS_RETURN) = PRVM_SetString(tmp); +} + //============================================================================= // Draw builtins (client & menu) @@ -3061,6 +3084,40 @@ void VM_M_keynumtostring(void) PRVM_G_INT(OFS_RETURN) = PRVM_SetString(tmp); } +/* +========= +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(char *command, int *keys); +void VM_M_findkeysforcommand(void) +{ + char *cmd, *ret; + int keys[NUMKEYS]; + int i; + + VM_SAFEPARMCOUNT(1, VM_M_findkeysforcommand); + + cmd = PRVM_G_STRING(OFS_PARM0); + + VM_CheckEmptyString(cmd); + + (ret = VM_GetTempString())[0] = 0; + + M_FindKeysForCommand(cmd, keys); + + for(i = 0; i < NUMKEYS; i++) + ret = strcat(ret, va(" \'%i\'", keys[i])); + + PRVM_G_INT(OFS_RETURN) = PRVM_SetString(ret); +} + prvm_builtin_t vm_m_builtins[] = { 0, // to be consistent with the old vm // common builtings (mostly) @@ -3141,7 +3198,8 @@ prvm_builtin_t vm_m_builtins[] = { VM_search_end, VM_search_getsize, VM_search_getfilename, // 77 - 0,0,0,// 80 + VM_chr, //78 + 0,0,// 80 e10, // 90 e10, // 100 e100, // 200 @@ -3187,7 +3245,8 @@ prvm_builtin_t vm_m_builtins[] = { VM_M_writetofile, VM_M_isfunction, VM_M_getresolution, - VM_M_keynumtostring // 609 + VM_M_keynumtostring, + VM_M_findkeysforcommand// 610 }; const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t); @@ -3201,4 +3260,4 @@ void VM_M_Cmd_Reset(void) { //VM_Cmd_Init(); VM_Cmd_Reset(); -} \ No newline at end of file +}