From 84d2e30940f999fbf9252de7dc0c7bb2fd5f471a Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Thu, 12 Feb 2026 10:28:23 +0100 Subject: [PATCH] Filters/Fixup * implement NPC 'has location' criterium * fix NPC 'uses model' criterium using string comparison on int values --- includes/dbtypes/creature.class.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/includes/dbtypes/creature.class.php b/includes/dbtypes/creature.class.php index 9dcbe7d2..8c21a7b3 100644 --- a/includes/dbtypes/creature.class.php +++ b/includes/dbtypes/creature.class.php @@ -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]; + } } ?>