Filter/Fixups

* fixed wrong indizes for gem color picker in locale 3 (deDE)
 * fixed interpretation of filter enums. Some are providing their value directly, others have an intermediate key.
 * createSQLForCriterium is no longer abstract. (was implemented in exactly the same way everywhere)
 * erronous criteria are now logged and discarded entirely)
This commit is contained in:
Sarjuuk
2023-08-02 23:29:53 +02:00
parent 837fdf78a0
commit 0f186576d3
16 changed files with 30 additions and 148 deletions

View File

@@ -908,7 +908,7 @@ abstract class Filter
[FILTER_CR_FLAG, <string:colName>, <int:testBit>, <bool:matchAny>] # default param2: matchExact [FILTER_CR_FLAG, <string:colName>, <int:testBit>, <bool:matchAny>] # default param2: matchExact
[FILTER_CR_NUMERIC, <string:colName>, <int:NUM_FLAGS>, <bool:addExtraCol>] [FILTER_CR_NUMERIC, <string:colName>, <int:NUM_FLAGS>, <bool:addExtraCol>]
[FILTER_CR_STRING, <string:colName>, <int:STR_FLAGS>, null] [FILTER_CR_STRING, <string:colName>, <int:STR_FLAGS>, null]
[FILTER_CR_ENUM, <string:colName>, <bool:useANY>, <bool:useNONE>] [FILTER_CR_ENUM, <string:colName>, <bool:ANYNONE>, <bool:isEnumVal>] # param3 ? cr[2] is val in enum : key in enum
[FILTER_CR_STAFFFLAG, <string:colName>, null, null] [FILTER_CR_STAFFFLAG, <string:colName>, null, null]
[FILTER_CR_CALLBACK, <string:fnName>, <mixed:param1>, <mixed:param2>] [FILTER_CR_CALLBACK, <string:fnName>, <mixed:param1>, <mixed:param2>]
[FILTER_CR_NYI_PH, null, <int:returnVal>, param2] # mostly 1: to ignore this criterium; 0: to fail the whole query [FILTER_CR_NYI_PH, null, <int:returnVal>, param2] # mostly 1: to ignore this criterium; 0: to fail the whole query
@@ -1072,7 +1072,8 @@ abstract class Filter
// criteria // criteria
foreach ($this->criteriaIterator() as &$_cr) foreach ($this->criteriaIterator() as &$_cr)
$this->cndSet[] = $this->createSQLForCriterium($_cr); if ($cnd = $this->createSQLForCriterium($_cr))
$this->cndSet[] = $cnd;
if ($this->cndSet) if ($this->cndSet)
array_unshift($this->cndSet, empty($this->fiData['v']['ma']) ? 'AND' : 'OR'); array_unshift($this->cndSet, empty($this->fiData['v']['ma']) ? 'AND' : 'OR');
@@ -1514,9 +1515,11 @@ abstract class Filter
$result = $this->genericString($gen[1], $cr[2], $gen[2]); $result = $this->genericString($gen[1], $cr[2], $gen[2]);
break; break;
case FILTER_CR_ENUM: case FILTER_CR_ENUM:
if (isset($this->enums[$cr[0]][$cr[1]])) if (!$gen[3] && isset($this->enums[$cr[0]][$cr[1]]))
$result = $this->genericEnum($gen[1], $this->enums[$cr[0]][$cr[1]]); $result = $this->genericEnum($gen[1], $this->enums[$cr[0]][$cr[1]]);
else if (($gen[2] && $cr[1] == FILTER_ENUM_ANY) || ($gen[3] && $cr[1] == FILTER_ENUM_NONE)) if ($gen[3] && in_array($cr[1], $this->enums[$cr[0]]))
$result = $this->genericEnum($gen[1], $cr[1]);
else if ($gen[2] && ($cr[1] == FILTER_ENUM_ANY || $cr[1] == FILTER_ENUM_NONE))
$result = $this->genericEnum($gen[1], $cr[1]); $result = $this->genericEnum($gen[1], $cr[1]);
break; break;
case FILTER_CR_CALLBACK: case FILTER_CR_CALLBACK:
@@ -1550,7 +1553,23 @@ abstract class Filter
/* non-generic values and criteria */ /* non-generic values and criteria */
/***********************************/ /***********************************/
abstract protected function createSQLForCriterium(&$cr); protected function createSQLForCriterium(array &$cr) : array
{
if (!$this->genericFilter) // criteria not in use - no error
return [];
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
$this->error = true;
trigger_error('Filter::createSQLForCriterium - received unhandled criterium: ["'.$cr[0].'", "'.$cr[1].'", "'.$cr[2].'"]', E_USER_WARNING);
unset($cr);
return [];
}
abstract protected function createSQLForValues(); abstract protected function createSQLForValues();
} }

