Core/Conditions

* rewritten and moved to its own class, should be easier to expand in the future
 * add missing sources and types from TrinityCore
 * implement conditions on Areatrigger and Loot containers
 * implement reverse lookups (e.g. a spell is a conditional for something else)
 * general beautification pass .. should be more legible in general

NOTE:
 * texts have been changed, so the existing translation for esES ist gone
 * selecting and describing condition targets is still wonky
This commit is contained in:
Sarjuuk
2024-04-01 21:33:09 +02:00
parent 84555afae3
commit bc7d561da2
26 changed files with 2158 additions and 1272 deletions

View File

@@ -266,6 +266,15 @@ class AchievementPage extends GenericPage
$this->extendGlobalData($coList->getJSGlobals());
}
// tab: condition for
$cnd = new Conditions();
if ($cnd->getByCondition(Type::ACHIEVEMENT, $this->typeId))
{
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for');
}
/*****************/
/* Criteria List */
/*****************/

View File

@@ -115,6 +115,15 @@ class AreaTriggerPage extends GenericPage
/* Extra Tabs */
/**************/
// tab: conditions
$cnd = new Conditions();
$cnd->getBySourceEntry($this->typeId, Conditions::SRC_AREATRIGGER_CLIENT);
if ($tab = $cnd->toListviewTab());
{
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $tab;
}
if ($_type == AT_TYPE_OBJECTIVE)
{
$relQuest = new QuestList(array(['id', $this->subject->getField('quest')]));

View File

@@ -118,9 +118,7 @@ class CurrencyPage extends GenericPage
if (!$soldBy->error)
{
$sbData = $soldBy->getListviewData();
$extraCols = ['$Listview.extraCols.stock', "\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'];
$holidays = [];
$extraCols = ['$Listview.extraCols.stock', "\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost', '$Listview.extraCols.condition'];
foreach ($sbData as $k => &$row)
{
$items = [];
@@ -137,14 +135,9 @@ class CurrencyPage extends GenericPage
$items[] = [-$id, $qty];
}
if ($vendors[$k][0]['event'])
{
if (count($extraCols) == 3) // not already pushed
$extraCols[] = '$Listview.extraCols.condition';
$this->extendGlobalIds(Type::WORLDEVENT, $vendors[$k][0]['event']);
$row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $vendors[$k][0]['event']]];
}
if ($e = $vendors[$k][0]['event'])
if (Conditions::extendListviewRow($row, Conditions::SRC_NONE, $k, [Conditions::ACTIVE_EVENT, $e]))
$this->extendGlobalIds(Type::WORLDEVENT, $e);
$row['stock'] = $vendors[$k][0]['stock'];
$row['stack'] = $itemObj->getField('buyCount');
@@ -155,6 +148,10 @@ class CurrencyPage extends GenericPage
);
}
// no conditions > remove conditions column
if (!array_column($sbData, 'condition'))
array_pop($extraCols);
$this->lvTabs[] = [CreatureList::$brickFile, array(
'data' => array_values($sbData),
'name' => '$LANG.tab_soldby',

View File

@@ -244,21 +244,16 @@ class EventPage extends GenericPage
$this->extendGlobalData($relEvents->getJSGlobals());
$relData = $relEvents->getListviewData();
foreach ($relEvents->getFoundIDs() as $id)
$relData[$id]['condition'][0][$this->typeId][] = [[-CND_ACTIVE_EVENT, $this->eId]];
Conditions::extendListviewRow($relData[$id], Conditions::SRC_NONE, $this->typeId, [-Conditions::ACTIVE_EVENT, $this->eId]);
$this->extendGlobalData($this->subject->getJSGlobals());
$d = $this->subject->getListviewData();
foreach ($rel as $r)
{
if ($r <= 0)
continue;
if ($r > 0)
if (Conditions::extendListviewRow($d[$this->eId], Conditions::SRC_NONE, $this->typeId, [-Conditions::ACTIVE_EVENT, $r]))
$this->extendGlobalIds(Type::WORLDEVENT, $r);
$this->extendGlobalIds(Type::WORLDEVENT, $r);
$d = $this->subject->getListviewData();
$d[$this->eId]['condition'][0][$this->typeId][] = [[-CND_ACTIVE_EVENT, $r]];
$relData = array_merge($relData, $d);
}
$relData = array_merge($relData, $d);
$this->lvTabs[] = [WorldEventList::$brickFile, array(
'data' => array_values($relData),
@@ -269,6 +264,14 @@ class EventPage extends GenericPage
)];
}
}
// tab: condition for
$cnd = new Conditions();
if ($cnd->getByCondition(Type::WORLDEVENT, $this->typeId))
{
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for');
}
}
protected function generateTooltip() : string
@@ -343,7 +346,6 @@ class EventPage extends GenericPage
$data['endDate'] = $updated['end'] ? date(Util::$dateFormatInternal, $updated['end']) : false;
$data['rec'] = $updated['rec'];
}
}
}
}

View File

