From 824e9a3f2178deeca89aa347c122676f184d26be Mon Sep 17 00:00:00 2001 From: divverent Date: Fri, 23 Jan 2009 10:32:27 +0000 Subject: [PATCH] add an argument to filter out a cvar prefix git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8664 d7cf8633-e32d-0410-b094-e92efae38249 --- clvm_cmds.c | 2 +- mvm_cmds.c | 2 +- prvm_cmds.c | 23 +++++++++++++++++++---- svvm_cmds.c | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/clvm_cmds.c b/clvm_cmds.c index beb7db28..82ce9fbd 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -3547,7 +3547,7 @@ VM_uri_get, // #513 float(string uril, float id) uri_get = #512; (DP_QC_URI VM_tokenize_console, // #514 float(string str) tokenize_console = #514; (DP_QC_TOKENIZE_CONSOLE) VM_argv_start_index, // #515 float(float idx) argv_start_index = #515; (DP_QC_TOKENIZE_CONSOLE) VM_argv_end_index, // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE) -VM_buf_cvarlist, // #517 void(float buf, string prefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST) +VM_buf_cvarlist, // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST) VM_cvar_description, // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION) NULL, // #519 VM_keynumtostring, // #520 string keynumtostring(float keynum) diff --git a/mvm_cmds.c b/mvm_cmds.c index af39e50a..69ed427e 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -1338,7 +1338,7 @@ VM_uri_get, // #513 float(string uril, float id) uri_get = #513; (DP_QC_URI VM_tokenize_console, // #514 float(string str) tokenize_console = #514; (DP_QC_TOKENIZE_CONSOLE) VM_argv_start_index, // #515 float(float idx) argv_start_index = #515; (DP_QC_TOKENIZE_CONSOLE) VM_argv_end_index, // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE) -VM_buf_cvarlist, // #517 void(float buf, string prefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST) +VM_buf_cvarlist, // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST) VM_cvar_description, // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION) NULL, // #519 NULL, // #520 diff --git a/prvm_cmds.c b/prvm_cmds.c index 3356fda5..51559a91 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -439,6 +439,7 @@ float CVAR_TYPEFLAG_SAVED = 2; float CVAR_TYPEFLAG_PRIVATE = 4; float CVAR_TYPEFLAG_ENGINE = 8; float CVAR_TYPEFLAG_HASDESCRIPTION = 16; +float CVAR_TYPEFLAG_READONLY = 32; ================= */ void VM_cvar_type (void) @@ -468,6 +469,8 @@ void VM_cvar_type (void) ret |= 8; // CVAR_TYPE_ENGINE if(cvar->description != cvar_dummy_description) ret |= 16; // CVAR_TYPE_HASDESCRIPTION + if(cvar->flags & CVAR_READONLY) + ret |= 32; // CVAR_TYPE_READONLY PRVM_G_FLOAT(OFS_RETURN) = ret; } @@ -4391,12 +4394,12 @@ void VM_bufstr_free (void) void VM_buf_cvarlist(void) { cvar_t *cvar; - const char *partial; - size_t len; + const char *partial, *antipartial; + size_t len, antilen; size_t alloclen; int n; prvm_stringbuffer_t *stringbuffer; - VM_SAFEPARMCOUNT(2, VM_bufstr_free); + VM_SAFEPARMCOUNTRANGE(2, 3, VM_buf_cvarlist); stringbuffer = (prvm_stringbuffer_t *)Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, (int)PRVM_G_FLOAT(OFS_PARM0)); if(!stringbuffer) @@ -4410,6 +4413,15 @@ void VM_buf_cvarlist(void) len = 0; else len = strlen(partial); + + if(prog->argc == 3) + antipartial = PRVM_G_STRING(OFS_PARM2); + else + antipartial = NULL; + if(!antipartial) + antilen = 0; + else + antilen = strlen(antipartial); for (n = 0;n < stringbuffer->num_strings;n++) if (stringbuffer->strings[n]) @@ -4433,7 +4445,10 @@ void VM_buf_cvarlist(void) n = 0; for(cvar = cvar_vars; cvar; cvar = cvar->next) { - if(partial && strncasecmp(partial, cvar->name, len)) + if(len && strncasecmp(partial, cvar->name, len)) + continue; + + if(antilen && !strncasecmp(antipartial, cvar->name, antilen)) continue; alloclen = strlen(cvar->name) + 1; diff --git a/svvm_cmds.c b/svvm_cmds.c index 08440e65..3fcba476 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -3422,7 +3422,7 @@ VM_uri_get, // #513 float(string uril, float id) uri_get = #513; (DP_QC_URI VM_tokenize_console, // #514 float(string str) tokenize_console = #514; (DP_QC_TOKENIZE_CONSOLE) VM_argv_start_index, // #515 float(float idx) argv_start_index = #515; (DP_QC_TOKENIZE_CONSOLE) VM_argv_end_index, // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE) -VM_buf_cvarlist, // #517 void(float buf, string prefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST) +VM_buf_cvarlist, // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST) VM_cvar_description, // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION) NULL, // #519 }; -- 2.39.2