Misc/Fixups

* colAddins should be null if not in use
 * fix index warnings in search + profiler
 * cast url param 'locale' to int for all uses
 * fix breadcrumbs for sounds page
 * fix determining actionOwner for SmartAI
This commit is contained in:
Sarjuuk
2022-04-05 16:13:56 +02:00
parent 6594d6fa42
commit c0e9159c1e
9 changed files with 22 additions and 15 deletions

View File

@@ -360,7 +360,7 @@ class AjaxProfile extends AjaxHandler
$cuProfile['sourceId'] = $_; $cuProfile['sourceId'] = $_;
} }
if ($cuProfile['sourceId']) if (!empty($cuProfile['sourceId']))
$cuProfile['sourceName'] = DB::Aowow()->selectCell('SELECT name FROM ?_profiler_profiles WHERE id = ?d', $cuProfile['sourceId']); $cuProfile['sourceName'] = DB::Aowow()->selectCell('SELECT name FROM ?_profiler_profiles WHERE id = ?d', $cuProfile['sourceId']);
$charId = -1; $charId = -1;
@@ -420,7 +420,7 @@ class AjaxProfile extends AjaxHandler
$itemData[2] = 0; $itemData[2] = 0;
// item sockets are fubar // item sockets are fubar
$nSockets = $items->json[$itemData[1]]['nsockets']; $nSockets = $items->json[$itemData[1]]['nsockets'] ?? 0;
$nSockets += in_array($slot, [SLOT_WAIST, SLOT_WRISTS, SLOT_HANDS]) ? 1 : 0; $nSockets += in_array($slot, [SLOT_WAIST, SLOT_WRISTS, SLOT_HANDS]) ? 1 : 0;
for ($i = 5; $i < 9; $i++) for ($i = 5; $i < 9; $i++)
if ($itemData[$i] > 0 && (!$items->getEntry($itemData[$i]) || $i >= (5 + $nSockets))) if ($itemData[$i] > 0 && (!$items->getEntry($itemData[$i]) || $i >= (5 + $nSockets)))

View File

@@ -255,9 +255,12 @@ if (!CLI)
// all strings attached.. // all strings attached..
if (!empty($AoWoWconf['aowow'])) if (!empty($AoWoWconf['aowow']))
{ {
if (isset($_GET['locale']) && (int)$_GET['locale'] <= MAX_LOCALES && (int)$_GET['locale'] >= 0) if (isset($_GET['locale']))
if (CFG_LOCALES & (1 << $_GET['locale'])) {
User::useLocale($_GET['locale']); $loc = intVal($_GET['locale']);
if ($loc <= MAX_LOCALES && $loc >= 0 && (CFG_LOCALES & (1 << $loc)))
User::useLocale($loc);
}
Lang::load(User::$localeString); Lang::load(User::$localeString);
} }

View File

@@ -164,7 +164,11 @@ class SmartAI
} }
if ($q) if ($q)
$result = DB::Aowow()->selectCol(sprintf('SELECT `type` AS ARRAY_KEY, `typeId` FROM ?_spawns WHERE (%s)', implode(') OR (', $q))); {
$owner = DB::Aowow()->select(sprintf('SELECT `type` AS "0", `typeId` AS "1" FROM ?_spawns WHERE (%s)', implode(') OR (', $q)));
foreach ($owner as [$ty, $id])
$result[$ty][] = $id;
}
} }
foreach ($smartS as [$st, $eog]) foreach ($smartS as [$st, $eog])
@@ -258,7 +262,7 @@ class SmartAI
return self::getOwnerAction($srcType, $entry, $lookup); return self::getOwnerAction($srcType, $entry, $lookup);
} }
private static function getOwnerAction(int $sourceType, int $entry, array $lookup, ?array $moreInfo = []) : array private static function getOwnerAction(int $sourceType, int $entry, array $lookup, ?array &$moreInfo = []) : array
{ {
if ($entry < 0) // please not individual entities :( if ($entry < 0) // please not individual entities :(
return []; return [];

View File

@@ -1577,8 +1577,8 @@ abstract class Util
} }
return array( return array(
round($mainHand['gearscore'] * $mh), round(($mainHand['gearscore'] ?? 0) * $mh),
round($offHand['gearscore'] * $oh) round(($offHand['gearscore'] ?? 0) * $oh)
); );
} }

