Filters/Fixup

* implement NPC 'has location' criterium
 * fix NPC 'uses model' criterium using string comparison on int values
This commit is contained in:
Sarjuuk 2026-02-12 10:28:23 +01:00
parent 2216b664fa
commit 84d2e30940

View file

@ -328,12 +328,12 @@ class CreatureListFilter extends Filter
31 => [parent::CR_FLAG, 'cuFlags', CUSTOM_HAS_SCREENSHOT ], // hasscreenshots
32 => [parent::CR_FLAG, 'cuFlags', NPC_CU_INSTANCE_BOSS ], // instanceboss
33 => [parent::CR_FLAG, 'cuFlags', CUSTOM_HAS_COMMENT ], // hascomments
34 => [parent::CR_STRING, 'modelId', STR_MATCH_EXACT | STR_ALLOW_SHORT ], // usemodel [str] (wants int in string fmt <_<)
34 => [parent::CR_CALLBACK, 'cbUseModel' ], // usemodel [str]
35 => [parent::CR_STRING, 'textureString' ], // useskin [str]
37 => [parent::CR_NUMERIC, 'id', NUM_CAST_INT, true ], // id
38 => [parent::CR_CALLBACK, 'cbRelEvent', null, null ], // relatedevent [enum]
40 => [parent::CR_FLAG, 'cuFlags', CUSTOM_HAS_VIDEO ], // hasvideos
41 => [parent::CR_NYI_PH, 1, null ], // haslocation [yn] [staff]
41 => [parent::CR_CALLBACK, 'cbHasLocation' ], // haslocation [yn] [staff]
42 => [parent::CR_CALLBACK, 'cbReputation', '>', null ], // increasesrepwith [enum]
43 => [parent::CR_CALLBACK, 'cbReputation', '<', null ], // decreasesrepwith [enum]
44 => [parent::CR_CALLBACK, 'cbSpecialSkinLoot', NPC_TYPEFLAG_SKIN_WITH_ENGINEERING, null ] // salvageable [yn]
@ -551,6 +551,23 @@ class CreatureListFilter extends Filter
return $facTpls ? ['faction', $facTpls] : [0];
}
// input is string, so there is no prompt for an operator. But a CR_NUMERIC expects crs to not be 0
protected function cbUseModel(int $cr, int $crs, string $crv) : ?array
{
if (!Util::checkNumeric($crv, NUM_CAST_INT))
return null;
return ['modelId', $crv];
}
protected function cbHasLocation(int $cr, int $crs, string $crv) : ?array
{
if (!$this->int2Bool($crs))
return null;
return ['s.typeId', null, $crs ? '!' : null];
}
}
?>