View File

@@ -330,17 +330,6 @@ class AchievementListFilter extends Filter
'maxpt' => [FILTER_V_RANGE, [1, 99], false] // required level max 'maxpt' => [FILTER_V_RANGE, [1, 99], false] // required level max
); );
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if (($genCr = $this->genericCriterion($cr)) !== null)
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -70,17 +70,6 @@ class AreaTriggerListFilter extends Filter
'ty' => [FILTER_V_RANGE, [0, 5], true ] // types 'ty' => [FILTER_V_RANGE, [0, 5], true ] // types
); );
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -55,8 +55,6 @@ class ArenaTeamListFilter extends Filter
'sv' => [FILTER_V_CALLBACK, 'cbServerCheck', false], // server 'sv' => [FILTER_V_CALLBACK, 'cbServerCheck', false], // server
); );
protected function createSQLForCriterium(&$cr) { }
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -295,7 +295,7 @@ class CreatureListFilter extends Filter
2 => [FILTER_CR_CALLBACK, 'cbHealthMana', 'manaMin', 'manaMax' ], // mana [num] 2 => [FILTER_CR_CALLBACK, 'cbHealthMana', 'manaMin', 'manaMax' ], // mana [num]
3 => [FILTER_CR_CALLBACK, 'cbFaction', null, null ], // faction [enum] 3 => [FILTER_CR_CALLBACK, 'cbFaction', null, null ], // faction [enum]
5 => [FILTER_CR_FLAG, 'npcflag', NPC_FLAG_REPAIRER ], // canrepair 5 => [FILTER_CR_FLAG, 'npcflag', NPC_FLAG_REPAIRER ], // canrepair
6 => [FILTER_CR_ENUM, 's.areaId', ], // foundin 6 => [FILTER_CR_ENUM, 's.areaId', false, true ], // foundin
7 => [FILTER_CR_CALLBACK, 'cbQuestRelation', 'startsQuests', 0x1 ], // startsquest [enum] 7 => [FILTER_CR_CALLBACK, 'cbQuestRelation', 'startsQuests', 0x1 ], // startsquest [enum]
8 => [FILTER_CR_CALLBACK, 'cbQuestRelation', 'endsQuests', 0x2 ], // endsquest [enum] 8 => [FILTER_CR_CALLBACK, 'cbQuestRelation', 'endsQuests', 0x2 ], // endsquest [enum]
9 => [FILTER_CR_BOOLEAN, 'lootId', ], // lootable 9 => [FILTER_CR_BOOLEAN, 'lootId', ], // lootable
@@ -344,17 +344,6 @@ class CreatureListFilter extends Filter
'rh' => [FILTER_V_LIST, [-1, 0, 1], false] // react horde [int] 'rh' => [FILTER_V_LIST, [-1, 0, 1], false] // react horde [int]
); );
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -312,17 +312,6 @@ class EnchantmentListFilter extends Filter
'ty' => [FILTER_V_RANGE, [1, 8], true ] // types 'ty' => [FILTER_V_RANGE, [1, 8], true ] // types
); );
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -144,15 +144,11 @@ class GameObjectListFilter extends Filter
protected $enums = array( protected $enums = array(
1 => parent::ENUM_ZONE, 1 => parent::ENUM_ZONE,
16 => parent::ENUM_EVENT, 16 => parent::ENUM_EVENT,
50 => array( 50 => [1, 2, 3, 4, 663, 883]
null, 1, 2, 3, 4,
663 => 663,
883 => 883
)
); );
protected $genericFilter = array( protected $genericFilter = array(
1 => [FILTER_CR_ENUM, 's.areaId' ], // foundin 1 => [FILTER_CR_ENUM, 's.areaId', false, true], // foundin
2 => [FILTER_CR_CALLBACK, 'cbQuestRelation', 'startsQuests', 0x1 ], // startsquest [side] 2 => [FILTER_CR_CALLBACK, 'cbQuestRelation', 'startsQuests', 0x1 ], // startsquest [side]
3 => [FILTER_CR_CALLBACK, 'cbQuestRelation', 'endsQuests', 0x2 ], // endsquest [side] 3 => [FILTER_CR_CALLBACK, 'cbQuestRelation', 'endsQuests', 0x2 ], // endsquest [side]
4 => [FILTER_CR_CALLBACK, 'cbOpenable', null, null], // openable [yn] 4 => [FILTER_CR_CALLBACK, 'cbOpenable', null, null], // openable [yn]
@@ -174,17 +170,6 @@ class GameObjectListFilter extends Filter
'ma' => [FILTER_V_EQUAL, 1, false] // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false] // match any / all filter
); );
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCR = $this->genericCriterion($cr))
return $genCR;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -97,8 +97,6 @@ class GuildListFilter extends Filter
'sv' => [FILTER_V_CALLBACK, 'cbServerCheck', false], // server 'sv' => [FILTER_V_CALLBACK, 'cbServerCheck', false], // server
); );
protected function createSQLForCriterium(&$cr) { }
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -164,17 +164,6 @@ class IconListFilter extends Filter
return $ids ? ['id', array_keys($ids), '!'] : [1]; return $ids ? ['id', array_keys($ids), '!'] : [1];
} }
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -1889,7 +1889,7 @@ class ItemListFilter extends Filter
88 => [FILTER_CR_CALLBACK, 'cbObtainedBy', 20, null ], // otprospecting [yn] 88 => [FILTER_CR_CALLBACK, 'cbObtainedBy', 20, null ], // otprospecting [yn]
89 => [FILTER_CR_FLAG, 'flags', ITEM_FLAG_PROSPECTABLE ], // prospectable 89 => [FILTER_CR_FLAG, 'flags', ITEM_FLAG_PROSPECTABLE ], // prospectable
90 => [FILTER_CR_CALLBACK, 'cbAvgBuyout', null, null ], // avgbuyout [op] [int] 90 => [FILTER_CR_CALLBACK, 'cbAvgBuyout', null, null ], // avgbuyout [op] [int]
91 => [FILTER_CR_ENUM, 'totemCategory' ], // tool 91 => [FILTER_CR_ENUM, 'totemCategory', false, true ], // tool
92 => [FILTER_CR_CALLBACK, 'cbObtainedBy', 5, null ], // soldbyvendor [yn] 92 => [FILTER_CR_CALLBACK, 'cbObtainedBy', 5, null ], // soldbyvendor [yn]
93 => [FILTER_CR_CALLBACK, 'cbObtainedBy', 3, null ], // otpvp [pvp] 93 => [FILTER_CR_CALLBACK, 'cbObtainedBy', 3, null ], // otpvp [pvp]
94 => [FILTER_CR_NUMERIC, 'is.splpen', NUM_CAST_INT, true ], // splpen 94 => [FILTER_CR_NUMERIC, 'is.splpen', NUM_CAST_INT, true ], // splpen
@@ -2049,17 +2049,6 @@ class ItemListFilter extends Filter
return $this->wtCnd; return $this->wtCnd;
} }
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -204,17 +204,6 @@ class ItemsetListFilter extends Filter
'ta' => [FILTER_V_RANGE, [1, 30], false] // tag / content group 'ta' => [FILTER_V_RANGE, [1, 30], false] // tag / content group
); );
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCR = $this->genericCriterion($cr))
return $genCR;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -308,17 +308,6 @@ class ProfileListFilter extends Filter
$this->useLocalList = true; $this->useLocalList = true;
} }
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCR = $this->genericCriterion($cr))
return $genCR;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -485,17 +485,6 @@ class QuestListFilter extends Filter
'ty' => [FILTER_V_LIST, [0, 1, 21, 41, 62, [81, 85], 88, 89], true ] // type 'ty' => [FILTER_V_LIST, [0, 1, 21, 41, 62, [81, 85], 88, 89], true ] // type
); );
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -101,14 +101,6 @@ class SoundListFilter extends Filter
'ty' => [FILTER_V_LIST, [[1, 4], 6, 9, 10, 12, 13, 14, 16, 17, [19, 23], [25, 31], 50, 52, 53], true ] // type 'ty' => [FILTER_V_LIST, [[1, 4], 6, 9, 10, 12, 13, 14, 16, 17, [19, 23], [25, 31], 50, 52, 53], true ] // type
); );
// we have no criteria for this one...
protected function createSQLForCriterium(&$cr)
{
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -2547,17 +2547,6 @@ class SpellListFilter extends Filter
'me' => [FILTER_V_RANGE, [1, 31], false] // mechanics 'me' => [FILTER_V_RANGE, [1, 31], false] // mechanics
); );
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -3612,8 +3612,8 @@ var LANG = {
[1, "Heilig"], [0, "Physisch"] [1, "Heilig"], [0, "Physisch"]
], ],
gem: [ gem: [
[7, "Ja"], [1, "Meta"], [2, "Rot"], [3, "Gelb"], [4, "Blau"], [5, "Ja"], [1, "Meta"], [2, "Rot"], [3, "Gelb"], [4, "Blau"],
[8, "Nein"] [6, "Nein"]
], ],
profession: [ profession: [
[11, "Ja"], [1, "Alchemie"], [13, "Angeln"], [9, "Bergbau"], [6, "Erste Hilfe"], [11, "Ja"], [1, "Alchemie"], [13, "Angeln"], [9, "Bergbau"], [6, "Erste Hilfe"],