Now, bufstr_set'ing an item to string_null will yield string_null on bufstr_get,
and bufstr_set'ing an item to "" will yield "" on bufstr_get.
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10184
d7cf8633-e32d-0410-b094-
e92efae38249
::stable-branch::merge=
9399e2dd28d4db4dde5fc1f03af9cbf2c3aad3ac
*/
void VM_bufstr_set (void)
{
*/
void VM_bufstr_set (void)
{
int strindex;
prvm_stringbuffer_t *stringbuffer;
const char *news;
int strindex;
prvm_stringbuffer_t *stringbuffer;
const char *news;
Mem_Free(stringbuffer->strings[strindex]);
stringbuffer->strings[strindex] = NULL;
Mem_Free(stringbuffer->strings[strindex]);
stringbuffer->strings[strindex] = NULL;
- news = PRVM_G_STRING(OFS_PARM2);
- if (news && news[0])
+ if(PRVM_G_INT(OFS_PARM2))
- size_t alloclen = strlen(news) + 1;
+ // not the NULL string!
+ news = PRVM_G_STRING(OFS_PARM2);
+ alloclen = strlen(news) + 1;
stringbuffer->strings[strindex] = (char *)Mem_Alloc(prog->progs_mempool, alloclen);
memcpy(stringbuffer->strings[strindex], news, alloclen);
}
stringbuffer->strings[strindex] = (char *)Mem_Alloc(prog->progs_mempool, alloclen);
memcpy(stringbuffer->strings[strindex], news, alloclen);
}
VM_Warning("VM_bufstr_add: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
return;
}
VM_Warning("VM_bufstr_add: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
return;
}
- string = PRVM_G_STRING(OFS_PARM1);
- if(!string || !string[0])
+ if(!PRVM_G_INT(OFS_PARM1)) // NULL string
{
VM_Warning("VM_bufstr_add: can not add an empty string to buffer %i in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
return;
}
{
VM_Warning("VM_bufstr_add: can not add an empty string to buffer %i in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
return;
}
+ string = PRVM_G_STRING(OFS_PARM1);
order = (int)PRVM_G_FLOAT(OFS_PARM2);
if(order)
strindex = stringbuffer->num_strings;
order = (int)PRVM_G_FLOAT(OFS_PARM2);
if(order)
strindex = stringbuffer->num_strings;