@@ -443,8 +443,8 @@ class ItemPage extends genericPage
foreach ($lvData as $sId => &$data)
{
$data['percent'] = $perfItem[$sId]['perfectCreateChance'];
$data['condition'][0][$this->typeId] = [[[CND_SPELL, $perfItem[$sId]['requiredSpecialization']]]];
$this->extendGlobalIDs(Type::SPELL, $perfItem[$sId]['requiredSpecialization']);
if (Conditions::extendListviewRow($data, Conditions::SRC_NONE, $this->typeId, [Conditions::SPELL, $perfItem[$sId]['requiredSpecialization']]))
$this->extendGlobalIDs(Type::SPELL, $perfItem[$sId]['requiredSpecialization']);
}
$this->lvTabs[] = [SpellList::$brickFile, array(
@@ -471,7 +471,6 @@ class ItemPage extends genericPage
if ($idx == 16)
$createdBy = array_column($tabData['data'], 'id');
$s = $sm = null;
if ($idx == 4 && $this->subject->getSources($s, $sm) && $s[0] == SRC_DROP && isset($sm[0]['dd']))
{
switch ($sm[0]['dd'])
@@ -492,76 +491,36 @@ class ItemPage extends genericPage
// tabs: this item contains..
$sourceFor = array(
[LOOT_ITEM, $this->subject->id, '$LANG.tab_contains', 'contains', ['$Listview.extraCols.percent'], [] , []],
[LOOT_PROSPECTING, $this->subject->id, '$LANG.tab_prospecting', 'prospecting', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []],
[LOOT_MILLING, $this->subject->id, '$LANG.tab_milling', 'milling', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []],
[LOOT_DISENCHANT, $this->subject->getField('disenchantId'), '$LANG.tab_disenchanting', 'disenchanting', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []]
[LOOT_ITEM, $this->subject->id, '$LANG.tab_contains', 'contains', ['$Listview.extraCols.percent'], [] ],
[LOOT_PROSPECTING, $this->subject->id, '$LANG.tab_prospecting', 'prospecting', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel']],
[LOOT_MILLING, $this->subject->id, '$LANG.tab_milling', 'milling', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel']],
[LOOT_DISENCHANT, $this->subject->getField('disenchantId'), '$LANG.tab_disenchanting', 'disenchanting', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel']]
);
$reqQuest = [];
foreach ($sourceFor as $sf)
foreach ($sourceFor as [$lootTemplate, $lootId, $tabName, $tabId, $extraCols, $hiddenCols])
{
$lootTab = new Loot();
if ($lootTab->getByContainer($sf[0], $sf[1]))
if ($lootTab->getByContainer($lootTemplate, $lootId))
{
$this->extendGlobalData($lootTab->jsGlobals);
$sf[4] = array_merge($sf[4], $lootTab->extraCols);
foreach ($lootTab->iterate() as $lv)
{
if (!$lv['quest'])
continue;
$sf[4] = array_merge($sf[4], ['$Listview.extraCols.condition']);
$reqQuest[$lv['id']] = 0;
$lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
}
$extraCols = array_merge($extraCols, $lootTab->extraCols);
$tabData = array(
'data' => array_values($lootTab->getResult()),
'name' => $sf[2],
'id' => $sf[3],
'name' => $tabName,
'id' => $tabId,
);
if ($sf[4])
$tabData['extraCols'] = array_unique($sf[4]);
if ($extraCols)
$tabData['extraCols'] = array_unique($extraCols);
if ($sf[5])
$tabData['hiddenCols'] = array_unique($sf[5]);
if ($sf[6])
$tabData['visibleCols'] = array_unique($sf[6]);
if ($hiddenCols)
$tabData['hiddenCols'] = array_unique($hiddenCols);
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
}
}
if ($reqIds = array_keys($reqQuest)) // apply quest-conditions as back-reference
{
$conditions = array(
'OR',
['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds],
['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds],
['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds],
['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]
);
$reqQuests = new QuestList($conditions);
$reqQuests->getJSGlobals(GLOBALINFO_SELF);
foreach ($reqQuests->iterate() as $qId => $__)
{
if (empty($reqQuests->requires[$qId][Type::ITEM]))
continue;
foreach ($reqIds as $rId)
if (in_array($rId, $reqQuests->requires[$qId][Type::ITEM]))
$reqQuest[$rId] = $reqQuests->id;
}
}
// tab: container can contain
if ($this->subject->getField('slots') > 0)
{
@@ -795,7 +754,7 @@ class ItemPage extends genericPage
$extraCols = ['$Listview.extraCols.stock', "\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'];
$holidays = [];
$cnd = new Conditions();
foreach ($sbData as $k => &$row)
{
$currency = [];
@@ -817,13 +776,7 @@ class ItemPage extends genericPage
$row['cost'] = [empty($vendors[$k][0][0]) ? 0 : $vendors[$k][0][0]];
if ($e = $vendors[$k][0]['event'])
{
if (count($extraCols) == 3)
$extraCols[] = '$Listview.extraCols.condition';
$this->extendGlobalIds(Type::WORLDEVENT, $e);
$row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $e]];
}
$cnd->addExternalCondition(Conditions::SRC_NONE, $k, [Conditions::ACTIVE_EVENT, $e]);
if ($currency || $tokens) // fill idx:3 if required
$row['cost'][] = $currency;
@@ -841,6 +794,8 @@ class ItemPage extends genericPage
$row['stack'] = $x;
}
if ($cnd->toListviewColumn($sbData, $extraCols))
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = [CreatureList::$brickFile, array(
'data' => array_values($sbData),
@@ -1102,11 +1057,11 @@ class ItemPage extends genericPage
}
// itemsource
if ($this->subject->getSources($s, $m))
if ($this->subject->getSources($s, $sm))
{
$json['source'] = $s;
if ($m)
$json['sourcemore'] = $m;
if ($sm)
$json['sourcemore'] = $sm;
}
$xml->addChild('json')->addCData(substr(json_encode($json), 1, -1));

View File

@@ -572,40 +572,25 @@ class NpcPage extends GenericPage
$this->extendGlobalData($teaches->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$data = $teaches->getListviewData();
$extra = [];
$extraCols = [];
$cnd = new Conditions();
foreach ($tSpells as $sId => $train)
{
if (empty($data[$sId]))
continue;
if ($_ = $train['reqSkillId'])
{
if (count($data[$sId]['skill']) == 1 && $_ != $data[$sId]['skill'][0])
{
$this->extendGlobalIds(Type::SKILL, $_);
if (!isset($extra[0]))
$extra[0] = '$Listview.extraCols.condition';
$data[$sId]['condition'][0][$this->typeId][] = [[CND_SKILL, $_, $train['reqSkillValue']]];
}
}
$cnd->addExternalCondition(Conditions::SRC_NONE, $sId, [Conditions::SKILL, $_, $train['reqSkillValue']]);
for ($i = 1; $i < 3; $i++)
{
if ($_ = $train['reqSpellId'.$i])
{
$this->extendGlobalIds(Type::SPELL, $_);
if (!isset($extra[0]))
$extra[0] = '$Listview.extraCols.condition';
$data[$sId]['condition'][0][$this->typeId][] = [[CND_SPELL, $_]];
}
}
$cnd->addExternalCondition(Conditions::SRC_NONE, $sId, [Conditions::SPELL, $_]);
if ($_ = $train['reqLevel'])
{
if (!isset($extra[1]))
$extra[1] = "\$Listview.funcBox.createSimpleCol('reqLevel', LANG.tooltip_reqlevel, '7%', 'reqLevel')";
if (!isset($extraCols[1]))
$extraCols[1] = "\$Listview.funcBox.createSimpleCol('reqLevel', LANG.tooltip_reqlevel, '7%', 'reqLevel')";
$data[$sId]['reqLevel'] = $_;
}
@@ -614,6 +599,9 @@ class NpcPage extends GenericPage
$data[$sId]['trainingcost'] = $_;
}
if ($cnd->toListviewColumn($data, $extraCols))
$this->extendGlobalData($cnd->getJsGlobals());
$tabData = array(
'data' => array_values($data),
'name' => '$LANG.tab_teaches',
@@ -621,8 +609,8 @@ class NpcPage extends GenericPage
'visibleCols' => ['trainingcost']
);
if ($extra)
$tabData['extraCols'] = array_values($extra);
if ($extraCols)
$tabData['extraCols'] = array_values($extraCols);
$this->lvTabs[] = [SpellList::$brickFile, $tabData];
}
@@ -639,28 +627,23 @@ class NpcPage extends GenericPage
{
$colAddIn = null;
$extraCols = ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'];
if ($soldItems->hasSetFields('condition'))
$extraCols[] = '$Listview.extraCols.condition';
$lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [Type::NPC => [$this->typeId]]);
if (array_column($lvData, 'condition'))
$extraCols[] = '$Listview.extraCols.condition';
if (array_filter(array_column($lvData, 'restock')))
{
$extraCols[] = '$_';
$colAddIn = 'vendorRestockCol';
}
$sc = Util::getServerConditions(CND_SRC_NPC_VENDOR, $this->typeId);
if (!empty($sc[0]))
$cnd = new Conditions();
if ($cnd->getBySourceGroup($this->typeId, Conditions::SRC_NPC_VENDOR))
{
$this->extendGlobalData($sc[1]);
$extraCols[] = '$Listview.extraCols.condition';
foreach ($lvData as $id => &$row)
foreach ($sc[0] as $srcType => $cndData)
if (!empty($cndData[$id.':'.$this->typeId]))
$row['condition'][0][$id.':'.$this->typeId] = $cndData[$id.':'.$this->typeId];
$this->extendGlobalData($cnd->getJsGlobals());
$cnd->toListviewColumn($lvData, $extraCols);
}
$this->lvTabs[] = [ItemList::$brickFile, array(
@@ -725,65 +708,36 @@ class NpcPage extends GenericPage
foreach ($lootGOs as $idx => $lgo)
array_splice($sourceFor, 1, 0, [[LOOT_GAMEOBJECT, $lgo['lootId'], $mapType ? $langref[($mapType == 1 ? -1 : 1) + ($lgo['modeDummy'] ? 1 : 0)] : '$LANG.tab_drops', 'drops-object-'.$idx, [], 'note' => '$$WH.sprintf(LANG.lvnote_npcobjectsource, '.$lgo['id'].', "'.Util::localizedString($lgo, 'name').'")']]);
$lootGOs = DB::World()->select('select SourceEntry, ConditionValue1, ConditionValue2 from conditions where SourceTypeOrReferenceId = 1 and SourceGroup = ?d and ConditionTypeOrReference = ?d', $this->typeId, CND_SKILL);
$reqQuest = [];
foreach ($sourceFor as $sf)
foreach ($sourceFor as [$lootTpl, $lootId, $tabName, $tabId, $hiddenCols])
{
$creatureLoot = new Loot();
if ($creatureLoot->getByContainer($sf[0], $sf[1]))
if ($creatureLoot->getByContainer($lootTpl, $lootId))
{
$extraCols = $creatureLoot->extraCols;
$extraCols[] = '$Listview.extraCols.percent';
$this->extendGlobalData($creatureLoot->jsGlobals);
$this->extendWithConditions($creatureLoot, $lootGOs, $extraCols, $reqQuest);
$tabData = array(
'data' => array_values($creatureLoot->getResult()),
'name' => $sf[2],
'id' => $sf[3],
'extraCols' => $extraCols,
'name' => $tabName,
'id' => $tabId,
'extraCols' => array_values(array_unique($extraCols)),
'sort' => ['-percent', 'name']
);
if (!empty($sf['note']))
$tabData['note'] = $sf['note'];
else if ($sf[0] == LOOT_SKINNING)
else if ($lootTpl == LOOT_SKINNING)
$tabData['note'] = '<b>'.Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill($skinTab[2], $this->subject->getField('maxLevel')), Lang::FMT_HTML).'</b>';
if ($sf[4])
$tabData['hiddenCols'] = $sf[4];
if ($hiddenCols)
$tabData['hiddenCols'] = $hiddenCols;
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
}
}
if ($reqIds = array_keys($reqQuest)) // apply quest-conditions as back-reference
{
$conditions = array(
'OR',
['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds],
['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds],
['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds],
['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]
);
$reqQuests = new QuestList($conditions);
$this->extendGlobalData($reqQuests->getJSGlobals());
foreach ($reqQuests->iterate() as $qId => $__)
{
if (empty($reqQuests->requires[$qId][Type::ITEM]))
continue;
foreach ($reqIds as $rId)
if (in_array($rId, $reqQuests->requires[$qId][Type::ITEM]))
$reqQuest[$rId] = $reqQuests->id;
}
}
// tab: starts quest
// tab: ends quest
$startEnd = new QuestList(array(['qse.type', Type::NPC], ['qse.typeId', $this->typeId]));
@@ -914,6 +868,14 @@ class NpcPage extends GenericPage
$this->lvTabs[] = [SoundList::$brickFile, $tabData];
}
}
// tab: conditions
$cnd = new Conditions();
if ($cnd->getBySourceEntry($this->typeId, Conditions::SRC_CREATURE_TEMPLATE_VEHICLE))
{
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab();
}
}
protected function generateTooltip()
@@ -1045,49 +1007,6 @@ class NpcPage extends GenericPage
return [$quotes, $nQuotes];
}
private function getConditions($itemId, $data)
{
foreach ($data as $datum)
{
if ($datum['SourceEntry'] == $itemId)
{
return [CND_SKILL, $datum['ConditionValue1'], $datum['ConditionValue2']];
}
}
return null;
}
private function extendWithConditions($creatureLoot, $lootConditions, &$extraCols, &$reqQuest)
{
$hasExtraCol = false;
$reqSkill = [];
foreach ($creatureLoot->iterate() as &$lv)
{
if ($lv['quest'])
{
$hasExtraCol = true;
$reqQuest[$lv['id']] = 0;
$lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
}
elseif ($skill = $this->getConditions($lv['id'], $lootConditions))
{
$hasExtraCol = true;
$lv['condition'][0][$this->typeId][] = [$skill];
$reqSkill[] = $skill[1];
}
}
if ($hasExtraCol)
{
$extraCols[] = '$Listview.extraCols.condition';
}
$reqSkills = new SkillList(['OR', ['id', array_unique($reqSkill)]]);
$this->extendGlobalData($reqSkills->getJSGlobals());
}
}

View File

@@ -230,7 +230,7 @@ class ObjectPage extends GenericPage
$relBoss = null;
if ($ll = DB::Aowow()->selectRow('SELECT * FROM ?_loot_link WHERE objectId = ?d ORDER BY priority DESC LIMIT 1', $this->typeId))
if ($ll = DB::Aowow()->selectRow('SELECT * FROM ?_loot_link WHERE `objectId` = ?d ORDER BY `priority` DESC LIMIT 1', $this->typeId))
{
// group encounter
if ($ll['encounterId'])
@@ -386,7 +386,6 @@ class ObjectPage extends GenericPage
}
// tab: contains
$reqQuest = [];
if ($_ = $this->subject->getField('lootId'))
{
$goLoot = new Loot();
@@ -397,24 +396,18 @@ class ObjectPage extends GenericPage
$hiddenCols = ['source', 'side', 'slot', 'reqlevel'];
$this->extendGlobalData($goLoot->jsGlobals);
$lootResult = $goLoot->getResult();
foreach ($goLoot->iterate() as &$lv)
foreach ($hiddenCols as $k => $str)
{
if (!empty($hiddenCols))
foreach ($hiddenCols as $k => $str)
if (!empty($lv[$str]))
unset($hiddenCols[$k]);
if (!$lv['quest'])
continue;
$extraCols[] = '$Listview.extraCols.condition';
$reqQuest[$lv['id']] = 0;
$lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
if ($k == 1 && array_filter(array_column($lootResult, $str), function ($x) { return $x != SIDE_BOTH; }))
unset($hiddenCols[$k]);
else if ($k != 1 && array_column($lootResult, $str))
unset($hiddenCols[$k]);
}
$tabData = array(
'data' => array_values($goLoot->getResult()),
'data' => array_values($lootResult),
'id' => 'contains',
'name' => '$LANG.tab_contains',
'sort' => ['-percent', 'name'],
@@ -422,36 +415,12 @@ class ObjectPage extends GenericPage
);
if ($hiddenCols)
$tabData['hiddenCols'] = $hiddenCols;
$tabData['hiddenCols'] = array_values($hiddenCols);
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
}
}
if ($reqIds = array_keys($reqQuest)) // apply quest-conditions as back-reference
{
$conditions = array(
'OR',
['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds],
['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds],
['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds],
['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]
);
$reqQuests = new QuestList($conditions);
$this->extendGlobalData($reqQuests->getJSGlobals());
foreach ($reqQuests->iterate() as $qId => $__)
{
if (empty($reqQuests->requires[$qId][Type::ITEM]))
continue;
foreach ($reqIds as $rId)
if (in_array($rId, $reqQuests->requires[$qId][Type::ITEM]))
$reqQuest[$rId] = $reqQuests->id;
}
}
// tab: Spell Focus for
if ($sfId = $this->subject->getField('spellFocusId'))
{

View File

@@ -1012,49 +1012,19 @@ class QuestPage extends GenericPage
}
// tab: conditions
$cnd = [];
$cnd = new Conditions();
$cnd->getBySourceEntry($this->typeId, Conditions::SRC_QUEST_AVAILABLE, Conditions::SRC_QUEST_SHOW_MARK);
if ($_ = $this->subject->getField('reqMinRepFaction'))
{
$cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0][] = [CND_REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMinRepValue'))];
$this->extendGlobalIds(Type::FACTION, $_);
}
$cnd->addExternalCondition(Conditions::SRC_QUEST_AVAILABLE, $this->typeId, [Conditions::REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMinRepValue'))]);
if ($_ = $this->subject->getField('reqMaxRepFaction'))
$cnd->addExternalCondition(Conditions::SRC_QUEST_AVAILABLE, $this->typeId, [-Conditions::REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMaxRepValue'))]);
if ($tab = $cnd->toListviewTab())
{
$cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0][] = [-CND_REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMaxRepValue'))];
$this->extendGlobalIds(Type::FACTION, $_);
}
$_ = Util::getServerConditions([CND_SRC_QUEST_ACCEPT, CND_SRC_QUEST_SHOW_MARK], null, $this->typeId);
if (!empty($_[0]))
{
// awkward merger
if (isset($_[0][CND_SRC_QUEST_ACCEPT][$this->typeId][0]))
{
if (isset($cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0]))
$cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0] = array_merge($cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0], $_[0][CND_SRC_QUEST_ACCEPT][$this->typeId][0]);
else
$cnd[CND_SRC_QUEST_ACCEPT] = $_[0][CND_SRC_QUEST_ACCEPT];
}
if (isset($_[0][CND_SRC_QUEST_SHOW_MARK]))
$cnd[CND_SRC_QUEST_SHOW_MARK] = $_[0][CND_SRC_QUEST_SHOW_MARK];
$this->extendGlobalData($_[1]);
}
if ($cnd)
{
$tab = "<script type=\"text/javascript\">\n" .
"var markup = ConditionList.createTab(".Util::toJSON($cnd).");\n" .
"Markup.printHtml(markup, 'tab-conditions', { allow: Markup.CLASS_STAFF })" .
"</script>";
$this->lvTabs[] = [null, array(
'data' => $tab,
'id' => 'conditions',
'name' => '$LANG.requires'
)];
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $tab;
}
}

View File

@@ -249,7 +249,7 @@ class SoundPage extends GenericPage
foreach ($zoneIds as $zData)
if ($zData['worldStateId'])
$zoneData[$zData['id']]['condition'][0][$this->typeId][] = [[CND_WORLD_STATE, $zData['worldStateId'], $zData['worldStateValue']]];
Conditions::extendListviewRow($zoneData[$zData['id']], Conditions::SRC_NONE, $this->typeId, [Conditions::WORLD_STATE, $zData['worldStateId'], $zData['worldStateValue']]);
}
$tabData['data'] = array_values($zoneData);

View File

@@ -746,12 +746,15 @@ class SpellPage extends GenericPage
$lv[$bar] = $foo[$bar];
$lv[$bar]['percent'] = $extraItem['additionalCreateChance'];
$lv[$bar]['pctstack'] = $this->buildPctStack($extraItem['additionalCreateChance'] / 100, $extraItem['additionalMaxNum']);
$lv[$bar]['condition'][0][$this->typeId][] = [[CND_SPELL, $extraItem['requiredSpecialization']]];
$this->extendGlobalIds(Type::SPELL, $extraItem['requiredSpecialization']);
$extraCols[] = '$Listview.extraCols.condition';
if ($max = ($extraItem['additionalMaxNum'] - 1))
$lv[$bar]['stack'] = [1, $max];
if (Conditions::extendListviewRow($lv[$bar], Conditions::SRC_NONE, $this->typeId, [Conditions::SPELL, $extraItem['requiredSpecialization']]))
{
$this->extendGlobalIds(Type::SPELL, $extraItem['requiredSpecialization']);
$extraCols[] = '$Listview.extraCols.condition';
}
break; // skill_extra_item_template can only contain 1 item
}
}
@@ -926,119 +929,46 @@ class SpellPage extends GenericPage
}
// tab: zone
if ($areas = DB::World()->select('SELECT * FROM spell_area WHERE spell = ?d', $this->typeId))
if ($areaSpells = DB::World()->select('SELECT `area` AS ARRAY_KEY, `aura_spell` AS "0", `quest_start` AS "1", `quest_end` AS "2", `quest_start_status` AS "3", `quest_end_status` AS "4", `racemask` AS "5", `gender` AS "6" FROM spell_area WHERE spell = ?d', $this->typeId))
{
$zones = new ZoneList(array(['id', array_column($areas, 'area')]));
$zones = new ZoneList(array(['id', array_keys($areaSpells)]));
if (!$zones->error)
{
$lvZones = $zones->getListviewData();
$this->extendGlobalData($zones->getJSGlobals());
$lv = [];
$parents = [];
$extra = false;
foreach ($areas as $a)
$resultLv = [];
$parents = [];
foreach ($areaSpells as $areaId => $condition)
{
if (empty($lvZones[$a['area']]))
if (empty($lvZones[$areaId]))
continue;
$condition = [];
if ($a['aura_spell'])
{
$this->extendGlobalIds(Type::SPELL, abs($a['aura_spell']));
$condition[0][$this->typeId][] = [[$a['aura_spell'] > 0 ? CND_AURA : -CND_AURA, abs($a['aura_spell'])]];
}
$row = $lvZones[$areaId];
if ($a['quest_start']) // status for quests needs work
{
$this->extendGlobalIds(Type::QUEST, $a['quest_start']);
$group = [];
for ($i = 0; $i < 7; $i++)
{
if (!($a['quest_start_status'] & (1 << $i)))
continue;
// attach to lv row and evaluate after merging
$row['__condition'] = $condition;
if ($i == 0)
$group[] = [CND_QUEST_NONE, $a['quest_start']];
else if ($i == 1)
$group[] = [CND_QUEST_COMPLETE, $a['quest_start']];
else if ($i == 3)
$group[] = [CND_QUESTTAKEN, $a['quest_start']];
else if ($i == 6)
$group[] = [CND_QUESTREWARDED, $a['quest_start']];
}
if ($group)
$condition[0][$this->typeId][] = $group;
}
if ($a['quest_end'] && $a['quest_end'] != $a['quest_start'])
{
$this->extendGlobalIds(Type::QUEST, $a['quest_end']);
$group = [];
for ($i = 0; $i < 7; $i++)
{
if (!($a['quest_end_status'] & (1 << $i)))
continue;
if ($i == 0)
$group[] = [-CND_QUEST_NONE, $a['quest_end']];
else if ($i == 1)
$group[] = [-CND_QUEST_COMPLETE, $a['quest_end']];
else if ($i == 3)
$group[] = [-CND_QUESTTAKEN, $a['quest_end']];
else if ($i == 6)
$group[] = [-CND_QUESTREWARDED, $a['quest_end']];
}
if ($group)
$condition[0][$this->typeId][] = $group;
}
if ($a['racemask'])
{
$foo = [];
for ($i = 0; $i < 11; $i++)
if ($a['racemask'] & (1 << $i))
$foo[] = $i + 1;
$this->extendGlobalIds(Type::CHR_RACE, ...$foo);
$condition[0][$this->typeId][] = [[CND_RACE, $a['racemask']]];
}
if ($a['gender'] != 2) // 2: both
$condition[0][$this->typeId][] = [[CND_GENDER, $a['gender'] + 1]];
$row = $lvZones[$a['area']];
if ($condition)
{
$extra = true;
$row = array_merge($row, ['condition' => $condition]);
}
// merge subzones, into one row, if: conditions match && parentZone is shared
if ($p = $zones->getEntry($a['area'])['parentArea'])
// merge subzones, into one row, if: spell_area data is identical && parentZone is shared
if ($p = $zones->getEntry($areaId)['parentArea'])
{
$parents[] = $p;
$row['parentArea'] = $p;
$row['subzones'] = [$a['area']];
$row['__parent'] = $p;
$row['subzones'] = [$areaId];
}
else
$row['parentArea'] = 0;
$row['__parent'] = 0;
$set = false;
foreach ($lv as &$v)
foreach ($resultLv as &$v)
{
if ($v['parentArea'] != $row['parentArea'] && $v['id'] != $row['parentArea'])
if ($v['__parent'] != $row['__parent'] && $v['id'] != $row['__parent'])
continue;
if (empty($v['condition']) xor empty($row['condition']))
if ($v['__condition'] != $row['__condition'])
continue;
if (!empty($row['condition']) && !empty($v['condition']) && $v['condition'] != $row['condition'])
continue;
if (!$row['parentArea'] && $v['id'] != $row['parentArea'])
if (!$row['__parent'] && $v['id'] != $row['__parent'])
continue;
$set = true;
@@ -1050,7 +980,7 @@ class SpellPage extends GenericPage
if (!$set)
{
$row['subzones'] = [$row['id']];
$lv[] = $row;
$resultLv[] = $row;
}
}
@@ -1058,16 +988,44 @@ class SpellPage extends GenericPage
if ($parents)
{
$parents = (new ZoneList(array(['id', $parents])))->getListviewData();
foreach ($lv as &$_)
if (isset($parents[$_['parentArea']]))
$_ = array_merge($_, $parents[$_['parentArea']]);
foreach ($resultLv as &$_)
if (isset($parents[$_['__parent']]))
$_ = array_merge($_, $parents[$_['__parent']]);
}
$tabData = ['data' => array_values($lv)];
if ($extra)
$cnd = new Conditions();
foreach ($resultLv as $idx => $lv)
{
$tabData['extraCols'] = ['$Listview.extraCols.condition'];
[$auraSpell, $questStart, $questEnd, $questStartState, $questEndState, $raceMask, $gender] = $lv['__condition'];
if ($auraSpell)
$cnd->addExternalCondition(Conditions::SRC_NONE, $lv['id'], [$auraSpell > 0 ? Conditions::AURA : -Conditions::AURA, abs($auraSpell)]);
if ($questStart)
$cnd->addExternalCondition(Conditions::SRC_NONE, $lv['id'], [Conditions::QUESTSTATE, $questStart, $questStartState]);
if ($questEnd && $questEnd != $questStart)
$cnd->addExternalCondition(Conditions::SRC_NONE, $lv['id'], [-Conditions::QUESTSTATE, $questEnd, $questEndState]);
if ($raceMask)
$cnd->addExternalCondition(Conditions::SRC_NONE, $lv['id'], [-Conditions::CHR_RACE, $raceMask]);
if ($gender != 2) // 2: both
$cnd->addExternalCondition(Conditions::SRC_NONE, $lv['id'], [-Conditions::GENDER, $gender + 1]);
// remove temp storage from result
unset($resultLv[$idx]['__condition']);
unset($resultLv[$idx]['__parent']);
}
if ($cnd->toListviewColumn($resultLv, $extraCols))
$this->extendGlobalData($cnd->getJsGlobals());
$tabData = ['data' => array_values($resultLv)];
if ($extraCols)
{
$tabData['extraCols'] = $extraCols;
$tabData['hiddenCols'] = ['instancetype'];
}
@@ -1107,35 +1065,55 @@ class SpellPage extends GenericPage
}
}
// tab: taught by npc (source:6 => trainer)
if (!empty($this->subject->sources[$this->typeId][6]))
// tab: taught by npc
if ($this->subject->getSources($s) && in_array(SRC_TRAINER, $s))
{
$src = $this->subject->sources[$this->typeId][6];
$list = [];
if (count($src) == 1 && $src[0] == 1) // multiple trainer
{
$list = DB::World()->selectCol('
SELECT cdt.CreatureId
FROM creature_default_trainer cdt
JOIN trainer_spell ts ON ts.TrainerId = cdt.TrainerId
WHERE ts.SpellId = ?d',
$this->typeId
);
}
else if ($src)
$list = array_values($src);
$trainers = DB::World()->select('
SELECT cdt.CreatureId AS ARRAY_KEY, ts.ReqSkillLine AS reqSkillId, ts.ReqSkillRank AS reqSkillValue, ts.ReqLevel AS reqLevel, ts.ReqAbility1 AS reqSpellId1, ts.reqAbility2 AS reqSpellId2
FROM creature_default_trainer cdt
JOIN trainer_spell ts ON ts.TrainerId = cdt.TrainerId
WHERE ts.SpellId = ?d',
$this->typeId
);
if ($list)
if ($trainers)
{
$tbTrainer = new CreatureList(array(Cfg::get('SQL_LIMIT_NONE'), ['ct.id', $list], ['s.guid', null, '!'], ['ct.npcflag', 0x10, '&']));
$tbTrainer = new CreatureList(array(Cfg::get('SQL_LIMIT_NONE'), ['ct.id', array_keys($trainers)], ['s.guid', null, '!'], ['ct.npcflag', NPC_FLAG_TRAINER, '&']));
if (!$tbTrainer->error)
{
$this->extendGlobalData($tbTrainer->getJSGlobals());
$this->lvTabs[] = [CreatureList::$brickFile, array(
'data' => array_values($tbTrainer->getListviewData()),
$cnd = new Conditions();
$skill = $this->subject->getField('skill');
foreach ($trainers as $tId => $train)
{
if ($_ = $train['reqLevel'])
$cnd->addExternalCondition(Conditions::SRC_NONE, $tId, [Conditions::LEVEL, $_, Conditions::OP_GT_E]);
if ($_ = $train['reqSkillId'])
if (count($skill) == 1 && $_ != $skill[0])
$cnd->addExternalCondition(Conditions::SRC_NONE, $tId, [Conditions::SKILL, $_, $train['reqSkillValue']]);
for ($i = 1; $i < 3; $i++)
if ($_ = $train['reqSpellId'.$i])
$cnd->addExternalCondition(Conditions::SRC_NONE, $tId, [Conditions::SPELL, $_]);
}
$lvData = $tbTrainer->getListviewData();
if ($cnd->toListviewColumn($lvData, $extraCols))
$this->extendGlobalData($cnd->getJsGlobals());
$lvTab = array(
'data' => array_values($lvData),
'id' => 'taught-by-npc',
'name' => '$LANG.tab_taughtby',
)];
);
if ($extraCols)
$lvTab['extraCols'] = $extraCols;
$this->lvTabs[] = [CreatureList::$brickFile, $lvTab];
}
}
}
@@ -1261,20 +1239,19 @@ class SpellPage extends GenericPage
// taughtbyitem
// tab: conditions
$sc = Util::getServerConditions([CND_SRC_SPELL_LOOT_TEMPLATE, CND_SRC_SPELL_IMPLICIT_TARGET, CND_SRC_SPELL, CND_SRC_SPELL_CLICK_EVENT, CND_SRC_VEHICLE_SPELL, CND_SRC_SPELL_PROC], null, $this->typeId);
if (!empty($sc[0]))
$cnd = new Conditions();
if ($cnd->getBySourceEntry($this->typeId, Conditions::SRC_SPELL_LOOT_TEMPLATE, Conditions::SRC_SPELL_IMPLICIT_TARGET, Conditions::SRC_SPELL, Conditions::SRC_SPELL_CLICK_EVENT, Conditions::SRC_VEHICLE_SPELL, Conditions::SRC_SPELL_PROC))
{
$this->extendGlobalData($sc[1]);
$tab = "<script type=\"text/javascript\">\n" .
"var markup = ConditionList.createTab(".Util::toJSON($sc[0]).");\n" .
"Markup.printHtml(markup, 'tab-conditions', { allow: Markup.CLASS_STAFF })" .
"</script>";
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab();
}
$this->lvTabs[] = [null, array(
'data' => $tab,
'id' => 'conditions',
'name' => '$LANG.requires'
)];
// tab: condition for
$cnd = new Conditions();
if ($cnd->getByCondition(Type::SPELL, $this->typeId))
{
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for');
}
}

View File

@@ -631,32 +631,24 @@ class ZonePage extends GenericPage
$this->extendGlobalData($fish->jsGlobals);
$xCols = array_merge(['$Listview.extraCols.percent'], $fish->extraCols);
foreach ($fish->iterate() as $lv)
{
if (!$lv['quest'])
continue;
$xCols = array_merge($xCols, ['$Listview.extraCols.condition']);
$reqQuest[$lv['id']] = 0;
$lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
}
$note = '';
if ($skill = DB::World()->selectCell('SELECT `skill` FROM skill_fishing_base_level WHERE `entry` = ?d', $this->typeId))
$note = sprintf(Util::$lvTabNoteString, Lang::zone('fishingSkill'), Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill(SKILL_FISHING, $skill), Lang::FMT_HTML));
else if ($parentArea && ($skill = DB::World()->selectCell('SELECT `skill` FROM skill_fishing_base_level WHERE `entry` = ?d', $parentArea)))
$note = sprintf(Util::$lvTabNoteString, Lang::zone('fishingSkill'), Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill(SKILL_FISHING, $skill), Lang::FMT_HTML));
$this->lvTabs[] = [ItemList::$brickFile, array(
$tabData = array(
'data' => array_values($fish->getResult()),
'name' => '$LANG.tab_fishing',
'id' => 'fishing',
'extraCols' => array_unique($xCols),
'hiddenCols' => ['side'],
'note' => $note
)];
'hiddenCols' => ['side']
);
if ($note)
$tabData['note'] = $note;
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
}
// tab: spells
@@ -668,93 +660,38 @@ class ZonePage extends GenericPage
$lvSpells = $spells->getListviewData();
$this->extendGlobalData($spells->getJSGlobals());
$extra = false;
$cnd = new Conditions();
foreach ($saData as $a)
{
if (empty($lvSpells[$a['spell']]))
continue;
$condition = [];
if ($a['aura_spell'])
{
$this->extendGlobalIds(Type::SPELL, abs($a['aura_spell']));
$condition[0][$this->typeId][] = [[$a['aura_spell'] > 0 ? CND_AURA : -CND_AURA, abs($a['aura_spell'])]];
}
$cnd->addExternalCondition(Conditions::SRC_NONE, $a['spell'], [$a['aura_spell'] > 0 ? Conditions::AURA : -Conditions::AURA, abs($a['aura_spell'])]);
if ($a['quest_start']) // status for quests needs work
{
$this->extendGlobalIds(Type::QUEST, $a['quest_start']);
$group = [];
for ($i = 0; $i < 7; $i++)
{
if (!($a['quest_start_status'] & (1 << $i)))
continue;
if ($i == 0)
$group[] = [CND_QUEST_NONE, $a['quest_start']];
else if ($i == 1)
$group[] = [CND_QUEST_COMPLETE, $a['quest_start']];
else if ($i == 3)
$group[] = [CND_QUESTTAKEN, $a['quest_start']];
else if ($i == 6)
$group[] = [CND_QUESTREWARDED, $a['quest_start']];
}
if ($group)
$condition[0][$this->typeId][] = $group;
}
$cnd->addExternalCondition(Conditions::SRC_NONE, $a['spell'], [Conditions::QUESTSTATE, $a['quest_start'], $a['quest_start_status']]);
if ($a['quest_end'] && $a['quest_end'] != $a['quest_start'])
{
$this->extendGlobalIds(Type::QUEST, $a['quest_end']);
$group = [];
for ($i = 0; $i < 7; $i++)
{
if (!($a['quest_end_status'] & (1 << $i)))
continue;
if ($i == 0)
$group[] = [-CND_QUEST_NONE, $a['quest_end']];
else if ($i == 1)
$group[] = [-CND_QUEST_COMPLETE, $a['quest_end']];
else if ($i == 3)
$group[] = [-CND_QUESTTAKEN, $a['quest_end']];
else if ($i == 6)
$group[] = [-CND_QUESTREWARDED, $a['quest_end']];
}
if ($group)
$condition[0][$this->typeId][] = $group;
}
$cnd->addExternalCondition(Conditions::SRC_NONE, $a['spell'], [Conditions::QUESTSTATE, $a['quest_end'], $a['quest_end_status']]);
if ($a['racemask'])
{
$foo = [];
for ($i = 0; $i < 11; $i++)
if ($a['racemask'] & (1 << $i))
$foo[] = $i + 1;
$this->extendGlobalIds(Type::CHR_RACE, ...$foo);
$condition[0][$this->typeId][] = [[CND_RACE, $a['racemask']]];
}
$cnd->addExternalCondition(Conditions::SRC_NONE, $a['spell'], [Conditions::CHR_RACE, $a['racemask']]);
if ($a['gender'] != 2) // 2: both
$condition[0][$this->typeId][] = [[CND_GENDER, $a['gender'] + 1]];
if ($condition)
{
$extra = true;
$lvSpells[$a['spell']] = array_merge($lvSpells[$a['spell']], ['condition' => $condition]);
}
$cnd->addExternalCondition(Conditions::SRC_NONE, $a['spell'], [Conditions::GENDER, $a['gender']]);
}
if ($cnd->toListviewColumn($lvSpells, $extraCols))
$this->extendGlobalData($cnd->getJsGlobals());
$tabData = array(
'data' => array_values($lvSpells),
'hiddenCols' => ['skill']
);
if ($extra)
$tabData['extraCols'] = ['$Listview.extraCols.condition'];
if ($extraCols)
$tabData['extraCols'] = $extraCols;
$this->lvTabs[] = [SpellList::$brickFile, $tabData];
}
@@ -782,21 +719,18 @@ class ZonePage extends GenericPage
$areaIds[] = $this->typeId;
$soundIds = [];
$zoneMusic = DB::Aowow()->select('
SELECT
x.soundId AS ARRAY_KEY, x.soundId, x.worldStateId, x.worldStateValue, x.type
FROM (
SELECT ambienceDay AS soundId, worldStateId, worldStateValue, 1 AS `type` FROM ?_zones_sounds WHERE id IN (?a) AND ambienceDay > 0 UNION
SELECT ambienceNight AS soundId, worldStateId, worldStateValue, 1 AS `type` FROM ?_zones_sounds WHERE id IN (?a) AND ambienceNight > 0 UNION
SELECT musicDay AS soundId, worldStateId, worldStateValue, 2 AS `type` FROM ?_zones_sounds WHERE id IN (?a) AND musicDay > 0 UNION
SELECT musicNight AS soundId, worldStateId, worldStateValue, 2 AS `type` FROM ?_zones_sounds WHERE id IN (?a) AND musicNight > 0 UNION
SELECT intro AS soundId, worldStateId, worldStateValue, 3 AS `type` FROM ?_zones_sounds WHERE id IN (?a) AND intro > 0
) x
GROUP BY
x.soundId, x.worldStateId, x.worldStateValue
', $areaIds, $areaIds, $areaIds, $areaIds, $areaIds);
$zoneMusic = DB::Aowow()->select(
'SELECT x.soundId AS ARRAY_KEY, x.soundId, x.worldStateId, x.worldStateValue, x.type
FROM (SELECT `ambienceDay` AS soundId, `worldStateId`, `worldStateValue`, 1 AS `type` FROM ?_zones_sounds WHERE `id` IN (?a) AND `ambienceDay` > 0 UNION
SELECT `ambienceNight` AS soundId, `worldStateId`, `worldStateValue`, 1 AS `type` FROM ?_zones_sounds WHERE `id` IN (?a) AND `ambienceNight` > 0 UNION
SELECT `musicDay` AS soundId, `worldStateId`, `worldStateValue`, 2 AS `type` FROM ?_zones_sounds WHERE `id` IN (?a) AND `musicDay` > 0 UNION
SELECT `musicNight` AS soundId, `worldStateId`, `worldStateValue`, 2 AS `type` FROM ?_zones_sounds WHERE `id` IN (?a) AND `musicNight` > 0 UNION
SELECT `intro` AS soundId, `worldStateId`, `worldStateValue`, 3 AS `type` FROM ?_zones_sounds WHERE `id` IN (?a) AND `intro` > 0) x
GROUP BY x.soundId, x.worldStateId, x.worldStateValue',
$areaIds, $areaIds, $areaIds, $areaIds, $areaIds
);
if ($sSpawns = DB::Aowow()->selectCol('SELECT typeId FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::SOUND))
if ($sSpawns = DB::Aowow()->selectCol('SELECT `typeId` FROM ?_spawns WHERE `areaId` = ?d AND `type` = ?d', $this->typeId, Type::SOUND))
$soundIds = array_merge($soundIds, $sSpawns);
if ($zoneMusic)
@@ -817,7 +751,7 @@ class ZonePage extends GenericPage
foreach ($soundIds as $sId)
if (!empty($zoneMusic[$sId]['worldStateId']))
$data[$sId]['condition'][0][$this->typeId][] = [[CND_WORLD_STATE, $zoneMusic[$sId]['worldStateId'], $zoneMusic[$sId]['worldStateValue']]];
Conditions::extendListviewRow($data[$sId], Conditions::SRC_NONE, $this->typeId, [Conditions::WORLD_STATE, $zoneMusic[$sId]['worldStateId'], $zoneMusic[$sId]['worldStateValue']]);
}
$tabData['data'] = array_values($data);
@@ -826,28 +760,27 @@ class ZonePage extends GenericPage
$this->extendGlobalData($music->getJSGlobals(GLOBALINFO_SELF));
$typeFilter = function(array $music, int $type) use ($data) : array
{
$result = [];
foreach (array_filter($music, function ($x) use ($type) { return $x['type'] == $type; } ) as $sId => $_)
$result = array_merge($result, $data[$sId]['files'] ?? []);
return $result;
};
// audio controls
// ambience
if ($sounds = array_filter($zoneMusic, function ($x) { return $x['type'] == 1; } ))
foreach ($sounds as $sId => $_)
if (!empty($data[$sId]['files']))
foreach ($data[$sId]['files'] as $f)
$this->zoneMusic['ambience'][] = $f;
if ($_ = $typeFilter($zoneMusic, 1))
$this->zoneMusic['ambience'] = $_;
// music
if ($sounds = array_filter($zoneMusic, function ($x) { return $x['type'] == 2; } ))
foreach ($sounds as $sId => $_)
if (!empty($data[$sId]['files']))
foreach ($data[$sId]['files'] as $f)
$this->zoneMusic['music'][] = $f;
if ($_ = $typeFilter($zoneMusic, 2))
$this->zoneMusic['music'] = $_;
// intro
if ($sounds = array_filter($zoneMusic, function ($x) { return $x['type'] == 3; } ))
foreach ($sounds as $sId => $_)
if (!empty($data[$sId]['files']))
foreach ($data[$sId]['files'] as $f)
$this->zoneMusic['intro'][] = $f;
if ($_ = $typeFilter($zoneMusic, 3))
$this->zoneMusic['intro'] = $_;
}
}
}