From: havoc Date: Tue, 25 Apr 2006 13:21:24 +0000 (+0000) Subject: reenabled support of find() with an empty string as the search value, this fixes... X-Git-Tag: xonotic-v0.1.0preview~4037 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b765d3b84f4557582b3fff801680838d8adcab47;p=xonotic%2Fdarkplaces.git reenabled support of find() with an empty string as the search value, this fixes the Blood Mage monster movement slight optimization to findflags and findchainflags git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6328 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/prvm_cmds.c b/prvm_cmds.c index b2ae2599..e298e8eb 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -783,12 +783,11 @@ void VM_find (void) f = PRVM_G_INT(OFS_PARM1); s = PRVM_G_STRING(OFS_PARM2); - if (!s || !s[0]) - { - // return reserved edict 0 (could be used for whatever the prog wants) - VM_RETURN_EDICT(prog->edicts); - return; - } + // LordHavoc: apparently BloodMage does a find(world, weaponmodel, "") and + // expects it to find all the monsters, so we must be careful to support + // searching for "" + if (!s) + s = ""; for (e++ ; e < prog->num_edicts ; e++) { @@ -798,7 +797,7 @@ void VM_find (void) continue; t = PRVM_E_STRING(ed,f); if (!t) - continue; + t = ""; if (!strcmp(t,s)) { VM_RETURN_EDICT(ed); @@ -876,11 +875,12 @@ void VM_findchain (void) f = PRVM_G_INT(OFS_PARM0); s = PRVM_G_STRING(OFS_PARM1); - if (!s || !s[0]) - { - VM_RETURN_EDICT(prog->edicts); - return; - } + + // LordHavoc: apparently BloodMage does a find(world, weaponmodel, "") and + // expects it to find all the monsters, so we must be careful to support + // searching for "" + if (!s) + s = ""; ent = PRVM_NEXT_EDICT(prog->edicts); for (i = 1;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent)) @@ -890,7 +890,7 @@ void VM_findchain (void) continue; t = PRVM_E_STRING(ent,f); if (!t) - continue; + t = ""; if (strcmp(t,s)) continue; @@ -975,6 +975,8 @@ void VM_findflags (void) ed = PRVM_EDICT_NUM(e); if (ed->priv.required->free) continue; + if (!PRVM_E_FLOAT(ed,f)) + continue; if ((int)PRVM_E_FLOAT(ed,f) & s) { VM_RETURN_EDICT(ed); @@ -1019,6 +1021,8 @@ void VM_findchainflags (void) prog->xfunction->builtinsprofile++; if (ent->priv.required->free) continue; + if (!PRVM_E_FLOAT(ent,f)) + continue; if (!((int)PRVM_E_FLOAT(ent,f) & s)) continue;