View File

@@ -621,7 +621,7 @@ class NpcPage extends GenericPage
$soldItems = new ItemList(array(['id', $sells])); $soldItems = new ItemList(array(['id', $sells]));
if (!$soldItems->error) if (!$soldItems->error)
{ {
$colAddIn = ''; $colAddIn = null;
$extraCols = ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost']; $extraCols = ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'];
if ($soldItems->hasSetFields(['condition'])) if ($soldItems->hasSetFields(['condition']))
$extraCols[] = '$Listview.extraCols.condition'; $extraCols[] = '$Listview.extraCols.condition';

View File

@@ -38,6 +38,7 @@ class ProfilePage extends GenericPage
private $isCustom = false; private $isCustom = false;
private $profile = null; private $profile = null;
private $subject = null;
private $rnItr = 0; private $rnItr = 0;
private $powerTpl = '$WowheadPower.registerProfile(%s, %d, %s);'; private $powerTpl = '$WowheadPower.registerProfile(%s, %d, %s);';
@@ -108,7 +109,7 @@ class ProfilePage extends GenericPage
$this->notFound(); $this->notFound();
} }
// 2) not yet synced but exists on realm (and not a gm character) // 2) not yet synced but exists on realm (and not a gm character)
else if (!$this->rnItr && ($char = DB::Characters($this->realmId)->selectRow('SELECT c.guid AS realmGUID, c.name, c.race, c.class, c.level, c.gender, g.guildid AS guildGUID, IFNULL(g.name, "") AS guildName, IFNULL(gm.rank, 0) AS guildRank FROM characters c LEFT JOIN guild_member gm ON gm.guid = c.guid LEFT JOIN guild g ON g.guildid = gm.guildid WHERE c.name = ? AND level <= ?d AND (extra_flags & ?d) = 0', Util::ucFirst($this->subjectName), MAX_LEVEL, Profiler::CHAR_GMFLAGS))) else if (!$this->rnItr && ($char = DB::Characters($this->realmId)->selectRow('SELECT c.guid AS realmGUID, c.name, c.race, c.class, c.level, c.gender, c.at_login, g.guildid AS guildGUID, IFNULL(g.name, "") AS guildName, IFNULL(gm.rank, 0) AS guildRank FROM characters c LEFT JOIN guild_member gm ON gm.guid = c.guid LEFT JOIN guild g ON g.guildid = gm.guildid WHERE c.name = ? AND level <= ?d AND (extra_flags & ?d) = 0', Util::ucFirst($this->subjectName), MAX_LEVEL, Profiler::CHAR_GMFLAGS)))
{ {
$char['realm'] = $this->realmId; $char['realm'] = $this->realmId;
$char['cuFlags'] = PROFILER_CU_NEEDS_RESYNC; $char['cuFlags'] = PROFILER_CU_NEEDS_RESYNC;

View File

@@ -640,7 +640,7 @@ class SearchPage extends GenericPage
{ {
$multiClass = 0; $multiClass = 0;
for ($i = 1; $i <= 10; $i++) for ($i = 1; $i <= 10; $i++)
if ($d['reqclass'] & (1 << ($i - 1))) if (isset($d['reqclass']) && ($d['reqclass'] & (1 << ($i - 1))))
$multiClass++; $multiClass++;
if ($multiClass > 1) if ($multiClass > 1)

View File

@@ -81,7 +81,7 @@ class SoundsPage extends GenericPage
{ {
$form = $this->filterObj->getForm(); $form = $this->filterObj->getForm();
if (isset($form['ty']) && count($form['ty']) == 1) if (isset($form['ty']) && count($form['ty']) == 1)
$this->path[] = $form['ty']; $this->path[] = $form['ty'][0];
} }
} }

View File

@@ -132,9 +132,8 @@ if ($this->offerReward && ($this->requestItems || $this->objectives)):
<?php <?php
endif; endif;
$offset = 0;
if ($r = $this->rewards): if ($r = $this->rewards):
$offset = 0;
echo ' <h3>'.Lang::main('rewards')."</h3>\n"; echo ' <h3>'.Lang::main('rewards')."</h3>\n";
if (!empty($r['choice'])): if (!empty($r['choice'])):