]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix bug in stringbuffers with bufstr_set not updating num_strings; add a new builtin...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Jan 2008 01:46:58 +0000 (01:46 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Jan 2008 01:46:58 +0000 (01:46 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7979 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c
prvm_cmds.h
svvm_cmds.c

index a3505fe8e63ff0637002be738f198e969139eb01..c3292266cbe6f135ad567251d1bfee600b53a483 100644 (file)
@@ -3916,6 +3916,7 @@ void VM_bufstr_set (void)
        }
 
        BufStr_Expand(stringbuffer, strindex);
+       stringbuffer->num_strings = max(stringbuffer->num_strings, strindex + 1);
 
        if(stringbuffer->strings[strindex])
                Mem_Free(stringbuffer->strings[strindex]);
@@ -3964,7 +3965,7 @@ void VM_bufstr_add (void)
        }
        order = (int)PRVM_G_FLOAT(OFS_PARM2);
        if(order)
-               strindex = stringbuffer->num_strings++;
+               strindex = stringbuffer->num_strings;
        else
                for (strindex = 0;strindex < stringbuffer->num_strings;strindex++)
                        if (stringbuffer->strings[strindex] == NULL)
@@ -4452,6 +4453,17 @@ void VM_strncasecmp (void)
        }
 }
 
+// #487 float(float caseinsensitive, string s, ...) hash
+void VM_hash(void)
+{
+       float insensitive;
+       static char s[VM_STRINGTEMP_LENGTH];
+       VM_SAFEPARMCOUNTRANGE(2, 8, VM_hash);
+       insensitive = PRVM_G_FLOAT(OFS_PARM0);
+       VM_VarString(1, s, sizeof(s));
+       PRVM_G_FLOAT(OFS_RETURN) = (unsigned short) ((insensitive ? CRC_Block_CaseInsensitive : CRC_Block) ((unsigned char *) s, strlen(s)));
+}
+
 void VM_wasfreed (void)
 {
        VM_SAFEPARMCOUNT(1, VM_wasfreed);
index 85f8e8763bbda113c7b492ef59b2aea960b96d52..33eedb555e2fa561e3ab138dfd69a286ae481ea8 100644 (file)
@@ -404,6 +404,8 @@ void VM_wasfreed (void);
 void VM_strreplace (void);
 void VM_strireplace (void);
 
+void VM_hash(void);
+
 void VM_SetTraceGlobals(const trace_t *trace);
 
 void VM_Cmd_Init(void);
index 45e5adccd0f4a2fdbdb4c9d7de7a93cc5fb5714d..74e0e4785c207fff21a9aa8a52527a84b594cb20 100644 (file)
@@ -3296,7 +3296,7 @@ VM_SV_pointsound,                         // #483 void(vector origin, string sample, float volume, fl
 VM_strreplace,                                 // #484 string(string search, string replace, string subject) strreplace (DP_QC_STRREPLACE)
 VM_strireplace,                                        // #485 string(string search, string replace, string subject) strireplace (DP_QC_STRREPLACE)
 VM_SV_getsurfacepointattribute,// #486 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
-NULL,                                                  // #487
+VM_hash,                                               // #487 float(float caseinsensitive, string s, ...) hash = #487;
 NULL,                                                  // #488
 NULL,                                                  // #489
 NULL,                                                  // #490