Structure/Types

* move distributed constant values to object
 * move reused iterators and checks to object
This commit is contained in:
Sarjuuk
2022-03-21 15:20:31 +01:00
parent e109a6deed
commit 33a870ef78
126 changed files with 970 additions and 885 deletions

View File

@@ -50,7 +50,7 @@ class AjaxAccount extends AjaxHandler
$type = $this->_post['type'];
$ids = $this->_post['id'];
if (!isset(Util::$typeStrings[$type]) || empty($ids))
if (!Type::exists($type) || empty($ids))
{
trigger_error('AjaxAccount::handleExclude - invalid type #'.$type.(empty($ids) ? ' or id-list empty' : ''), E_USER_ERROR);
return;
@@ -146,16 +146,10 @@ class AjaxAccount extends AjaxHandler
if ($type = $this->_post['add'])
{
if (empty(Util::$typeClasses[$type]))
$tc = Type::newList($type, [['id', $typeId]]);
if (!$tc || $tc->error)
{
trigger_error('AjaxAccount::handleFavorites - invalid type #'.$type, E_USER_ERROR);
return;
}
$tc = new Util::$typeClasses[$type]([['id', $typeId]]);
if ($tc->error)
{
trigger_error('AjaxAccount::handleFavorites - invalid typeId #'.$typeId.' for type '.$tc::$brickFile, E_USER_ERROR);
trigger_error('AjaxAccount::handleFavorites - invalid typeId #'.$typeId.' for type #'.$type, E_USER_ERROR);
return;
}

View File

@@ -186,7 +186,7 @@ class AjaxAdmin extends AjaxHandler
DB::Aowow()->query('UPDATE ?_screenshots SET status = ?d, userIdApprove = ?d WHERE id = ?d', CC_FLAG_APPROVED, User::$id, $id);
Util::gainSiteReputation($ssEntry['userIdOwner'], SITEREP_ACTION_UPLOAD, ['id' => $id, 'what' => 1, 'date' => $ssEntry['date']]);
// flag DB entry as having screenshots
if (Util::$typeClasses[$ssEntry['type']] && ($tbl = get_class_vars(Util::$typeClasses[$ssEntry['type']])['dataTable']))
if ($tbl = Type::getClassAttrib($ssEntry['type'], 'dataTable'))
DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags | ?d WHERE id = ?d', CUSTOM_HAS_SCREENSHOT, $ssEntry['typeId']);
}
else
@@ -267,7 +267,7 @@ class AjaxAdmin extends AjaxHandler
{
$typeIds = explode(',', $typeIds);
$toUnflag = DB::Aowow()->selectCol('SELECT typeId AS ARRAY_KEY, IF(BIT_OR(`status`) & ?d, 1, 0) AS hasMore FROM ?_screenshots WHERE `type` = ?d AND typeId IN (?a) GROUP BY typeId HAVING hasMore = 0', CC_FLAG_APPROVED, $type, $typeIds);
if ($toUnflag && Util::$typeClasses[$type] && ($tbl = get_class_vars(Util::$typeClasses[$type])['dataTable']))
if ($toUnflag && ($tbl = Type::getClassAttrib($type, 'dataTable')))
DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags & ~?d WHERE id IN (?a)', CUSTOM_HAS_SCREENSHOT, array_keys($toUnflag));
}
}
@@ -286,8 +286,8 @@ class AjaxAdmin extends AjaxHandler
[$type, $oldTypeId] = array_values(DB::Aowow()->selectRow('SELECT type, typeId FROM ?_screenshots WHERE id = ?d', $id));
$typeId = (int)$this->_get['typeid'];
$tc = new Util::$typeClasses[$type]([['id', $typeId]]);
if (!$tc->error)
$tc = Type::newList($type, [['id', $typeId]]);
if ($tc && !$tc->error)
{
// move screenshot
DB::Aowow()->query('UPDATE ?_screenshots SET typeId = ?d WHERE id = ?d', $typeId, $id);
@@ -301,7 +301,7 @@ class AjaxAdmin extends AjaxHandler
DB::Aowow()->query('UPDATE '.$tc::$dataTable.' SET cuFlags = cuFlags & ~?d WHERE id = ?d', CUSTOM_HAS_SCREENSHOT, $oldTypeId);
}
else
trigger_error('AjaxAdmin::ssRelocate - invalid typeId #'.$typeId.' for type '.$tc::$brickFile, E_USER_ERROR);
trigger_error('AjaxAdmin::ssRelocate - invalid typeId #'.$typeId.' for type #'.$type, E_USER_ERROR);
}
protected function confAdd() : string
@@ -405,7 +405,7 @@ class AjaxAdmin extends AjaxHandler
$area = $this->_get['area'];
$floor = $this->_get['floor'];
if (!in_array($type, [TYPE_NPC, TYPE_OBJECT, TYPE_SOUND, TYPE_AREATRIGGER]))
if (!in_array($type, [Type::NPC, Type::OBJECT, Type::SOUND, Type::AREATRIGGER]))
return '-3';
DB::Aowow()->query('REPLACE INTO ?_spawns_override VALUES (?d, ?d, ?d, ?d, ?d)', $type, $guid, $area, $floor, AOWOW_REVISION);
@@ -423,7 +423,7 @@ class AjaxAdmin extends AjaxHandler
);
// if creature try for waypoints
if ($type == TYPE_NPC)
if ($type == Type::NPC)
{
$jobs = array(
'SELECT -w.id AS `entry`, w.point AS `pointId`, w.position_y AS `posX`, w.position_x AS `posY` FROM creature_addon ca JOIN waypoint_data w ON w.id = ca.path_id WHERE ca.guid = ?d AND ca.path_id <> 0',
@@ -467,6 +467,11 @@ class AjaxAdmin extends AjaxHandler
return '-1';
}
/***************************/
/* additional input filter */
/***************************/
protected static function checkKey(string $val) : string
{
// expecting string

View File

@@ -39,12 +39,12 @@ class AjaxArenaTeam extends AjaxHandler
{
if ($teams = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_arena_team WHERE id IN (?a)', $this->_get['id']))
foreach ($teams as $t)
Profiler::scheduleResync(TYPE_ARENA_TEAM, $t['realm'], $t['realmGUID']);
Profiler::scheduleResync(Type::ARENA_TEAM, $t['realm'], $t['realmGUID']);
if ($this->_get['profile'])
if ($chars = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_profiles p JOIN ?_profiler_arena_team_member atm ON atm.profileId = p.id WHERE atm.arenaTeamId IN (?a)', $this->_get['id']))
foreach ($chars as $c)
Profiler::scheduleResync(TYPE_PROFILE, $c['realm'], $c['realmGUID']);
Profiler::scheduleResync(Type::PROFILE, $c['realm'], $c['realmGUID']);
return '1';
}
@@ -74,7 +74,7 @@ class AjaxArenaTeam extends AjaxHandler
*/
protected function handleStatus() : string
{
$response = Profiler::resyncStatus(TYPE_ARENA_TEAM, $this->_get['id']);
$response = Profiler::resyncStatus(Type::ARENA_TEAM, $this->_get['id']);
return Util::toJSON($response);
}
}

View File

@@ -77,14 +77,14 @@ class AjaxComment extends AjaxHandler
// i .. have problems believing, that everything uses nifty ajax while adding comments requires a brutal header(Loacation: <wherever>), yet, thats how it is
protected function handleCommentAdd() : string
{
if (!$this->_get['typeid'] || !$this->_get['type'] || !isset(Util::$typeClasses[$this->_get['type']]))
if (!$this->_get['typeid'] || !$this->_get['type'] || !Type::exists($this->_get['type']))
{
trigger_error('AjaxComment::handleCommentAdd - malforemd request received', E_USER_ERROR);
return ''; // whatever, we cant even send him back
}
// this type cannot be commented on
if (!(get_class_vars(Util::$typeClasses[$this->_get['type']])['contribute'] & CONTRIBUTE_CO))
if (!Type::checkClassAttrib($this->_get['type'], 'contribute', CONTRIBUTE_CO))
{
trigger_error('AjaxComment::handleCommentAdd - tried to comment on unsupported type #'.$this->_get['type'], E_USER_ERROR);
return '';
@@ -106,7 +106,7 @@ class AjaxComment extends AjaxHandler
DB::Aowow()->query('INSERT INTO ?_comments_rates (commentId, userId, value) VALUES (?d, 0, 1)', $postIdx);
// flag target with hasComment
if ($tbl = get_class_vars(Util::$typeClasses[$this->_get['type']])['dataTable'])
if ($tbl = Type::getClassAttrib($this->_get['type'], 'dataTable'))
DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags | ?d WHERE id = ?d', CUSTOM_HAS_COMMENT, $this->_get['typeid']);
}
else
@@ -122,7 +122,7 @@ class AjaxComment extends AjaxHandler
$_SESSION['error']['co'] = Lang::main('cannotComment');
$this->doRedirect = true;
return '?'.Util::$typeStrings[$this->_get['type']].'='.$this->_get['typeid'].'#comments';
return '?'.Type::getFileString($this->_get['type']).'='.$this->_get['typeid'].'#comments';
}
protected function handleCommentEdit() : void
@@ -186,7 +186,7 @@ class AjaxComment extends AjaxHandler
$this->_post['id']
);
if (!$coInfo['hasMore'] && Util::$typeClasses[$coInfo['type']] && ($tbl = get_class_vars(Util::$typeClasses[$coInfo['type']])['dataTable']))
if (!$coInfo['hasMore'] && ($tbl = Type::getClassAttrib($coInfo['type'], 'dataTable')))
DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags & ~?d WHERE id = ?d', CUSTOM_HAS_COMMENT, $coInfo['typeId']);
}
else
@@ -212,7 +212,7 @@ class AjaxComment extends AjaxHandler
if ($ok)
{
$coInfo = DB::Aowow()->selectRow('SELECT type, typeId FROM ?_comments WHERE id = ?d', $this->_post['id']);
if (Util::$typeClasses[$coInfo['type']] && ($tbl = get_class_vars(Util::$typeClasses[$coInfo['type']])['dataTable']))
if ($tbl = Type::getClassAttrib($coInfo['type'], 'dataTable'))
DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags | ?d WHERE id = ?d', CUSTOM_HAS_COMMENT, $coInfo['typeId']);
}
else

View File

@@ -27,7 +27,7 @@ class AjaxGotocomment extends AjaxHandler
return '.'; // go home
if ($_ = DB::Aowow()->selectRow('SELECT IFNULL(c2.id, c1.id) AS id, IFNULL(c2.type, c1.type) AS type, IFNULL(c2.typeId, c1.typeId) AS typeId FROM ?_comments c1 LEFT JOIN ?_comments c2 ON c1.replyTo = c2.id WHERE c1.id = ?d', $this->_get['id']))
return '?'.Util::$typeStrings[$_['type']].'='.$_['typeId'].'#comments:id='.$_['id'].($_['id'] != $this->_get['id'] ? ':reply='.$this->_get['id'] : null);
return '?'.Type::getFileString(intVal($_['type'])).'='.$_['typeId'].'#comments:id='.$_['id'].($_['id'] != $this->_get['id'] ? ':reply='.$this->_get['id'] : null);
else
trigger_error('AjaxGotocomment::handleGoToComment - could not find comment #'.$this->get['id'], E_USER_ERROR);

View File

@@ -39,12 +39,12 @@ class AjaxGuild extends AjaxHandler
{
if ($guilds = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_guild WHERE id IN (?a)', $this->_get['id']))
foreach ($guilds as $g)
Profiler::scheduleResync(TYPE_GUILD, $g['realm'], $g['realmGUID']);
Profiler::scheduleResync(Type::GUILD, $g['realm'], $g['realmGUID']);
if ($this->_get['profile'])
if ($chars = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_profiles WHERE guild IN (?a)', $this->_get['id']))
foreach ($chars as $c)
Profiler::scheduleResync(TYPE_PROFILE, $c['realm'], $c['realmGUID']);
Profiler::scheduleResync(Type::PROFILE, $c['realm'], $c['realmGUID']);
return '1';
}
@@ -74,7 +74,7 @@ class AjaxGuild extends AjaxHandler
*/
protected function handleStatus() : string
{
$response = Profiler::resyncStatus(TYPE_GUILD, $this->_get['id']);
$response = Profiler::resyncStatus(Type::GUILD, $this->_get['id']);
return Util::toJSON($response);
}
}

View File

@@ -258,7 +258,7 @@ class AjaxProfile extends AjaxHandler
if ($chars = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_profiles WHERE id IN (?a)', $this->_get['id']))
{
foreach ($chars as $c)
Profiler::scheduleResync(TYPE_PROFILE, $c['realm'], $c['realmGUID']);
Profiler::scheduleResync(Type::PROFILE, $c['realm'], $c['realmGUID']);
}
else
trigger_error('AjaxProfile::handleResync - profiles '.implode(', ', $this->_get['id']).' not found in db', E_USER_ERROR);
@@ -305,7 +305,7 @@ class AjaxProfile extends AjaxHandler
return Util::toJSON([1, [PR_QUEUE_STATUS_ERROR, 0, 0, PR_QUEUE_ERROR_CHAR]]);
}
$response = Profiler::resyncStatus(TYPE_PROFILE, $ids);
$response = Profiler::resyncStatus(Type::PROFILE, $ids);
return Util::toJSON($response);
}
@@ -603,28 +603,28 @@ class AjaxProfile extends AjaxHandler
{
switch ($type)
{
case TYPE_FACTION: // factionId => amount
case Type::FACTION: // factionId => amount
$profile['reputation'] = array_combine(array_keys($data), array_column($data, 'cur'));
break;
case TYPE_TITLE:
case Type::TITLE:
foreach ($data as &$d)
$d = 1;
$profile['titles'] = $data;
break;
case TYPE_QUEST:
case Type::QUEST:
foreach ($data as &$d)
$d = 1;
$profile['quests'] = $data;
break;
case TYPE_SPELL:
case Type::SPELL:
foreach ($data as &$d)
$d = 1;
$profile['spells'] = $data;
break;
case TYPE_ACHIEVEMENT:
case Type::ACHIEVEMENT:
$achievements = array_filter($data, function ($x) { return $x['max'] === null; });
$statistics = array_filter($data, function ($x) { return $x['max'] !== null; });
@@ -642,7 +642,7 @@ class AjaxProfile extends AjaxHandler
$profile['statistics'] = array_combine(array_keys($statistics), array_column($statistics, 'max'));
$profile['activity'] = $activity;
break;
case TYPE_SKILL:
case Type::SKILL:
foreach ($data as &$d)
$d = [$d['cur'], $d['max']];

View File

@@ -440,7 +440,7 @@ abstract class BaseType
'q': cssQuality [Items]
'z': zone [set when all happens in here]
'p': PvP [pvpSourceId]
's': TYPE_TITLE: side; TYPE_SPELL: skillId (yeah, double use. Ain't life just grand)
's': Type::TITLE: side; Type::SPELL: skillId (yeah, double use. Ain't life just grand)
'c': category [Spells / Quests]
'c2': subCat [Quests]
'icon': iconString
@@ -590,7 +590,7 @@ trait spawnHelper
{
// check, if we can attach waypoints to creature
// we will get a nice clusterfuck of dots if we do this for more GUIDs, than we have colors though
if (count($spawns) < 6 && self::$type == TYPE_NPC)
if (count($spawns) < 6 && self::$type == Type::NPC)
{
if ($wPoints = DB::Aowow()->select('SELECT * FROM ?_creature_waypoints WHERE creatureOrPath = ?d AND floor = ?d', $s['pathId'] ? -$s['pathId'] : $this->id, $s['floor']))
{
@@ -645,7 +645,7 @@ trait spawnHelper
$info[4] = Lang::game('mode').Lang::main('colon').implode(', ', $_);
}
if (self::$type == TYPE_AREATRIGGER)
if (self::$type == Type::AREATRIGGER)
{
$o = Util::O2Deg($this->getField('orientation'));
$info[5] = 'Orientation'.Lang::main('colon').$o[0].'° ('.$o[1].')';
@@ -752,7 +752,7 @@ trait spawnHelper
private function createQuestSpawns() // [zoneId => [floor => [[x1, y1], [x2, y2], ..]]] mapper on quest detail page
{
if (self::$type == TYPE_SOUND)
if (self::$type == Type::SOUND)
return;
$res = DB::Aowow()->select('SELECT areaId, floor, typeId, posX, posY FROM ?_spawns WHERE type = ?d AND typeId IN (?a) AND posX > 0 AND posY > 0', self::$type, $this->getFoundIDs());
@@ -785,7 +785,7 @@ trait spawnHelper
public function getSpawns($mode)
{
// only Creatures, GOs and SoundEmitters can be spawned
if (!self::$type || !$this->getfoundIDs() || (self::$type != TYPE_NPC && self::$type != TYPE_OBJECT && self::$type != TYPE_SOUND && self::$type != TYPE_AREATRIGGER))
if (!self::$type || !$this->getfoundIDs() || (self::$type != Type::NPC && self::$type != Type::OBJECT && self::$type != Type::SOUND && self::$type != Type::AREATRIGGER))
return [];
switch ($mode)

View File

@@ -118,32 +118,9 @@ class CommunityContent
if (!$_)
continue;
$cnd = [CFG_SQL_LIMIT_NONE, ['id', $_]];
switch ($type)
{
case TYPE_NPC: $obj = new CreatureList($cnd); break;
case TYPE_OBJECT: $obj = new GameobjectList($cnd); break;
case TYPE_ITEM: $obj = new ItemList($cnd); break;
case TYPE_ITEMSET: $obj = new ItemsetList($cnd); break;
case TYPE_QUEST: $obj = new QuestList($cnd); break;
case TYPE_SPELL: $obj = new SpellList($cnd); break;
case TYPE_ZONE: $obj = new ZoneList($cnd); break;
case TYPE_FACTION: $obj = new FactionList($cnd); break;
case TYPE_PET: $obj = new PetList($cnd); break;
case TYPE_ACHIEVEMENT: $obj = new AchievementList($cnd); break;
case TYPE_TITLE: $obj = new TitleList($cnd); break;
case TYPE_WORLDEVENT: $obj = new WorldEventList($cnd); break;
case TYPE_CLASS: $obj = new CharClassList($cnd); break;
case TYPE_RACE: $obj = new CharRaceList($cnd); break;
case TYPE_SKILL: $obj = new SkillList($cnd); break;
case TYPE_CURRENCY: $obj = new CurrencyList($cnd); break;
case TYPE_EMOTE: $obj = new EmoteList($cnd); break;
case TYPE_ENCHANTMENT: $obj = new EnchantmentList($cnd); break;
case TYPE_SOUND: $obj = new SoundList($cnd); break;
case TYPE_ICON: $obj = new IconList($cnd); break;
default: continue 2;
}
$obj = Type::newList($type, [CFG_SQL_LIMIT_NONE, ['id', $_]]);
if (!$obj)
continue;
foreach ($obj->iterate() as $id => $__)
self::$subjCache[$type][$id] = $obj->getField('name', true);
@@ -323,8 +300,7 @@ class CommunityContent
if ($pages)
{
// limit to one actually existing type each
$types = array_intersect(array_unique(array_column($pages, 'type')), array_keys(Util::$typeClasses));
foreach ($types as $t)
foreach (array_unique(array_column($pages, 'type')) as $t)
{
$ids = [];
foreach ($pages as $row)
@@ -334,11 +310,14 @@ class CommunityContent
if (!$ids)
continue;
$tClass = new Util::$typeClasses[$t](array(['id', $ids], CFG_SQL_LIMIT_NONE));
$obj = Type::newList($t, [CFG_SQL_LIMIT_NONE, ['id', $ids]]);
if (!$obj || $obj->error)
continue;
foreach ($pages as &$p)
if ($p['type'] == $t)
if ($tClass->getEntry($p['typeId']))
$p['name'] = $tClass->getField('name', true);
if ($obj->getEntry($p['typeId']))
$p['name'] = $obj->getField('name', true);
}
foreach ($pages as &$p)
@@ -371,7 +350,7 @@ class CommunityContent
{
(new Markup($r['body']))->parseGlobalsFromText(self::$jsGlobals);
self::$jsGlobals[TYPE_USER][$r['userId']] = $r['userId'];
self::$jsGlobals[Type::USER][$r['userId']] = $r['userId'];
$c = array(
'commentv2' => 1, // always 1.. enables some features i guess..?

View File

@@ -26,35 +26,6 @@ define('ERR_MISSING_FILE', 'file %s not found');
define('ERR_NONE', 'created file %s');
define('ERR_MISSING_INCL', 'required function %s() could not be found at %s');
// TypeIds
define('TYPE_NPC', 1);
define('TYPE_OBJECT', 2);
define('TYPE_ITEM', 3);
define('TYPE_ITEMSET', 4);
define('TYPE_QUEST', 5);
define('TYPE_SPELL', 6);
define('TYPE_ZONE', 7);
define('TYPE_FACTION', 8);
define('TYPE_PET', 9);
define('TYPE_ACHIEVEMENT', 10);
define('TYPE_TITLE', 11);
define('TYPE_WORLDEVENT', 12);
define('TYPE_CLASS', 13);
define('TYPE_RACE', 14);
define('TYPE_SKILL', 15);
define('TYPE_CURRENCY', 17);
define('TYPE_SOUND', 19);
define('TYPE_ICON', 29);
define('TYPE_PROFILE', 100);
// internal types (not published to js)
define('TYPE_GUILD', 101);
define('TYPE_ARENA_TEAM', 102);
define('TYPE_USER', 500);
define('TYPE_EMOTE', 501);
define('TYPE_ENCHANTMENT', 502);
define('TYPE_AREATRIGGER', 503);
define('TYPE_MAIL', 504);
define('CACHE_TYPE_NONE', 0); // page will not be cached
define('CACHE_TYPE_PAGE', 1);
define('CACHE_TYPE_TOOLTIP', 2);
@@ -1674,4 +1645,5 @@ define('AT_TYPE_TELEPORT', 2);
define('AT_TYPE_OBJECTIVE', 3);
define('AT_TYPE_SMART', 4);
define('AT_TYPE_SCRIPT', 5);
?>

View File

@@ -285,16 +285,16 @@ class Game
switch ($type)
{
case TYPE_NPC:
case Type::NPC:
$result = DB::World()->select('SELECT `guid` AS ARRAY_KEY, `id`, `map` AS `mapId`, `position_y` AS `posX`, `position_x` AS `posY` FROM creature WHERE `guid` IN (?a)', $guids);
break;
case TYPE_OBJECT:
case Type::OBJECT:
$result = DB::World()->select('SELECT `guid` AS ARRAY_KEY, `id`, `map` AS `mapId`, `position_y` AS `posX`, `position_x` AS `posY` FROM gameobject WHERE `guid` IN (?a)', $guids);
break;
case TYPE_SOUND:
case Type::SOUND:
$result = DB::AoWoW()->select('SELECT `soundId` AS ARRAY_KEY, `soundId` AS `id`, `mapId`, `posX`, `posY` FROM dbc_soundemitters WHERE `soundId` IN (?a)', $guids);
break;
case TYPE_AREATRIGGER:
case Type::AREATRIGGER:
$result = DB::AoWoW()->select('SELECT `id` AS ARRAY_KEY, `id`, `mapId`, `posX`, `posY` FROM dbc_areatrigger WHERE `id` IN (?a)', $guids);
break;
default:

View File

@@ -328,7 +328,7 @@ class Loot
);
$this->results[] = array_merge($base, $data);
$this->jsGlobals[TYPE_ITEM][$loot['reference']] = $data;
$this->jsGlobals[Type::ITEM][$loot['reference']] = $data;
}
}

View File

@@ -40,7 +40,7 @@ class Markup
{
$sm = explode(',', $submatch[1]);
for ($i = 0; $i < count($sm); $i+=2)
$this->jsGlobals[TYPE_ITEM][$sm[$i]] = $sm[$i];
$this->jsGlobals[Type::ITEM][$sm[$i]] = $sm[$i];
}
}
@@ -50,11 +50,11 @@ class Markup
{
$sm = explode(',', $submatch[1]);
for ($i = 0; $i < count($sm); $i+=2)
$this->jsGlobals[TYPE_CURRENCY][$sm[$i]] = $sm[$i];
$this->jsGlobals[Type::CURRENCY][$sm[$i]] = $sm[$i];
}
}
}
else if ($type = array_search($match[1], Util::$typeStrings))
else if ($type = Type::getIndexFrom(Type::IDX_FILE_STR, $match[1]))
$this->jsGlobals[$type][$match[2]] = $match[2];
}
}
@@ -82,8 +82,8 @@ class Markup
$sm = explode(',', $submatch[1]);
for ($i = 0; $i < count($sm); $i += 2)
{
if (!empty($globals[TYPE_ITEM][1][$sm[$i]]))
$moneys[] = $globals[TYPE_ITEM][1][$sm[$i]]['name'];
if (!empty($globals[Type::ITEM][1][$sm[$i]]))
$moneys[] = $globals[Type::ITEM][1][$sm[$i]]['name'];
else
$moneys[] = Util::ucFirst(Lang::game('item')).' #'.$sm[$i];
}
@@ -97,8 +97,8 @@ class Markup
$sm = explode(',', $submatch[1]);
for ($i = 0; $i < count($sm); $i += 2)
{
if (!empty($globals[TYPE_CURRENCY][1][$sm[$i]]))
$moneys[] = $globals[TYPE_CURRENCY][1][$sm[$i]]['name'];
if (!empty($globals[Type::CURRENCY][1][$sm[$i]]))
$moneys[] = $globals[Type::CURRENCY][1][$sm[$i]]['name'];
else
$moneys[] = Util::ucFirst(Lang::game('curency')).' #'.$sm[$i];
}
@@ -107,8 +107,7 @@ class Markup
return Lang::concat($moneys);
}
if ($type = array_search($match[1], Util::$typeStrings))
if ($type = Type::getIndexFrom(Type::IDX_FILE_STR, $match[1]))
{
if (!empty($globals[$type][1][$match[2]]))
return $globals[$type][1][$match[2]]['name'];

View File

@@ -234,19 +234,19 @@ class Profiler
switch ($type)
{
case TYPE_PROFILE:
case Type::PROFILE:
if ($newId = DB::Aowow()->selectCell('SELECT id FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID = ?d', $realmId, $guid))
self::queueInsert($realmId, $guid, TYPE_PROFILE, $newId);
self::queueInsert($realmId, $guid, Type::PROFILE, $newId);
break;
case TYPE_GUILD:
case Type::GUILD:
if ($newId = DB::Aowow()->selectCell('SELECT id FROM ?_profiler_guild WHERE realm = ?d AND realmGUID = ?d', $realmId, $guid))
self::queueInsert($realmId, $guid, TYPE_GUILD, $newId);
self::queueInsert($realmId, $guid, Type::GUILD, $newId);
break;
case TYPE_ARENA_TEAM:
case Type::ARENA_TEAM:
if ($newId = DB::Aowow()->selectCell('SELECT id FROM ?_profiler_arena_team WHERE realm = ?d AND realmGUID = ?d', $realmId, $guid))
self::queueInsert($realmId, $guid, TYPE_ARENA_TEAM, $newId);
self::queueInsert($realmId, $guid, Type::ARENA_TEAM, $newId);
break;
default:
@@ -547,7 +547,7 @@ class Profiler
DB::Aowow()->query('DELETE FROM ?_profiler_completion WHERE id = ?d', $profileId);
// done quests
if ($quests = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, quest AS typeId FROM character_queststatus_rewarded WHERE guid = ?d', $profileId, TYPE_QUEST, $char['guid']))
if ($quests = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, quest AS typeId FROM character_queststatus_rewarded WHERE guid = ?d', $profileId, Type::QUEST, $char['guid']))
foreach (Util::createSqlBatchInsert($quests) as $q)
DB::Aowow()->query('INSERT INTO ?_profiler_completion (?#) VALUES '.$q, array_keys($quests[0]));
@@ -556,7 +556,7 @@ class Profiler
// known skills (professions only)
$skAllowed = DB::Aowow()->selectCol('SELECT id FROM ?_skillline WHERE typeCat IN (9, 11) AND (cuFlags & ?d) = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW);
$skills = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, skill AS typeId, `value` AS cur, max FROM character_skills WHERE guid = ?d AND skill IN (?a)', $profileId, TYPE_SKILL, $char['guid'], $skAllowed);
$skills = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, skill AS typeId, `value` AS cur, max FROM character_skills WHERE guid = ?d AND skill IN (?a)', $profileId, Type::SKILL, $char['guid'], $skAllowed);
// manually apply racial profession bonuses
foreach ($skills as &$sk)
@@ -595,7 +595,7 @@ class Profiler
acquireMethod = 1 AND
(reqRaceMask = 0 OR reqRaceMask & ?d) AND
(reqClassMask = 0 OR reqClassMask & ?d)',
$profileId, TYPE_SPELL,
$profileId, Type::SPELL,
array_column($skills, 'typeId'),
1 << ($char['race'] - 1),
1 << ($char['class'] - 1)
@@ -623,7 +623,7 @@ class Profiler
((baseRepClassMask4 & ?d) || !baseRepClassMask4)
', $ra, $cl, $ra, $cl, $ra, $cl, $ra, $cl);
if ($reputation = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, faction AS typeId, standing AS cur FROM character_reputation WHERE guid = ?d AND (flags & 0x4) = 0', $profileId, TYPE_FACTION, $char['guid']))
if ($reputation = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, faction AS typeId, standing AS cur FROM character_reputation WHERE guid = ?d AND (flags & 0x4) = 0', $profileId, Type::FACTION, $char['guid']))
{
// merge back base values for encountered factions
foreach ($reputation as &$set)
@@ -640,7 +640,7 @@ class Profiler
foreach ($baseRep as $id => $val)
$reputation[] = array(
'id' => $profileId,
'type' => TYPE_FACTION,
'type' => Type::FACTION,
'typeId' => $id,
'cur' => $val
);
@@ -660,13 +660,13 @@ class Profiler
$indizes[] = $j + ($i * 32);
if ($indizes)
DB::Aowow()->query('INSERT INTO ?_profiler_completion SELECT ?d, ?d, id, NULL, NULL FROM ?_titles WHERE bitIdx IN (?a)', $profileId, TYPE_TITLE, $indizes);
DB::Aowow()->query('INSERT INTO ?_profiler_completion SELECT ?d, ?d, id, NULL, NULL FROM ?_titles WHERE bitIdx IN (?a)', $profileId, Type::TITLE, $indizes);
CLI::write(' ..titles');
// achievements
if ($achievements = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, achievement AS typeId, date AS cur FROM character_achievement WHERE guid = ?d', $profileId, TYPE_ACHIEVEMENT, $char['guid']))
if ($achievements = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, achievement AS typeId, date AS cur FROM character_achievement WHERE guid = ?d', $profileId, Type::ACHIEVEMENT, $char['guid']))
{
foreach (Util::createSqlBatchInsert($achievements) as $a)
DB::Aowow()->query('INSERT INTO ?_profiler_completion (?#) VALUES '.$a, array_keys($achievements[0]));
@@ -678,7 +678,7 @@ class Profiler
// raid progression
if ($progress = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, criteria AS typeId, date AS cur, counter AS `max` FROM character_achievement_progress WHERE guid = ?d AND criteria IN (?a)', $profileId, TYPE_ACHIEVEMENT, $char['guid'], self::$raidProgression))
if ($progress = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, criteria AS typeId, date AS cur, counter AS `max` FROM character_achievement_progress WHERE guid = ?d AND criteria IN (?a)', $profileId, Type::ACHIEVEMENT, $char['guid'], self::$raidProgression))
{
array_walk($progress, function (&$val) { $val['typeId'] = array_search($val['typeId'], self::$raidProgression); });
foreach (Util::createSqlBatchInsert($progress) as $p)
@@ -689,7 +689,7 @@ class Profiler
// known spells
if ($spells = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, spell AS typeId FROM character_spell WHERE guid = ?d AND disabled = 0', $profileId, TYPE_SPELL, $char['guid']))
if ($spells = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, spell AS typeId FROM character_spell WHERE guid = ?d AND disabled = 0', $profileId, Type::SPELL, $char['guid']))
foreach (Util::createSqlBatchInsert($spells) as $s)
DB::Aowow()->query('INSERT INTO ?_profiler_completion (?#) VALUES '.$s, array_keys($spells[0]));

View File

@@ -33,7 +33,7 @@ class SmartAI
SAI_ACTION_MOUNT_TO_ENTRY_OR_MODEL => [1 => $npcId]
);
if ($npcGuids = DB::Aowow()->selectCol('SELECT guid FROM ?_spawns WHERE `type` = ?d AND `typeId` = ?d', TYPE_NPC, $npcId))
if ($npcGuids = DB::Aowow()->selectCol('SELECT guid FROM ?_spawns WHERE `type` = ?d AND `typeId` = ?d', Type::NPC, $npcId))
if ($groups = DB::World()->selectCol('SELECT `groupId` FROM spawn_group WHERE `spawnType` = 0 AND `spawnId` IN (?a)', $npcGuids))
foreach ($groups as $g)
$lookup[SAI_ACTION_SPAWN_SPAWNGROUP][1] = $g;
@@ -57,7 +57,7 @@ class SmartAI
SAI_ACTION_SUMMON_GO => [1 => $objectId]
);
if ($objGuids = DB::Aowow()->selectCol('SELECT guid FROM ?_spawns WHERE `type` = ?d AND `typeId` = ?d', TYPE_OBJECT, $objectId))
if ($objGuids = DB::Aowow()->selectCol('SELECT guid FROM ?_spawns WHERE `type` = ?d AND `typeId` = ?d', Type::OBJECT, $objectId))
if ($groups = DB::World()->selectCol('SELECT `groupId` FROM spawn_group WHERE `spawnType` = 1 AND `spawnId` IN (?a)', $objGuids))
foreach ($groups as $g)
$lookup[SAI_ACTION_SPAWN_SPAWNGROUP][1] = $g;
@@ -100,15 +100,15 @@ class SmartAI
$genLimit = $talLimit = [];
switch ($typeFilter)
{
case TYPE_NPC:
case Type::NPC:
$genLimit = [SAI_SRC_TYPE_CREATURE, SAI_SRC_TYPE_ACTIONLIST];
$talLimit = [SAI_SRC_TYPE_CREATURE];
break;
case TYPE_OBJECT:
case Type::OBJECT:
$genLimit = [SAI_SRC_TYPE_OBJECT, SAI_SRC_TYPE_ACTIONLIST];
$talLimit = [SAI_SRC_TYPE_OBJECT];
break;
case TYPE_AREATRIGGER:
case Type::AREATRIGGER:
$genLimit = [SAI_SRC_TYPE_AREATRIGGER, SAI_SRC_TYPE_ACTIONLIST];
$talLimit = [SAI_SRC_TYPE_AREATRIGGER];
break;
@@ -158,9 +158,9 @@ class SmartAI
foreach ($smartG as [$st, $eog])
{
if ($st == SAI_SRC_TYPE_CREATURE)
$q[] = '`type` = '.TYPE_NPC.' AND `guid` = '.-$eog;
$q[] = '`type` = '.Type::NPC.' AND `guid` = '.-$eog;
else if ($st == SAI_SRC_TYPE_OBJECT)
$q[] = '`type` = '.TYPE_OBJECT.' AND `guid` = '.-$eog;
$q[] = '`type` = '.Type::OBJECT.' AND `guid` = '.-$eog;
}
if ($q)
@@ -170,11 +170,11 @@ class SmartAI
foreach ($smartS as [$st, $eog])
{
if ($st == SAI_SRC_TYPE_CREATURE)
$result[TYPE_NPC][] = $eog;
$result[Type::NPC][] = $eog;
else if ($st == SAI_SRC_TYPE_OBJECT)
$result[TYPE_OBJECT][] = $eog;
$result[Type::OBJECT][] = $eog;
else if ($st == SAI_SRC_TYPE_AREATRIGGER)
$result[TYPE_AREATRIGGER][] = $eog;
$result[Type::AREATRIGGER][] = $eog;
}
return $result;
@@ -208,7 +208,7 @@ class SmartAI
{
$grp = $moreInfo[SAI_ACTION_SPAWN_SPAWNGROUP];
if ($sgs = DB::World()->selectCol('SELECT `spawnId` FROM spawn_group WHERE `spawnType` = ?d AND `groupId` IN (?a)', 0 /*0:SUMMONER_TYPE_CREATURE*/, $grp))
if ($ids = DB::Aowow()->selectCol('SELECT DISTINCT `typeId` FROM ?_spawns WHERE `type` = ?d AND `guid` IN (?a)', TYPE_NPC, $sgs))
if ($ids = DB::Aowow()->selectCol('SELECT DISTINCT `typeId` FROM ?_spawns WHERE `type` = ?d AND `guid` IN (?a)', Type::NPC, $sgs))
$result = array_merge($result, $ids);
}
@@ -229,7 +229,7 @@ class SmartAI
{
$grp = $moreInfo[SAI_ACTION_SPAWN_SPAWNGROUP];
if ($sgs = DB::World()->selectCol('SELECT `spawnId` FROM spawn_group WHERE `spawnType` = ?d AND `groupId` IN (?a)', 1 /*1:SUMMONER_TYPE_GAMEOBJECT*/, $grp))
if ($ids = DB::Aowow()->selectCol('SELECT DISTINCT `typeId` FROM ?_spawns WHERE `type` = ?d AND `guid` IN (?a)', TYPE_OBJECT, $sgs))
if ($ids = DB::Aowow()->selectCol('SELECT DISTINCT `typeId` FROM ?_spawns WHERE `type` = ?d AND `guid` IN (?a)', Type::OBJECT, $sgs))
$result = array_merge($result, $ids);
}
@@ -721,13 +721,13 @@ class SmartAI
// creature link
case SAI_TARGET_CREATURE_RANGE: // 9
if ($t['param'][0])
$this->jsGlobals[TYPE_NPC][] = $t['param'][0];
$this->jsGlobals[Type::NPC][] = $t['param'][0];
$t['param'][10] = $getDist($t['param'][1], $t['param'][2]);
break;
case SAI_TARGET_CREATURE_GUID: // 10
if ($t['param'][10] = DB::World()->selectCell('SELECT id FROM creature WHERE guid = ?d', $t['param'][0]))
$this->jsGlobals[TYPE_NPC][] = $t['param'][10];
$this->jsGlobals[Type::NPC][] = $t['param'][10];
else
trigger_error('SmartAI::resloveTarget - creature with guid '.$t['param'][0].' not in DB');
break;
@@ -736,12 +736,12 @@ class SmartAI
$t['param'][10] = $getDist(0, $t['param'][1]);
if ($t['param'][0])
$this->jsGlobals[TYPE_NPC][] = $t['param'][0];
$this->jsGlobals[Type::NPC][] = $t['param'][0];
break;
// gameobject link
case SAI_TARGET_GAMEOBJECT_GUID: // 14
if ($t['param'][10] = DB::World()->selectCell('SELECT id FROM gameobject WHERE guid = ?d', $t['param'][0]))
$this->jsGlobals[TYPE_OBJECT][] = $t['param'][10];
$this->jsGlobals[Type::OBJECT][] = $t['param'][10];
else
trigger_error('SmartAI::resloveTarget - gameobject with guid '.$t['param'][0].' not in DB');
break;
@@ -749,7 +749,7 @@ class SmartAI
$t['param'][10] = $getDist($t['param'][1], $t['param'][2]);
if ($t['param'][0])
$this->jsGlobals[TYPE_OBJECT][] = $t['param'][0];
$this->jsGlobals[Type::OBJECT][] = $t['param'][0];
break;
case SAI_TARGET_GAMEOBJECT_DISTANCE: // 15
case SAI_TARGET_CLOSEST_GAMEOBJECT: // 20
@@ -757,7 +757,7 @@ class SmartAI
$t['param'][10] = $getDist(0, $t['param'][1]);
if ($t['param'][0])
$this->jsGlobals[TYPE_OBJECT][] = $t['param'][0];
$this->jsGlobals[Type::OBJECT][] = $t['param'][0];
break;
// error
default:
@@ -859,7 +859,7 @@ class SmartAI
$footer = $time;
if ($e['param'][3] && !$e['param'][2])
$this->jsGlobals[TYPE_NPC][] = $e['param'][3];
$this->jsGlobals[Type::NPC][] = $e['param'][3];
break;
case SAI_EVENT_SPELLHIT: // 8 - On Creature/Gameobject Spell Hit
case SAI_EVENT_HAS_AURA: // 23 - On Creature Has Aura
@@ -872,11 +872,11 @@ class SmartAI
$e['param'][10] = Lang::getMagicSchools($e['param'][1]);
if ($e['param'][0])
$this->jsGlobals[TYPE_SPELL][] = $e['param'][0];
$this->jsGlobals[Type::SPELL][] = $e['param'][0];
break;
case SAI_EVENT_VICTIM_CASTING: // 13 - On Target Casting Spell
if ($e['param'][2])
$this->jsGlobals[TYPE_SPELL][$e['param'][2]];
$this->jsGlobals[Type::SPELL][$e['param'][2]];
// do not break;
case SAI_EVENT_PASSENGER_BOARDED: // 27 -
case SAI_EVENT_PASSENGER_REMOVED: // 28 -
@@ -887,7 +887,7 @@ class SmartAI
case SAI_EVENT_SUMMONED_UNIT: // 17 - On Creature/Gameobject Summoned Unit
case SAI_EVENT_SUMMONED_UNIT_DIES: // 82 - On Summoned Unit Dies
if ($e['param'][0])
$this->jsGlobals[TYPE_NPC][] = $e['param'][0];
$this->jsGlobals[Type::NPC][] = $e['param'][0];
// do not break;
case SAI_EVENT_FRIENDLY_IS_CC: // 15 -
case SAI_EVENT_SUMMON_DESPAWNED: // 35 - On Summoned Unit Despawned
@@ -897,19 +897,19 @@ class SmartAI
case SAI_EVENT_ACCEPTED_QUEST: // 19 - On Target Accepted Quest
case SAI_EVENT_REWARD_QUEST: // 20 - On Target Rewarded Quest
if ($e['param'][0])
$this->jsGlobals[TYPE_QUEST][] = $e['param'][0];
$this->jsGlobals[Type::QUEST][] = $e['param'][0];
if ($time = $this->numRange('event', 1, true))
$footer = $time;
break;
case SAI_EVENT_RECEIVE_EMOTE: // 22 - On Receive Emote.
$this->jsGlobals[TYPE_EMOTE][] = $e['param'][0];
$this->jsGlobals[Type::EMOTE][] = $e['param'][0];
if ($time = $this->numRange('event', 1, true))
$footer = $time;
break;
case SAI_EVENT_TEXT_OVER: // 52 - On TEXT_OVER Event Triggered After SMART_ACTION_TALK
if ($e['param'][1])
$this->jsGlobals[TYPE_NPC][] = $e['param'][1];
$this->jsGlobals[Type::NPC][] = $e['param'][1];
break;
case SAI_EVENT_LINK: // 61 - Used to link together multiple events as a chain of events.
$e['param'][10] = LANG::concat(DB::World()->selectCol('SELECT CONCAT("#[b]", id, "[/b]") FROM smart_scripts WHERE link = ?d AND entryorguid = ?d AND source_type = ?d', $this->itr['id'], $this->entry, $this->srcType), false);
@@ -931,7 +931,7 @@ class SmartAI
break;
case SAI_EVENT_GAME_EVENT_START: // 68 - On game_event started.
case SAI_EVENT_GAME_EVENT_END: // 69 - On game_event ended.
$this->jsGlobals[TYPE_WORLDEVENT][] = $e['param'][0];
$this->jsGlobals[Type::WORLDEVENT][] = $e['param'][0];
break;
case SAI_EVENT_DISTANCE_CREATURE: // 75 - On creature guid OR any instance of creature entry is within distance.
if ($e['param'][0])
@@ -946,7 +946,7 @@ class SmartAI
trigger_error('SmartAI::event - entity for event #'.$e['type'].' not defined');
if ($e['param'][10])
$this->jsGlobals[TYPE_NPC][] = $e['param'][10];
$this->jsGlobals[Type::NPC][] = $e['param'][10];
if ($e['param'][3])
$footer = Util::formatTime($e['param'][3], true);
@@ -1040,36 +1040,36 @@ class SmartAI
case SAI_ACTION_PLAY_EMOTE: // 5 -> any target
case SAI_ACTION_SET_EMOTE_STATE: // 17 -> any target
if ($a['param'][0])
$this->jsGlobals[TYPE_EMOTE][] = $a['param'][0];
$this->jsGlobals[Type::EMOTE][] = $a['param'][0];
break;
case SAI_ACTION_FAIL_QUEST: // 6 -> any target
case SAI_ACTION_OFFER_QUEST: // 7 -> invoker
case SAI_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS:// 15 -> any target
case SAI_ACTION_CALL_GROUPEVENTHAPPENS: // 26 -> invoker
if ($a['param'][0])
$this->jsGlobals[TYPE_QUEST][] = $a['param'][0];
$this->jsGlobals[Type::QUEST][] = $a['param'][0];
break;
case SAI_ACTION_REMOVEAURASFROMSPELL: // 28 -> any target
if ($a['param'][2])
$footer = true;
case SAI_ACTION_ADD_AURA: // 75 -> any target
if ($a['param'][0])
$this->jsGlobals[TYPE_SPELL][] = $a['param'][0];
$this->jsGlobals[Type::SPELL][] = $a['param'][0];
break;
case SAI_ACTION_CALL_KILLEDMONSTER: // 33 -> any target
case SAI_ACTION_UPDATE_TEMPLATE: // 36 -> self
if ($a['param'][0])
$this->jsGlobals[TYPE_NPC][] = $a['param'][0];
$this->jsGlobals[Type::NPC][] = $a['param'][0];
break;
case SAI_ACTION_ADD_ITEM: // 56 -> invoker
case SAI_ACTION_REMOVE_ITEM: // 57 -> invoker
if ($a['param'][0])
$this->jsGlobals[TYPE_ITEM][] = $a['param'][0];
$this->jsGlobals[Type::ITEM][] = $a['param'][0];
break;
case SAI_ACTION_GAME_EVENT_STOP: // 111 -> doesnt matter
case SAI_ACTION_GAME_EVENT_START: // 112 -> doesnt matter
if ($a['param'][0])
$this->jsGlobals[TYPE_WORLDEVENT][] = $a['param'][0];
$this->jsGlobals[Type::WORLDEVENT][] = $a['param'][0];
break;
// simple preparse from param[0] to param[6]
case SAI_ACTION_SET_REACT_STATE: // 8 -> any target
@@ -1125,18 +1125,18 @@ class SmartAI
if ($a['param'][0])
{
$a['param'][6] = DB::Aowow()->selectCell('SELECT factionId FROM ?_factiontemplate WHERE id = ?d', $a['param'][0]);
$this->jsGlobals[TYPE_FACTION][] = $a['param'][6];
$this->jsGlobals[Type::FACTION][] = $a['param'][6];
}
break;
case SAI_ACTION_MORPH_TO_ENTRY_OR_MODEL: // 3 -> self
if ($a['param'][0])
$this->jsGlobals[TYPE_NPC][] = $a['param'][0];
$this->jsGlobals[Type::NPC][] = $a['param'][0];
else if (!$a['param'][1])
$a['param'][6] = 1;
break;
case SAI_ACTION_SOUND: // 4 -> self [param3 set in DB but not used in core?]
$this->jsGlobals[TYPE_SOUND][] = $a['param'][0];
$this->jsGlobals[Type::SOUND][] = $a['param'][0];
if ($a['param'][2])
$footer = true;
@@ -1149,18 +1149,18 @@ class SmartAI
continue;
$buff[] = '[emote='.$a['param'][$i].']';
$this->jsGlobals[TYPE_EMOTE][] = $a['param'][$i];
$this->jsGlobals[Type::EMOTE][] = $a['param'][$i];
}
$a['param'][6] = Lang::concat($buff, false);
break;
case SAI_ACTION_CAST: // 11 -> any target
$this->jsGlobals[TYPE_SPELL][] = $a['param'][0];
$this->jsGlobals[Type::SPELL][] = $a['param'][0];
if ($_ = $this->castFlags('action', 1))
$footer = $_;
break;
case SAI_ACTION_SUMMON_CREATURE: // 12 -> any target
$this->jsGlobals[TYPE_NPC][] = $a['param'][0];
$this->jsGlobals[Type::NPC][] = $a['param'][0];
if ($a['param'][2])
$a['param'][6] = Util::formatTime($a['param'][2], true);
@@ -1181,7 +1181,7 @@ class SmartAI
$footer = true;
break;
case SAI_ACTION_FOLLOW: // 29 -> any target [what the heck are param 4 & 5]
$this->jsGlobals[TYPE_NPC][] = $a['param'][2];
$this->jsGlobals[Type::NPC][] = $a['param'][2];
if ($a['param'][1])
$a['param'][6] = Util::O2Deg($a['param'][1])[0];
if ($a['param'][3] || $a['param'][4])
@@ -1212,7 +1212,7 @@ class SmartAI
break;
case SAI_ACTION_MOUNT_TO_ENTRY_OR_MODEL: // 43 -> self
if ($a['param'][0])
$this->jsGlobals[TYPE_NPC][] = $a['param'][0];
$this->jsGlobals[Type::NPC][] = $a['param'][0];
else if (!$a['param'][1])
$a['param'][6] = 1;
break;
@@ -1220,7 +1220,7 @@ class SmartAI
$a['param'][6] = $a['param'][0] ? Lang::concat(Util::mask2bits($a['param'][0])) : 0;
break;
case SAI_ACTION_SUMMON_GO: // 50 -> self, world coords
$this->jsGlobals[TYPE_OBJECT][] = $a['param'][0];
$this->jsGlobals[Type::OBJECT][] = $a['param'][0];
$a['param'][6] = Util::formatTime($a['param'][1] * 1000, true);
if (!$a['param'][2])
@@ -1242,7 +1242,7 @@ class SmartAI
case SAI_ACTION_WP_START: // 53 -> any .. why tho?
$a['param'][7] = $this->reactState($a['param'][5]);
if ($a['param'][3])
$this->jsGlobals[TYPE_QUEST][] = $a['param'][3];
$this->jsGlobals[Type::QUEST][] = $a['param'][3];
if ($a['param'][4])
$a['param'][6] = Util::formatTime($a['param'][4], true);
if ($a['param'][2])
@@ -1258,7 +1258,7 @@ class SmartAI
if ($a['param'][1])
{
$this->jsGlobals[TYPE_QUEST][] = $a['param'][1];
$this->jsGlobals[Type::QUEST][] = $a['param'][1];
$a['param'][$a['param'][2] ? 7 : 8] = 1;
}
@@ -1268,7 +1268,7 @@ class SmartAI
break;
case SAI_ACTION_TELEPORT: // 62 -> invoker [resolved coords already stored in areatrigger entry]
$a['param'][6] = $this->miscData['teleportA'];
$this->jsGlobals[TYPE_ZONE][] = $a['param'][6];
$this->jsGlobals[Type::ZONE][] = $a['param'][6];
break;
case SAI_ACTION_SET_ORIENTATION: // 66 -> any target
if ($this->itr['target']['type'] == SAI_TARGET_POSITION)
@@ -1301,7 +1301,7 @@ class SmartAI
$items = DB::World()->selectRow('SELECT ItemID1, ItemID2, ItemID3 FROM creature_equip_template WHERE CreatureID = ?d AND ID = ?d', $this->miscData['baseEntry'] ?: $this->entry, $a['param'][0]);
foreach ($items as $i)
$this->jsGlobals[TYPE_ITEM][] = $i;
$this->jsGlobals[Type::ITEM][] = $i;
foreach ($slots as $s)
if ($_ = $items['ItemID'.$s])
@@ -1311,17 +1311,17 @@ class SmartAI
{
if ($_ = $a['param'][2])
{
$this->jsGlobals[TYPE_ITEM][] = $_;
$this->jsGlobals[Type::ITEM][] = $_;
$buff[] = '[item='.$_.']';
}
if ($_ = $a['param'][3])
{
$this->jsGlobals[TYPE_ITEM][] = $_;
$this->jsGlobals[Type::ITEM][] = $_;
$buff[] = '[item='.$_.']';
}
if ($_ = $a['param'][4])
{
$this->jsGlobals[TYPE_ITEM][] = $_;
$this->jsGlobals[Type::ITEM][] = $_;
$buff[] = '[item='.$_.']';
}
}
@@ -1383,7 +1383,7 @@ class SmartAI
// do not break;
case SAI_ACTION_SELF_CAST: // 85 -> self
case SAI_ACTION_INVOKER_CAST: // 134 -> any target
$this->jsGlobals[TYPE_SPELL][] = $a['param'][0];
$this->jsGlobals[Type::SPELL][] = $a['param'][0];
if ($_ = $this->castFlags('action', 1))
$footer = $_;
break;
@@ -1435,7 +1435,7 @@ class SmartAI
break;
case SAI_ACTION_INTERRUPT_SPELL: // 92 -> self
if ($_ = $a['param'][1])
$this->jsGlobals[TYPE_SPELL][] = $a['param'][1];
$this->jsGlobals[Type::SPELL][] = $a['param'][1];
if ($a['param'][0] || $a['param'][2])
$footer = [$a['param'][0]];
@@ -1475,7 +1475,7 @@ class SmartAI
{
foreach ($this->summons[$a['param'][0]] as $id => $n)
{
$this->jsGlobals[TYPE_NPC][] = $id;
$this->jsGlobals[Type::NPC][] = $id;
$buff[] = $n.'x [npc='.$id.']';
}
}
@@ -1497,7 +1497,7 @@ class SmartAI
{
if ($x = $a['param'][$i])
{
$this->jsGlobals[TYPE_SOUND][] = $x;
$this->jsGlobals[Type::SOUND][] = $x;
$a['param'][6] .= '[sound='.$x.']';
}
}
@@ -1531,7 +1531,7 @@ class SmartAI
if (!$i)
continue;
$this->jsGlobals[TYPE_ITEM][] = $i;
$this->jsGlobals[Type::ITEM][] = $i;
$buff[] = '[item='.$i.']';
}
}
@@ -1553,16 +1553,16 @@ class SmartAI
$n = 5;
foreach ($entities as [$spawnType, $guid])
{
$type = TYPE_NPC;
$type = Type::NPC;
if ($spawnType == 1)
$type == TYPE_GAMEOBJECT;
$type == Type::GAMEOBJECT;
$a['param'][7] = $this->spawnFlags('action', 3);
if ($_ = DB::Aowow()->selectCell('SELECT `typeId` FROM ?_spawns WHERE `type` = ?d AND `guid` = ?d', $type, $guid))
{
$this->jsGlobals[$type][] = $_;
$a['param'][8] .= '[li]['.Util::$typeStrings[$type].'='.$_.'][small class=q0] (GUID: '.$guid.')[/small][/li]';
$a['param'][8] .= '[li]['.Type::getFileString($type).'='.$_.'][small class=q0] (GUID: '.$guid.')[/small][/li]';
}
else
$a['param'][8] .= '[li]'.Lang::smartAI('entityUNK').'[small class=q0] (GUID: '.$guid.')[/small][/li]';
@@ -1580,12 +1580,12 @@ class SmartAI
$footer = [$time];
break;
case SAI_ACTION_RESPAWN_BY_SPAWNID: // 133
$type = TYPE_NPC;
$type = Type::NPC;
if ($a['param'][0] == 1)
$type == TYPE_GAMEOBJECT;
$type == Type::GAMEOBJECT;
if ($_ = DB::Aowow()->selectCell('SELECT `typeId` FROM ?_spawns WHERE `type` = ?d AND `guid` = ?d', $type, $a['param'][1]))
$a['param'][6] = '['.Util::$typeStrings[$type].'='.$_.']';
$a['param'][6] = '['.Type::getFileString($type).'='.$_.']';
else
$a['param'][6] = Lang::smartAI('entityUNK');
break;
@@ -1593,11 +1593,11 @@ class SmartAI
$a['param'][6] = $a['param'][1] + $a['param'][2] / pow(10, floor(log10($a['param'][2] ?: 1.0) + 1)); // i know string concatenation is a thing. don't @ me!
break;
case SAI_ACTION_OVERRIDE_LIGHT: // 138
$this->jsGlobals[TYPE_ZONE][] = $a['param'][0];
$this->jsGlobals[Type::ZONE][] = $a['param'][0];
$footer = [Util::formatTime($a['param'][2], true)];
break;
case SAI_ACTION_OVERRIDE_WEATHER: // 139
$this->jsGlobals[TYPE_ZONE][] = $a['param'][0];
$this->jsGlobals[Type::ZONE][] = $a['param'][0];
if (!($a['param'][6] = Lang::smartAI('weatherStates', $a['param'][1])))
$a['param'][6] = Lang::smartAI('weatherStateUNK', [$a['param'][1]]);
break;

View File

@@ -8,7 +8,7 @@ class AchievementList extends BaseType
{
use listviewHelper;
public static $type = TYPE_ACHIEVEMENT;
public static $type = Type::ACHIEVEMENT;
public static $brickFile = 'achievement';
public static $dataTable = '?_achievement';
@@ -71,25 +71,25 @@ class AchievementList extends BaseType
// $mailSrc = new Loot();
// $mailSrc->getByContainer(LOOT_MAIL, $rewards[$_id]['MailTemplateID']);
// foreach ($mailSrc->iterate() as $loot)
// $_curTpl['rewards'][] = [TYPE_ITEM, $loot['id']];
// $_curTpl['rewards'][] = [Type::ITEM, $loot['id']];
// lets just assume for now, that mailRewards for achievements do not contain references
$mailRew = DB::World()->selectCol('SELECT Item FROM mail_loot_template WHERE Reference <= 0 AND entry = ?d', $rewards[$_id]['MailTemplateID']);
foreach ($mailRew AS $mr)
$_curTpl['rewards'][] = [TYPE_ITEM, $mr];
$_curTpl['rewards'][] = [Type::ITEM, $mr];
}
}
//"rewards":[[11,137],[3,138]] [type, typeId]
if (!empty($_curTpl['ItemID']))
$_curTpl['rewards'][] = [TYPE_ITEM, $_curTpl['ItemID']];
$_curTpl['rewards'][] = [Type::ITEM, $_curTpl['ItemID']];
if (!empty($_curTpl['itemExtra']))
$_curTpl['rewards'][] = [TYPE_ITEM, $_curTpl['itemExtra']];
$_curTpl['rewards'][] = [Type::ITEM, $_curTpl['itemExtra']];
if (!empty($_curTpl['TitleA']))
$_curTpl['rewards'][] = [TYPE_TITLE, $_curTpl['TitleA']];
$_curTpl['rewards'][] = [Type::TITLE, $_curTpl['TitleA']];
if (!empty($_curTpl['TitleH']))
if (empty($_curTpl['TitleA']) || $_curTpl['TitleA'] != $_curTpl['TitleH'])
$_curTpl['rewards'][] = [TYPE_TITLE, $_curTpl['TitleH']];
$_curTpl['rewards'][] = [Type::TITLE, $_curTpl['TitleH']];
// icon
$_curTpl['iconString'] = $_curTpl['iconString'] ?: 'trade_engineering';
@@ -103,7 +103,7 @@ class AchievementList extends BaseType
foreach ($this->iterate() as $__)
{
if ($addMask & GLOBALINFO_SELF)
$data[TYPE_ACHIEVEMENT][$this->id] = ['icon' => $this->curTpl['iconString'], 'name' => $this->getField('name', true)];
$data[Type::ACHIEVEMENT][$this->id] = ['icon' => $this->curTpl['iconString'], 'name' => $this->getField('name', true)];
if ($addMask & GLOBALINFO_REWARDS)
foreach ($this->curTpl['rewards'] as $_)
@@ -266,7 +266,7 @@ class AchievementList extends BaseType
$data[$this->id] = array(
"n" => $this->getField('name', true),
"s" => $this->curTpl['faction'],
"t" => TYPE_ACHIEVEMENT,
"t" => Type::ACHIEVEMENT,
"ti" => $this->id
);
}

View File

@@ -8,7 +8,7 @@ class AreaTriggerList extends BaseType
{
use spawnHelper;
public static $type = TYPE_AREATRIGGER;
public static $type = Type::AREATRIGGER;
public static $brickFile = 'areatrigger';
public static $dataTable = '?_areatrigger';

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class CharClassList extends BaseType
{
public static $type = TYPE_CLASS;
public static $type = Type::CHR_CLASS;
public static $brickFile = 'class';
public static $dataTable = '?_classes';

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class CharRaceList extends BaseType
{
public static $type = TYPE_RACE;
public static $type = Type::CHR_RACE;
public static $brickFile = 'race';
public static $dataTable = '?_races';
@@ -40,7 +40,7 @@ class CharRaceList extends BaseType
$data = [];
foreach ($this->iterate() as $__)
$data[TYPE_RACE][$this->id] = ['name' => $this->getField('name', true)];
$data[Type::CHR_RACE][$this->id] = ['name' => $this->getField('name', true)];
return $data;
}

View File

@@ -8,7 +8,7 @@ class CreatureList extends BaseType
{
use spawnHelper;
public static $type = TYPE_NPC;
public static $type = Type::NPC;
public static $brickFile = 'creature';
public static $dataTable = '?_creature';
@@ -252,7 +252,7 @@ class CreatureList extends BaseType
$data = [];
foreach ($this->iterate() as $__)
$data[TYPE_NPC][$this->id] = ['name' => $this->getField('name', true)];
$data[Type::NPC][$this->id] = ['name' => $this->getField('name', true)];
return $data;
}
@@ -265,7 +265,7 @@ class CreatureList extends BaseType
{
$data[$this->id] = array(
'n' => $this->getField('parentId') ? $this->getField('parent', true) : $this->getField('name', true),
't' => TYPE_NPC,
't' => Type::NPC,
'ti' => $this->getField('parentId') ?: $this->id,
// 'bd' => (int)($this->curTpl['cuFlags'] & NPC_CU_INSTANCE_BOSS || ($this->curTpl['typeFlags'] & 0x4 && $this->curTpl['rank']))
// 'z' where am i spawned

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class CurrencyList extends BaseType
{
public static $type = TYPE_CURRENCY;
public static $type = Type::CURRENCY;
public static $brickFile = 'currency';
public static $dataTable = '?_currencies';
@@ -57,7 +57,7 @@ class CurrencyList extends BaseType
else
$icon = [$this->curTpl['iconString'], $this->curTpl['iconString']];
$data[TYPE_CURRENCY][$this->id] = ['name' => $this->getField('name', true), 'icon' => $icon];
$data[Type::CURRENCY][$this->id] = ['name' => $this->getField('name', true), 'icon' => $icon];
}
return $data;

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class EmoteList extends BaseType
{
public static $type = TYPE_EMOTE;
public static $type = Type::EMOTE;
public static $brickFile = 'emote';
public static $dataTable = '?_emotes';
@@ -47,7 +47,7 @@ class EmoteList extends BaseType
$data = [];
foreach ($this->iterate() as $__)
$data[TYPE_EMOTE][$this->id] = ['name' => $this->getField('cmd')];
$data[Type::EMOTE][$this->id] = ['name' => $this->getField('cmd')];
return $data;
}

View File

@@ -8,7 +8,7 @@ class EnchantmentList extends BaseType
{
use listviewHelper;
public static $type = TYPE_ENCHANTMENT;
public static $type = Type::ENCHANTMENT;
public static $brickFile = 'enchantment';
public static $dataTable = '?_itemenchantment';
@@ -17,7 +17,7 @@ class EnchantmentList extends BaseType
private $triggerIds = [];
protected $queryBase = 'SELECT ie.*, ie.id AS ARRAY_KEY FROM ?_itemenchantment ie';
protected $queryOpts = array( // 502 => TYPE_ENCHANTMENT
protected $queryOpts = array( // 502 => Type::ENCHANTMENT
'ie' => [['is']],
'is' => ['j' => ['?_item_stats `is` ON `is`.`type` = 502 AND `is`.`typeId` = `ie`.`id`', true], 's' => ', `is`.*'],
);
@@ -216,7 +216,7 @@ class EnchantmentList extends BaseType
if ($addMask & GLOBALINFO_SELF)
foreach ($this->iterate() as $__)
$data[TYPE_ENCHANTMENT][$this->id] = ['name' => $this->getField('name', true)];
$data[Type::ENCHANTMENT][$this->id] = ['name' => $this->getField('name', true)];
if ($addMask & GLOBALINFO_RELATED)
{
@@ -224,8 +224,8 @@ class EnchantmentList extends BaseType
$data = $this->relSpells->getJSGlobals(GLOBALINFO_SELF);
foreach ($this->triggerIds as $tId)
if (empty($data[TYPE_SPELL][$tId]))
$data[TYPE_SPELL][$tId] = $tId;
if (empty($data[Type::SPELL][$tId]))
$data[Type::SPELL][$tId] = $tId;
}
return $data;

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class FactionList extends BaseType
{
public static $type = TYPE_FACTION;
public static $type = Type::FACTION;
public static $brickFile = 'faction';
public static $dataTable = '?_factions';
@@ -75,7 +75,7 @@ class FactionList extends BaseType
$data = [];
foreach ($this->iterate() as $__)
$data[TYPE_FACTION][$this->id] = ['name' => $this->getField('name', true)];
$data[Type::FACTION][$this->id] = ['name' => $this->getField('name', true)];
return $data;
}

View File

@@ -8,7 +8,7 @@ class GameObjectList extends BaseType
{
use listviewHelper, spawnHelper;
public static $type = TYPE_OBJECT;
public static $type = Type::OBJECT;
public static $brickFile = 'object';
public static $dataTable = '?_objects';
@@ -115,7 +115,7 @@ class GameObjectList extends BaseType
$data = [];
foreach ($this->iterate() as $__)
$data[TYPE_OBJECT][$this->id] = ['name' => $this->getField('name', true)];
$data[Type::OBJECT][$this->id] = ['name' => $this->getField('name', true)];
return $data;
}
@@ -128,7 +128,7 @@ class GameObjectList extends BaseType
{
$data[$this->id] = array(
'n' => $this->getField('name', true),
't' => TYPE_OBJECT,
't' => Type::OBJECT,
'ti' => $this->id
// 'bd' => bossdrop
// 'dd' => dungeondifficulty

View File

@@ -8,7 +8,7 @@ class IconList extends BaseType
{
use listviewHelper;
public static $type = TYPE_ICON;
public static $type = Type::ICON;
public static $brickFile = 'icon';
public static $dataTable = '?_icons';
public static $contribute = CONTRIBUTE_CO;
@@ -24,7 +24,7 @@ class IconList extends BaseType
protected $queryBase = 'SELECT ic.*, ic.id AS ARRAY_KEY FROM ?_icons ic';
/* this works, but takes ~100x more time than i'm comfortable with .. kept as reference
protected $queryOpts = array( // 29 => TYPE_ICON
protected $queryOpts = array( // 29 => Type::ICON
'ic' => [['s', 'i', 'a', 'c', 'p'], 'g' => 'ic.id'],
'i' => ['j' => ['?_items `i` ON `i`.`iconId` = `ic`.`id`', true], 's' => ', COUNT(DISTINCT `i`.`id`) AS nItems'],
's' => ['j' => ['?_spell `s` ON `s`.`iconId` = `ic`.`id`', true], 's' => ', COUNT(DISTINCT `s`.`id`) AS nSpells'],
@@ -90,7 +90,7 @@ class IconList extends BaseType
$data = [];
foreach ($this->iterate() as $__)
$data[TYPE_ICON][$this->id] = ['name' => $this->getField('name', true, true), 'icon' => $this->getField('name', true, true)];
$data[Type::ICON][$this->id] = ['name' => $this->getField('name', true, true), 'icon' => $this->getField('name', true, true)];
return $data;
}

View File

@@ -8,7 +8,7 @@ class ItemList extends BaseType
{
use ListviewHelper;
public static $type = TYPE_ITEM;
public static $type = Type::ITEM;
public static $brickFile = 'item';
public static $dataTable = '?_items';
@@ -25,7 +25,7 @@ class ItemList extends BaseType
private $jsGlobals = []; // getExtendedCost creates some and has no access to template
protected $queryBase = 'SELECT i.*, i.block AS tplBlock, i.id AS ARRAY_KEY, i.id AS id FROM ?_items i';
protected $queryOpts = array( // 3 => TYPE_ITEM
protected $queryOpts = array( // 3 => Type::ITEM
'i' => [['is', 'src', 'ic'], 'o' => 'i.quality DESC, i.itemLevel DESC'],
'ic' => ['j' => ['?_icons `ic` ON `ic`.`id` = `i`.`iconId`', true], 's' => ', ic.name AS iconString'],
'is' => ['j' => ['?_item_stats `is` ON `is`.`type` = 3 AND `is`.`typeId` = `i`.`id`', true], 's' => ', `is`.*'],
@@ -105,9 +105,9 @@ class ItemList extends BaseType
SELECT nv.item, nv.entry, 0 AS eventId, nv.maxcount, nv.extendedCost FROM npc_vendor nv WHERE {nv.entry IN (?a) AND} nv.item IN (?a)
UNION
SELECT genv.item, c.id AS `entry`, ge.eventEntry AS eventId, genv.maxcount, genv.extendedCost FROM game_event_npc_vendor genv LEFT JOIN game_event ge ON genv.eventEntry = ge.eventEntry JOIN creature c ON c.guid = genv.guid WHERE {c.id IN (?a) AND} genv.item IN (?a)',
empty($filter[TYPE_NPC]) || !is_array($filter[TYPE_NPC]) ? DBSIMPLE_SKIP : $filter[TYPE_NPC],
empty($filter[Type::NPC]) || !is_array($filter[Type::NPC]) ? DBSIMPLE_SKIP : $filter[Type::NPC],
array_keys($this->templates),
empty($filter[TYPE_NPC]) || !is_array($filter[TYPE_NPC]) ? DBSIMPLE_SKIP : $filter[TYPE_NPC],
empty($filter[Type::NPC]) || !is_array($filter[Type::NPC]) ? DBSIMPLE_SKIP : $filter[Type::NPC],
array_keys($this->templates)
);
@@ -147,13 +147,13 @@ class ItemList extends BaseType
if (!empty($costs['reqArenaPoints']))
{
$data[-103] = $costs['reqArenaPoints'];
$this->jsGlobals[TYPE_CURRENCY][103] = 103;
$this->jsGlobals[Type::CURRENCY][103] = 103;
}
if (!empty($costs['reqHonorPoints']))
{
$data[-104] = $costs['reqHonorPoints'];
$this->jsGlobals[TYPE_CURRENCY][104] = 104;
$this->jsGlobals[Type::CURRENCY][104] = 104;
}
for ($i = 1; $i < 6; $i++)
@@ -212,7 +212,7 @@ class ItemList extends BaseType
}
if (!$found)
$this->jsGlobals[TYPE_ITEM][$k] = $k;
$this->jsGlobals[Type::ITEM][$k] = $k;
}
}
$costData[$itr] = $cost;
@@ -229,8 +229,8 @@ class ItemList extends BaseType
$result = $this->vendors;
// apply filter if given
$tok = !empty($filter[TYPE_ITEM]) ? $filter[TYPE_ITEM] : null;
$cur = !empty($filter[TYPE_CURRENCY]) ? $filter[TYPE_CURRENCY] : null;
$tok = !empty($filter[Type::ITEM]) ? $filter[Type::ITEM] : null;
$cur = !empty($filter[Type::CURRENCY]) ? $filter[Type::CURRENCY] : null;
foreach ($result as $itemId => &$data)
{
@@ -366,7 +366,7 @@ class ItemList extends BaseType
if ($entries['event'])
{
$this->jsGlobals[TYPE_WORLDEVENT][$entries['event']] = $entries['event'];
$this->jsGlobals[Type::WORLDEVENT][$entries['event']] = $entries['event'];
$costArr['condition'][0][$this->id][] = [[CND_ACTIVE_EVENT, $entries['event']]];
}
@@ -464,7 +464,7 @@ class ItemList extends BaseType
{
if ($addMask & GLOBALINFO_SELF)
{
$data[TYPE_ITEM][$id] = array(
$data[Type::ITEM][$id] = array(
'name' => $this->getField('name', true),
'quality' => $this->curTpl['quality'],
'icon' => $this->curTpl['iconString']
@@ -878,8 +878,8 @@ class ItemList extends BaseType
if ($classes = Lang::getClassString($this->curTpl['requiredClass'], $jsg))
{
foreach ($jsg as $js)
if (empty($this->jsGlobals[TYPE_CLASS][$js]))
$this->jsGlobals[TYPE_CLASS][$js] = $js;
if (empty($this->jsGlobals[Type::CHR_CLASS][$js]))
$this->jsGlobals[Type::CHR_CLASS][$js] = $js;
$x .= Lang::game('classes').Lang::main('colon').$classes.'<br />';
}
@@ -888,8 +888,8 @@ class ItemList extends BaseType
if ($races = Lang::getRaceString($this->curTpl['requiredRace'], $jsg))
{
foreach ($jsg as $js)
if (empty($this->jsGlobals[TYPE_RACE][$js]))
$this->jsGlobals[TYPE_RACE][$js] = $js;
if (empty($this->jsGlobals[Type::CHR_RACE][$js]))
$this->jsGlobals[Type::CHR_ACE][$js] = $js;
$x .= Lang::game('races').Lang::main('colon').$races.'<br />';
}
@@ -1302,7 +1302,7 @@ class ItemList extends BaseType
if ($enchantments)
{
$eStats = DB::Aowow()->select('SELECT *, typeId AS ARRAY_KEY FROM ?_item_stats WHERE `type` = ?d AND typeId IN (?a)', TYPE_ENCHANTMENT, array_keys($enchantments));
$eStats = DB::Aowow()->select('SELECT *, typeId AS ARRAY_KEY FROM ?_item_stats WHERE `type` = ?d AND typeId IN (?a)', Type::ENCHANTMENT, array_keys($enchantments));
Util::checkNumeric($eStats);
// and merge enchantments back
@@ -1362,7 +1362,7 @@ class ItemList extends BaseType
{
$data[$this->id] = array(
'n' => $this->getField('name', true),
't' => TYPE_ITEM,
't' => Type::ITEM,
'ti' => $this->id,
'q' => $this->curTpl['quality'],
// 'p' => PvP [NYI]
@@ -1424,7 +1424,7 @@ class ItemList extends BaseType
$buff[$_curTpl['moreType']][] = $_curTpl['moreTypeId'];
foreach ($buff as $type => $ids)
$this->sourceMore[$type] = (new Util::$typeClasses[$type](array(['id', $ids])))->getSourceData();
$this->sourceMore[$type] = (Type::newList($type, [['id', $ids]]))?->getSourceData();
}
$s = array_keys($this->sources[$this->id]);

View File

@@ -8,7 +8,7 @@ class ItemsetList extends BaseType
{
use ListviewHelper;
public static $type = TYPE_ITEMSET;
public static $type = Type::ITEMSET;
public static $brickFile = 'itemset';
public static $dataTable = '?_itemset';
@@ -80,14 +80,14 @@ class ItemsetList extends BaseType
$data = [];
if ($this->classes && ($addMask & GLOBALINFO_RELATED))
$data[TYPE_CLASS] = array_combine($this->classes, $this->classes);
$data[Type::CHR_CLASS] = array_combine($this->classes, $this->classes);
if ($this->pieceToSet && ($addMask & GLOBALINFO_SELF))
$data[TYPE_ITEM] = array_combine(array_keys($this->pieceToSet), array_keys($this->pieceToSet));
$data[Type::ITEM] = array_combine(array_keys($this->pieceToSet), array_keys($this->pieceToSet));
if ($addMask & GLOBALINFO_SELF)
foreach ($this->iterate() as $id => $__)
$data[TYPE_ITEMSET][$id] = ['name' => $this->getField('name', true)];
$data[Type::ITEMSET][$id] = ['name' => $this->getField('name', true)];
return $data;
}

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class MailList extends BaseType
{
public static $type = TYPE_MAIL;
public static $type = Type::MAIL;
public static $brickFile = 'mail';
public static $dataTable = '?_mails';
@@ -63,7 +63,7 @@ class MailList extends BaseType
foreach ($this->iterate() as $__)
if ($a = $this->curTpl['attachment'])
$data[TYPE_ITEM][$a] = $a;
$data[Type::ITEM][$a] = $a;
return $data;
}

View File

@@ -8,7 +8,7 @@ class PetList extends BaseType
{
use ListviewHelper;
public static $type = TYPE_PET;
public static $type = Type::PET;
public static $brickFile = 'pet';
public static $dataTable = '?_pet';
@@ -59,10 +59,10 @@ class PetList extends BaseType
if ($addMask & GLOBALINFO_RELATED)
for ($i = 1; $i <= 4; $i++)
if ($this->curTpl['spellId'.$i] > 0)
$data[TYPE_SPELL][$this->curTpl['spellId'.$i]] = $this->curTpl['spellId'.$i];
$data[Type::SPELL][$this->curTpl['spellId'.$i]] = $this->curTpl['spellId'.$i];
if ($addMask & GLOBALINFO_SELF)
$data[TYPE_PET][$this->id] = ['icon' => $this->curTpl['iconString']];
$data[Type::PET][$this->id] = ['icon' => $this->curTpl['iconString']];
}
return $data;

View File

@@ -417,7 +417,7 @@ class ProfileListFilter extends Filter
if ($this->useLocalList)
{
$this->extraOpts[$k] = array(
'j' => ['?_profiler_completion '.$k.' ON '.$k.'.id = p.id AND '.$k.'.`type` = '.TYPE_SKILL.' AND '.$k.'.typeId = '.$skillId.' AND '.$k.'.cur '.$cr[1].' '.$cr[2], true],
'j' => ['?_profiler_completion '.$k.' ON '.$k.'.id = p.id AND '.$k.'.`type` = '.Type::SKILL.' AND '.$k.'.typeId = '.$skillId.' AND '.$k.'.cur '.$cr[1].' '.$cr[2], true],
's' => [', '.$k.'.cur AS '.$col]
);
return [$k.'.typeId', null, '!'];
@@ -444,7 +444,7 @@ class ProfileListFilter extends Filter
if ($this->useLocalList)
{
$this->extraOpts[$k] = ['j' => ['?_profiler_completion '.$k.' ON '.$k.'.id = p.id AND '.$k.'.`type` = '.TYPE_ACHIEVEMENT.' AND '.$k.'.typeId = '.$cr[2], true]];
$this->extraOpts[$k] = ['j' => ['?_profiler_completion '.$k.' ON '.$k.'.id = p.id AND '.$k.'.`type` = '.Type::ACHIEVEMENT.' AND '.$k.'.typeId = '.$cr[2], true]];
return [$k.'.typeId', null, '!'];
}
else
@@ -754,7 +754,7 @@ class LocalProfileList extends ProfileList
$realms = Profiler::getRealms();
// post processing
$acvPoints = DB::Aowow()->selectCol('SELECT pc.id AS ARRAY_KEY, SUM(a.points) FROM ?_profiler_completion pc LEFT JOIN ?_achievement a ON a.id = pc.typeId WHERE pc.`type` = ?d AND pc.id IN (?a) GROUP BY pc.id', TYPE_ACHIEVEMENT, $this->getFoundIDs());
$acvPoints = DB::Aowow()->selectCol('SELECT pc.id AS ARRAY_KEY, SUM(a.points) FROM ?_profiler_completion pc LEFT JOIN ?_achievement a ON a.id = pc.typeId WHERE pc.`type` = ?d AND pc.id IN (?a) GROUP BY pc.id', Type::ACHIEVEMENT, $this->getFoundIDs());
foreach ($this->iterate() as $id => &$curTpl)
{

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class QuestList extends BaseType
{
public static $type = TYPE_QUEST;
public static $type = Type::QUEST;
public static $brickFile = 'quest';
public static $dataTable = '?_quests';
@@ -49,18 +49,18 @@ class QuestList extends BaseType
for ($i = 1; $i < 7; $i++)
{
if ($_ = $_curTpl['reqItemId'.$i])
$requires[TYPE_ITEM][] = $_;
$requires[Type::ITEM][] = $_;
if ($i > 4)
continue;
if ($_curTpl['reqNpcOrGo'.$i] > 0)
$requires[TYPE_NPC][] = $_curTpl['reqNpcOrGo'.$i];
$requires[Type::NPC][] = $_curTpl['reqNpcOrGo'.$i];
else if ($_curTpl['reqNpcOrGo'.$i] < 0)
$requires[TYPE_OBJECT][] = -$_curTpl['reqNpcOrGo'.$i];
$requires[Type::OBJECT][] = -$_curTpl['reqNpcOrGo'.$i];
if ($_ = $_curTpl['reqSourceItemId'.$i])
$requires[TYPE_ITEM][] = $_;
$requires[Type::ITEM][] = $_;
}
if ($requires)
$this->requires[$id] = $requires;
@@ -70,24 +70,24 @@ class QuestList extends BaseType
$choices = [];
if ($_ = $_curTpl['rewardTitleId'])
$rewards[TYPE_TITLE][] = $_;
$rewards[Type::TITLE][] = $_;
if ($_ = $_curTpl['rewardHonorPoints'])
$rewards[TYPE_CURRENCY][104] = $_;
$rewards[Type::CURRENCY][104] = $_;
if ($_ = $_curTpl['rewardArenaPoints'])
$rewards[TYPE_CURRENCY][103] = $_;
$rewards[Type::CURRENCY][103] = $_;
for ($i = 1; $i < 7; $i++)
{
if ($_ = $_curTpl['rewardChoiceItemId'.$i])
$choices[TYPE_ITEM][$_] = $_curTpl['rewardChoiceItemCount'.$i];
$choices[Type::ITEM][$_] = $_curTpl['rewardChoiceItemCount'.$i];
if ($i > 5)
continue;
if ($_ = $_curTpl['rewardFactionId'.$i])
$rewards[TYPE_FACTION][$_] = $_curTpl['rewardFactionValue'.$i];
$rewards[Type::FACTION][$_] = $_curTpl['rewardFactionValue'.$i];
if ($i > 4)
continue;
@@ -96,9 +96,9 @@ class QuestList extends BaseType
{
$qty = $_curTpl['rewardItemCount'.$i];
if (in_array($_, $currencies))
$rewards[TYPE_CURRENCY][array_search($_, $currencies)] = $qty;
$rewards[Type::CURRENCY][array_search($_, $currencies)] = $qty;
else
$rewards[TYPE_ITEM][$_] = $qty;
$rewards[Type::ITEM][$_] = $qty;
}
}
if ($rewards)
@@ -156,7 +156,7 @@ class QuestList extends BaseType
{
$data[$this->id] = array(
"n" => $this->getField('name', true),
"t" => TYPE_QUEST,
"t" => Type::QUEST,
"ti" => $this->id,
"c" => $this->curTpl['cat1'],
"c2" => $this->curTpl['cat2']
@@ -214,16 +214,16 @@ class QuestList extends BaseType
'xp' => $this->curTpl['rewardXP']
);
if (!empty($this->rewards[$this->id][TYPE_CURRENCY]))
foreach ($this->rewards[$this->id][TYPE_CURRENCY] as $iId => $qty)
if (!empty($this->rewards[$this->id][Type::CURRENCY]))
foreach ($this->rewards[$this->id][Type::CURRENCY] as $iId => $qty)
$data[$this->id]['currencyrewards'][] = [$iId, $qty];
if (!empty($this->rewards[$this->id][TYPE_ITEM]))
foreach ($this->rewards[$this->id][TYPE_ITEM] as $iId => $qty)
if (!empty($this->rewards[$this->id][Type::ITEM]))
foreach ($this->rewards[$this->id][Type::ITEM] as $iId => $qty)
$data[$this->id]['itemrewards'][] = [$iId, $qty];
if (!empty($this->choices[$this->id][TYPE_ITEM]))
foreach ($this->choices[$this->id][TYPE_ITEM] as $iId => $qty)
if (!empty($this->choices[$this->id][Type::ITEM]))
foreach ($this->choices[$this->id][Type::ITEM] as $iId => $qty)
$data[$this->id]['itemchoices'][] = [$iId, $qty];
if ($_ = $this->curTpl['rewardTitleId'])
@@ -390,31 +390,31 @@ class QuestList extends BaseType
// items
for ($i = 1; $i < 5; $i++)
if ($this->curTpl['rewardItemId'.$i] > 0)
$data[TYPE_ITEM][$this->curTpl['rewardItemId'.$i]] = $this->curTpl['rewardItemId'.$i];
$data[Type::ITEM][$this->curTpl['rewardItemId'.$i]] = $this->curTpl['rewardItemId'.$i];
for ($i = 1; $i < 7; $i++)
if ($this->curTpl['rewardChoiceItemId'.$i] > 0)
$data[TYPE_ITEM][$this->curTpl['rewardChoiceItemId'.$i]] = $this->curTpl['rewardChoiceItemId'.$i];
$data[Type::ITEM][$this->curTpl['rewardChoiceItemId'.$i]] = $this->curTpl['rewardChoiceItemId'.$i];
// spells
if ($this->curTpl['rewardSpell'] > 0)
$data[TYPE_SPELL][$this->curTpl['rewardSpell']] = $this->curTpl['rewardSpell'];
$data[Type::SPELL][$this->curTpl['rewardSpell']] = $this->curTpl['rewardSpell'];
if ($this->curTpl['rewardSpellCast'] > 0)
$data[TYPE_SPELL][$this->curTpl['rewardSpellCast']] = $this->curTpl['rewardSpellCast'];
$data[Type::SPELL][$this->curTpl['rewardSpellCast']] = $this->curTpl['rewardSpellCast'];
// titles
if ($this->curTpl['rewardTitleId'] > 0)
$data[TYPE_TITLE][$this->curTpl['rewardTitleId']] = $this->curTpl['rewardTitleId'];
$data[Type::TITLE][$this->curTpl['rewardTitleId']] = $this->curTpl['rewardTitleId'];
// currencies
if (!empty($this->rewards[$this->id][TYPE_CURRENCY]))
foreach ($this->rewards[$this->id][TYPE_CURRENCY] as $id => $__)
$data[TYPE_CURRENCY][$id] = $id;
if (!empty($this->rewards[$this->id][Type::CURRENCY]))
foreach ($this->rewards[$this->id][Type::CURRENCY] as $id => $__)
$data[Type::CURRENCY][$id] = $id;
}
if ($addMask & GLOBALINFO_SELF)
$data[TYPE_QUEST][$this->id] = ['name' => $this->getField('name', true)];
$data[Type::QUEST][$this->id] = ['name' => $this->getField('name', true)];
}
return $data;
@@ -581,11 +581,11 @@ class QuestListFilter extends Filter
switch ($cr[1])
{
case 1: // npc
return ['AND', ['qse.type', TYPE_NPC], ['qse.method', $flags, '&']];
return ['AND', ['qse.type', Type::NPC], ['qse.method', $flags, '&']];
case 2: // object
return ['AND', ['qse.type', TYPE_OBJECT], ['qse.method', $flags, '&']];
return ['AND', ['qse.type', Type::OBJECT], ['qse.method', $flags, '&']];
case 3: // item
return ['AND', ['qse.type', TYPE_ITEM], ['qse.method', $flags, '&']];
return ['AND', ['qse.type', Type::ITEM], ['qse.method', $flags, '&']];
}
return false;

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class SkillList extends BaseType
{
public static $type = TYPE_SKILL;
public static $type = Type::SKILL;
public static $brickFile = 'skill';
public static $dataTable = '?_skillline';

View File

@@ -8,7 +8,7 @@ class SoundList extends BaseType
{
use spawnHelper;
public static $type = TYPE_SOUND;
public static $type = Type::SOUND;
public static $brickFile = 'sound';
public static $dataTable = '?_sounds';
public static $contribute = CONTRIBUTE_CO;

View File

@@ -12,7 +12,7 @@ class SpellList extends BaseType
public $relItems = null;
public $sources = [];
public static $type = TYPE_SPELL;
public static $type = Type::SPELL;
public static $brickFile = 'spell';
public static $dataTable = '?_spell';
@@ -54,7 +54,7 @@ class SpellList extends BaseType
protected $queryBase = 'SELECT s.*, s.id AS ARRAY_KEY FROM ?_spell s';
protected $queryOpts = array(
's' => [['src', 'sr', 'ic', 'ica']], // 6: TYPE_SPELL
's' => [['src', 'sr', 'ic', 'ica']], // 6: Type::SPELL
'ic' => ['j' => ['?_icons ic ON ic.id = s.iconId', true], 's' => ', ic.name AS iconString'],
'ica' => ['j' => ['?_icons ica ON ica.id = s.iconIdAlt', true], 's' => ', ica.name AS iconStringAlt'],
'sr' => ['j' => ['?_spellrange sr ON sr.id = s.rangeId'], 's' => ', sr.rangeMinHostile, sr.rangeMinFriend, sr.rangeMaxHostile, sr.rangeMaxFriend, sr.name_loc0 AS rangeText_loc0, sr.name_loc2 AS rangeText_loc2, sr.name_loc3 AS rangeText_loc3, sr.name_loc4 AS rangeText_loc4, sr.name_loc6 AS rangeText_loc6, sr.name_loc8 AS rangeText_loc8'],
@@ -161,7 +161,7 @@ class SpellList extends BaseType
// Enchant Item Permanent (53) / Temporary (54)
if (in_array($this->curTpl['effect'.$i.'Id'], [53, 54]))
{
if ($mv && ($json = DB::Aowow()->selectRow('SELECT * FROM ?_item_stats WHERE `type` = ?d AND `typeId` = ?d', TYPE_ENCHANTMENT, $mv)))
if ($mv && ($json = DB::Aowow()->selectRow('SELECT * FROM ?_item_stats WHERE `type` = ?d AND `typeId` = ?d', Type::ENCHANTMENT, $mv)))
{
$mods = [];
foreach ($json as $str => $val)
@@ -637,18 +637,18 @@ class SpellList extends BaseType
// GO Model from MiscVal
if (in_array($this->curTpl['effect'.$i.'Id'], [50, 76, 104, 105, 106, 107]))
{
if (isset($displays[TYPE_OBJECT][$id]))
$displays[TYPE_OBJECT][$id][0][] = $i;
if (isset($displays[Type::OBJECT][$id]))
$displays[Type::OBJECT][$id][0][] = $i;
else
$displays[TYPE_OBJECT][$id] = [[$i], $effMV];
$displays[Type::OBJECT][$id] = [[$i], $effMV];
}
// NPC Model from MiscVal
else if (in_array($this->curTpl['effect'.$i.'Id'], [28, 90, 56, 112, 134]) || in_array($this->curTpl['effect'.$i.'AuraId'], [56, 78]))
{
if (isset($displays[TYPE_NPC][$id]))
$displays[TYPE_NPC][$id][0][] = $i;
if (isset($displays[Type::NPC][$id]))
$displays[Type::NPC][$id][0][] = $i;
else
$displays[TYPE_NPC][$id] = [[$i], $effMV];
$displays[Type::NPC][$id] = [[$i], $effMV];
}
// Shapeshift
else if ($this->curTpl['effect'.$i.'AuraId'] == 36)
@@ -679,12 +679,12 @@ class SpellList extends BaseType
$results = $displays[0];
if (!empty($displays[TYPE_NPC]))
if (!empty($displays[Type::NPC]))
{
$nModels = new CreatureList(array(['id', array_column($displays[TYPE_NPC], 1)]));
$nModels = new CreatureList(array(['id', array_column($displays[Type::NPC], 1)]));
foreach ($nModels->iterate() as $nId => $__)
{
foreach ($displays[TYPE_NPC] as $srcId => [$indizes, $npcId])
foreach ($displays[Type::NPC] as $srcId => [$indizes, $npcId])
{
if ($npcId == $nId)
{
@@ -701,12 +701,12 @@ class SpellList extends BaseType
}
}
if (!empty($displays[TYPE_OBJECT]))
if (!empty($displays[Type::OBJECT]))
{
$oModels = new GameObjectList(array(['id', array_column($displays[TYPE_OBJECT], 1)]));
$oModels = new GameObjectList(array(['id', array_column($displays[Type::OBJECT], 1)]));
foreach ($oModels->iterate() as $oId => $__)
{
foreach ($displays[TYPE_OBJECT] as $srcId => [$indizes, $objId])
foreach ($displays[Type::OBJECT] as $srcId => [$indizes, $objId])
{
if ($objId == $oId)
{
@@ -2205,24 +2205,24 @@ class SpellList extends BaseType
if ($mask = $this->curTpl['reqClassMask'])
for ($i = 0; $i < 11; $i++)
if ($mask & (1 << $i))
$data[TYPE_CLASS][$i + 1] = $i + 1;
$data[Type::CHR_CLASS][$i + 1] = $i + 1;
if ($mask = $this->curTpl['reqRaceMask'])
for ($i = 0; $i < 11; $i++)
if ($mask & (1 << $i))
$data[TYPE_RACE][$i + 1] = $i + 1;
$data[Type::CHR_RACE][$i + 1] = $i + 1;
// play sound effect
for ($i = 1; $i < 4; $i++)
if ($this->getField('effect'.$i.'Id') == 131 || $this->getField('effect'.$i.'Id') == 132)
$data[TYPE_SOUND][$this->getField('effect'.$i.'MiscValue')] = $this->getField('effect'.$i.'MiscValue');
$data[Type::SOUND][$this->getField('effect'.$i.'MiscValue')] = $this->getField('effect'.$i.'MiscValue');
}
if ($addMask & GLOBALINFO_SELF)
{
$iconString = $this->curTpl['iconStringAlt'] ? 'iconStringAlt' : 'iconString';
$data[TYPE_SPELL][$id] = array(
$data[Type::SPELL][$id] = array(
'icon' => $this->curTpl[$iconString],
'name' => $this->getField('name', true),
);
@@ -2234,12 +2234,12 @@ class SpellList extends BaseType
$tTip = $this->renderTooltip(MAX_LEVEL, true);
foreach ($tTip[1] as $relId => $_)
if (empty($data[TYPE_SPELL][$relId]))
$data[TYPE_SPELL][$relId] = $relId;
if (empty($data[Type::SPELL][$relId]))
$data[Type::SPELL][$relId] = $relId;
foreach ($buff[1] as $relId => $_)
if (empty($data[TYPE_SPELL][$relId]))
$data[TYPE_SPELL][$relId] = $relId;
if (empty($data[Type::SPELL][$relId]))
$data[Type::SPELL][$relId] = $relId;
$extra[$id] = array(
'id' => $id,
@@ -2336,7 +2336,7 @@ class SpellList extends BaseType
{
$data[$this->id] = array(
'n' => $this->getField('name', true),
't' => TYPE_SPELL,
't' => Type::SPELL,
'ti' => $this->id,
's' => empty($this->curTpl['skillLines']) ? 0 : $this->curTpl['skillLines'][0],
'c' => $this->curTpl['typeCat'],

View File

@@ -8,7 +8,7 @@ class TitleList extends BaseType
{
use listviewHelper;
public static $type = TYPE_TITLE;
public static $type = Type::TITLE;
public static $brickFile = 'title';
public static $dataTable = '?_titles';
@@ -16,7 +16,7 @@ class TitleList extends BaseType
protected $queryBase = 'SELECT t.*, id AS ARRAY_KEY FROM ?_titles t';
protected $queryOpts = array(
't' => [['src']], // 11: TYPE_TITLE
't' => [['src']], // 11: Type::TITLE
'src' => ['j' => ['?_source src ON type = 11 AND typeId = t.id', true], 's' => ', src13, moreType, moreTypeId']
);
@@ -28,9 +28,9 @@ class TitleList extends BaseType
foreach ($this->iterate() as $id => &$_curTpl)
{
// preparse sources - notice: under this system titles can't have more than one source (or two for achivements), which is enough for standard TC cases but may break custom cases
if ($_curTpl['moreType'] == TYPE_ACHIEVEMENT)
if ($_curTpl['moreType'] == Type::ACHIEVEMENT)
$this->sources[$this->id][12][] = $_curTpl['moreTypeId'];
else if ($_curTpl['moreType'] == TYPE_QUEST)
else if ($_curTpl['moreType'] == Type::QUEST)
$this->sources[$this->id][4][] = $_curTpl['moreTypeId'];
else if ($_curTpl['src13'])
$this->sources[$this->id][13][] = $_curTpl['src13'];
@@ -81,10 +81,10 @@ class TitleList extends BaseType
foreach ($this->iterate() as $__)
{
$data[TYPE_TITLE][$this->id]['name'] = $this->getField('male', true);
$data[Type::TITLE][$this->id]['name'] = $this->getField('male', true);
if ($_ = $this->getField('female', true))
$data[TYPE_TITLE][$this->id]['namefemale'] = $_;
$data[Type::TITLE][$this->id]['namefemale'] = $_;
}
return $data;

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class UserList extends BaseType
{
public static $type = TYPE_USER;
public static $type = Type::USER;
public static $brickFile = 'user';
public static $dataTable = ''; // doesn't have community content
@@ -52,7 +52,7 @@ class UserList extends BaseType
// border: seen as null|1|3 .. changes the border around the avatar (i suspect its meaning changed and got decupled from premium-status with the introduction of patron-status)
}
return [TYPE_USER => $data];
return [Type::USER => $data];
}
public function renderTooltip() { }

View File

@@ -6,7 +6,7 @@ if (!defined('AOWOW_REVISION'))
class WorldEventList extends BaseType
{
public static $type = TYPE_WORLDEVENT;
public static $type = Type::WORLDEVENT;
public static $brickFile = 'event';
public static $dataTable = '?_events';
@@ -162,7 +162,7 @@ class WorldEventList extends BaseType
$data = [];
foreach ($this->iterate() as $__)
$data[TYPE_WORLDEVENT][$this->id] = ['name' => $this->getField('name', true), 'icon' => $this->curTpl['iconString']];
$data[Type::WORLDEVENT][$this->id] = ['name' => $this->getField('name', true), 'icon' => $this->curTpl['iconString']];
return $data;
}

View File

@@ -8,7 +8,7 @@ class ZoneList extends BaseType
{
use listviewHelper;
public static $type = TYPE_ZONE;
public static $type = Type::ZONE;
public static $brickFile = 'zone';
public static $dataTable = '?_zones';
@@ -100,7 +100,7 @@ class ZoneList extends BaseType
$data = [];
foreach ($this->iterate() as $__)
$data[TYPE_ZONE][$this->id] = ['name' => $this->getField('name', true)];
$data[Type::ZONE][$this->id] = ['name' => $this->getField('name', true)];
return $data;
}

View File

@@ -663,11 +663,8 @@ class User
$data = [];
foreach ($res as $type => $ids)
{
if (empty(Util::$typeClasses[$type]))
continue;
$tc = new Util::$typeClasses[$type]([['id', array_values($ids)]]);
if ($tc->error)
$tc = Type::newList($type, [['id', array_values($ids)]]);
if (!$tc || $tc->error)
continue;
$entities = [];

View File

@@ -116,7 +116,7 @@ trait TrRequestData
}
}
class CLI
abstract class CLI
{
const CHR_BELL = 7;
const CHR_BACK = 8;
@@ -411,7 +411,7 @@ class CLI
}
class Util
abstract class Util
{
const FILE_ACCESS = 0777;
@@ -432,29 +432,6 @@ class Util
'us', 'eu', 'kr', 'tw', 'cn'
);
public static $typeClasses = array(
null, 'CreatureList', 'GameObjectList', 'ItemList', 'ItemsetList', 'QuestList', 'SpellList',
'ZoneList', 'FactionList', 'PetList', 'AchievementList', 'TitleList', 'WorldEventList', 'CharClassList',
'CharRaceList', 'SkillList', null, 'CurrencyList', null, 'SoundList',
TYPE_ICON => 'IconList',
TYPE_EMOTE => 'EmoteList',
TYPE_ENCHANTMENT => 'EnchantmentList',
TYPE_AREATRIGGER => 'AreatriggerList',
TYPE_MAIL => 'MailList'
);
public static $typeStrings = array( // zero-indexed
null, 'npc', 'object', 'item', 'itemset', 'quest', 'spell', 'zone', 'faction',
'pet', 'achievement', 'title', 'event', 'class', 'race', 'skill', null, 'currency',
null, 'sound',
TYPE_ICON => 'icon',
TYPE_USER => 'user',
TYPE_EMOTE => 'emote',
TYPE_ENCHANTMENT => 'enchantment',
TYPE_AREATRIGGER => 'areatrigger',
TYPE_MAIL => 'mail'
);
# todo (high): find a sensible way to write data here on setup
private static $gtCombatRatings = array(
12 => 1.5, 13 => 13.8, 14 => 13.8, 15 => 5, 16 => 10, 17 => 10, 18 => 8, 19 => 14, 20 => 14,
@@ -1031,7 +1008,7 @@ class Util
foreach ($arr as $type => $data)
{
// bad data or empty
if (empty(Util::$typeStrings[$type]) || !is_array($data) || !$data)
if (!Type::exists($type) || !is_array($data) || !$data)
continue;
if (!isset($master[$type]))
@@ -1159,7 +1136,7 @@ class Util
case CND_SRC_SPELL_CLICK_EVENT: // 18
case CND_SRC_VEHICLE_SPELL: // 21
case CND_SRC_NPC_VENDOR: // 23
$jsGlobals[TYPE_NPC][] = $c['SourceGroup'];
$jsGlobals[Type::NPC][] = $c['SourceGroup'];
break;
}
@@ -1168,12 +1145,12 @@ class Util
case CND_AURA: // 1
$c['ConditionValue2'] = null; // do not use his param
case CND_SPELL: // 25
$jsGlobals[TYPE_SPELL][] = $c['ConditionValue1'];
$jsGlobals[Type::SPELL][] = $c['ConditionValue1'];
break;
case CND_ITEM: // 2
$c['ConditionValue3'] = null; // do not use his param
case CND_ITEM_EQUIPPED: // 3
$jsGlobals[TYPE_ITEM][] = $c['ConditionValue1'];
$jsGlobals[Type::ITEM][] = $c['ConditionValue1'];
break;
case CND_MAPID: // 22 - break down to area or remap for use with g_zone_categories
switch ($c['ConditionValue1'])
@@ -1197,7 +1174,7 @@ class Util
$zone = new ZoneList($cnd);
if (!$zone->error)
{
$jsGlobals[TYPE_ZONE][] = $zone->getField('id');
$jsGlobals[Type::ZONE][] = $zone->getField('id');
$c['ConditionTypeOrReference'] = CND_ZONEID;
$c['ConditionValue1'] = $zone->getField('id');
break;
@@ -1207,50 +1184,50 @@ class Util
}
case CND_ZONEID: // 4
case CND_AREAID: // 23
$jsGlobals[TYPE_ZONE][] = $c['ConditionValue1'];
$jsGlobals[Type::ZONE][] = $c['ConditionValue1'];
break;
case CND_REPUTATION_RANK: // 5
$jsGlobals[TYPE_FACTION][] = $c['ConditionValue1'];
$jsGlobals[Type::FACTION][] = $c['ConditionValue1'];
break;
case CND_SKILL: // 7
$jsGlobals[TYPE_SKILL][] = $c['ConditionValue1'];
$jsGlobals[Type::SKILL][] = $c['ConditionValue1'];
break;
case CND_QUESTREWARDED: // 8
case CND_QUESTTAKEN: // 9
case CND_QUEST_NONE: // 14
case CND_QUEST_COMPLETE: // 28
$jsGlobals[TYPE_QUEST][] = $c['ConditionValue1'];
$jsGlobals[Type::QUEST][] = $c['ConditionValue1'];
break;
case CND_ACTIVE_EVENT: // 12
$jsGlobals[TYPE_WORLDEVENT][] = $c['ConditionValue1'];
$jsGlobals[Type::WORLDEVENT][] = $c['ConditionValue1'];
break;
case CND_ACHIEVEMENT: // 17
$jsGlobals[TYPE_ACHIEVEMENT][] = $c['ConditionValue1'];
$jsGlobals[Type::ACHIEVEMENT][] = $c['ConditionValue1'];
break;
case CND_TITLE: // 18
$jsGlobals[TYPE_TITLE][] = $c['ConditionValue1'];
$jsGlobals[Type::TITLE][] = $c['ConditionValue1'];
break;
case CND_NEAR_CREATURE: // 29
$jsGlobals[TYPE_NPC][] = $c['ConditionValue1'];
$jsGlobals[Type::NPC][] = $c['ConditionValue1'];
break;
case CND_NEAR_GAMEOBJECT: // 30
$jsGlobals[TYPE_OBJECT][] = $c['ConditionValue1'];
$jsGlobals[Type::OBJECT][] = $c['ConditionValue1'];
break;
case CND_CLASS: // 15
for ($i = 0; $i < 11; $i++)
if ($c['ConditionValue1'] & (1 << $i))
$jsGlobals[TYPE_CLASS][] = $i + 1;
$jsGlobals[Type::CHR_CLASS][] = $i + 1;
break;
case CND_RACE: // 16
for ($i = 0; $i < 11; $i++)
if ($c['ConditionValue1'] & (1 << $i))
$jsGlobals[TYPE_RACE][] = $i + 1;
$jsGlobals[Type::CHR_RACE][] = $i + 1;
break;
case CND_OBJECT_ENTRY: // 31
if ($c['ConditionValue1'] == 3)
$jsGlobals[TYPE_NPC][] = $c['ConditionValue2'];
$jsGlobals[Type::NPC][] = $c['ConditionValue2'];
else if ($c['ConditionValue1'] == 5)
$jsGlobals[TYPE_OBJECT][] = $c['ConditionValue2'];
$jsGlobals[Type::OBJECT][] = $c['ConditionValue2'];
break;
case CND_TEAM: // 6
if ($c['ConditionValue1'] == 469) // Alliance
@@ -1673,4 +1650,223 @@ class Util
}
}
abstract class Type
{
public const NPC = 1;
public const OBJECT = 2;
public const ITEM = 3;
public const ITEMSET = 4;
public const QUEST = 5;
public const SPELL = 6;
public const ZONE = 7;
public const FACTION = 8;
public const PET = 9;
public const ACHIEVEMENT = 10;
public const TITLE = 11;
public const WORLDEVENT = 12;
public const CHR_CLASS = 13;
public const CHR_RACE = 14;
public const SKILL = 15;
public const STATISTIC = 16;
public const CURRENCY = 17;
// PROJECT = 18;
public const SOUND = 19;
// BUILDING = 20;
// FOLLOWER = 21;
// MISSION_ABILITY = 22;
// MISSION = 23;
// SHIP = 25;
// THREAT = 26;
// RESOURCE = 27;
// CHAMPION = 28;
public const ICON = 29;
// ORDER_ADVANCEMENT = 30;
// FOLLOWER_ALLIANCE = 31;
// FOLLOWER_HORDE = 32;
// SHIP_ALLIANCE = 33;
// SHIP_HORDE = 34;
// CHAMPION_ALLIANCE = 35;
// CHAMPION_HORDE = 36;
// TRANSMOG_ITEM = 37;
// BFA_CHAMPION = 38;
// BFA_CHAMPION_ALLIANCE = 39;
// AFFIX = 40;
// BFA_CHAMPION_HORDE = 41;
// AZERITE_ESSENCE_POWER = 42;
// AZERITE_ESSENCE = 43;
// STORYLINE = 44;
// ADVENTURE_COMBATANT_ABILITY = 46;
// ENCOUNTER = 47;
// COVENANT = 48;
// SOULBIND = 49;
// DI_ITEM = 50;
// GATHERER_SCREENSHOT = 91;
// GATHERER_GUIDE_IMAGE = 98;
public const PROFILE = 100;
// our own things
public const GUILD = 101;
// TRANSMOG_SET = 101; // future conflict inc.
public const ARENA_TEAM = 102;
// OUTFIT = 110;
// GEAR_SET = 111;
// GATHERER_LISTVIEW = 158;
// GATHERER_SURVEY_COVENANTS = 161;
// NEWS_POST = 162;
// BATTLE_PET_ABILITY = 200;
public const GUIDE = 300; // should have been 100, but conflicts with old version of Profile/List
public const USER = 500;
public const EMOTE = 501;
public const ENCHANTMENT = 502;
public const AREATRIGGER = 503;
public const MAIL = 504;
// Blizzard API things
// MOUNT = -1000;
// RECIPE = -1001;
// BATTLE_PET = -1002;
public const FLAG_NONE = 0x0;
public const FLAG_RANDOM_SEARCHABLE = 0x1;
/* public const FLAG_SEARCHABLE = 0x2 general search? */
public const IDX_LIST_OBJ = 0;
public const IDX_FILE_STR = 1;
public const IDX_JSG_TPL = 2;
public const IDX_FLAGS = 3;
private static /* array */ $data = array(
self::NPC => ['CreatureList', 'npc', 'g_npcs', 0x1],
self::OBJECT => ['GameObjectList', 'object', 'g_objects', 0x1],
self::ITEM => ['ItemList', 'item', 'g_items', 0x1],
self::ITEMSET => ['ItemsetList', 'itemset', 'g_itemsets', 0x1],
self::QUEST => ['QuestList', 'quest', 'g_quests', 0x1],
self::SPELL => ['SpellList', 'spell', 'g_spells', 0x1],
self::ZONE => ['ZoneList', 'zone', 'g_gatheredzones', 0x1],
self::FACTION => ['FactionList', 'faction', 'g_factions', 0x1],
self::PET => ['PetList', 'pet', 'g_pets', 0x1],
self::ACHIEVEMENT => ['AchievementList', 'achievement', 'g_achievements', 0x1],
self::TITLE => ['TitleList', 'title', 'g_titles', 0x1],
self::WORLDEVENT => ['WorldEventList', 'event', 'g_holidays', 0x1],
self::CHR_CLASS => ['CharClassList', 'class', 'g_classes', 0x1],
self::CHR_RACE => ['CharRaceList', 'race', 'g_races', 0x1],
self::SKILL => ['SkillList', 'skill', 'g_skills', 0x1],
self::STATISTIC => ['AchievementList', 'achievement', 'g_achievements', 0x1], // alias for achievements; exists only for Markup
self::CURRENCY => ['CurrencyList', 'currency', 'g_gatheredcurrencies',0x1],
self::SOUND => ['SoundList', 'sound', 'g_sounds', 0x1],
self::ICON => ['IconList', 'icon', 'g_icons', 0x1],
self::GUIDE => ['GuideList', 'guide', '', 0x0],
self::PROFILE => ['ProfileList', '', '', 0x0], // x - not known in javascript
self::GUILD => ['GuildList', '', '', 0x0], // x
self::ARENA_TEAM => ['ArenaTeamList', '', '', 0x0], // x
self::USER => ['UserList', 'user', 'g_users', 0x0], // x
self::EMOTE => ['EmoteList', 'emote', 'g_emotes', 0x1],
self::ENCHANTMENT => ['EnchantmentList', 'enchantment', 'g_enchantments', 0x1],
self::AREATRIGGER => ['AreatriggerList', 'areatrigger', '', 0x0],
self::MAIL => ['MailList', 'mail', '', 0x1]
);
/********************/
/* Field Operations */
/********************/
public static function newList(int $type, ?array $conditions = []) : ?BaseType
{
if (!self::exists($type))
return null;
return new (self::$data[$type][self::IDX_LIST_OBJ])($conditions);
}
public static function getFileString(int $type) : string
{
if (!self::exists($type))
return '';
return self::$data[$type][self::IDX_FILE_STR];
}
public static function getJSGlobalString(int $type) : string
{
if (!self::exists($type))
return '';
return self::$data[$type][self::IDX_JSG_TPL];
}
public static function getJSGlobalTemplate(int $type) : array
{
if (!self::exists($type))
return [];
// [key, [data], [extraData]]
return [self::$data[$type][self::IDX_JSG_TPL], [], []];
}
public static function checkClassAttrib(int $type, string $attr, ?int $attrVal = null) : bool
{
if (!self::exists($type))
return false;
return isset((self::$data[$type][self::IDX_LIST_OBJ])::$$attr) && ($attrVal === null || ((self::$data[$type][self::IDX_LIST_OBJ])::$$attr & $attrVal));
}
public static function getClassAttrib(int $type, string $attr) : mixed
{
if (!self::exists($type))
return null;
return (self::$data[$type][self::IDX_LIST_OBJ])::$$attr ?? null;
}
public static function exists(int $type) : bool
{
return !empty(self::$data[$type]);
}
public static function getIndexFrom(int $idx, string $match) : int
{
$i = array_search($match, array_column(self::$data, $idx));
if ($i === false)
return 0;
return array_keys(self::$data)[$i];
}
/*********************/
/* Column Operations */
/*********************/
public static function getClassesFor(int $flags = 0x0, string $attr = '', ?int $attrVal = null) : array
{
$x = [];
foreach (self::$data as $k => [$o, , , $f])
if ($o && (!$flags || $flags & $f))
if (!$attr || self::checkClassAttrib($attr, $attrVal))
$x[$k] = $o;
return $x;
}
public static function getFileStringsFor(int $flags = 0x0) : array
{
$x = [];
foreach (self::$data as $k => [, $s, , $f])
if ($s && (!$flags || $flags & $f))
$x[$k] = $s;
return $x;
}
public static function getJSGTemplatesFor(int $flags = 0x0) : array
{
$x = [];
foreach (self::$data as $k => [, , $a, $f])
if ($a && (!$flags || $flags & $f))
$x[$k] = $a;
return $x;
}
}
?>