mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Localization/Caching
* store source lists as object so different locales can be fetched * store parsed spell texts locale dependent so the locale isn't fixed
This commit is contained in:
@@ -445,7 +445,7 @@ abstract class BaseType
|
||||
'c2': subCat [Quests]
|
||||
'icon': iconString
|
||||
*/
|
||||
public function getSourceData() {}
|
||||
public function getSourceData(int $id = 0) : array { return []; }
|
||||
|
||||
// should return data required to display a listview of any kind
|
||||
// this is a rudimentary example, that will not suffice for most Types
|
||||
@@ -863,12 +863,12 @@ trait sourceHelper
|
||||
$buff[$_curTpl['moreType']][] = $_curTpl['moreTypeId'];
|
||||
|
||||
foreach ($buff as $type => $ids)
|
||||
$this->sourceMore[$type] = (Type::newList($type, [CFG_SQL_LIMIT_NONE, ['id', $ids]]))->getSourceData();
|
||||
$this->sourceMore[$type] = Type::newList($type, [CFG_SQL_LIMIT_NONE, ['id', $ids]]);
|
||||
}
|
||||
|
||||
$s = array_keys($this->sources[$this->id]);
|
||||
if ($this->curTpl['moreType'] && $this->curTpl['moreTypeId'] && !empty($this->sourceMore[$this->curTpl['moreType']][$this->curTpl['moreTypeId']]))
|
||||
$sm = $this->sourceMore[$this->curTpl['moreType']][$this->curTpl['moreTypeId']];
|
||||
if ($this->curTpl['moreType'] && $this->curTpl['moreTypeId'] && ($srcData = $this->sourceMore[$this->curTpl['moreType']]->getSourceData($this->curTpl['moreTypeId'])))
|
||||
$sm = $srcData;
|
||||
else if (!empty($this->sources[$this->id][SRC_PVP]))
|
||||
$sm['p'] = $this->sources[$this->id][SRC_PVP][0];
|
||||
|
||||
|
||||
@@ -257,12 +257,15 @@ class AchievementList extends BaseType
|
||||
return $x;
|
||||
}
|
||||
|
||||
public function getSourceData()
|
||||
public function getSourceData(int $id = 0) : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->iterate() as $__)
|
||||
{
|
||||
if ($id && $id != $this->id)
|
||||
continue;
|
||||
|
||||
$data[$this->id] = array(
|
||||
"n" => $this->getField('name', true),
|
||||
"s" => $this->curTpl['faction'],
|
||||
|
||||
@@ -257,12 +257,15 @@ class CreatureList extends BaseType
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getSourceData()
|
||||
public function getSourceData(int $id = 0) : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->iterate() as $__)
|
||||
{
|
||||
if ($id && $id != $this->id)
|
||||
continue;
|
||||
|
||||
$data[$this->id] = array(
|
||||
'n' => $this->getField('parentId') ? $this->getField('parent', true) : $this->getField('name', true),
|
||||
't' => Type::NPC,
|
||||
|
||||
@@ -120,12 +120,15 @@ class GameObjectList extends BaseType
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getSourceData()
|
||||
public function getSourceData(int $id = 0) : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->iterate() as $__)
|
||||
{
|
||||
if ($id && $id != $this->id)
|
||||
continue;
|
||||
|
||||
$data[$this->id] = array(
|
||||
'n' => $this->getField('name', true),
|
||||
't' => Type::OBJECT,
|
||||
|
||||
@@ -1363,12 +1363,15 @@ class ItemList extends BaseType
|
||||
return $onUseStats;
|
||||
}
|
||||
|
||||
public function getSourceData()
|
||||
public function getSourceData(int $id = 0) : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->iterate() as $__)
|
||||
{
|
||||
if ($id && $id != $this->id)
|
||||
continue;
|
||||
|
||||
$data[$this->id] = array(
|
||||
'n' => $this->getField('name', true),
|
||||
't' => Type::ITEM,
|
||||
|
||||
@@ -148,12 +148,15 @@ class QuestList extends BaseType
|
||||
return in_array($this->getField('zoneOrSortBak'), [-22, -284, -366, -369, -370, -376, -374]) && !$this->isRepeatable();
|
||||
}
|
||||
|
||||
public function getSourceData()
|
||||
public function getSourceData(int $id = 0) : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->iterate() as $__)
|
||||
{
|
||||
if ($id && $id != $this->id)
|
||||
continue;
|
||||
|
||||
$data[$this->id] = array(
|
||||
"n" => $this->getField('name', true),
|
||||
"t" => Type::QUEST,
|
||||
|
||||
@@ -1586,8 +1586,8 @@ class SpellList extends BaseType
|
||||
$this->charLevel = $level;
|
||||
|
||||
// step -1: already handled?
|
||||
if (isset($this->parsedText[$this->id][$type][$this->charLevel][(int)$this->interactive]))
|
||||
return $this->parsedText[$this->id][$type][$this->charLevel][(int)$this->interactive];
|
||||
if (isset($this->parsedText[$this->id][$type][User::$localeId][$this->charLevel][(int)$this->interactive]))
|
||||
return $this->parsedText[$this->id][$type][User::$localeId][$this->charLevel][(int)$this->interactive];
|
||||
|
||||
// step 0: get text
|
||||
$data = $this->getField($type, true);
|
||||
@@ -1693,7 +1693,7 @@ class SpellList extends BaseType
|
||||
$data = strtr($data, ["\r" => '', "\n" => '<br />']);
|
||||
|
||||
// cache result
|
||||
$this->parsedText[$this->id][$type][$this->charLevel][(int)$this->interactive] = [$data, $relSpells];
|
||||
$this->parsedText[$this->id][$type][User::$localeId][$this->charLevel][(int)$this->interactive] = [$data, $relSpells];
|
||||
|
||||
return [$data, $relSpells];
|
||||
}
|
||||
@@ -2397,12 +2397,15 @@ class SpellList extends BaseType
|
||||
return $castingTime;
|
||||
}
|
||||
|
||||
public function getSourceData()
|
||||
public function getSourceData(int $id = 0) : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->iterate() as $__)
|
||||
{
|
||||
if ($id && $id != $this->id)
|
||||
continue;
|
||||
|
||||
$data[$this->id] = array(
|
||||
'n' => $this->getField('name', true),
|
||||
't' => Type::SPELL,
|
||||
|
||||
Reference in New Issue
Block a user