]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
Fix bug in stringbuffers with bufstr_set not updating num_strings; add a new builtin...
[xonotic/darkplaces.git] / prvm_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);