From 33a870ef783d36766e79fb1abfc68016510bc6fd Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Mon, 21 Mar 2022 15:20:31 +0100 Subject: [PATCH] Structure/Types * move distributed constant values to object * move reused iterators and checks to object --- includes/ajaxHandler/account.class.php | 14 +- includes/ajaxHandler/admin.class.php | 19 +- includes/ajaxHandler/arenateam.class.php | 6 +- includes/ajaxHandler/comment.class.php | 12 +- includes/ajaxHandler/gotocomment.class.php | 2 +- includes/ajaxHandler/guild.class.php | 6 +- includes/ajaxHandler/profile.class.php | 16 +- includes/basetype.class.php | 10 +- includes/community.class.php | 43 +-- includes/defines.php | 30 +-- includes/game.php | 8 +- includes/loot.class.php | 2 +- includes/markup.class.php | 17 +- includes/profiler.class.php | 30 +-- includes/smartAI.class.php | 124 ++++----- includes/types/achievement.class.php | 18 +- includes/types/areatrigger.class.php | 2 +- includes/types/charclass.class.php | 2 +- includes/types/charrace.class.php | 4 +- includes/types/creature.class.php | 6 +- includes/types/currency.class.php | 4 +- includes/types/emote.class.php | 4 +- includes/types/enchantment.class.php | 10 +- includes/types/faction.class.php | 4 +- includes/types/gameobject.class.php | 6 +- includes/types/icon.class.php | 6 +- includes/types/item.class.php | 36 +-- includes/types/itemset.class.php | 8 +- includes/types/mail.class.php | 4 +- includes/types/pet.class.php | 6 +- includes/types/profile.class.php | 6 +- includes/types/quest.class.php | 62 ++--- includes/types/skill.class.php | 2 +- includes/types/sound.class.php | 2 +- includes/types/spell.class.php | 48 ++-- includes/types/title.class.php | 12 +- includes/types/user.class.php | 4 +- includes/types/worldevent.class.php | 4 +- includes/types/zone.class.php | 4 +- includes/user.class.php | 7 +- includes/utilities.php | 282 +++++++++++++++++--- localization/lang.class.php | 12 +- pages/achievement.php | 26 +- pages/achievements.php | 2 +- pages/areatrigger.php | 2 +- pages/areatriggers.php | 2 +- pages/arenateam.php | 4 +- pages/arenateams.php | 2 +- pages/class.php | 2 +- pages/classes.php | 2 +- pages/currencies.php | 2 +- pages/currency.php | 8 +- pages/emote.php | 2 +- pages/emotes.php | 2 +- pages/enchantment.php | 4 +- pages/enchantments.php | 2 +- pages/event.php | 10 +- pages/events.php | 2 +- pages/faction.php | 4 +- pages/factions.php | 2 +- pages/genericPage.class.php | 60 +---- pages/guild.php | 4 +- pages/guilds.php | 2 +- pages/icon.php | 2 +- pages/icons.php | 2 +- pages/item.php | 22 +- pages/items.php | 2 +- pages/itemset.php | 8 +- pages/itemsets.php | 2 +- pages/mail.php | 18 +- pages/mails.php | 2 +- pages/npc.php | 30 +-- pages/npcs.php | 2 +- pages/object.php | 18 +- pages/objects.php | 2 +- pages/pet.php | 4 +- pages/pets.php | 2 +- pages/profile.php | 8 +- pages/profiles.php | 2 +- pages/quest.php | 94 +++---- pages/quests.php | 2 +- pages/race.php | 6 +- pages/races.php | 2 +- pages/screenshot.php | 21 +- pages/search.php | 64 ++--- pages/skill.php | 4 +- pages/skills.php | 2 +- pages/sound.php | 8 +- pages/sounds.php | 2 +- pages/spell.php | 64 ++--- pages/spells.php | 2 +- pages/title.php | 4 +- pages/titles.php | 2 +- pages/utility.php | 44 ++- pages/zone.php | 66 ++--- pages/zones.php | 2 +- setup/tools/filegen/pets.func.php | 2 +- setup/tools/filegen/profiler.func.php | 14 +- setup/tools/sqlgen/achievement.func.php | 2 +- setup/tools/sqlgen/areatrigger.func.php | 2 +- setup/tools/sqlgen/classes.func.php | 2 +- setup/tools/sqlgen/creature.func.php | 2 +- setup/tools/sqlgen/currencies.func.php | 2 +- setup/tools/sqlgen/emotes.func.php | 2 +- setup/tools/sqlgen/events.func.php | 2 +- setup/tools/sqlgen/factions.func.php | 2 +- setup/tools/sqlgen/icons.func.php | 2 +- setup/tools/sqlgen/item_stats.func.php | 4 +- setup/tools/sqlgen/itemenchantment.func.php | 2 +- setup/tools/sqlgen/items.func.php | 2 +- setup/tools/sqlgen/itemset.func.php | 2 +- setup/tools/sqlgen/objects.func.php | 2 +- setup/tools/sqlgen/pet.func.php | 2 +- setup/tools/sqlgen/quests.func.php | 2 +- setup/tools/sqlgen/races.func.php | 2 +- setup/tools/sqlgen/skillline.func.php | 2 +- setup/tools/sqlgen/sounds.func.php | 2 +- setup/tools/sqlgen/source.func.php | 168 ++++++------ setup/tools/sqlgen/spawns.func.php | 20 +- setup/tools/sqlgen/spell.func.php | 2 +- setup/tools/sqlgen/titles.func.php | 2 +- setup/tools/sqlgen/zones.func.php | 20 +- template/bricks/lvTabs.tpl.php | 2 +- template/bricks/mapper.tpl.php | 14 +- template/bricks/reagentList.tpl.php | 2 +- template/pages/admin/screenshots.tpl.php | 4 +- 126 files changed, 970 insertions(+), 885 deletions(-) diff --git a/includes/ajaxHandler/account.class.php b/includes/ajaxHandler/account.class.php index 222c1565..e851f553 100644 --- a/includes/ajaxHandler/account.class.php +++ b/includes/ajaxHandler/account.class.php @@ -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; } diff --git a/includes/ajaxHandler/admin.class.php b/includes/ajaxHandler/admin.class.php index 62aa1d20..1564a09b 100644 --- a/includes/ajaxHandler/admin.class.php +++ b/includes/ajaxHandler/admin.class.php @@ -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 diff --git a/includes/ajaxHandler/arenateam.class.php b/includes/ajaxHandler/arenateam.class.php index 1b7b9eca..df95cafd 100644 --- a/includes/ajaxHandler/arenateam.class.php +++ b/includes/ajaxHandler/arenateam.class.php @@ -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); } } diff --git a/includes/ajaxHandler/comment.class.php b/includes/ajaxHandler/comment.class.php index 0ce1670d..89ebeb0d 100644 --- a/includes/ajaxHandler/comment.class.php +++ b/includes/ajaxHandler/comment.class.php @@ -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: ), 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 diff --git a/includes/ajaxHandler/gotocomment.class.php b/includes/ajaxHandler/gotocomment.class.php index f4e612d7..54637470 100644 --- a/includes/ajaxHandler/gotocomment.class.php +++ b/includes/ajaxHandler/gotocomment.class.php @@ -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); diff --git a/includes/ajaxHandler/guild.class.php b/includes/ajaxHandler/guild.class.php index 1c9e2aba..01c6780e 100644 --- a/includes/ajaxHandler/guild.class.php +++ b/includes/ajaxHandler/guild.class.php @@ -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); } } diff --git a/includes/ajaxHandler/profile.class.php b/includes/ajaxHandler/profile.class.php index 91327ffe..64e3654a 100644 --- a/includes/ajaxHandler/profile.class.php +++ b/includes/ajaxHandler/profile.class.php @@ -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']]; diff --git a/includes/basetype.class.php b/includes/basetype.class.php index 08fa4e79..4bb50195 100644 --- a/includes/basetype.class.php +++ b/includes/basetype.class.php @@ -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) diff --git a/includes/community.class.php b/includes/community.class.php index 8ea1ad34..ca9a3c0a 100644 --- a/includes/community.class.php +++ b/includes/community.class.php @@ -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..? diff --git a/includes/defines.php b/includes/defines.php index 52684d27..6c98992a 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -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); + ?> diff --git a/includes/game.php b/includes/game.php index f638c5df..5225110b 100644 --- a/includes/game.php +++ b/includes/game.php @@ -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: diff --git a/includes/loot.class.php b/includes/loot.class.php index e4f2883d..8224e6c3 100644 --- a/includes/loot.class.php +++ b/includes/loot.class.php @@ -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; } } diff --git a/includes/markup.class.php b/includes/markup.class.php index cb69efc5..13df1c50 100644 --- a/includes/markup.class.php +++ b/includes/markup.class.php @@ -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']; diff --git a/includes/profiler.class.php b/includes/profiler.class.php index 76db217b..0b1fa509 100644 --- a/includes/profiler.class.php +++ b/includes/profiler.class.php @@ -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])); diff --git a/includes/smartAI.class.php b/includes/smartAI.class.php index 9c4983f6..0929b740 100644 --- a/includes/smartAI.class.php +++ b/includes/smartAI.class.php @@ -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; diff --git a/includes/types/achievement.class.php b/includes/types/achievement.class.php index 3ae835eb..b33d4b11 100644 --- a/includes/types/achievement.class.php +++ b/includes/types/achievement.class.php @@ -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 ); } diff --git a/includes/types/areatrigger.class.php b/includes/types/areatrigger.class.php index 1eca832e..80c5bee2 100644 --- a/includes/types/areatrigger.class.php +++ b/includes/types/areatrigger.class.php @@ -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'; diff --git a/includes/types/charclass.class.php b/includes/types/charclass.class.php index 2b9f9d1d..de908059 100644 --- a/includes/types/charclass.class.php +++ b/includes/types/charclass.class.php @@ -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'; diff --git a/includes/types/charrace.class.php b/includes/types/charrace.class.php index 163b0e2d..1b654197 100644 --- a/includes/types/charrace.class.php +++ b/includes/types/charrace.class.php @@ -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; } diff --git a/includes/types/creature.class.php b/includes/types/creature.class.php index 45d3882b..673ed8e1 100644 --- a/includes/types/creature.class.php +++ b/includes/types/creature.class.php @@ -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 diff --git a/includes/types/currency.class.php b/includes/types/currency.class.php index e79a3406..e1a3ba8b 100644 --- a/includes/types/currency.class.php +++ b/includes/types/currency.class.php @@ -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; diff --git a/includes/types/emote.class.php b/includes/types/emote.class.php index c641b7ea..4e1b4a57 100644 --- a/includes/types/emote.class.php +++ b/includes/types/emote.class.php @@ -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; } diff --git a/includes/types/enchantment.class.php b/includes/types/enchantment.class.php index 1c4cf56a..31c77ac6 100644 --- a/includes/types/enchantment.class.php +++ b/includes/types/enchantment.class.php @@ -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; diff --git a/includes/types/faction.class.php b/includes/types/faction.class.php index 3a6ab6af..2ac9e042 100644 --- a/includes/types/faction.class.php +++ b/includes/types/faction.class.php @@ -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; } diff --git a/includes/types/gameobject.class.php b/includes/types/gameobject.class.php index 99cf284d..f835b723 100644 --- a/includes/types/gameobject.class.php +++ b/includes/types/gameobject.class.php @@ -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 diff --git a/includes/types/icon.class.php b/includes/types/icon.class.php index 71f3bf0c..f74f69e7 100644 --- a/includes/types/icon.class.php +++ b/includes/types/icon.class.php @@ -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; } diff --git a/includes/types/item.class.php b/includes/types/item.class.php index 08ea72c2..d0927833 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -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.'
'; } @@ -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.'
'; } @@ -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]); diff --git a/includes/types/itemset.class.php b/includes/types/itemset.class.php index 114ce7c9..12ed5638 100644 --- a/includes/types/itemset.class.php +++ b/includes/types/itemset.class.php @@ -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; } diff --git a/includes/types/mail.class.php b/includes/types/mail.class.php index 07e7907f..b20fdf16 100644 --- a/includes/types/mail.class.php +++ b/includes/types/mail.class.php @@ -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; } diff --git a/includes/types/pet.class.php b/includes/types/pet.class.php index ea2bb2d5..6a9ecf17 100644 --- a/includes/types/pet.class.php +++ b/includes/types/pet.class.php @@ -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; diff --git a/includes/types/profile.class.php b/includes/types/profile.class.php index 77cd62c3..ac7dce7b 100644 --- a/includes/types/profile.class.php +++ b/includes/types/profile.class.php @@ -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) { diff --git a/includes/types/quest.class.php b/includes/types/quest.class.php index 70defc62..1b6e6d90 100644 --- a/includes/types/quest.class.php +++ b/includes/types/quest.class.php @@ -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; diff --git a/includes/types/skill.class.php b/includes/types/skill.class.php index a3609812..101dfda0 100644 --- a/includes/types/skill.class.php +++ b/includes/types/skill.class.php @@ -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'; diff --git a/includes/types/sound.class.php b/includes/types/sound.class.php index bfd17cbc..0b7d00cf 100644 --- a/includes/types/sound.class.php +++ b/includes/types/sound.class.php @@ -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; diff --git a/includes/types/spell.class.php b/includes/types/spell.class.php index 4c7f5287..09e6c0d2 100644 --- a/includes/types/spell.class.php +++ b/includes/types/spell.class.php @@ -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'], diff --git a/includes/types/title.class.php b/includes/types/title.class.php index 6e6de03c..77bb80ee 100644 --- a/includes/types/title.class.php +++ b/includes/types/title.class.php @@ -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; diff --git a/includes/types/user.class.php b/includes/types/user.class.php index 2a23413c..2fbceb18 100644 --- a/includes/types/user.class.php +++ b/includes/types/user.class.php @@ -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() { } diff --git a/includes/types/worldevent.class.php b/includes/types/worldevent.class.php index f4954f0c..1c25969e 100644 --- a/includes/types/worldevent.class.php +++ b/includes/types/worldevent.class.php @@ -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; } diff --git a/includes/types/zone.class.php b/includes/types/zone.class.php index 695b42c0..ea67a238 100644 --- a/includes/types/zone.class.php +++ b/includes/types/zone.class.php @@ -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; } diff --git a/includes/user.class.php b/includes/user.class.php index f495b836..75fe4481 100644 --- a/includes/user.class.php +++ b/includes/user.class.php @@ -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 = []; diff --git a/includes/utilities.php b/includes/utilities.php index f049e0f0..c10bc4b4 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -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; + } +} + ?> diff --git a/localization/lang.class.php b/localization/lang.class.php index 39559e56..c817320d 100644 --- a/localization/lang.class.php +++ b/localization/lang.class.php @@ -245,7 +245,7 @@ class Lang else if ($interactive && !$asHTML) { $name = '[item='.$prop.']'; - $ids[TYPE_ITEM][] = $prop; + $ids[Type::ITEM][] = $prop; } } else if ($lock['type'.$i] == LOCK_TYPE_SKILL) @@ -269,7 +269,7 @@ class Lang else if ($interactive && !$asHTML) { $name = '[skill='.$skills[$prop].']'; - $ids[TYPE_SKILL][] = $skills[$prop]; + $ids[Type::SKILL][] = $skills[$prop]; } if ($rank > 0) @@ -283,7 +283,7 @@ class Lang else if ($interactive && !$asHTML) { $name = '[spell=1842]'; - $ids[TYPE_SPELL][] = 1842; + $ids[Type::SPELL][] = 1842; } } // exclude unusual stuff @@ -481,6 +481,12 @@ class Lang return number_format($number, $decimals, $seps[User::$localeId][1], $no1k ? '' : $seps[User::$localeId][0]); } + public static function typeName(int $type) : string + { + return Util::ucFirst(self::game(Type::getFileString($type))); + } + + private static function vspf($var, $args) { if (is_array($var)) diff --git a/pages/achievement.php b/pages/achievement.php index faf6f9c5..6570116b 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -25,7 +25,7 @@ class AchievementPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_ACHIEVEMENT; + protected $type = Type::ACHIEVEMENT; protected $typeId = 0; protected $tpl = 'achievement'; protected $path = [0, 9]; @@ -107,7 +107,7 @@ class AchievementPage extends GenericPage if ($_ = $this->subject->getField('iconId')) { $infobox[] = Util::ucFirst(lang::game('icon')).Lang::main('colon').'[icondb='.$_.' name=true]'; - $this->extendGlobalIds(TYPE_ICON, $_); + $this->extendGlobalIds(Type::ICON, $_); } // realm first available? @@ -140,7 +140,7 @@ class AchievementPage extends GenericPage $series[$pos][] = array( 'side' => $chainAcv->getField('faction'), - 'typeStr' => Util::$typeStrings[TYPE_ACHIEVEMENT], + 'typeStr' => Type::getFileString(Type::ACHIEVEMENT), 'typeId' => $aId, 'name' => $chainAcv->getField('name', true) ); @@ -160,7 +160,7 @@ class AchievementPage extends GenericPage BUTTON_WOWHEAD => !($this->subject->getField('cuFlags') & CUSTOM_SERVERSIDE), BUTTON_LINKS => array( 'linkColor' => 'ffffff00', - 'linkId' => Util::$typeStrings[TYPE_ACHIEVEMENT].':'.$this->typeId.':"..UnitGUID("player")..":0:0:0:0:0:0:0:0', + 'linkId' => Type::getFileString(Type::ACHIEVEMENT).':'.$this->typeId.':"..UnitGUID("player")..":0:0:0:0:0:0:0:0', 'linkName' => $this->name, 'type' => $this->type, 'typeId' => $this->typeId @@ -179,7 +179,7 @@ class AchievementPage extends GenericPage if ($foo = $this->subject->getField('rewards')) { array_walk($foo, function(&$item) { - $item = $item[0] != TYPE_ITEM ? null : $item[1]; + $item = $item[0] != Type::ITEM ? null : $item[1]; }); $bar = new ItemList(array(['i.id', $foo])); @@ -188,9 +188,9 @@ class AchievementPage extends GenericPage $this->rewards['item'][] = array( 'name' => $bar->getField('name', true), 'quality' => $bar->getField('quality'), - 'typeStr' => Util::$typeStrings[TYPE_ITEM], + 'typeStr' => Type::getFileString(Type::ITEM), 'id' => $id, - 'globalStr' => 'g_items' + 'globalStr' => Type::getJSGlobalString(Type::ITEM) ); } } @@ -198,7 +198,7 @@ class AchievementPage extends GenericPage if ($foo = $this->subject->getField('rewards')) { array_walk($foo, function(&$item) { - $item = $item[0] != TYPE_TITLE ? null : $item[1]; + $item = $item[0] != Type::TITLE ? null : $item[1]; }); $bar = new TitleList(array(['id', $foo])); @@ -366,10 +366,10 @@ class AchievementPage extends GenericPage $tmp['icon'] = $iconId; $this->criteria['icons'][] = array( 'itr' => $iconId++, - 'type' => 'g_achievements', + 'type' => Type::getJSGlobalString(Type::ACHIEVEMENT), 'id' => $obj, ); - $this->extendGlobalIds(TYPE_ACHIEVEMENT, $obj); + $this->extendGlobalIds(Type::ACHIEVEMENT, $obj); break; // link to quest case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST: @@ -389,11 +389,11 @@ class AchievementPage extends GenericPage 'href' => '?spell='.$obj, 'text' => ($crtName ?: SpellList::getName($obj)) ); - $this->extendGlobalIds(TYPE_SPELL, $obj); + $this->extendGlobalIds(Type::SPELL, $obj); $tmp['icon'] = $iconId; $this->criteria['icons'][] = array( 'itr' => $iconId++, - 'type' => 'g_spells', + 'type' => Type::getJSGlobalString(Type::SPELL), 'id' => $obj, ); break; @@ -413,7 +413,7 @@ class AchievementPage extends GenericPage $tmp['icon'] = $iconId; $this->criteria['icons'][] = array( 'itr' => $iconId++, - 'type' => 'g_items', + 'type' => Type::getJSGlobalString(Type::ITEM), 'id' => $obj, 'count' => $qty, ); diff --git a/pages/achievements.php b/pages/achievements.php index 8579badb..5f35a411 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -10,7 +10,7 @@ class AchievementsPage extends GenericPage { use TrListPage; - protected $type = TYPE_ACHIEVEMENT; + protected $type = Type::ACHIEVEMENT; protected $tpl = 'achievements'; protected $path = [0, 9]; protected $tabId = 0; diff --git a/pages/areatrigger.php b/pages/areatrigger.php index 8071d111..b5ea1743 100644 --- a/pages/areatrigger.php +++ b/pages/areatrigger.php @@ -10,7 +10,7 @@ class AreaTriggerPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_AREATRIGGER; + protected $type = Type::AREATRIGGER; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 102]; diff --git a/pages/areatriggers.php b/pages/areatriggers.php index a2906a5d..47d94079 100644 --- a/pages/areatriggers.php +++ b/pages/areatriggers.php @@ -10,7 +10,7 @@ class AreaTriggersPage extends GenericPage { use TrListPage; - protected $type = TYPE_AREATRIGGER; + protected $type = Type::AREATRIGGER; protected $tpl = 'areatriggers'; protected $path = [0, 102]; protected $tabId = 0; diff --git a/pages/arenateam.php b/pages/arenateam.php index 97f974f3..8c67667e 100644 --- a/pages/arenateam.php +++ b/pages/arenateam.php @@ -12,7 +12,7 @@ class ArenaTeamPage extends GenericPage protected $lvTabs = []; - protected $type = TYPE_ARENA_TEAM; + protected $type = Type::ARENA_TEAM; protected $tabId = 1; protected $path = [1, 5, 3]; @@ -134,7 +134,7 @@ class ArenaTeamPage extends GenericPage private function handleIncompleteData($teamGuid) { //display empty page and queue status - $newId = Profiler::scheduleResync(TYPE_ARENA_TEAM, $this->realmId, $teamGuid); + $newId = Profiler::scheduleResync(Type::ARENA_TEAM, $this->realmId, $teamGuid); $this->doResync = ['arena-team', $newId]; $this->initialSync(); diff --git a/pages/arenateams.php b/pages/arenateams.php index bc6a3c2d..9a7abe51 100644 --- a/pages/arenateams.php +++ b/pages/arenateams.php @@ -10,7 +10,7 @@ class ArenaTeamsPage extends GenericPage { use TrProfiler; - protected $type = TYPE_ARENA_TEAM; + protected $type = Type::ARENA_TEAM; protected $tabId = 1; protected $path = [1, 5, 3]; diff --git a/pages/class.php b/pages/class.php index 193a0f6f..45ed32a7 100644 --- a/pages/class.php +++ b/pages/class.php @@ -10,7 +10,7 @@ class ClassPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_CLASS; + protected $type = Type::CHR_CLASS; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 12]; diff --git a/pages/classes.php b/pages/classes.php index 838fd5cb..7a068afa 100644 --- a/pages/classes.php +++ b/pages/classes.php @@ -10,7 +10,7 @@ class ClassesPage extends GenericPage { use TrListPage; - protected $type = TYPE_CLASS; + protected $type = Type::CHR_CLASS; protected $tpl = 'list-page-generic'; protected $path = [0, 12]; protected $tabId = 0; diff --git a/pages/currencies.php b/pages/currencies.php index 0534f4db..a5f8cf55 100644 --- a/pages/currencies.php +++ b/pages/currencies.php @@ -10,7 +10,7 @@ class CurrenciesPage extends GenericPage { use TrListPage; - protected $type = TYPE_CURRENCY; + protected $type = Type::CURRENCY; protected $tpl = 'list-page-generic'; protected $path = [0, 15]; protected $tabId = 0; diff --git a/pages/currency.php b/pages/currency.php index c8d9b7bb..34f8a40d 100644 --- a/pages/currency.php +++ b/pages/currency.php @@ -10,7 +10,7 @@ class CurrencyPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_CURRENCY; + protected $type = Type::CURRENCY; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 15]; @@ -68,7 +68,7 @@ class CurrencyPage extends GenericPage if ($_ = $this->subject->getField('iconId')) { $infobox[] = Util::ucFirst(lang::game('icon')).Lang::main('colon').'[icondb='.$_.' name=true]'; - $this->extendGlobalIds(TYPE_ICON, $_); + $this->extendGlobalIds(Type::ICON, $_); } /****************/ @@ -138,7 +138,7 @@ class CurrencyPage extends GenericPage if (count($extraCols) == 3) // not already pushed $extraCols[] = '$Listview.extraCols.condition'; - $this->extendGlobalIds(TYPE_WORLDEVENT, $vendors[$k][0]['event']); + $this->extendGlobalIds(Type::WORLDEVENT, $vendors[$k][0]['event']); $row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $vendors[$k][0]['event']]]; } @@ -208,7 +208,7 @@ class CurrencyPage extends GenericPage if (!$boughtBy->error) { $tabData = array( - 'data' => array_values($boughtBy->getListviewData(ITEMINFO_VENDOR, [TYPE_CURRENCY => $this->typeId])), + 'data' => array_values($boughtBy->getListviewData(ITEMINFO_VENDOR, [Type::CURRENCY => $this->typeId])), 'name' => '$LANG.tab_currencyfor', 'id' => 'currency-for', 'extraCols' => ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'], diff --git a/pages/emote.php b/pages/emote.php index 18e83ef9..44a8cb29 100644 --- a/pages/emote.php +++ b/pages/emote.php @@ -10,7 +10,7 @@ class EmotePage extends GenericPage { use TrDetailPage; - protected $type = TYPE_EMOTE; + protected $type = Type::EMOTE; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 100]; diff --git a/pages/emotes.php b/pages/emotes.php index 6720fe40..a2f12b8d 100644 --- a/pages/emotes.php +++ b/pages/emotes.php @@ -10,7 +10,7 @@ class EmotesPage extends GenericPage { use TrListPage; - protected $type = TYPE_EMOTE; + protected $type = Type::EMOTE; protected $tpl = 'list-page-generic'; protected $path = [0, 100]; protected $tabId = 0; diff --git a/pages/enchantment.php b/pages/enchantment.php index f1b5d659..f660014d 100644 --- a/pages/enchantment.php +++ b/pages/enchantment.php @@ -10,7 +10,7 @@ class EnchantmentPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_ENCHANTMENT; + protected $type = Type::ENCHANTMENT; protected $typeId = 0; protected $tpl = 'enchantment'; protected $path = [0, 101]; @@ -64,7 +64,7 @@ class EnchantmentPage extends GenericPage // reqskill if ($_ = $this->subject->getField('skillLine')) { - $this->extendGlobalIds(TYPE_SKILL, $_); + $this->extendGlobalIds(Type::SKILL, $_); $foo = sprintf(Lang::game('requires'), ' [skill='.$_.']'); if ($_ = $this->subject->getField('skillLevel')) diff --git a/pages/enchantments.php b/pages/enchantments.php index 877bd7bd..c4a55527 100644 --- a/pages/enchantments.php +++ b/pages/enchantments.php @@ -10,7 +10,7 @@ class EnchantmentsPage extends GenericPage { use TrListPage; - protected $type = TYPE_ENCHANTMENT; + protected $type = Type::ENCHANTMENT; protected $tpl = 'enchantments'; protected $path = [0, 101]; protected $tabId = 0; diff --git a/pages/event.php b/pages/event.php index 31ea8755..841203c3 100644 --- a/pages/event.php +++ b/pages/event.php @@ -10,7 +10,7 @@ class EventPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_WORLDEVENT; + protected $type = Type::WORLDEVENT; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 11]; @@ -78,7 +78,7 @@ class EventPage extends GenericPage // boss if ($_ = $this->subject->getField('bossCreature')) { - $this->extendGlobalIds(TYPE_NPC, $_); + $this->extendGlobalIds(Type::NPC, $_); $this->infobox[] = Lang::npc('rank', 3).Lang::main('colon').'[npc='.$_.']'; } @@ -187,10 +187,10 @@ class EventPage extends GenericPage $this->lvTabs[] = ['quest', $tabData]; $questItems = []; - foreach (array_column($quests->rewards, TYPE_ITEM) as $arr) + foreach (array_column($quests->rewards, Type::ITEM) as $arr) $questItems = array_merge($questItems, $arr); - foreach (array_column($quests->requires, TYPE_ITEM) as $arr) + foreach (array_column($quests->requires, Type::ITEM) as $arr) $questItems = array_merge($questItems, $arr); if ($questItems) @@ -250,7 +250,7 @@ class EventPage extends GenericPage if ($r <= 0) continue; - $this->extendGlobalIds(TYPE_WORLDEVENT, $r); + $this->extendGlobalIds(Type::WORLDEVENT, $r); $d = $this->subject->getListviewData(); $d[$this->eId]['condition'][0][$this->typeId][] = [[-CND_ACTIVE_EVENT, $r]]; diff --git a/pages/events.php b/pages/events.php index c8b25867..02ea9f9c 100644 --- a/pages/events.php +++ b/pages/events.php @@ -10,7 +10,7 @@ class EventsPage extends GenericPage { use TrListPage; - protected $type = TYPE_WORLDEVENT; + protected $type = Type::WORLDEVENT; protected $tpl = 'list-page-generic'; protected $path = [0, 11]; protected $tabId = 0; diff --git a/pages/faction.php b/pages/faction.php index 19e49f06..8fcc114f 100644 --- a/pages/faction.php +++ b/pages/faction.php @@ -10,7 +10,7 @@ class FactionPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_FACTION; + protected $type = Type::FACTION; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 7]; @@ -58,7 +58,7 @@ class FactionPage extends GenericPage // Quartermaster if any if ($ids = $this->subject->getField('qmNpcIds')) { - $this->extendGlobalIds(TYPE_NPC, ...$ids); + $this->extendGlobalIds(Type::NPC, ...$ids); $qmStr = Lang::faction('quartermaster').Lang::main('colon'); diff --git a/pages/factions.php b/pages/factions.php index bb8bba39..cffd56a1 100644 --- a/pages/factions.php +++ b/pages/factions.php @@ -10,7 +10,7 @@ class FactionsPage extends GenericPage { use TrListPage; - protected $type = TYPE_FACTION; + protected $type = Type::FACTION; protected $tpl = 'list-page-generic'; protected $path = [0, 7]; protected $tabId = 0; diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index c981764c..963cf60a 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -739,7 +739,7 @@ class GenericPage foreach ($data as $k => $v) { // localizes expected fields .. except for icons .. icons are special - if (in_array($k, ['name', 'namefemale']) && $struct[0] != 'g_icons') + if (in_array($k, ['name', 'namefemale']) && $struct[0] != Type::getJSGlobalString(Type::ICON)) { $data[$k.'_'.User::$localeString] = $v; unset($data[$k]); @@ -859,31 +859,8 @@ class GenericPage if (isset($jsg[$type])) return; - switch ($type) - { // [varName, [data], [extra]] - case TYPE_NPC: $jsg[TYPE_NPC] = ['g_npcs', [], []]; break; - case TYPE_OBJECT: $jsg[TYPE_OBJECT] = ['g_objects', [], []]; break; - case TYPE_ITEM: $jsg[TYPE_ITEM] = ['g_items', [], []]; break; - case TYPE_ITEMSET: $jsg[TYPE_ITEMSET] = ['g_itemsets', [], []]; break; - case TYPE_QUEST: $jsg[TYPE_QUEST] = ['g_quests', [], []]; break; - case TYPE_SPELL: $jsg[TYPE_SPELL] = ['g_spells', [], []]; break; - case TYPE_ZONE: $jsg[TYPE_ZONE] = ['g_gatheredzones', [], []]; break; - case TYPE_FACTION: $jsg[TYPE_FACTION] = ['g_factions', [], []]; break; - case TYPE_PET: $jsg[TYPE_PET] = ['g_pets', [], []]; break; - case TYPE_ACHIEVEMENT: $jsg[TYPE_ACHIEVEMENT] = ['g_achievements', [], []]; break; - case TYPE_TITLE: $jsg[TYPE_TITLE] = ['g_titles', [], []]; break; - case TYPE_WORLDEVENT: $jsg[TYPE_WORLDEVENT] = ['g_holidays', [], []]; break; - case TYPE_CLASS: $jsg[TYPE_CLASS] = ['g_classes', [], []]; break; - case TYPE_RACE: $jsg[TYPE_RACE] = ['g_races', [], []]; break; - case TYPE_SKILL: $jsg[TYPE_SKILL] = ['g_skills', [], []]; break; - case TYPE_CURRENCY: $jsg[TYPE_CURRENCY] = ['g_gatheredcurrencies', [], []]; break; - case TYPE_SOUND: $jsg[TYPE_SOUND] = ['g_sounds', [], []]; break; - case TYPE_ICON: $jsg[TYPE_ICON] = ['g_icons', [], []]; break; - // well, this is awkward - case TYPE_USER: $jsg[TYPE_USER] = ['g_users', [], []]; break; - case TYPE_EMOTE: $jsg[TYPE_EMOTE] = ['g_emotes', [], []]; break; - case TYPE_ENCHANTMENT: $jsg[TYPE_ENCHANTMENT] = ['g_enchantments', [], []]; break; - } + if ($tpl = Type::getJSGlobalTemplate($type)) + $jsg[$type] = $tpl; } // lookup jsGlobals from collected typeIds @@ -900,34 +877,9 @@ class GenericPage $this->initJSGlobal($type); - $cnd = [CFG_SQL_LIMIT_NONE, ['id', array_unique($ids, SORT_NUMERIC)]]; - - 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_SOUND: $obj = new SoundList($cnd); break; - case TYPE_ICON: $obj = new IconList($cnd); break; - // "um, eh":, he ums and ehs. - case TYPE_USER: $obj = new UserList($cnd); break; - case TYPE_EMOTE: $obj = new EmoteList($cnd); break; - case TYPE_ENCHANTMENT: $obj = new EnchantmentList($cnd); break; - default: continue 2; - } + $obj = Type::newList($type, [CFG_SQL_LIMIT_NONE, ['id', array_unique($ids, SORT_NUMERIC)]]); + if (!$obj) + continue; $this->extendGlobalData($obj->getJSGlobals(GLOBALINFO_SELF)); diff --git a/pages/guild.php b/pages/guild.php index 14bbcb6a..25bd3490 100644 --- a/pages/guild.php +++ b/pages/guild.php @@ -12,7 +12,7 @@ class GuildPage extends GenericPage protected $lvTabs = []; - protected $type = TYPE_GUILD; + protected $type = Type::GUILD; protected $tabId = 1; protected $path = [1, 5, 2]; @@ -138,7 +138,7 @@ class GuildPage extends GenericPage private function handleIncompleteData($teamGuid) { //display empty page and queue status - $newId = Profiler::scheduleResync(TYPE_GUILD, $this->realmId, $teamGuid); + $newId = Profiler::scheduleResync(Type::GUILD, $this->realmId, $teamGuid); $this->doResync = ['guild', $newId]; $this->initialSync(); diff --git a/pages/guilds.php b/pages/guilds.php index d346358b..a13d5256 100644 --- a/pages/guilds.php +++ b/pages/guilds.php @@ -10,7 +10,7 @@ class GuildsPage extends GenericPage { use TrProfiler; - protected $type = TYPE_GUILD; + protected $type = Type::GUILD; protected $tabId = 1; protected $path = [1, 5, 2]; diff --git a/pages/icon.php b/pages/icon.php index 5b31487f..0188603f 100644 --- a/pages/icon.php +++ b/pages/icon.php @@ -10,7 +10,7 @@ class IconPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_ICON; + protected $type = Type::ICON; protected $typeId = 0; protected $tpl = 'icon'; protected $path = [0, 31]; diff --git a/pages/icons.php b/pages/icons.php index 60179f4c..de087fe6 100644 --- a/pages/icons.php +++ b/pages/icons.php @@ -10,7 +10,7 @@ class IconsPage extends GenericPage { use TrListPage; - protected $type = TYPE_ICON; + protected $type = Type::ICON; protected $tpl = 'icons'; protected $path = [0, 31]; protected $tabId = 0; diff --git a/pages/item.php b/pages/item.php index a080f566..379d178d 100644 --- a/pages/item.php +++ b/pages/item.php @@ -10,7 +10,7 @@ class ItemPage extends genericPage { use TrDetailPage; - protected $type = TYPE_ITEM; + protected $type = Type::ITEM; protected $typeId = 0; protected $tpl = 'item'; protected $path = [0, 0]; @@ -159,7 +159,7 @@ class ItemPage extends genericPage if ($_ = $this->subject->getField('iconId')) { $infobox[] = Util::ucFirst(lang::game('icon')).Lang::main('colon').'[icondb='.$_.' name=true]'; - $this->extendGlobalIds(TYPE_ICON, $_); + $this->extendGlobalIds(Type::ICON, $_); } // consumable / not consumable @@ -187,7 +187,7 @@ class ItemPage extends genericPage // related holiday if ($eId = $this->subject->getField('eventId')) { - $this->extendGlobalIds(TYPE_WORLDEVENT, $eId); + $this->extendGlobalIds(Type::WORLDEVENT, $eId); $infobox[] = Lang::game('eventShort').Lang::main('colon').'[event='.$eId.']'; } @@ -225,12 +225,12 @@ class ItemPage extends genericPage if ($c < 0) // currency items (and honor or arena) { $currency[] = -$c.','.($qty / $stack); - $this->extendGlobalIds(TYPE_CURRENCY, -$c); + $this->extendGlobalIds(Type::CURRENCY, -$c); } else if ($c > 0) // plain items (item1,count1,item2,count2,...) { $tokens[$c] = $c.','.($qty / $stack); - $this->extendGlobalIds(TYPE_ITEM, $c); + $this->extendGlobalIds(Type::ITEM, $c); } } @@ -360,7 +360,7 @@ class ItemPage extends genericPage $this->tooltip = $this->subject->renderTooltip(true); $this->redButtons = array( BUTTON_WOWHEAD => true, - BUTTON_VIEW3D => in_array($_slot, $_visSlots) && $_model ? ['displayId' => $this->subject->getField('displayId'), 'slot' => $_slot, 'type' => TYPE_ITEM, 'typeId' => $this->typeId] : false, + BUTTON_VIEW3D => in_array($_slot, $_visSlots) && $_model ? ['displayId' => $this->subject->getField('displayId'), 'slot' => $_slot, 'type' => Type::ITEM, 'typeId' => $this->typeId] : false, BUTTON_COMPARE => $_cu, BUTTON_EQUIP => in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]), BUTTON_UPGRADE => ($_cu ? ['class' => $_class, 'slot' => $_slot] : false), @@ -441,7 +441,7 @@ class ItemPage extends genericPage { $data['percent'] = $perfItem[$sId]['perfectCreateChance']; $data['condition'][0][$this->typeId] = [[[CND_SPELL, $perfItem[$sId]['requiredSpecialization']]]]; - $this->extendGlobalIDs(TYPE_SPELL, $perfItem[$sId]['requiredSpecialization']); + $this->extendGlobalIDs(Type::SPELL, $perfItem[$sId]['requiredSpecialization']); } $this->lvTabs[] = ['spell', array( @@ -535,11 +535,11 @@ class ItemPage extends genericPage foreach ($reqQuests->iterate() as $qId => $__) { - if (empty($reqQuests->requires[$qId][TYPE_ITEM])) + if (empty($reqQuests->requires[$qId][Type::ITEM])) continue; foreach ($reqIds as $rId) - if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM])) + if (in_array($rId, $reqQuests->requires[$qId][Type::ITEM])) $reqQuest[$rId] = $reqQuests->id; } } @@ -803,7 +803,7 @@ class ItemPage extends genericPage if (count($extraCols) == 3) $extraCols[] = '$Listview.extraCols.condition'; - $this->extendGlobalIds(TYPE_WORLDEVENT, $e); + $this->extendGlobalIds(Type::WORLDEVENT, $e); $row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $e]]; } @@ -860,7 +860,7 @@ class ItemPage extends genericPage if (!$boughtBy->error) { $iCur = new CurrencyList(array(['itemId', $this->typeId])); - $filter = $iCur->error ? [TYPE_ITEM => $this->typeId] : [TYPE_CURRENCY => $iCur->id]; + $filter = $iCur->error ? [Type::ITEM => $this->typeId] : [Type::CURRENCY => $iCur->id]; $tabData = array( 'data' => array_values($boughtBy->getListviewData(ITEMINFO_VENDOR, $filter)), diff --git a/pages/items.php b/pages/items.php index 7beb12f4..99db56d3 100644 --- a/pages/items.php +++ b/pages/items.php @@ -10,7 +10,7 @@ class ItemsPage extends GenericPage { use TrListPage; - protected $type = TYPE_ITEM; + protected $type = Type::ITEM; protected $tpl = 'items'; protected $path = [0, 0]; protected $tabId = 0; diff --git a/pages/itemset.php b/pages/itemset.php index 5a467249..bcd06555 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -10,7 +10,7 @@ class ItemsetPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_ITEMSET; + protected $type = Type::ITEMSET; protected $typeId = 0; protected $tpl = 'itemset'; protected $path = [0, 2]; @@ -77,7 +77,7 @@ class ItemsetPage extends GenericPage if ($e = $this->subject->getField('eventId')) { $infobox[] = Lang::game('eventShort').Lang::main('colon').'[event='.$e.']'; - $this->extendGlobalIds(TYPE_WORLDEVENT, $e); + $this->extendGlobalIds(Type::WORLDEVENT, $e); } // itemLevel @@ -96,7 +96,7 @@ class ItemsetPage extends GenericPage $jsg = []; if ($cl = Lang::getClassString($this->subject->getField('classMask'), $jsg, false)) { - $this->extendGlobalIds(TYPE_CLASS, ...$jsg); + $this->extendGlobalIds(Type::CHR_CLASS, ...$jsg); $t = count($jsg)== 1 ? Lang::game('class') : Lang::game('classes'); $infobox[] = Util::ucFirst($t).Lang::main('colon').$cl; } @@ -166,7 +166,7 @@ class ItemsetPage extends GenericPage $this->redButtons = array( BUTTON_WOWHEAD => $this->typeId > 0, // bool only BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId], - BUTTON_VIEW3D => ['type' => TYPE_ITEMSET, 'typeId' => $this->typeId, 'equipList' => $eqList], + BUTTON_VIEW3D => ['type' => Type::ITEMSET, 'typeId' => $this->typeId, 'equipList' => $eqList], BUTTON_COMPARE => ['eqList' => implode(':', $compare), 'qty' => $_cnt] ); $this->summary = array( diff --git a/pages/itemsets.php b/pages/itemsets.php index ff2deb58..67b5c03f 100644 --- a/pages/itemsets.php +++ b/pages/itemsets.php @@ -10,7 +10,7 @@ class ItemsetsPage extends GenericPage { use TrListPage; - protected $type = TYPE_ITEMSET; + protected $type = Type::ITEMSET; protected $tpl = 'itemsets'; protected $path = [0, 2]; protected $tabId = 0; diff --git a/pages/mail.php b/pages/mail.php index 24c07f37..0a7d2e95 100644 --- a/pages/mail.php +++ b/pages/mail.php @@ -10,7 +10,7 @@ class MailPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_MAIL; + protected $type = Type::MAIL; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 103]; @@ -47,7 +47,7 @@ class MailPage extends GenericPage if ($npcId = DB::World()->selectCell('SELECT Sender FROM achievement_reward WHERE ID = ?d', -$this->typeId)) { $infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$npcId.']'; - $this->extendGlobalIds(TYPE_NPC, $npcId); + $this->extendGlobalIds(Type::NPC, $npcId); } } else if ($mlr = DB::World()->selectRow('SELECT * FROM mail_level_reward WHERE mailTemplateId = ?d', $this->typeId)) // level rewards @@ -59,11 +59,11 @@ class MailPage extends GenericPage if ($r = Lang::getRaceString($mlr['raceMask'], $rIds, false)) { $infobox[] = Lang::game('races').Lang::main('colon').$r; - $this->extendGlobalIds(TYPE_RACE, ...$rIds); + $this->extendGlobalIds(Type::CHR_RACE, ...$rIds); } $infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$mlr['senderEntry'].']'; - $this->extendGlobalIds(TYPE_NPC, $mlr['senderEntry']); + $this->extendGlobalIds(Type::NPC, $mlr['senderEntry']); } else // achievement or quest { @@ -72,12 +72,12 @@ class MailPage extends GenericPage if ($npcId= DB::World()->selectCell('SELECT RewardMailSenderEntry FROM quest_mail_sender WHERE QuestId = ?d', $q['id'])) { $infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$npcId.']'; - $this->extendGlobalIds(TYPE_NPC, $npcId); + $this->extendGlobalIds(Type::NPC, $npcId); } - else if ($npcId = DB::Aowow()->selectCell('SELECT typeId FROM ?_quests_startend WHERE questId = ?d AND type = ?d AND method & ?d', $q['id'], TYPE_NPC, 0x2)) + else if ($npcId = DB::Aowow()->selectCell('SELECT typeId FROM ?_quests_startend WHERE questId = ?d AND type = ?d AND method & ?d', $q['id'], Type::NPC, 0x2)) { $infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$npcId.']'; - $this->extendGlobalIds(TYPE_NPC, $npcId); + $this->extendGlobalIds(Type::NPC, $npcId); } if ($q['rewardMailDelay'] > 0) @@ -86,7 +86,7 @@ class MailPage extends GenericPage else if ($npcId = DB::World()->selectCell('SELECT Sender FROM achievement_reward WHERE MailTemplateId = ?d', $this->typeId)) { $infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$npcId.']'; - $this->extendGlobalIds(TYPE_NPC, $npcId); + $this->extendGlobalIds(Type::NPC, $npcId); } } @@ -139,7 +139,7 @@ class MailPage extends GenericPage else if ($npcId = DB::World()->selectCell('SELECT ID FROM achievement_reward WHERE MailTemplateId = ?d', $this->typeId)) { $infobox[] = '[Sender]: [npc='.$npcId.']'; - $this->extendGlobalIds(TYPE_NPC, $npcId); + $this->extendGlobalIds(Type::NPC, $npcId); } else // used by: quest diff --git a/pages/mails.php b/pages/mails.php index 9644a55d..4a3e48f2 100644 --- a/pages/mails.php +++ b/pages/mails.php @@ -10,7 +10,7 @@ class MailsPage extends GenericPage { use TrListPage; - protected $type = TYPE_MAIL; + protected $type = Type::MAIL; protected $tpl = 'list-page-generic'; protected $path = [0, 103]; protected $tabId = 0; diff --git a/pages/npc.php b/pages/npc.php index 26b24d06..b94c4a59 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -10,7 +10,7 @@ class NpcPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_NPC; + protected $type = Type::NPC; protected $typeId = 0; protected $tpl = 'npc'; protected $path = [0, 4]; @@ -87,7 +87,7 @@ class NpcPage extends GenericPage // try to determine, if it's spawned in a dungeon or raid (shaky at best, if spawned by script) $mapType = 0; - if ($maps = DB::Aowow()->selectCol('SELECT DISTINCT areaId from ?_spawns WHERE type = ?d AND typeId = ?d', TYPE_NPC, $this->typeId)) + if ($maps = DB::Aowow()->selectCol('SELECT DISTINCT areaId from ?_spawns WHERE type = ?d AND typeId = ?d', Type::NPC, $this->typeId)) { if (count($maps) == 1) // should only exist in one instance { @@ -122,7 +122,7 @@ class NpcPage extends GenericPage // Event (ignore events, where the object only gets removed) if ($_ = DB::World()->selectCol('SELECT DISTINCT ge.eventEntry FROM game_event ge, game_event_creature gec, creature c WHERE ge.eventEntry = gec.eventEntry AND c.guid = gec.guid AND c.id = ?d', $this->typeId)) { - $this->extendGlobalIds(TYPE_WORLDEVENT, ...$_); + $this->extendGlobalIds(Type::WORLDEVENT, ...$_); $ev = []; foreach ($_ as $i => $e) $ev[] = ($i % 2 ? '[br]' : ' ') . '[event='.$e.']'; @@ -160,7 +160,7 @@ class NpcPage extends GenericPage $infobox[] = Lang::npc('react').Lang::main('colon').'[color=q'.$_($this->subject->getField('A')).']A[/color] [color=q'.$_($this->subject->getField('H')).']H[/color]'; // Faction - $this->extendGlobalIds(TYPE_FACTION, $this->subject->getField('factionId')); + $this->extendGlobalIds(Type::FACTION, $this->subject->getField('factionId')); $infobox[] = Util::ucFirst(Lang::game('faction')).Lang::main('colon').'[faction='.$this->subject->getField('factionId').']'; // Tameable @@ -398,7 +398,7 @@ class NpcPage extends GenericPage $this->redButtons = array( BUTTON_WOWHEAD => true, BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId], - BUTTON_VIEW3D => ['type' => TYPE_NPC, 'typeId' => $this->typeId, 'displayId' => $this->subject->getRandomModelId()] + BUTTON_VIEW3D => ['type' => Type::NPC, 'typeId' => $this->typeId, 'displayId' => $this->subject->getRandomModelId()] ); if ($this->subject->getField('humanoid')) @@ -507,9 +507,9 @@ class NpcPage extends GenericPage // tab: summoned by [NPC] $sb = SmartAI::getOwnerOfNPCSummon($this->typeId); - if (!empty($sb[TYPE_NPC])) + if (!empty($sb[Type::NPC])) { - $sbNPC = new CreatureList(array(['id', $sb[TYPE_NPC]])); + $sbNPC = new CreatureList(array(['id', $sb[Type::NPC]])); if (!$sbNPC->error) { $this->extendGlobalData($sbNPC->getJSGlobals()); @@ -523,9 +523,9 @@ class NpcPage extends GenericPage } // tab: summoned by [Object] - if (!empty($sb[TYPE_OBJECT])) + if (!empty($sb[Type::OBJECT])) { - $sbGO = new GameObjectList(array(['id', $sb[TYPE_OBJECT]])); + $sbGO = new GameObjectList(array(['id', $sb[Type::OBJECT]])); if (!$sbGO->error) { $this->extendGlobalData($sbGO->getJSGlobals()); @@ -566,7 +566,7 @@ class NpcPage extends GenericPage { if (count($data[$sId]['skill']) == 1 && $_ != $data[$sId]['skill'][0]) { - $this->extendGlobalIds(TYPE_SKILL, $_); + $this->extendGlobalIds(Type::SKILL, $_); if (!isset($extra[0])) $extra[0] = '$Listview.extraCols.condition'; @@ -578,7 +578,7 @@ class NpcPage extends GenericPage { if ($_ = $train['reqSpellId'.$i]) { - $this->extendGlobalIds(TYPE_SPELL, $_); + $this->extendGlobalIds(Type::SPELL, $_); if (!isset($extra[0])) $extra[0] = '$Listview.extraCols.condition'; @@ -625,7 +625,7 @@ class NpcPage extends GenericPage if ($soldItems->hasSetFields(['condition'])) $extraCols[] = '$Listview.extraCols.condition'; - $lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [TYPE_NPC => [$this->typeId]]); + $lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [Type::NPC => [$this->typeId]]); $sc = Util::getServerConditions(CND_SRC_NPC_VENDOR, $this->typeId); if (!empty($sc[0])) @@ -752,18 +752,18 @@ class NpcPage extends GenericPage foreach ($reqQuests->iterate() as $qId => $__) { - if (empty($reqQuests->requires[$qId][TYPE_ITEM])) + if (empty($reqQuests->requires[$qId][Type::ITEM])) continue; foreach ($reqIds as $rId) - if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM])) + if (in_array($rId, $reqQuests->requires[$qId][Type::ITEM])) $reqQuest[$rId] = $reqQuests->id; } } // tab: starts quest // tab: ends quest - $startEnd = new QuestList(array(['qse.type', TYPE_NPC], ['qse.typeId', $this->typeId])); + $startEnd = new QuestList(array(['qse.type', Type::NPC], ['qse.typeId', $this->typeId])); if (!$startEnd->error) { $this->extendGlobalData($startEnd->getJSGlobals()); diff --git a/pages/npcs.php b/pages/npcs.php index 9a06a70a..96175e78 100644 --- a/pages/npcs.php +++ b/pages/npcs.php @@ -10,7 +10,7 @@ class NpcsPage extends GenericPage { use TrListPage; - protected $type = TYPE_NPC; + protected $type = Type::NPC; protected $tpl = 'npcs'; protected $path = [0, 4]; protected $tabId = 0; diff --git a/pages/object.php b/pages/object.php index 6122828f..9e31ddc6 100644 --- a/pages/object.php +++ b/pages/object.php @@ -10,7 +10,7 @@ class ObjectPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_OBJECT; + protected $type = Type::OBJECT; protected $typeId = 0; protected $tpl = 'object'; protected $path = [0, 5]; @@ -62,7 +62,7 @@ class ObjectPage extends GenericPage // Event (ignore events, where the object only gets removed) if ($_ = DB::World()->selectCol('SELECT DISTINCT ge.eventEntry FROM game_event ge, game_event_gameobject geg, gameobject g WHERE ge.eventEntry = geg.eventEntry AND g.guid = geg.guid AND g.id = ?d', $this->typeId)) { - $this->extendGlobalIds(TYPE_WORLDEVENT, ...$_); + $this->extendGlobalIds(Type::WORLDEVENT, ...$_); $ev = []; foreach ($_ as $i => $e) $ev[] = ($i % 2 ? '[br]' : ' ') . '[event='.$e.']'; @@ -73,7 +73,7 @@ class ObjectPage extends GenericPage // Faction if ($_ = DB::Aowow()->selectCell('SELECT factionId FROM ?_factiontemplate WHERE id = ?d', $this->subject->getField('faction'))) { - $this->extendGlobalIds(TYPE_FACTION, $_); + $this->extendGlobalIds(Type::FACTION, $_); $infobox[] = Util::ucFirst(Lang::game('faction')).Lang::main('colon').'[faction='.$_.']'; } @@ -125,7 +125,7 @@ class ObjectPage extends GenericPage // linked trap if ($_ = $this->subject->getField('linkedTrap')) { - $this->extendGlobalIds(TYPE_OBJECT, $_); + $this->extendGlobalIds(Type::OBJECT, $_); $infobox[] = Lang::gameObject('trap').Lang::main('colon').'[object='.$_.']'; } @@ -158,7 +158,7 @@ class ObjectPage extends GenericPage { if ($_ = $this->subject->getField('mStone')) { - $this->extendGlobalIds(TYPE_ZONE, $_[2]); + $this->extendGlobalIds(Type::ZONE, $_[2]); $m = Lang::game('meetingStone').Lang::main('colon').'[zone='.$_[2].']'; $l = $_[0]; @@ -278,7 +278,7 @@ class ObjectPage extends GenericPage $this->redButtons = array( BUTTON_WOWHEAD => true, BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId], - BUTTON_VIEW3D => ['displayId' => $this->subject->getField('displayId'), 'type' => TYPE_OBJECT, 'typeId' => $this->typeId] + BUTTON_VIEW3D => ['displayId' => $this->subject->getField('displayId'), 'type' => Type::OBJECT, 'typeId' => $this->typeId] ); @@ -343,7 +343,7 @@ class ObjectPage extends GenericPage // tab: starts quest // tab: ends quest - $startEnd = new QuestList(array(['qse.type', TYPE_OBJECT], ['qse.typeId', $this->typeId])); + $startEnd = new QuestList(array(['qse.type', Type::OBJECT], ['qse.typeId', $this->typeId])); if (!$startEnd->error) { $this->extendGlobalData($startEnd->getJSGlobals()); @@ -448,11 +448,11 @@ class ObjectPage extends GenericPage foreach ($reqQuests->iterate() as $qId => $__) { - if (empty($reqQuests->requires[$qId][TYPE_ITEM])) + if (empty($reqQuests->requires[$qId][Type::ITEM])) continue; foreach ($reqIds as $rId) - if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM])) + if (in_array($rId, $reqQuests->requires[$qId][Type::ITEM])) $reqQuest[$rId] = $reqQuests->id; } } diff --git a/pages/objects.php b/pages/objects.php index 67508336..028c88de 100644 --- a/pages/objects.php +++ b/pages/objects.php @@ -10,7 +10,7 @@ class ObjectsPage extends GenericPage { use TrListPage; - protected $type = TYPE_OBJECT; + protected $type = Type::OBJECT; protected $tpl = 'objects'; protected $path = [0, 5]; protected $tabId = 0; diff --git a/pages/pet.php b/pages/pet.php index 67eda397..29d68ebf 100644 --- a/pages/pet.php +++ b/pages/pet.php @@ -10,7 +10,7 @@ class PetPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_PET; + protected $type = Type::PET; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 8]; @@ -62,7 +62,7 @@ class PetPage extends GenericPage if ($_ = $this->subject->getField('iconId')) { $infobox[] = Util::ucFirst(lang::game('icon')).Lang::main('colon').'[icondb='.$_.' name=true]'; - $this->extendGlobalIds(TYPE_ICON, $_); + $this->extendGlobalIds(Type::ICON, $_); } /****************/ diff --git a/pages/pets.php b/pages/pets.php index f1686033..db75efab 100644 --- a/pages/pets.php +++ b/pages/pets.php @@ -10,7 +10,7 @@ class PetsPage extends GenericPage { use TrListPage; - protected $type = TYPE_PET; + protected $type = Type::PET; protected $tpl = 'list-page-generic'; protected $path = [0, 8]; protected $tabId = 0; diff --git a/pages/profile.php b/pages/profile.php index 11d0f30c..d3decda8 100644 --- a/pages/profile.php +++ b/pages/profile.php @@ -13,7 +13,7 @@ class ProfilePage extends GenericPage protected $gDataKey = true; protected $mode = CACHE_TYPE_PAGE; - protected $type = TYPE_PROFILE; + protected $type = Type::PROFILE; protected $tabId = 1; protected $path = [1, 5, 1]; @@ -166,11 +166,11 @@ class ProfilePage extends GenericPage /* Anub, Faerlina, Maexxna, Noth, Heigan, Loatheb, Razuvious, Gothik, Patchwerk, Grobbulus, Gluth, Thaddius, Sapphiron, Kel'Thuzad */ /* nax */ 15956, 15953, 15952, 15954, 15936, 16011, 16061, 16060, 16028, 15931, 15932, 15928, 15989, 15990 ); - $this->extendGlobalIds(TYPE_NPC, ...$bossIds); + $this->extendGlobalIds(Type::NPC, ...$bossIds); // dummy title from dungeon encounter foreach (Lang::profiler('encounterNames') as $id => $name) - $this->extendGlobalData([TYPE_NPC => [$id => ['name_'.User::$localeString => $name]]]); + $this->extendGlobalData([Type::NPC => [$id => ['name_'.User::$localeString => $name]]]); } protected function generatePath() @@ -242,7 +242,7 @@ class ProfilePage extends GenericPage $this->mode = CACHE_TYPE_NONE; // queue full fetch - $newId = Profiler::scheduleResync(TYPE_PROFILE, $this->realmId, $guid); + $newId = Profiler::scheduleResync(Type::PROFILE, $this->realmId, $guid); $this->doResync = ['profile', $newId]; $this->initialSync(); diff --git a/pages/profiles.php b/pages/profiles.php index d3e5dbde..3b3132e7 100644 --- a/pages/profiles.php +++ b/pages/profiles.php @@ -12,7 +12,7 @@ class ProfilesPage extends GenericPage protected $roster = 0; // $_GET['roster'] = 1|2|3|4 .. 2,3,4 arenateam-size (4 => 5-man), 1 guild .. it puts a resync button on the lv... - protected $type = TYPE_PROFILE; + protected $type = Type::PROFILE; protected $tabId = 1; protected $path = [1, 5, 0]; diff --git a/pages/quest.php b/pages/quest.php index 0ee6f2ee..fd26b1a7 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -10,7 +10,7 @@ class QuestPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_QUEST; + protected $type = Type::QUEST; protected $typeId = 0; protected $tpl = 'quest'; protected $path = [0, 3]; @@ -90,7 +90,7 @@ class QuestPage extends GenericPage // event (todo: assign eventData) if ($_ = $this->subject->getField('eventId')) { - $this->extendGlobalIds(TYPE_WORLDEVENT, $_); + $this->extendGlobalIds(Type::WORLDEVENT, $_); $infobox[] = Lang::game('eventShort').Lang::main('colon').'[event='.$_.']'; } @@ -164,7 +164,7 @@ class QuestPage extends GenericPage // races if ($_ = Lang::getRaceString($this->subject->getField('reqRaceMask'), $jsg, false)) { - $this->extendGlobalIds(TYPE_RACE, ...$jsg); + $this->extendGlobalIds(Type::CHR_RACE, ...$jsg); $t = count($jsg) == 1 ? Lang::game('race') : Lang::game('races'); $infobox[] = Util::ucFirst($t).Lang::main('colon').$_; } @@ -172,7 +172,7 @@ class QuestPage extends GenericPage // classes if ($_ = Lang::getClassString($this->subject->getField('reqClassMask'), $jsg, false)) { - $this->extendGlobalIds(TYPE_CLASS, ...$jsg); + $this->extendGlobalIds(Type::CHR_CLASS, ...$jsg); $t = count($jsg) == 1 ? Lang::game('class') : Lang::game('classes'); $infobox[] = Util::ucFirst($t).Lang::main('colon').$_; } @@ -180,7 +180,7 @@ class QuestPage extends GenericPage // profession / skill if ($_ = $this->subject->getField('reqSkillId')) { - $this->extendGlobalIds(TYPE_SKILL, $_); + $this->extendGlobalIds(Type::SKILL, $_); $sk = '[skill='.$_.']'; if ($_ = $this->subject->getField('reqSkillPoints')) $sk .= ' ('.$_.')'; @@ -202,7 +202,7 @@ class QuestPage extends GenericPage if ($se['method'] & 0x1) { $this->extendGlobalIds($se['type'], $se['typeId']); - $s[] = ($s ? '[span=invisible]'.$start.'[/span] ' : $start.' ') .'['.Util::$typeStrings[$se['type']].'='.$se['typeId'].']'; + $s[] = ($s ? '[span=invisible]'.$start.'[/span] ' : $start.' ') .'['.Type::getFileString($se['type']).'='.$se['typeId'].']'; } } @@ -217,7 +217,7 @@ class QuestPage extends GenericPage if ($se['method'] & 0x2) { $this->extendGlobalIds($se['type'], $se['typeId']); - $e[] = ($e ? '[span=invisible]'.$end.'[/span] ' : $end.' ') . '['.Util::$typeStrings[$se['type']].'='.$se['typeId'].']'; + $e[] = ($e ? '[span=invisible]'.$end.'[/span] ' : $end.' ') . '['.Type::getFileString($se['type']).'='.$se['typeId'].']'; } } @@ -276,7 +276,7 @@ class QuestPage extends GenericPage array( array( 'side' => $_side, - 'typeStr' => Util::$typeStrings[TYPE_QUEST], + 'typeStr' => Type::getFileString(Type::QUEST), 'typeId' => $this->typeId, 'name' => $this->name, '_next' => $this->subject->getField('nextQuestIdChain') @@ -299,7 +299,7 @@ class QuestPage extends GenericPage array_unshift($chain, array( array( 'side' => Game::sideByRaceMask($_['reqRaceMask']), - 'typeStr' => Util::$typeStrings[TYPE_QUEST], + 'typeStr' => Type::getFileString(Type::QUEST), 'typeId' => $_['typeId'], 'name' => Util::htmlEscape(Lang::trimTextClean($n, 40)), ) @@ -319,7 +319,7 @@ class QuestPage extends GenericPage array_push($chain, array( array( 'side' => Game::sideByRaceMask($_['reqRaceMask']), - 'typeStr' => Util::$typeStrings[TYPE_QUEST], + 'typeStr' => Type::getFileString(Type::QUEST), 'typeId' => $_['typeId'], 'name' => Util::htmlEscape(Lang::trimTextClean($n, 40)), '_next' => $_['_next'], @@ -345,7 +345,7 @@ class QuestPage extends GenericPage $n = $list->getField('name', true); $chain[] = array(array( 'side' => Game::sideByRaceMask($list->getField('reqRaceMask')), - 'typeStr' => Util::$typeStrings[TYPE_QUEST], + 'typeStr' => Type::getFileString(Type::QUEST), 'typeId' => $id, 'name' => Util::htmlEscape(Lang::trimTextClean($n, 40)) )); @@ -421,7 +421,7 @@ class QuestPage extends GenericPage $providedRequired = true; $this->objectiveList[] = array( - 'typeStr' => Util::$typeStrings[TYPE_ITEM], + 'typeStr' => Type::getFileString(Type::ITEM), 'id' => $itemId, 'name' => $olItemData->json[$itemId]['name'], 'qty' => $qty > 1 ? $qty : 0, @@ -478,7 +478,7 @@ class QuestPage extends GenericPage continue; $ol = array( - 'typeStr' => Util::$typeStrings[TYPE_NPC], + 'typeStr' => Type::getFileString(Type::NPC), 'id' => $i, 'name' => $pair[1] ?: Util::localizedString($olNPCData->getEntry($i), 'name'), 'qty' => $pair[0] > 1 ? $pair[0] : 0, @@ -505,7 +505,7 @@ class QuestPage extends GenericPage continue; $this->objectiveList[] = array( - 'typeStr' => Util::$typeStrings[TYPE_OBJECT], + 'typeStr' => Type::getFileString(Type::OBJECT), 'id' => $i, 'name' => $pair[1] ?: Util::localizedString($olGOData->getEntry($i), 'name'), 'qty' => $pair[0] > 1 ? $pair[0] : 0, @@ -536,7 +536,7 @@ class QuestPage extends GenericPage continue; $this->objectiveList[] = array( - 'typeStr' => Util::$typeStrings[TYPE_FACTION], + 'typeStr' => Type::getFileString(Type::FACTION), 'id' => $i, 'name' => Util::localizedString($olFactionsData->getEntry($i), 'name'), 'qty' => sprintf(Util::$dfnString, $val.' '.Lang::achievement('points'), Lang::getReputationLevelForPoints($val)), @@ -548,9 +548,9 @@ class QuestPage extends GenericPage // granted spell if ($_ = $this->subject->getField('sourceSpellId')) { - $this->extendGlobalIds(TYPE_SPELL, $_); + $this->extendGlobalIds(Type::SPELL, $_); $this->objectiveList[] = array( - 'typeStr' => Util::$typeStrings[TYPE_SPELL], + 'typeStr' => Type::getFileString(Type::SPELL), 'id' => $_, 'name' => SpellList::getName($_), 'qty' => 0, @@ -665,11 +665,11 @@ class QuestPage extends GenericPage // POI: start + end foreach ($startEnd as $se) { - if ($se['type'] == TYPE_NPC) + if ($se['type'] == Type::NPC) $mapNPCs[] = [$se['typeId'], $se['method'], 0]; - else if ($se['type'] == TYPE_OBJECT) + else if ($se['type'] == Type::OBJECT) $mapGOs[] = [$se['typeId'], $se['method'], 0]; - else if ($se['type'] == TYPE_ITEM) + else if ($se['type'] == Type::ITEM) $getItemSource($se['typeId'], $se['method']); } @@ -698,12 +698,12 @@ class QuestPage extends GenericPage // areatrigger if ($atir = DB::Aowow()->selectCol('SELECT id FROM ?_areatrigger WHERE type = ?d AND quest = ?d', AT_TYPE_OBJECTIVE, $this->typeId)) { - if ($atSpawns = DB::AoWoW()->select('SELECT typeId AS ARRAY_KEY, posX, posY, floor, areaId FROM ?_spawns WHERE `type` = ?d AND `typeId` IN (?a)', TYPE_AREATRIGGER, $atir)) + if ($atSpawns = DB::AoWoW()->select('SELECT typeId AS ARRAY_KEY, posX, posY, floor, areaId FROM ?_spawns WHERE `type` = ?d AND `typeId` IN (?a)', Type::AREATRIGGER, $atir)) { foreach ($atSpawns as $atId => $atsp) { $atSpawn = array ( - 'type' => User::isInGroup(U_GROUP_STAFF) ? TYPE_AREATRIGGER : -1, + 'type' => User::isInGroup(U_GROUP_STAFF) ? Type::AREATRIGGER : -1, 'id' => $atId, 'point' => 'requirement', 'name' => $this->subject->parseText('end', false), @@ -1017,13 +1017,13 @@ class QuestPage extends GenericPage if ($_ = $this->subject->getField('reqMinRepFaction')) { $cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0][] = [CND_REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMinRepValue'))]; - $this->extendGlobalIds(TYPE_FACTION, $_); + $this->extendGlobalIds(Type::FACTION, $_); } if ($_ = $this->subject->getField('reqMaxRepFaction')) { $cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0][] = [-CND_REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMaxRepValue'))]; - $this->extendGlobalIds(TYPE_FACTION, $_); + $this->extendGlobalIds(Type::FACTION, $_); } $_ = Util::getServerConditions([CND_SRC_QUEST_ACCEPT, CND_SRC_QUEST_SHOW_MARK], null, $this->typeId); @@ -1091,9 +1091,9 @@ class QuestPage extends GenericPage $rewards['money'] = sprintf(Lang::quest('expConvert2'), Util::formatMoney($realComp), MAX_LEVEL); // itemChoices - if (!empty($this->subject->choices[$this->typeId][TYPE_ITEM])) + if (!empty($this->subject->choices[$this->typeId][Type::ITEM])) { - $c = $this->subject->choices[$this->typeId][TYPE_ITEM]; + $c = $this->subject->choices[$this->typeId][Type::ITEM]; $choiceItems = new ItemList(array(['id', array_keys($c)])); if (!$choiceItems->error) { @@ -1101,21 +1101,21 @@ class QuestPage extends GenericPage foreach ($choiceItems->Iterate() as $id => $__) { $rewards['choice'][] = array( - 'typeStr' => Util::$typeStrings[TYPE_ITEM], + 'typeStr' => Type::getFileString(Type::ITEM), 'id' => $id, 'name' => $choiceItems->getField('name', true), 'quality' => $choiceItems->getField('quality'), 'qty' => $c[$id], - 'globalStr' => 'g_items' + 'globalStr' => Type::getJSGlobalString(Type::ITEM) ); } } } // itemRewards - if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM])) + if (!empty($this->subject->rewards[$this->typeId][Type::ITEM])) { - $ri = $this->subject->rewards[$this->typeId][TYPE_ITEM]; + $ri = $this->subject->rewards[$this->typeId][Type::ITEM]; $rewItems = new ItemList(array(['id', array_keys($ri)])); if (!$rewItems->error) { @@ -1123,20 +1123,20 @@ class QuestPage extends GenericPage foreach ($rewItems->Iterate() as $id => $__) { $rewards['items'][] = array( - 'typeStr' => Util::$typeStrings[TYPE_ITEM], + 'typeStr' => Type::getFileString(Type::ITEM), 'id' => $id, 'name' => $rewItems->getField('name', true), 'quality' => $rewItems->getField('quality'), 'qty' => $ri[$id], - 'globalStr' => 'g_items' + 'globalStr' => Type::getJSGlobalString(Type::ITEM) ); } } } - if (!empty($this->subject->rewards[$this->typeId][TYPE_CURRENCY])) + if (!empty($this->subject->rewards[$this->typeId][Type::CURRENCY])) { - $rc = $this->subject->rewards[$this->typeId][TYPE_CURRENCY]; + $rc = $this->subject->rewards[$this->typeId][Type::CURRENCY]; $rewCurr = new CurrencyList(array(['id', array_keys($rc)])); if (!$rewCurr->error) { @@ -1144,12 +1144,12 @@ class QuestPage extends GenericPage foreach ($rewCurr->Iterate() as $id => $__) { $rewards['items'][] = array( - 'typeStr' => Util::$typeStrings[TYPE_CURRENCY], + 'typeStr' => Type::getFileString(Type::CURRENCY), 'id' => $id, 'name' => $rewCurr->getField('name', true), 'quality' => 1, 'qty' => $rc[$id] * ($side == 2 ? -1 : 1), // toggles the icon - 'globalStr' => 'g_gatheredcurrencies' + 'globalStr' => Type::getJSGlobalString(Type::CURRENCY) ); } } @@ -1179,10 +1179,10 @@ class QuestPage extends GenericPage { $rewards['spells']['extra'] = $extra; $rewards['spells']['cast'][] = array( - 'typeStr' => Util::$typeStrings[TYPE_SPELL], + 'typeStr' => Type::getFileString(Type::SPELL), 'id' => $cast, 'name' => Util::localizedString($_, 'name'), - 'globalStr' => 'g_spells' + 'globalStr' => Type::getJSGlobalString(Type::SPELL) ); } } @@ -1198,20 +1198,20 @@ class QuestPage extends GenericPage { $rewards['spells']['extra'] = null; $rewards['spells'][$teach ? 'learn' : 'cast'][] = array( - 'typeStr' => Util::$typeStrings[TYPE_SPELL], + 'typeStr' => Type::getFileString(Type::SPELL), 'id' => $displ, 'name' => Util::localizedString($_, 'name'), - 'globalStr' => 'g_spells' + 'globalStr' => Type::getJSGlobalString(Type::SPELL) ); } else if (($_ = $rewSpells->getEntry($cast)) && !$teach) { $rewards['spells']['extra'] = null; $rewards['spells']['cast'][] = array( - 'typeStr' => Util::$typeStrings[TYPE_SPELL], + 'typeStr' => Type::getFileString(Type::SPELL), 'id' => $cast, 'name' => Util::localizedString($_, 'name'), - 'globalStr' => 'g_spells' + 'globalStr' => Type::getJSGlobalString(Type::SPELL) ); } else @@ -1224,10 +1224,10 @@ class QuestPage extends GenericPage foreach ($taught->iterate() as $id => $__) { $rewards['spells']['learn'][] = array( - 'typeStr' => Util::$typeStrings[TYPE_SPELL], + 'typeStr' => Type::getFileString(Type::SPELL), 'id' => $id, 'name' => $taught->getField('name', true), - 'globalStr' => 'g_spells' + 'globalStr' => Type::getJSGlobalString(Type::SPELL) ); } } @@ -1261,7 +1261,7 @@ class QuestPage extends GenericPage $senderTypeId = $_; else foreach ($startEnd as $se) - if (($se['method'] & 0x2) && $se['type'] == TYPE_NPC) + if (($se['method'] & 0x2) && $se['type'] == Type::NPC) $senderTypeId = $se['typeId']; if ($ti = CreatureList::getName($senderTypeId)) @@ -1275,12 +1275,12 @@ class QuestPage extends GenericPage foreach ($mailLoot->getResult() as $loot) { $mail['attachments'][] = array( - 'typeStr' => Util::$typeStrings[TYPE_ITEM], + 'typeStr' => Type::getFileString(Type::ITEM), 'id' => $loot['id'], 'name' => substr($loot['name'], 1), 'quality' => 7 - $loot['name'][0], 'qty' => $loot['stack'][0], - 'globalStr' => 'g_items' + 'globalStr' => Type::getJSGlobalString(Type::ITEM) ); } } diff --git a/pages/quests.php b/pages/quests.php index 7e29f454..90738f3a 100644 --- a/pages/quests.php +++ b/pages/quests.php @@ -9,7 +9,7 @@ class QuestsPage extends GenericPage { use TrListPage; - protected $type = TYPE_QUEST; + protected $type = Type::QUEST; protected $tpl = 'quests'; protected $path = [0, 3]; protected $tabId = 0; diff --git a/pages/race.php b/pages/race.php index 49c138b9..fb369710 100644 --- a/pages/race.php +++ b/pages/race.php @@ -10,7 +10,7 @@ class RacePage extends GenericPage { use TrDetailPage; - protected $type = TYPE_RACE; + protected $type = Type::CHR_RACE; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 13]; @@ -72,14 +72,14 @@ class RacePage extends GenericPage // leader if ($_ = $this->subject->getField('leader')) { - $this->extendGlobalIds(TYPE_NPC, $_); + $this->extendGlobalIds(Type::NPC, $_); $infobox[] = Lang::race('racialLeader').Lang::main('colon').'[npc='.$_.']'; } // start area if ($_ = $this->subject->getField('startAreaId')) { - $this->extendGlobalIds(TYPE_ZONE, $_); + $this->extendGlobalIds(Type::ZONE, $_); $infobox[] = Lang::race('startZone').Lang::main('colon').'[zone='.$_.']'; } diff --git a/pages/races.php b/pages/races.php index 9a11d86d..76621a11 100644 --- a/pages/races.php +++ b/pages/races.php @@ -10,7 +10,7 @@ class RacesPage extends GenericPage { use TrListPage; - protected $type = TYPE_RACE; + protected $type = Type::CHR_RACE; protected $tpl = 'list-page-generic'; protected $path = [0, 13]; protected $tabId = 0; diff --git a/pages/screenshot.php b/pages/screenshot.php index f26d2bd5..6335b42f 100644 --- a/pages/screenshot.php +++ b/pages/screenshot.php @@ -49,21 +49,14 @@ class ScreenshotPage extends GenericPage // target delivered as screenshot=&.. (hash is optional) if (preg_match('/^screenshot=\w+&(-?\d+)\.(-?\d+)(\.(\w{16}))?$/i', $_SERVER['QUERY_STRING'] ?? '', $m)) { - // no such type - if (empty(Util::$typeClasses[$m[1]])) + // no such type or this type cannot receive screenshots + if (!Type::checkClassAttrib($m[1], 'contribute', CONTRIBUTE_SS)) $this->error(); - // this type cannot receive screenshots - if (!(get_class_vars(Util::$typeClasses[$m[1]])['contribute'] & CONTRIBUTE_SS)) - $this->error(); - - $t = Util::$typeClasses[$m[1]]; - $c = [['id', intVal($m[2])]]; - - $this->destination = new $t($c); + $this->destination = Type::newList($m[1], [['id', intVal($m[2])]]); // no such typeId - if ($this->destination->error) + if (!$this->destination || $this->destination->error) $this->error(); // only accept/expect hash for crop & complete @@ -89,7 +82,7 @@ class ScreenshotPage extends GenericPage if ($this->handleAdd()) header('Location: ?screenshot=crop&'.$this->destType.'.'.$this->destTypeId.'.'.$this->imgHash, true, 302); else - header('Location: ?'.Util::$typeStrings[$this->destType].'='.$this->destTypeId.'#submit-a-screenshot', true, 302); + header('Location: ?'.Type::getFileString($this->destType).'='.$this->destTypeId.'#submit-a-screenshot', true, 302); die(); case 'crop': $this->handleCrop(); @@ -184,7 +177,7 @@ class ScreenshotPage extends GenericPage $this->cropper['minCrop'] = $this->minSize; // target - $this->infobox = sprintf(Lang::screenshot('displayOn'), Util::ucFirst(Lang::game(Util::$typeStrings[$this->destType])), Util::$typeStrings[$this->destType], $this->destTypeId); + $this->infobox = sprintf(Lang::screenshot('displayOn'), Lang::typeName($this->destType), Type::getFileString($this->destType), $this->destTypeId); $this->extendGlobalIds($this->destType, $this->destTypeId); } @@ -240,7 +233,7 @@ class ScreenshotPage extends GenericPage private function handleThankyou() : void { $this->extraHTML = Lang::screenshot('thanks', 'contrib').'

'; - $this->extraHTML .= sprintf(Lang::screenshot('thanks', 'goBack'), Util::$typeStrings[$this->destType], $this->destTypeId)."

\n"; + $this->extraHTML .= sprintf(Lang::screenshot('thanks', 'goBack'), Type::getFileString($this->destType), $this->destTypeId)."

\n"; $this->extraHTML .= ''.Lang::screenshot('thanks', 'note').''; } diff --git a/pages/search.php b/pages/search.php index b42868b1..97243867 100644 --- a/pages/search.php +++ b/pages/search.php @@ -96,9 +96,9 @@ class SearchPage extends GenericPage if ($this->_get['slots']) $this->searchMask |= SEARCH_TYPE_JSON | 0x40; - else if ($this->_get['type'] == TYPE_ITEMSET) + else if ($this->_get['type'] == Type::ITEMSET) $this->searchMask |= SEARCH_TYPE_JSON | 0x60; - else if ($this->_get['type'] == TYPE_ITEM) + else if ($this->_get['type'] == Type::ITEM) $this->searchMask |= SEARCH_TYPE_JSON | 0x40; } else if ($this->_get['opensearch']) @@ -187,7 +187,7 @@ class SearchPage extends GenericPage if ($foundTotal == 1) // only one match -> redirect to find { $tab = array_pop($this->lvTabs); - $type = Util::$typeStrings[$tab[3][0]]; + $type = Type::getFileString($tab[3][0]); $typeId = array_pop($tab[1]['data'])['id']; header('Location: ?'.$type.'='.$typeId, true, 302); @@ -304,7 +304,7 @@ class SearchPage extends GenericPage $hasQ = is_numeric($data['name'][0]) || $data['name'][0] == '@'; $result[1][] = ($hasQ ? mb_substr($data['name'], 1) : $data['name']).$osInfo[1]; - $result[3][] = HOST_URL.'/?'.Util::$typeStrings[$osInfo[0]].'='.$data['id']; + $result[3][] = HOST_URL.'/?'.Type::getFileString($osInfo[0]).'='.$data['id']; $extra = [$osInfo[0], $data['id']]; // type, typeId @@ -381,7 +381,7 @@ class SearchPage extends GenericPage if ($data = $classes->getListviewData()) { $result['data'] = array_values($data); - $osInfo = [TYPE_CLASS, ' (Class)', $classes->getMatches(), []]; + $osInfo = [Type::CHR_CLASS, ' (Class)', $classes->getMatches(), []]; if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($classes->iterate() as $id => $__) @@ -407,7 +407,7 @@ class SearchPage extends GenericPage if ($data = $races->getListviewData()) { $result['data'] = array_values($data); - $osInfo = [TYPE_RACE, ' (Race)', $races->getMatches(), []]; + $osInfo = [Type::CHR_RACE, ' (Race)', $races->getMatches(), []]; if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($races->iterate() as $id => $__) @@ -433,7 +433,7 @@ class SearchPage extends GenericPage if ($data = $titles->getListviewData()) { $result['data'] = array_values($data); - $osInfo = [TYPE_TITLE, ' (Title)', $titles->getMatches(), []]; + $osInfo = [Type::TITLE, ' (Title)', $titles->getMatches(), []]; if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($titles->iterate() as $id => $__) @@ -468,7 +468,7 @@ class SearchPage extends GenericPage $this->extendGlobalData($wEvents->getJSGlobals()); $result['data'] = array_values($data); - $osInfo = [TYPE_WORLDEVENT, ' (World Event)', $wEvents->getMatches()]; + $osInfo = [Type::WORLDEVENT, ' (World Event)', $wEvents->getMatches()]; // as allways: dates are updated in postCache-step @@ -492,7 +492,7 @@ class SearchPage extends GenericPage if ($data = $money->getListviewData()) { $result['data'] = array_values($data); - $osInfo = [TYPE_CURRENCY, ' (Currency)', $money->getMatches()]; + $osInfo = [Type::CURRENCY, ' (Currency)', $money->getMatches()]; if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($money->iterate() as $id => $__) @@ -521,7 +521,7 @@ class SearchPage extends GenericPage $this->extendGlobalData($sets->getJSGlobals(GLOBALINFO_SELF)); $result['data'] = array_values($data); - $osInfo = [TYPE_ITEMSET, ' (Item Set)', $sets->getMatches()]; + $osInfo = [Type::ITEMSET, ' (Item Set)', $sets->getMatches()]; if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($sets->iterate() as $id => $__) @@ -591,7 +591,7 @@ class SearchPage extends GenericPage foreach ($data[$itemId]['subitems'] as &$si) $si['enchantment'] = implode(', ', $si['enchantment']); - $osInfo = [TYPE_ITEM, ' (Item)', $items->getMatches(), [], []]; + $osInfo = [Type::ITEM, ' (Item)', $items->getMatches(), [], []]; $result['data'] = array_values($data); if ($this->searchMask & SEARCH_TYPE_OPEN) @@ -653,7 +653,7 @@ class SearchPage extends GenericPage $vis[] = $multiClass > 1 ? 'classes' : 'singleclass'; - $osInfo = [TYPE_SPELL, ' (Ability)', $abilities->getMatches(), [], []]; + $osInfo = [Type::SPELL, ' (Ability)', $abilities->getMatches(), [], []]; $result = array( 'data' => array_values($data), 'id' => 'abilities', @@ -704,7 +704,7 @@ class SearchPage extends GenericPage if ($talents->hasSetFields(['reagent1'])) $vis[] = 'reagents'; - $osInfo = [TYPE_SPELL, ' (Talent)', $talents->getMatches(), [], []]; + $osInfo = [Type::SPELL, ' (Talent)', $talents->getMatches(), [], []]; $result = array( 'data' => array_values($data), 'id' => 'talents', @@ -751,7 +751,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($glyphs->getJSGlobals(GLOBALINFO_SELF)); - $osInfo = [TYPE_SPELL, ' (Glyph)', $glyphs->getMatches(), []]; + $osInfo = [Type::SPELL, ' (Glyph)', $glyphs->getMatches(), []]; $result = array( 'data' => array_values($data), 'id' => 'glyphs', @@ -793,7 +793,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($prof->getJSGlobals(GLOBALINFO_SELF)); - $osInfo = [TYPE_SPELL, ' (Proficiency)', $prof->getMatches(), []]; + $osInfo = [Type::SPELL, ' (Proficiency)', $prof->getMatches(), []]; $result = array( 'data' => array_values($data), 'id' => 'proficiencies', @@ -835,7 +835,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($prof->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $osInfo = [TYPE_SPELL, ' (Profession)', $prof->getMatches()]; + $osInfo = [Type::SPELL, ' (Profession)', $prof->getMatches()]; $result = array( 'data' => array_values($data), 'id' => 'professions', @@ -877,7 +877,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($vPets->getJSGlobals()); - $osInfo = [TYPE_SPELL, ' (Companion)', $vPets->getMatches(), []]; + $osInfo = [Type::SPELL, ' (Companion)', $vPets->getMatches(), []]; $result = array( 'data' => array_values($data), 'id' => 'companions', @@ -919,7 +919,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($mounts->getJSGlobals(GLOBALINFO_SELF)); - $osInfo = [TYPE_SPELL, ' (Mount)', $mounts->getMatches(), []]; + $osInfo = [Type::SPELL, ' (Mount)', $mounts->getMatches(), []]; $result = array( 'data' => array_values($data), 'id' => 'mounts', @@ -958,7 +958,7 @@ class SearchPage extends GenericPage if ($data = $npcs->getListviewData()) { - $osInfo = [TYPE_NPC, ' (NPC)', $npcs->getMatches()]; + $osInfo = [Type::NPC, ' (NPC)', $npcs->getMatches()]; $result = array( 'data' => array_values($data), 'id' => 'npcs', @@ -992,7 +992,7 @@ class SearchPage extends GenericPage if ($data = $quests->getListviewData()) { - $osInfo = [TYPE_QUEST, ' (Quest)', $quests->getMatches()]; + $osInfo = [Type::QUEST, ' (Quest)', $quests->getMatches()]; $result['data'] = array_values($data); if ($this->searchMask & SEARCH_TYPE_REGULAR) @@ -1028,7 +1028,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($acvs->getJSGlobals()); - $osInfo = [TYPE_ACHIEVEMENT, ' (Achievement)', $acvs->getMatches(), []]; + $osInfo = [Type::ACHIEVEMENT, ' (Achievement)', $acvs->getMatches(), []]; $result = array( 'data' => array_values($data), 'visibleCols' => ['category'] @@ -1068,7 +1068,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($stats->getJSGlobals(GLOBALINFO_SELF)); - $osInfo = [TYPE_ACHIEVEMENT, ' (Statistic)', $stats->getMatches()]; + $osInfo = [Type::ACHIEVEMENT, ' (Statistic)', $stats->getMatches()]; $result = array( 'data' => array_values($data), 'visibleCols' => ['category'], @@ -1104,7 +1104,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($zones->getJSGlobals()); - $osInfo = [TYPE_ZONE, ' (Zone)', $zones->getMatches()]; + $osInfo = [Type::ZONE, ' (Zone)', $zones->getMatches()]; $result['data'] = array_values($data); if ($zones->getMatches() > $this->maxResults) @@ -1129,7 +1129,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($objects->getJSGlobals()); - $osInfo = [TYPE_OBJECT, ' (Object)', $objects->getMatches()]; + $osInfo = [Type::OBJECT, ' (Object)', $objects->getMatches()]; $result['data'] = array_values($data); if ($objects->getMatches() > $this->maxResults) @@ -1156,7 +1156,7 @@ class SearchPage extends GenericPage if ($data = $factions->getListviewData()) { - $osInfo = [TYPE_FACTION, ' (Faction)', $factions->getMatches()]; + $osInfo = [Type::FACTION, ' (Faction)', $factions->getMatches()]; $result['data'] = array_values($data); if ($factions->getMatches() > $this->maxResults) @@ -1178,7 +1178,7 @@ class SearchPage extends GenericPage if ($data = $skills->getListviewData()) { - $osInfo = [TYPE_SKILL, ' (Skill)', $skills->getMatches(), []]; + $osInfo = [Type::SKILL, ' (Skill)', $skills->getMatches(), []]; $result['data'] = array_values($data); if ($this->searchMask & SEARCH_TYPE_OPEN) @@ -1204,7 +1204,7 @@ class SearchPage extends GenericPage if ($data = $pets->getListviewData()) { - $osInfo = [TYPE_PET, ' (Pet)', $pets->getMatches(), []]; + $osInfo = [Type::PET, ' (Pet)', $pets->getMatches(), []]; $result = array( 'data' => array_values($data), 'computeDataFunc' => '$_' @@ -1239,7 +1239,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($npcAbilities->getJSGlobals(GLOBALINFO_SELF)); - $osInfo = [TYPE_SPELL, ' (Spell)', $npcAbilities->getMatches(), []]; + $osInfo = [Type::SPELL, ' (Spell)', $npcAbilities->getMatches(), []]; $result = array( 'data' => array_values($data), 'id' => 'npc-abilities', @@ -1288,7 +1288,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($misc->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $osInfo = [TYPE_SPELL, ' (Spell)', $misc->getMatches(), []]; + $osInfo = [Type::SPELL, ' (Spell)', $misc->getMatches(), []]; $result = array( 'data' => array_values($data), 'name' => '$LANG.tab_uncategorizedspells', @@ -1324,7 +1324,7 @@ class SearchPage extends GenericPage if ($data = $emote->getListviewData()) { - $osInfo = [TYPE_EMOTE, ' (Emote)', $emote->getMatches()]; + $osInfo = [Type::EMOTE, ' (Emote)', $emote->getMatches()]; $result = array( 'data' => array_values($data), 'name' => Util::ucFirst(Lang::game('emotes')) @@ -1345,7 +1345,7 @@ class SearchPage extends GenericPage { $this->extendGlobalData($enchantment->getJSGlobals()); - $osInfo = [TYPE_ENCHANTMENT, ' (Enchantment)', $enchantment->getMatches()]; + $osInfo = [Type::ENCHANTMENT, ' (Enchantment)', $enchantment->getMatches()]; $result = array( 'data' => array_values($data), 'name' => Util::ucFirst(Lang::game('enchantments')) @@ -1379,7 +1379,7 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($sounds->getJSGlobals()); - $osInfo = [TYPE_SOUND, ' (Sound)', $sounds->getMatches()]; + $osInfo = [Type::SOUND, ' (Sound)', $sounds->getMatches()]; $result['data'] = array_values($data); if ($sounds->getMatches() > $this->maxResults) diff --git a/pages/skill.php b/pages/skill.php index 4322344d..92b2dcc2 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -10,7 +10,7 @@ class SkillPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_SKILL; + protected $type = Type::SKILL; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 14]; @@ -55,7 +55,7 @@ class SkillPage extends GenericPage if ($_ = $this->subject->getField('iconId')) { $infobox[] = Util::ucFirst(lang::game('icon')).Lang::main('colon').'[icondb='.$_.' name=true]'; - $this->extendGlobalIds(TYPE_ICON, $_); + $this->extendGlobalIds(Type::ICON, $_); } /****************/ diff --git a/pages/skills.php b/pages/skills.php index 5ecdf59d..d423a9f9 100644 --- a/pages/skills.php +++ b/pages/skills.php @@ -10,7 +10,7 @@ class SkillsPage extends GenericPage { use TrListPage; - protected $type = TYPE_SKILL; + protected $type = Type::SKILL; protected $tpl = 'list-page-generic'; protected $path = [0, 14]; protected $tabId = 0; diff --git a/pages/sound.php b/pages/sound.php index 5555d0e3..fb476401 100644 --- a/pages/sound.php +++ b/pages/sound.php @@ -10,7 +10,7 @@ class SoundPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_SOUND; + protected $type = Type::SOUND; protected $tpl = 'sound'; protected $path = [0, 19]; protected $tabId = 0; @@ -98,7 +98,7 @@ class SoundPage extends GenericPage BUTTON_WOWHEAD => true, BUTTON_PLAYLIST => true, BUTTON_LINKS => array( - 'type' => TYPE_SOUND, + 'type' => Type::SOUND, 'typeId' => $this->typeId, 'sound' => str_replace('\\', '\\\\', $fullpath) // escape for wow client ) @@ -274,8 +274,8 @@ class SoundPage extends GenericPage $creatureIds = DB::World()->selectCol('SELECT ct.CreatureID FROM creature_text ct LEFT JOIN broadcast_text bct ON bct.ID = ct.BroadCastTextId WHERE bct.SoundEntriesID = ?d OR ct.Sound = ?d', $this->typeId, $this->typeId); // can objects or areatrigger play sound...? - if ($goosp = SmartAI::getOwnerOfSoundPlayed($this->typeId, TYPE_NPC)) - $creatureIds = array_merge($creatureIds, $goosp[TYPE_NPC]); + if ($goosp = SmartAI::getOwnerOfSoundPlayed($this->typeId, Type::NPC)) + $creatureIds = array_merge($creatureIds, $goosp[Type::NPC]); // tab: NPC (dialogues...?, generic creature sound) // skipping (always empty): transforms, footsteps diff --git a/pages/sounds.php b/pages/sounds.php index 3656a919..ea7e382f 100644 --- a/pages/sounds.php +++ b/pages/sounds.php @@ -10,7 +10,7 @@ class SoundsPage extends GenericPage { use TrListPage; - protected $type = TYPE_SOUND; + protected $type = Type::SOUND; protected $tpl = 'sounds'; protected $path = [0, 19]; protected $tabId = 0; diff --git a/pages/spell.php b/pages/spell.php index e83a19af..195668cb 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -10,7 +10,7 @@ class SpellPage extends GenericPage { use TrDetailPage; - protected $type = TYPE_SPELL; + protected $type = Type::SPELL; protected $typeId = 0; protected $tpl = 'spell'; protected $path = [0, 1]; @@ -139,7 +139,7 @@ class SpellPage extends GenericPage BUTTON_WOWHEAD => true, BUTTON_LINKS => array( 'linkColor' => 'ff71d5ff', - 'linkId' => Util::$typeStrings[TYPE_SPELL].':'.$this->typeId, + 'linkId' => Type::getFileString(Type::SPELL).':'.$this->typeId, 'linkName' => $this->name, 'type' => $this->type, 'typeId' => $this->typeId @@ -165,7 +165,7 @@ class SpellPage extends GenericPage // races if ($_ = Lang::getRaceString($this->subject->getField('reqRaceMask'), $jsg, false)) { - $this->extendGlobalIds(TYPE_RACE, ...$jsg); + $this->extendGlobalIds(Type::CHR_RACE, ...$jsg); $t = count($jsg) == 1 ? Lang::game('race') : Lang::game('races'); $infobox[] = Util::ucFirst($t).Lang::main('colon').$_; } @@ -173,7 +173,7 @@ class SpellPage extends GenericPage // classes if ($_ = Lang::getClassString($this->subject->getField('reqClassMask'), $jsg, false)) { - $this->extendGlobalIds(TYPE_CLASS, ...$jsg); + $this->extendGlobalIds(Type::CHR_CLASS, ...$jsg); $t = count($jsg) == 1 ? Lang::game('class') : Lang::game('classes'); $infobox[] = Util::ucFirst($t).Lang::main('colon').$_; } @@ -235,7 +235,7 @@ class SpellPage extends GenericPage if ($_ = $this->subject->getField('iconId')) { $infobox[] = Util::ucFirst(lang::game('icon')).Lang::main('colon').'[icondb='.$_.' name=true]'; - $this->extendGlobalIds(TYPE_ICON, $_); + $this->extendGlobalIds(Type::ICON, $_); } // used in mode @@ -614,8 +614,8 @@ class SpellPage extends GenericPage ['onUseSpell', $this->subject->id], ['onSuccessSpell', $this->subject->id], ['auraSpell', $this->subject->id], ['triggeredSpell', $this->subject->id] ); - if (!empty($ubSAI[TYPE_OBJECT])) - $conditions[] = ['id', $ubSAI[TYPE_OBJECT]]; + if (!empty($ubSAI[Type::OBJECT])) + $conditions[] = ['id', $ubSAI[Type::OBJECT]]; $ubObjects = new GameObjectList($conditions); if (!$ubObjects->error) @@ -632,9 +632,9 @@ class SpellPage extends GenericPage // tab: used by - areatrigger if (User::isInGroup(U_GROUP_EMPLOYEE)) { - if (!empty($ubSAI[TYPE_AREATRIGGER])) + if (!empty($ubSAI[Type::AREATRIGGER])) { - $ubTriggers = new AreaTriggerList(array(['id', $ubSAI[TYPE_AREATRIGGER]])); + $ubTriggers = new AreaTriggerList(array(['id', $ubSAI[Type::AREATRIGGER]])); if (!$ubTriggers->error) { $this->lvTabs[] = ['areatrigger', array( @@ -689,7 +689,7 @@ class SpellPage extends GenericPage $lv[$bar] = $foo[$bar]; $lv[$bar]['percent'] = $extraItem['additionalCreateChance']; $lv[$bar]['condition'][0][$this->typeId][] = [[CND_SPELL, $extraItem['requiredSpecialization']]]; - $this->extendGlobalIds(TYPE_SPELL, $extraItem['requiredSpecialization']); + $this->extendGlobalIds(Type::SPELL, $extraItem['requiredSpecialization']); $extraCols[] = '$Listview.extraCols.condition'; if ($max = ($extraItem['additionalMaxNum'] - 1)) $lv[$bar]['stack'] = [1, $max]; @@ -849,8 +849,8 @@ class SpellPage extends GenericPage ['spell1', $this->typeId], ['spell2', $this->typeId], ['spell3', $this->typeId], ['spell4', $this->typeId], ['spell5', $this->typeId], ['spell6', $this->typeId], ['spell7', $this->typeId], ['spell8', $this->typeId] ); - if (!empty($ubSAI[TYPE_NPC])) - $conditions[] = ['id', $ubSAI[TYPE_NPC]]; + if (!empty($ubSAI[Type::NPC])) + $conditions[] = ['id', $ubSAI[Type::NPC]]; $ubCreature = new CreatureList($conditions); if (!$ubCreature->error) @@ -884,13 +884,13 @@ class SpellPage extends GenericPage $condition = []; if ($a['aura_spell']) { - $this->extendGlobalIds(TYPE_SPELL, abs($a['aura_spell'])); + $this->extendGlobalIds(Type::SPELL, abs($a['aura_spell'])); $condition[0][$this->typeId][] = [[$a['aura_spell'] > 0 ? CND_AURA : -CND_AURA, abs($a['aura_spell'])]]; } if ($a['quest_start']) // status for quests needs work { - $this->extendGlobalIds(TYPE_QUEST, $a['quest_start']); + $this->extendGlobalIds(Type::QUEST, $a['quest_start']); $group = []; for ($i = 0; $i < 7; $i++) { @@ -913,7 +913,7 @@ class SpellPage extends GenericPage if ($a['quest_end'] && $a['quest_end'] != $a['quest_start']) { - $this->extendGlobalIds(TYPE_QUEST, $a['quest_end']); + $this->extendGlobalIds(Type::QUEST, $a['quest_end']); $group = []; for ($i = 0; $i < 7; $i++) { @@ -941,7 +941,7 @@ class SpellPage extends GenericPage if ($a['racemask'] & (1 << $i)) $foo[] = $i + 1; - $this->extendGlobalIds(TYPE_RACE, ...$foo); + $this->extendGlobalIds(Type::CHR_RACE, ...$foo); $condition[0][$this->typeId][] = [[CND_RACE, $a['racemask']]]; } @@ -1246,19 +1246,19 @@ class SpellPage extends GenericPage if (!$item) return false; - $this->extendGlobalIds(TYPE_ITEM, $item['id']); + $this->extendGlobalIds(Type::ITEM, $item['id']); $_level++; $data = array( - 'type' => TYPE_ITEM, + 'type' => Type::ITEM, 'typeId' => $item['id'], - 'typeStr' => Util::$typeStrings[TYPE_ITEM], + 'typeStr' => Type::getFileString(Type::ITEM), 'quality' => $item['quality'], 'name' => Util::localizedString($item, 'name'), 'icon' => $item['iconString'], 'qty' => $_qty * $_mult, - 'path' => $_path.'.'.TYPE_ITEM.'-'.$item['id'], + 'path' => $_path.'.'.Type::ITEM.'-'.$item['id'], 'level' => $_level ); @@ -1299,16 +1299,16 @@ class SpellPage extends GenericPage if (in_array(-$sId, $alreadyUsed)) continue; - $this->extendGlobalIds(TYPE_SPELL, $sId); + $this->extendGlobalIds(Type::SPELL, $sId); $data = array( - 'type' => TYPE_SPELL, + 'type' => Type::SPELL, 'typeId' => $sId, - 'typeStr' => Util::$typeStrings[TYPE_SPELL], + 'typeStr' => Type::getFileString(Type::SPELL), 'name' => Util::localizedString($row, 'name'), 'icon' => $row['iconString'], 'qty' => $_qty, - 'path' => $_path.'.'.TYPE_SPELL.'-'.$sId, + 'path' => $_path.'.'.Type::SPELL.'-'.$sId, 'level' => $_level, ); @@ -1354,14 +1354,14 @@ class SpellPage extends GenericPage continue; $data = array( - 'type' => TYPE_ITEM, + 'type' => Type::ITEM, 'typeId' => $iId, - 'typeStr' => Util::$typeStrings[TYPE_ITEM], + 'typeStr' => Type::getFileString(Type::ITEM), 'quality' => $this->subject->relItems->getField('quality'), 'name' => $this->subject->relItems->getField('name', true), 'icon' => $this->subject->relItems->getField('iconString'), 'qty' => $reagents[$iId][1], - 'path' => TYPE_ITEM.'-'.$iId, // id of the html-element + 'path' => Type::ITEM.'-'.$iId, // id of the html-element 'level' => 0 // depths in array, used for indentation ); @@ -1702,7 +1702,7 @@ class SpellPage extends GenericPage case 112: // Summon Demon case 134: // Kill Credit2 if ($summon = $this->subject->getModelInfo($this->typeId, $i)) - $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $summon['displayId']]; + $redButtons[BUTTON_VIEW3D] = ['type' => Type::NPC, 'displayId' => $summon['displayId']]; $_ = Lang::game('npc').' #'.$effMV; if ($n = CreatureList::getName($effMV)) @@ -1754,7 +1754,7 @@ class SpellPage extends GenericPage case 106: // Summon Object (slot 3) case 107: // Summon Object (slot 4) if ($summon = $this->subject->getModelInfo($this->typeId, $i)) - $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_OBJECT, 'displayId' => $summon['displayId']]; + $redButtons[BUTTON_VIEW3D] = ['type' => Type::OBJECT, 'displayId' => $summon['displayId']]; $_ = Util::ucFirst(Lang::game('object')).' #'.$effMV; if ($n = GameobjectList::getName($effMV)) @@ -1920,7 +1920,7 @@ class SpellPage extends GenericPage if ($st = $this->subject->getModelInfo($this->typeId, $i)) { $redButtons[BUTTON_VIEW3D] = array( - 'type' => TYPE_NPC, + 'type' => Type::NPC, 'displayId' => $st['displayId'] ); @@ -2093,7 +2093,7 @@ class SpellPage extends GenericPage case 56: // Transform if ($transform = $this->subject->getModelInfo($this->typeId, $i)) { - $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $transform['displayId']]; + $redButtons[BUTTON_VIEW3D] = ['type' => Type::NPC, 'displayId' => $transform['displayId']]; $bar = $transform['typeId'] ? ' ('.$transform['displayName'].')' : ' (#0)'; } else @@ -2115,7 +2115,7 @@ class SpellPage extends GenericPage { if ($x = $so['spellId'.$j]) { - $this->extendGlobalData([TYPE_SPELL => [$x]]); + $this->extendGlobalData([Type::SPELL => [$x]]); $buff[] = '[spell='.$x.']'; } } diff --git a/pages/spells.php b/pages/spells.php index 95225ce3..6e6073dd 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -10,7 +10,7 @@ class SpellsPage extends GenericPage { use TrListPage; - protected $type = TYPE_SPELL; + protected $type = Type::SPELL; protected $tpl = 'spells'; protected $path = [0, 1]; protected $tabId = 0; diff --git a/pages/title.php b/pages/title.php index b12804a9..a363cc2d 100644 --- a/pages/title.php +++ b/pages/title.php @@ -10,7 +10,7 @@ class TitlePage extends GenericPage { use TrDetailPage; - protected $type = TYPE_TITLE; + protected $type = Type::TITLE; protected $typeId = 0; protected $tpl = 'detail-page-generic'; protected $path = [0, 10]; @@ -63,7 +63,7 @@ class TitlePage extends GenericPage if ($eId = $this->subject->getField('eventId')) { - $this->extendGlobalIds(TYPE_WORLDEVENT, $eId); + $this->extendGlobalIds(Type::WORLDEVENT, $eId); $infobox[] = Lang::game('eventShort').Lang::main('colon').'[event='.$eId.']'; } diff --git a/pages/titles.php b/pages/titles.php index e0904b24..fb0ce68f 100644 --- a/pages/titles.php +++ b/pages/titles.php @@ -10,7 +10,7 @@ class TitlesPage extends GenericPage { use TrListPage; - protected $type = TYPE_TITLE; + protected $type = Type::TITLE; protected $tpl = 'list-page-generic'; protected $path = [0, 10]; protected $tabId = 0; diff --git a/pages/utility.php b/pages/utility.php index 8f639859..f231fc5d 100644 --- a/pages/utility.php +++ b/pages/utility.php @@ -69,10 +69,10 @@ class UtilityPage extends GenericPage switch ($this->page) { case 'random': - $type = array_rand(array_filter(Util::$typeClasses)); - $typeId = (new Util::$typeClasses[$type](null))->getRandomId(); + $type = array_rand(Type::getClassesFor(Type::FLAG_RANDOM_SEARCHABLE)); + $typeId = (Type::newList($type, null))?->getRandomId(); - header('Location: ?'.Util::$typeStrings[$type].'='.$typeId, true, 302); + header('Location: ?'.Type::getFileString($type).'='.$typeId, true, 302); die(); case 'latest-comments': // rss $data = CommunityContent::getCommentPreviews(dateFmt: false); @@ -83,7 +83,7 @@ class UtilityPage extends GenericPage { // todo (low): preview should be html-formated $this->feedData[] = array( - 'title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])).Lang::main('colon').htmlentities($d['subject'])], + 'title' => [true, [], Lang::typeName($d['type']).Lang::main('colon').htmlentities($d['subject'])], 'link' => [false, [], HOST_URL.'/?go-to-comment&id='.$d['id']], 'description' => [true, [], htmlentities($d['preview'])."

".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true)], 'pubDate' => [false, [], date(DATE_RSS, $d['date'])], @@ -103,19 +103,19 @@ class UtilityPage extends GenericPage { foreach ($data as $d) { - $desc = ''; + $desc = ''; if ($d['caption']) $desc .= '
'.$d['caption']; $desc .= "

".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true); // enclosure/length => filesize('static/uploads/screenshots/thumb/'.$d['id'].'.jpg') .. always set to this placeholder value though $this->feedData[] = array( - 'title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])).Lang::main('colon').htmlentities($d['subject'])], - 'link' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#screenshots:id='.$d['id']], + 'title' => [true, [], Lang::typeName($d['type']).Lang::main('colon').htmlentities($d['subject'])], + 'link' => [false, [], HOST_URL.'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#screenshots:id='.$d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, $d['date'])], 'enclosure' => [false, ['url' => STATIC_URL.'/uploads/screenshots/thumb/'.$d['id'].'.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], - 'guid' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#screenshots:id='.$d['id']], + 'guid' => [false, [], HOST_URL.'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#screenshots:id='.$d['id']], // 'domain' => [false, [], live|ptr] ); } @@ -131,19 +131,19 @@ class UtilityPage extends GenericPage { foreach ($data as $d) { - $desc = ''; + $desc = ''; if ($d['caption']) $desc .= '
'.$d['caption']; $desc .= "

".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true); // is enclosure/length .. is this even relevant..? $this->feedData[] = array( - 'title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])).Lang::main('colon').htmlentities($d['subject'])], - 'link' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#videos:id='.$d['id']], + 'title' => [true, [], Lang::typeName($d['type']).Lang::main('colon').htmlentities($d['subject'])], + 'link' => [false, [], HOST_URL.'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#videos:id='.$d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, $d['date'])], 'enclosure' => [false, ['url' => '//i3.ytimg.com/vi/'.$d['videoId'].'/default.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], - 'guid' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#videos:id='.$d['id']], + 'guid' => [false, [], HOST_URL.'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#videos:id='.$d['id']], // 'domain' => [false, [], live|ptr] ); } @@ -167,14 +167,9 @@ class UtilityPage extends GenericPage if (!User::isInGroup(U_GROUP_EMPLOYEE)) $cnd[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; - foreach (Util::$typeClasses as $type => $classStr) + + foreach (Type::getClassesFor(Type::FLAG_NONE, 'contribute', CONTRIBUTE_SS) as $type => $classStr) { - if (!$classStr) - continue; - - if (!($classStr::$contribute & CONTRIBUTE_SS)) - continue; - $typeObj = new $classStr($cnd); if (!$typeObj->error) { @@ -192,11 +187,8 @@ class UtilityPage extends GenericPage 'sort' => ['-ncomments'] ); - foreach (Util::$typeClasses as $type => $classStr) + foreach (Type::getClassesFor() as $type => $classStr) { - if (!$classStr) - continue; - $comments = DB::Aowow()->selectCol(' SELECT `typeId` AS ARRAY_KEY, count(1) FROM ?_comments WHERE `replyTo` = 0 AND (`flags` & ?d) = 0 AND `type`= ?d AND `date` > (UNIX_TIMESTAMP() - ?d) @@ -219,9 +211,9 @@ class UtilityPage extends GenericPage foreach ($data as $typeId => &$d) { $this->feedData[] = array( - 'title' => [true, [], htmlentities(Util::$typeStrings[$type] == 'item' ? mb_substr($d['name'], 1) : $d['name'])], - 'type' => [false, [], Util::$typeStrings[$type]], - 'link' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$type].'='.$d['id']], + 'title' => [true, [], htmlentities(Type::getFileString($type) == 'item' ? mb_substr($d['name'], 1) : $d['name'])], + 'type' => [false, [], Type::getFileString($type)], + 'link' => [false, [], HOST_URL.'/?'.Type::getFileString($type).'='.$d['id']], 'ncomments' => [false, [], $comments[$typeId]] ); } diff --git a/pages/zone.php b/pages/zone.php index cf4cbb60..22e06102 100644 --- a/pages/zone.php +++ b/pages/zone.php @@ -12,7 +12,7 @@ class ZonePage extends GenericPage protected $path = [0, 6]; protected $tabId = 0; - protected $type = TYPE_ZONE; + protected $type = Type::ZONE; protected $tpl = 'detail-page-generic'; protected $js = [[JS_FILE, 'ShowOnMap.js']]; @@ -100,10 +100,10 @@ class ZonePage extends GenericPage $this->extendGlobalIds($type, ...array_map('abs', $ids)); foreach ($ids as $id) { - if ($type == TYPE_ITEM) + if ($type == Type::ITEM) $infobox[] = Lang::zone('key', (int)($id < 0)).Lang::main('colon').'[item='.abs($id).']'; else - $infobox[] = Lang::zone('attunement', (int)($id < 0)).Lang::main('colon').'['.Util::$typeStrings[$type].'='.abs($id).']'; + $infobox[] = Lang::zone('attunement', (int)($id < 0)).Lang::main('colon').'['.Type::getFileString($type).'='.abs($id).']'; } } } @@ -111,7 +111,7 @@ class ZonePage extends GenericPage // Instances if ($_ = DB::Aowow()->selectCol('SELECT id FROM ?_zones WHERE parentAreaId = ?d AND (flags & ?d) = 0', $this->typeId, CUSTOM_EXCLUDE_FOR_LISTVIEW)) { - $this->extendGlobalIds(TYPE_ZONE, ...$_); + $this->extendGlobalIds(Type::ZONE, ...$_); $infobox[] = Lang::maps('Instances').Lang::main('colon')."\n[zone=".implode("], \n[zone=", $_).']'; } @@ -165,13 +165,13 @@ class ZonePage extends GenericPage if ($_ = $this->subject->getField('parentArea')) { $this->extraText = sprintf(Lang::zone('zonePartOf'), $_); - $this->extendGlobalIds(TYPE_ZONE, $_); + $this->extendGlobalIds(Type::ZONE, $_); } // we cannot fetch spawns via lists. lists are grouped by entry - $oSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, TYPE_OBJECT); - $cSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, TYPE_NPC); - $aSpawns = User::isInGroup(U_GROUP_STAFF) ? DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, TYPE_AREATRIGGER) : []; + $oSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::OBJECT); + $cSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::NPC); + $aSpawns = User::isInGroup(U_GROUP_STAFF) ? DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::AREATRIGGER) : []; $conditions = [CFG_SQL_LIMIT_NONE, ['s.areaId', $this->typeId]]; if (!User::isInGroup(U_GROUP_STAFF)) @@ -237,7 +237,7 @@ class ZonePage extends GenericPage 'coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, - 'type' => TYPE_OBJECT, + 'type' => Type::OBJECT, 'id' => $tpl['id'] ); @@ -249,18 +249,18 @@ class ZonePage extends GenericPage if ($tpl['startsQuests']) { - $started = new QuestList(array(['qse.method', 1, '&'], ['qse.type', TYPE_OBJECT], ['qse.typeId', $tpl['id']])); + $started = new QuestList(array(['qse.method', 1, '&'], ['qse.type', Type::OBJECT], ['qse.typeId', $tpl['id']])); if ($started->error) continue; // store data for misc tabs foreach ($started->getListviewData() as $id => $data) { - if (!empty($started->rewards[$id][TYPE_ITEM])) - $rewardsLV = array_merge($rewardsLV, array_keys($started->rewards[$id][TYPE_ITEM])); + if (!empty($started->rewards[$id][Type::ITEM])) + $rewardsLV = array_merge($rewardsLV, array_keys($started->rewards[$id][Type::ITEM])); - if (!empty($started->choices[$id][TYPE_ITEM])) - $rewardsLV = array_merge($rewardsLV, array_keys($started->choices[$id][TYPE_ITEM])); + if (!empty($started->choices[$id][Type::ITEM])) + $rewardsLV = array_merge($rewardsLV, array_keys($started->choices[$id][Type::ITEM])); $questsLV[$id] = $data; } @@ -272,7 +272,7 @@ class ZonePage extends GenericPage 'coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, - 'type' => TYPE_OBJECT, + 'type' => Type::OBJECT, 'id' => $tpl['id'], 'side' => (($tpl['A'] < 0 ? 0 : 0x1) | ($tpl['H'] < 0 ? 0 : 0x2)), 'quests' => array_values($_) @@ -283,7 +283,7 @@ class ZonePage extends GenericPage 'coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, - 'type' => TYPE_OBJECT, + 'type' => Type::OBJECT, 'id' => $tpl['id'], 'side' => (($tpl['A'] < 0 ? 0 : 0x1) | ($tpl['H'] < 0 ? 0 : 0x2)), 'quests' => array_values($_) @@ -337,7 +337,7 @@ class ZonePage extends GenericPage 'coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, - 'type' => TYPE_NPC, + 'type' => Type::NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'] ?: 1, // no neutral (0) setting 'reactalliance' => $tpl['A'] ?: 1, @@ -346,18 +346,18 @@ class ZonePage extends GenericPage if ($tpl['startsQuests']) { - $started = new QuestList(array(['qse.method', 1, '&'], ['qse.type', TYPE_NPC], ['qse.typeId', $tpl['id']])); + $started = new QuestList(array(['qse.method', 1, '&'], ['qse.type', Type::NPC], ['qse.typeId', $tpl['id']])); if ($started->error) continue; // store data for misc tabs foreach ($started->getListviewData() as $id => $data) { - if (!empty($started->rewards[$id][TYPE_ITEM])) - $rewardsLV = array_merge($rewardsLV, array_keys($started->rewards[$id][TYPE_ITEM])); + if (!empty($started->rewards[$id][Type::ITEM])) + $rewardsLV = array_merge($rewardsLV, array_keys($started->rewards[$id][Type::ITEM])); - if (!empty($started->choices[$id][TYPE_ITEM])) - $rewardsLV = array_merge($rewardsLV, array_keys($started->choices[$id][TYPE_ITEM])); + if (!empty($started->choices[$id][Type::ITEM])) + $rewardsLV = array_merge($rewardsLV, array_keys($started->choices[$id][Type::ITEM])); $questsLV[$id] = $data; } @@ -369,7 +369,7 @@ class ZonePage extends GenericPage 'coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, - 'type' => TYPE_NPC, + 'type' => Type::NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'], 'reactalliance' => $tpl['A'], @@ -382,7 +382,7 @@ class ZonePage extends GenericPage 'coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, - 'type' => TYPE_NPC, + 'type' => Type::NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'], 'reactalliance' => $tpl['A'], @@ -402,7 +402,7 @@ class ZonePage extends GenericPage 'coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => Util::localizedString($tpl, 'name', true, true), - 'type' => TYPE_AREATRIGGER, + 'type' => Type::AREATRIGGER, 'id' => $spawn['typeId'], 'description' => 'Type: '.Lang::areatrigger('types', $tpl['type']) )); @@ -550,9 +550,9 @@ class ZonePage extends GenericPage SELECT qse.typeId AS ARRAY_KEY, moreType, moreTypeId, moreZoneId FROM ?_quests_startend qse JOIN ?_source src ON src.type = qse.type AND src.typeId = qse.typeId WHERE src.src2 IS NOT NULL AND qse.type = ?d AND (moreZoneId = ?d OR (moreType = ?d AND moreTypeId IN (?a)) OR (moreType = ?d AND moreTypeId IN (?a)))', - TYPE_ITEM, $this->typeId, - TYPE_NPC, array_unique(array_column($cSpawns, 'typeId')) ?: [0], - TYPE_OBJECT, array_unique(array_column($oSpawns, 'typeId')) ?: [0] + Type::ITEM, $this->typeId, + Type::NPC, array_unique(array_column($cSpawns, 'typeId')) ?: [0], + Type::OBJECT, array_unique(array_column($oSpawns, 'typeId')) ?: [0] ); if ($questStartItem) @@ -635,13 +635,13 @@ class ZonePage extends GenericPage $condition = []; if ($a['aura_spell']) { - $this->extendGlobalIds(TYPE_SPELL, abs($a['aura_spell'])); + $this->extendGlobalIds(Type::SPELL, abs($a['aura_spell'])); $condition[0][$this->typeId][] = [[$a['aura_spell'] > 0 ? CND_AURA : -CND_AURA, abs($a['aura_spell'])]]; } if ($a['quest_start']) // status for quests needs work { - $this->extendGlobalIds(TYPE_QUEST, $a['quest_start']); + $this->extendGlobalIds(Type::QUEST, $a['quest_start']); $group = []; for ($i = 0; $i < 7; $i++) { @@ -664,7 +664,7 @@ class ZonePage extends GenericPage if ($a['quest_end'] && $a['quest_end'] != $a['quest_start']) { - $this->extendGlobalIds(TYPE_QUEST, $a['quest_end']); + $this->extendGlobalIds(Type::QUEST, $a['quest_end']); $group = []; for ($i = 0; $i < 7; $i++) { @@ -692,7 +692,7 @@ class ZonePage extends GenericPage if ($a['racemask'] & (1 << $i)) $foo[] = $i + 1; - $this->extendGlobalIds(TYPE_RACE, ...$foo); + $this->extendGlobalIds(Type::CHR_RACE, ...$foo); $condition[0][$this->typeId][] = [[CND_RACE, $a['racemask']]]; } @@ -754,7 +754,7 @@ class ZonePage extends GenericPage x.soundId, x.worldStateId, x.worldStateValue ', $areaIds, $areaIds, $areaIds, $areaIds, $areaIds); - if ($sSpawns = DB::Aowow()->selectCol('SELECT typeId FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, TYPE_SOUND)) + if ($sSpawns = DB::Aowow()->selectCol('SELECT typeId FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::SOUND)) $soundIds = array_merge($soundIds, $sSpawns); if ($zoneMusic) diff --git a/pages/zones.php b/pages/zones.php index e1d59aa1..47286f99 100644 --- a/pages/zones.php +++ b/pages/zones.php @@ -10,7 +10,7 @@ class ZonesPage extends GenericPage { use TrListPage; - protected $type = TYPE_ZONE; + protected $type = Type::ZONE; protected $tpl = 'list-page-generic'; protected $path = [0, 6]; protected $tabId = 0; diff --git a/setup/tools/filegen/pets.func.php b/setup/tools/filegen/pets.func.php index 371511df..ee2bb476 100644 --- a/setup/tools/filegen/pets.func.php +++ b/setup/tools/filegen/pets.func.php @@ -67,7 +67,7 @@ if (!CLI) // get locations // again: caching will save you time and nerves if (!isset($locations[$pet['id']])) - $locations[$pet['id']] = DB::Aowow()->SelectCol('SELECT DISTINCT areaId FROM ?_spawns WHERE type = ?d AND typeId = ?d', TYPE_NPC, $pet['id']); + $locations[$pet['id']] = DB::Aowow()->SelectCol('SELECT DISTINCT areaId FROM ?_spawns WHERE type = ?d AND typeId = ?d', Type::NPC, $pet['id']); $petsOut[$pet['id']] = array( 'id' => $pet['id'], diff --git a/setup/tools/filegen/profiler.func.php b/setup/tools/filegen/profiler.func.php index 088eb152..5ca1d526 100644 --- a/setup/tools/filegen/profiler.func.php +++ b/setup/tools/filegen/profiler.func.php @@ -52,19 +52,19 @@ if (!CLI) switch ($questz->getField('reqSkillId')) { case 356: - $exAdd(TYPE_QUEST, $id, PR_EXCLUDE_GROUP_REQ_FISHING); + $exAdd(Type::QUEST, $id, PR_EXCLUDE_GROUP_REQ_FISHING); break; case 202: - $exAdd(TYPE_QUEST, $id, PR_EXCLUDE_GROUP_REQ_ENGINEERING); + $exAdd(Type::QUEST, $id, PR_EXCLUDE_GROUP_REQ_ENGINEERING); break; case 197: - $exAdd(TYPE_QUEST, $id, PR_EXCLUDE_GROUP_REQ_TAILORING); + $exAdd(Type::QUEST, $id, PR_EXCLUDE_GROUP_REQ_TAILORING); break; } } $_ = []; - $currencies = array_column($questz->rewards, TYPE_CURRENCY); + $currencies = array_column($questz->rewards, Type::CURRENCY); foreach ($currencies as $curr) foreach ($curr as $cId => $qty) $_[] = $cId; @@ -110,7 +110,7 @@ if (!CLI) // get titles for exclusion foreach ($titlez->iterate() as $id => $__) if (empty($titlez->sources[$id][4]) && empty($titlez->sources[$id][12])) - $exAdd(TYPE_TITLE, $id, PR_EXCLUDE_GROUP_UNAVAILABLE); + $exAdd(Type::TITLE, $id, PR_EXCLUDE_GROUP_UNAVAILABLE); foreach (CLISetup::$localeIds as $l) { @@ -159,9 +159,9 @@ if (!CLI) foreach ($conditionSet as $mount => $skill) { if ($skill == 202) - $exAdd(TYPE_SPELL, $mount, PR_EXCLUDE_GROUP_REQ_ENGINEERING); + $exAdd(Type::SPELL, $mount, PR_EXCLUDE_GROUP_REQ_ENGINEERING); else if ($skill == 197) - $exAdd(TYPE_SPELL, $mount, PR_EXCLUDE_GROUP_REQ_TAILORING); + $exAdd(Type::SPELL, $mount, PR_EXCLUDE_GROUP_REQ_TAILORING); } foreach (CLISetup::$localeIds as $l) diff --git a/setup/tools/sqlgen/achievement.func.php b/setup/tools/sqlgen/achievement.func.php index 87196b30..829259a4 100644 --- a/setup/tools/sqlgen/achievement.func.php +++ b/setup/tools/sqlgen/achievement.func.php @@ -123,7 +123,7 @@ SqlGen::register(new class extends SetupScript if ($criteria = DB::World()->selectCol('SELECT entry FROM disables WHERE sourceType = 4')) DB::Aowow()->query('UPDATE aowow_achievement a JOIN aowow_achievementcriteria ac ON a.id = ac.refAchievementId SET a.cuFlags = ?d WHERE ac.id IN (?a)', CUSTOM_DISABLED, $criteria); - $this->reapplyCCFlags('achievement', TYPE_ACHIEVEMENT); + $this->reapplyCCFlags('achievement', Type::ACHIEVEMENT); return true; } diff --git a/setup/tools/sqlgen/areatrigger.func.php b/setup/tools/sqlgen/areatrigger.func.php index cc0e3a0e..2288bb20 100644 --- a/setup/tools/sqlgen/areatrigger.func.php +++ b/setup/tools/sqlgen/areatrigger.func.php @@ -80,7 +80,7 @@ SqlGen::register(new class extends SetupScript foreach ($addData as $id => $ad) DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $ad, $id); - $this->reapplyCCFlags('areatrigger', TYPE_AREATRIGGER); + $this->reapplyCCFlags('areatrigger', Type::AREATRIGGER); return true; } diff --git a/setup/tools/sqlgen/classes.func.php b/setup/tools/sqlgen/classes.func.php index 2675c73f..7860618f 100644 --- a/setup/tools/sqlgen/classes.func.php +++ b/setup/tools/sqlgen/classes.func.php @@ -37,7 +37,7 @@ SqlGen::register(new class extends SetupScript foreach ($classes as $cl) DB::Aowow()->query('REPLACE INTO ?_classes (?#) VALUES (?a)', array_keys($cl), array_values($cl)); - $this->reapplyCCFlags('classes', TYPE_CLASS); + $this->reapplyCCFlags('classes', Type::CHR_CLASS); return true; } diff --git a/setup/tools/sqlgen/creature.func.php b/setup/tools/sqlgen/creature.func.php index 8d322290..ac216555 100644 --- a/setup/tools/sqlgen/creature.func.php +++ b/setup/tools/sqlgen/creature.func.php @@ -182,7 +182,7 @@ SqlGen::register(new class extends SetupScript // apply cuFlag: exCludeFromListview [for nameparts indicating internal usage] DB::Aowow()->query('UPDATE ?_creature SET cuFlags = cuFlags | ?d WHERE name_loc0 LIKE "%[%" OR name_loc0 LIKE "%(%" OR name_loc0 LIKE "%visual%" OR name_loc0 LIKE "%trigger%" OR name_loc0 LIKE "%credit%" OR name_loc0 LIKE "%marker%"', CUSTOM_EXCLUDE_FOR_LISTVIEW); - $this->reapplyCCFlags('creature', TYPE_NPC); + $this->reapplyCCFlags('creature', Type::NPC); return true; } diff --git a/setup/tools/sqlgen/currencies.func.php b/setup/tools/sqlgen/currencies.func.php index 3ccfbeb4..2343ed0a 100644 --- a/setup/tools/sqlgen/currencies.func.php +++ b/setup/tools/sqlgen/currencies.func.php @@ -75,7 +75,7 @@ SqlGen::register(new class extends SetupScript c.itemId = ?d ', $iconId, $itemId); - $this->reapplyCCFlags('currencies', TYPE_CURRENCY); + $this->reapplyCCFlags('currencies', Type::CURRENCY); return true; } diff --git a/setup/tools/sqlgen/emotes.func.php b/setup/tools/sqlgen/emotes.func.php index fdfa427f..6c6ca436 100644 --- a/setup/tools/sqlgen/emotes.func.php +++ b/setup/tools/sqlgen/emotes.func.php @@ -95,7 +95,7 @@ SqlGen::register(new class extends SetupScript } } - $this->reapplyCCFlags('emotes', TYPE_EMOTE); + $this->reapplyCCFlags('emotes', Type::EMOTE); return $allOK; } diff --git a/setup/tools/sqlgen/events.func.php b/setup/tools/sqlgen/events.func.php index 57c19b01..5c618983 100644 --- a/setup/tools/sqlgen/events.func.php +++ b/setup/tools/sqlgen/events.func.php @@ -42,7 +42,7 @@ SqlGen::register(new class extends SetupScript foreach ($events as $e) DB::Aowow()->query('REPLACE INTO ?_events VALUES (?a)', array_values($e)); - $this->reapplyCCFlags('events', TYPE_WORLDEVENT); + $this->reapplyCCFlags('events', Type::WORLDEVENT); return true; } diff --git a/setup/tools/sqlgen/factions.func.php b/setup/tools/sqlgen/factions.func.php index 890244db..05c7671c 100644 --- a/setup/tools/sqlgen/factions.func.php +++ b/setup/tools/sqlgen/factions.func.php @@ -96,7 +96,7 @@ SqlGen::register(new class extends SetupScript foreach ($pairs as $p) DB::Aowow()->query($recursiveUpdateQuery, $p[0], $p[1], $p[0]); - $this->reapplyCCFlags('factions', TYPE_FACTION); + $this->reapplyCCFlags('factions', Type::FACTION); return true; } diff --git a/setup/tools/sqlgen/icons.func.php b/setup/tools/sqlgen/icons.func.php index 70444489..17becb4c 100644 --- a/setup/tools/sqlgen/icons.func.php +++ b/setup/tools/sqlgen/icons.func.php @@ -34,7 +34,7 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query($baseQuery); - $this->reapplyCCFlags('icons', TYPE_ICON); + $this->reapplyCCFlags('icons', Type::ICON); return true; } diff --git a/setup/tools/sqlgen/item_stats.func.php b/setup/tools/sqlgen/item_stats.func.php index ba2b53a8..94fece83 100644 --- a/setup/tools/sqlgen/item_stats.func.php +++ b/setup/tools/sqlgen/item_stats.func.php @@ -102,7 +102,7 @@ class ItemStatSetup extends ItemList // collect data and write to DB foreach ($this->iterate() as $__) { - $updateFields = ['type' => TYPE_ITEM, 'typeId' => $this->id]; + $updateFields = ['type' => Type::ITEM, 'typeId' => $this->id]; foreach (@$this->json[$this->id] as $k => $v) { @@ -228,7 +228,7 @@ SqlGen::register(new class extends SetupScript Util::arraySumByKey($result[$eId], [$str => $val]); } - $updateCols = ['type' => TYPE_ENCHANTMENT, 'typeId' => $eId]; + $updateCols = ['type' => Type::ENCHANTMENT, 'typeId' => $eId]; foreach ($result[$eId] as $k => $v) { if (!in_array($k, $statCols) || !$v || $k == 'id') diff --git a/setup/tools/sqlgen/itemenchantment.func.php b/setup/tools/sqlgen/itemenchantment.func.php index 85236e10..ef8870af 100644 --- a/setup/tools/sqlgen/itemenchantment.func.php +++ b/setup/tools/sqlgen/itemenchantment.func.php @@ -34,7 +34,7 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query('UPDATE ?_itemenchantment SET cuFlags = ?d WHERE type1 = 0 AND type2 = 0 AND type3 = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW); DB::Aowow()->query('UPDATE ?_itemenchantment SET cuFlags = ?d WHERE name_loc0 LIKE "%test%"', CUSTOM_EXCLUDE_FOR_LISTVIEW); - $this->reapplyCCFlags('itemenchantment', TYPE_ENCHANTMENT); + $this->reapplyCCFlags('itemenchantment', Type::ENCHANTMENT); return true; } diff --git a/setup/tools/sqlgen/items.func.php b/setup/tools/sqlgen/items.func.php index 862d1047..ba98c1ad 100644 --- a/setup/tools/sqlgen/items.func.php +++ b/setup/tools/sqlgen/items.func.php @@ -243,7 +243,7 @@ SqlGen::register(new class extends SetupScript WHERE durability > 0 AND ((classBak = 4 AND subClassBak IN (1, 2, 3, 4, 6)) OR (classBak = 2 AND subClassBak <> 9))'); - $this->reapplyCCFlags('items', TYPE_ITEM); + $this->reapplyCCFlags('items', Type::ITEM); return true; } diff --git a/setup/tools/sqlgen/itemset.func.php b/setup/tools/sqlgen/itemset.func.php index 360d1152..0b16d1fe 100644 --- a/setup/tools/sqlgen/itemset.func.php +++ b/setup/tools/sqlgen/itemset.func.php @@ -318,7 +318,7 @@ SqlGen::register(new class extends SetupScript } } - $this->reapplyCCFlags('itemset', TYPE_ITEMSET); + $this->reapplyCCFlags('itemset', Type::ITEMSET); return true; } diff --git a/setup/tools/sqlgen/objects.func.php b/setup/tools/sqlgen/objects.func.php index bc3e458d..fd17074a 100644 --- a/setup/tools/sqlgen/objects.func.php +++ b/setup/tools/sqlgen/objects.func.php @@ -120,7 +120,7 @@ SqlGen::register(new class extends SetupScript // apply typeCat and reqSkill depending on locks DB::Aowow()->query($updateQuery, $ids ?: DBSIMPLE_SKIP); - $this->reapplyCCFlags('objects', TYPE_OBJECT); + $this->reapplyCCFlags('objects', Type::OBJECT); return true; } diff --git a/setup/tools/sqlgen/pet.func.php b/setup/tools/sqlgen/pet.func.php index 412aced6..691ec7ca 100644 --- a/setup/tools/sqlgen/pet.func.php +++ b/setup/tools/sqlgen/pet.func.php @@ -119,7 +119,7 @@ SqlGen::register(new class extends SetupScript foreach ($res as $pId => $row) DB::Aowow()->query('UPDATE ?_pet SET ?a WHERE id = ?d', $row, $pId); - $this->reapplyCCFlags('pet', TYPE_PET); + $this->reapplyCCFlags('pet', Type::PET); return true; } diff --git a/setup/tools/sqlgen/quests.func.php b/setup/tools/sqlgen/quests.func.php index 12bf49ee..da6103d1 100644 --- a/setup/tools/sqlgen/quests.func.php +++ b/setup/tools/sqlgen/quests.func.php @@ -260,7 +260,7 @@ SqlGen::register(new class extends SetupScript // dungeon quests to Misc/Dungeon Finder DB::Aowow()->query('UPDATE ?_quests SET zoneOrSort = ?d WHERE (specialFlags & ?d OR id IN (?a)){ AND id IN (?a)}', -1010, QUEST_FLAG_SPECIAL_DUNGEON_FINDER, [24789, 24791, 24923], $ids ?: DBSIMPLE_SKIP); - $this->reapplyCCFlags('quests', TYPE_QUEST); + $this->reapplyCCFlags('quests', Type::QUEST); return true; } diff --git a/setup/tools/sqlgen/races.func.php b/setup/tools/sqlgen/races.func.php index d8e8a1d6..e299d8e4 100644 --- a/setup/tools/sqlgen/races.func.php +++ b/setup/tools/sqlgen/races.func.php @@ -37,7 +37,7 @@ SqlGen::register(new class extends SetupScript // add cuFlags DB::Aowow()->query('UPDATE ?_races SET cuFlags = ?d WHERE flags & ?d', CUSTOM_EXCLUDE_FOR_LISTVIEW, 0x1); - $this->reapplyCCFlags('races', TYPE_RACE); + $this->reapplyCCFlags('races', Type::CHR_RACE); return true; } diff --git a/setup/tools/sqlgen/skillline.func.php b/setup/tools/sqlgen/skillline.func.php index 0abcc0eb..e1511d06 100644 --- a/setup/tools/sqlgen/skillline.func.php +++ b/setup/tools/sqlgen/skillline.func.php @@ -58,7 +58,7 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query('UPDATE ?_skillline sl, ?_icons ic SET sl.iconId = ic.id WHERE ic.name = ? AND sl.id = ?d', 'inv_misc_pelt_wolf_01', 393); DB::Aowow()->query('UPDATE ?_skillline sl, ?_icons ic SET sl.iconId = ic.id WHERE ic.name = ? AND sl.id = ?d', 'inv_misc_key_03', 633); - $this->reapplyCCFlags('skillline', TYPE_SKILL); + $this->reapplyCCFlags('skillline', Type::SKILL); return true; } diff --git a/setup/tools/sqlgen/sounds.func.php b/setup/tools/sqlgen/sounds.func.php index b170ddf4..a8fef03f 100644 --- a/setup/tools/sqlgen/sounds.func.php +++ b/setup/tools/sqlgen/sounds.func.php @@ -422,7 +422,7 @@ SqlGen::register(new class extends SetupScript subClassMask = subClassMask | (1 << isc.subClass) '); - $this->reapplyCCFlags('sounds', TYPE_SOUND); + $this->reapplyCCFlags('sounds', Type::SOUND); return true; } diff --git a/setup/tools/sqlgen/source.func.php b/setup/tools/sqlgen/source.func.php index ccfb9dd1..1eb05aed 100644 --- a/setup/tools/sqlgen/source.func.php +++ b/setup/tools/sqlgen/source.func.php @@ -161,9 +161,9 @@ SqlGen::register(new class extends SetupScript foreach ($spellItems as $iId => $si) { if ($_ = $this->taughtSpell($si)) - $spellBuff[$_] = [TYPE_SPELL, $_, 1, TYPE_SPELL, $itemSpells[$iId]]; + $spellBuff[$_] = [Type::SPELL, $_, 1, Type::SPELL, $itemSpells[$iId]]; - $itemBuff[$iId] = [TYPE_ITEM, $iId, 1, TYPE_SPELL, $itemSpells[$iId]]; + $itemBuff[$iId] = [Type::ITEM, $iId, 1, Type::SPELL, $itemSpells[$iId]]; } if ($itemBuff) @@ -205,18 +205,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : Type::NPC, $l['entry'] /*, $lootmode */); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : Type::NPC, $l['entry'] /*, $lootmode */); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::NPC, $l['entry'] /*, $lootmode */); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : Type::NPC, $l['entry'] /*, $lootmode */); } $objectOT = []; @@ -247,20 +247,20 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : Type::OBJECT, $l['entry']); $objectOT[] = $iId; - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : Type::OBJECT, $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::OBJECT, $l['entry']); $objectOT[] = $roi; - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : Type::OBJECT, $l['entry']); } $itemOT = []; @@ -289,20 +289,20 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : Type::ITEM, $l['entry']); $itemOT[] = $iId; - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : Type::ITEM, $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::ITEM, $l['entry']); $itemOT[] = $roi; - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : Type::ITEM, $l['entry']); } if ($itemBuff) @@ -340,17 +340,17 @@ SqlGen::register(new class extends SetupScript foreach (DB::World()->select($vendorQuery, $xCostA, $xCostA) as $iId => $v) { if ($_ = $this->taughtSpell($v)) - $spellBuff[$_] = [TYPE_SPELL, $_, 1]; + $spellBuff[$_] = [Type::SPELL, $_, 1]; - $itemBuff[$iId] = [TYPE_ITEM, $iId, 1]; + $itemBuff[$iId] = [Type::ITEM, $iId, 1]; } foreach (DB::World()->select($vendorQuery, $xCostH, $xCostH) as $iId => $v) { if ($_ = $this->taughtSpell($v)) - $spellBuff[$_] = [TYPE_SPELL, $_, 2]; + $spellBuff[$_] = [Type::SPELL, $_, 2]; - $itemBuff[$iId] = [TYPE_ITEM, $iId, 2]; + $itemBuff[$iId] = [Type::ITEM, $iId, 2]; } if ($itemBuff) @@ -386,9 +386,9 @@ SqlGen::register(new class extends SetupScript foreach ($quests as $iId => $q) { if ($_ = $this->taughtSpell($q)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $q['qty'] > 1 ? 0 : TYPE_QUEST, $q['quest'], $q['side']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $q['qty'] > 1 ? 0 : Type::QUEST, $q['quest'], $q['side']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $q['qty'] > 1 ? 0 : TYPE_QUEST, $q['quest'], $q['side']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $q['qty'] > 1 ? 0 : Type::QUEST, $q['quest'], $q['side']); } $mailLoot = DB::World()->select(' @@ -419,20 +419,20 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : Type::QUEST, $l['entry'], $l['side']); $itemOT[] = $iId; - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : Type::QUEST, $l['entry'], $l['side']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::QUEST, $l['entry'], $l['side']); $itemOT[] = $roi; - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : Type::QUEST, $l['entry'], $l['side']); } if ($itemBuff) @@ -464,9 +464,9 @@ SqlGen::register(new class extends SetupScript foreach ($vendors as $iId => $v) { if ($_ = $this->taughtSpell($v)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $v['qty'] > 1 ? 0 : TYPE_NPC, $v['npc']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $v['qty'] > 1 ? 0 : Type::NPC, $v['npc']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $v['qty'] > 1 ? 0 : TYPE_NPC, $v['npc']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $v['qty'] > 1 ? 0 : Type::NPC, $v['npc']); } if ($itemBuff) @@ -481,11 +481,11 @@ SqlGen::register(new class extends SetupScript ############### CLI::write(' * #10 Starter'); - if ($pcii = DB::World()->select('SELECT ?d, itemid, 1 FROM playercreateinfo_item', TYPE_ITEM)) + if ($pcii = DB::World()->select('SELECT ?d, itemid, 1 FROM playercreateinfo_item', Type::ITEM)) DB::Aowow()->query($this->queryfy($pcii, $insBasic), 10, 10, 10); for ($i = 1; $i < 21; $i++) - DB::Aowow()->query($insSub, 10, DB::Aowow()->subquery('SELECT ?d, item?d, 1, NULL AS m, NULL AS mt FROM dbc_charstartoutfit WHERE item?d > 0', TYPE_ITEM, $i, $i), 10, 10); + DB::Aowow()->query($insSub, 10, DB::Aowow()->subquery('SELECT ?d, item?d, 1, NULL AS m, NULL AS mt FROM dbc_charstartoutfit WHERE item?d > 0', Type::ITEM, $i, $i), 10, 10); ################### @@ -517,9 +517,9 @@ SqlGen::register(new class extends SetupScript foreach ($extraItems as $iId => $l) { if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $xItems[$iId]['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $xItems[$iId]['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $xItems[$iId]['qty'] > 1 ? 0 : Type::ACHIEVEMENT, $xItems[$iId]['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $xItems[$iId]['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $xItems[$iId]['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $xItems[$iId]['qty'] > 1 ? 0 : Type::ACHIEVEMENT, $xItems[$iId]['entry']); } foreach ($rewItems as $iId => $l) @@ -529,18 +529,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::ACHIEVEMENT, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $l['qty'] > 1 ? 0 : Type::ACHIEVEMENT, $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::ACHIEVEMENT, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $l['qty'] > 1 ? 0 : Type::ACHIEVEMENT, $l['entry']); } if ($itemBuff) @@ -582,18 +582,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_); + $this->pushBuffer($spellBuff, Type::SPELL, $_); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId); + $this->pushBuffer($itemBuff, Type::ITEM, $iId); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_); + $this->pushBuffer($spellBuff, Type::SPELL, $_); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi); + $this->pushBuffer($itemBuff, Type::ITEM, $roi); } if ($itemBuff) @@ -633,18 +633,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : Type::OBJECT, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : Type::OBJECT, $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::OBJECT, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : Type::OBJECT, $l['entry']); } if ($itemBuff) @@ -677,8 +677,8 @@ SqlGen::register(new class extends SetupScript item_template it ON src.itemOrRef > 0 AND src.itemOrRef = it.entry GROUP BY ARRAY_KEY', - TYPE_NPC, NPC_TYPEFLAG_HERBLOOT, - TYPE_OBJECT, $herbLocks + Type::NPC, NPC_TYPEFLAG_HERBLOOT, + Type::OBJECT, $herbLocks ); foreach ($herbLoot as $roi => $l) @@ -688,18 +688,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); } if ($itemBuff) @@ -739,18 +739,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_); + $this->pushBuffer($spellBuff, Type::SPELL, $_); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId); + $this->pushBuffer($itemBuff, Type::ITEM, $iId); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_); + $this->pushBuffer($spellBuff, Type::SPELL, $_); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi); + $this->pushBuffer($itemBuff, Type::ITEM, $roi); } if ($itemBuff) @@ -783,8 +783,8 @@ SqlGen::register(new class extends SetupScript item_template it ON src.itemOrRef > 0 AND src.itemOrRef = it.entry GROUP BY ARRAY_KEY', - TYPE_NPC, NPC_TYPEFLAG_MININGLOOT, - TYPE_OBJECT, $mineLocks + Type::NPC, NPC_TYPEFLAG_MININGLOOT, + Type::OBJECT, $mineLocks ); foreach ($mineLoot as $roi => $l) @@ -794,18 +794,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']); } if ($itemBuff) @@ -845,18 +845,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_); + $this->pushBuffer($spellBuff, Type::SPELL, $_); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId); + $this->pushBuffer($itemBuff, Type::ITEM, $iId); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_); + $this->pushBuffer($spellBuff, Type::SPELL, $_); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi); + $this->pushBuffer($itemBuff, Type::ITEM, $roi); } if ($itemBuff) @@ -895,18 +895,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : Type::NPC, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : Type::NPC, $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::NPC, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : Type::NPC, $l['entry']); } if ($itemBuff) @@ -946,18 +946,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : Type::NPC, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : Type::NPC, $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::NPC, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : Type::NPC, $l['entry']); } if ($itemBuff) @@ -997,18 +997,18 @@ SqlGen::register(new class extends SetupScript foreach ($refLoot[-$roi] as $iId => $r) { if ($_ = $this->taughtSpell($r)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $r['qty'] > 1 ? 0 : Type::NPC, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $iId, $r['qty'] > 1 ? 0 : Type::NPC, $l['entry']); } continue; } if ($_ = $this->taughtSpell($l)) - $this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($spellBuff, Type::SPELL, $_, $l['qty'] > 1 ? 0 : Type::NPC, $l['entry']); - $this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']); + $this->pushBuffer($itemBuff, Type::ITEM, $roi, $l['qty'] > 1 ? 0 : Type::NPC, $l['entry']); } if ($itemBuff) @@ -1020,7 +1020,7 @@ SqlGen::register(new class extends SetupScript // flagging aowow_items for source (note: this is not exact! creatures dropping items may not be spawnd, quests granting items may be disabled) DB::Aowow()->query('UPDATE ?_items SET cuFlags = cuFlags & ?d', ~CUSTOM_UNAVAILABLE); - DB::Aowow()->query('UPDATE ?_items i LEFT JOIN ?_source s ON s.typeId = i.id AND s.type = ?d SET i.cuFlags = i.cuFlags | ?d WHERE s.typeId IS NULL', TYPE_ITEM, CUSTOM_UNAVAILABLE); + DB::Aowow()->query('UPDATE ?_items i LEFT JOIN ?_source s ON s.typeId = i.id AND s.type = ?d SET i.cuFlags = i.cuFlags | ?d WHERE s.typeId IS NULL', Type::ITEM, CUSTOM_UNAVAILABLE); /*********/ /* Spell */ @@ -1045,7 +1045,7 @@ SqlGen::register(new class extends SetupScript foreach ($qSpells as $sId => $spell) for ($i = 1; $i <= 3; $i++) if ($spell['effect'.$i.'Id'] == 36) // effect: learnSpell - $this->pushBuffer($buff, TYPE_SPELL, $spell['effect'.$i.'TriggerSpell'], $quests[$sId]['qty'] > 1 ? 0 : TYPE_QUEST, $quests[$sId]['qty'] > 1 ? 0 : $quests[$sId]['id'], $quests[$sId]['side']); + $this->pushBuffer($buff, Type::SPELL, $spell['effect'.$i.'TriggerSpell'], $quests[$sId]['qty'] > 1 ? 0 : Type::QUEST, $quests[$sId]['qty'] > 1 ? 0 : $quests[$sId]['id'], $quests[$sId]['side']); DB::Aowow()->query($this->queryfy($buff, $insMore), 4, 4, 4); } @@ -1068,9 +1068,9 @@ SqlGen::register(new class extends SetupScript for ($i = 1; $i <= 3; $i++) if ($effects['effect'.$i.'Id'] == 36) // effect: learnSpell - $this->pushBuffer($buff, TYPE_SPELL, $effects['effect'.$i.'TriggerSpell'], $trainerId ? TYPE_NPC : 0, $trainerId); + $this->pushBuffer($buff, Type::SPELL, $effects['effect'.$i.'TriggerSpell'], $trainerId ? Type::NPC : 0, $trainerId); - $this->pushBuffer($buff, TYPE_SPELL, $spellId, $trainerId ? TYPE_NPC : 0, $trainerId); + $this->pushBuffer($buff, Type::SPELL, $spellId, $trainerId ? Type::NPC : 0, $trainerId); } DB::Aowow()->query($this->queryfy($buff, $insMore), 6, 6, 6); @@ -1079,7 +1079,7 @@ SqlGen::register(new class extends SetupScript # 7: Discovery CLI::write(' * #7 Discovery'); // 61756: Northrend Inscription Research (FAST QA VERSION); - if ($disco = DB::World()->select('SELECT ?d, spellId, 1 FROM skill_discovery_template WHERE reqSpell <> ?d', TYPE_SPELL, 61756)) + if ($disco = DB::World()->select('SELECT ?d, spellId, 1 FROM skill_discovery_template WHERE reqSpell <> ?d', Type::SPELL, 61756)) DB::Aowow()->query($this->queryfy($disco, $insBasic), 7, 7, 7); # 9: Talent @@ -1109,7 +1109,7 @@ SqlGen::register(new class extends SetupScript } foreach ($tSpells as $tId => $__) - $buff[$tId] = [TYPE_SPELL, $tId, 1]; + $buff[$tId] = [Type::SPELL, $tId, 1]; if (!$recurse) break; @@ -1127,7 +1127,7 @@ SqlGen::register(new class extends SetupScript */ $pcis = DB::World()->selectCol('SELECT DISTINCT skill FROM playercreateinfo_skills'); - $subSkills = DB::Aowow()->subquery('SELECT ?d, spellId, 1, NULL AS m, NULL AS mt FROM dbc_skilllineability WHERE {(skillLineId IN (?a) AND acquireMethod = 2) OR} (acquireMethod = 1 AND (reqSkillLevel = 1 OR skillLineId = 129)) GROUP BY spellId', TYPE_SPELL, $pcis ?: DBSIMPLE_SKIP); + $subSkills = DB::Aowow()->subquery('SELECT ?d, spellId, 1, NULL AS m, NULL AS mt FROM dbc_skilllineability WHERE {(skillLineId IN (?a) AND acquireMethod = 2) OR} (acquireMethod = 1 AND (reqSkillLevel = 1 OR skillLineId = 129)) GROUP BY spellId', Type::SPELL, $pcis ?: DBSIMPLE_SKIP); DB::Aowow()->query($insSub, 10, $subSkills, 10, 10); @@ -1139,7 +1139,7 @@ SqlGen::register(new class extends SetupScript # 4: Quest CLI::write(' * #4 Quest'); - if ($quests = DB::World()->select('SELECT ?d, RewardTitle, 1, ?d, ID FROM quest_template WHERE RewardTitle > 0', TYPE_TITLE, TYPE_QUEST)) + if ($quests = DB::World()->select('SELECT ?d, RewardTitle, 1, ?d, ID FROM quest_template WHERE RewardTitle > 0', Type::TITLE, Type::QUEST)) DB::Aowow()->query($this->queryfy($quests, $insMore), 4, 4, 4); # 12: Achievement @@ -1153,7 +1153,7 @@ SqlGen::register(new class extends SetupScript ); foreach ($sets as $tId => $set) { - DB::Aowow()->query($this->queryfy([[TYPE_TITLE, $tId, 1, TYPE_ACHIEVEMENT, $set['srcId']]], $insMore), 12, 12, 12); + DB::Aowow()->query($this->queryfy([[Type::TITLE, $tId, 1, Type::ACHIEVEMENT, $set['srcId']]], $insMore), 12, 12, 12); if ($set['altSrcId']) DB::Aowow()->query('UPDATE ?_titles SET src12Ext = ?d WHERE id = ?d', $set['altSrcId'], $tId); @@ -1164,7 +1164,7 @@ SqlGen::register(new class extends SetupScript $src13 = [null, 42, 52, 71, 80, 157, 163, 167, 169, 177]; foreach ($src13 as $src => $tId) if ($tId) - DB::Aowow()->query($this->queryfy([[TYPE_TITLE, $tId, $src]], $insBasic), 13, 13, 13); + DB::Aowow()->query($this->queryfy([[Type::TITLE, $tId, $src]], $insBasic), 13, 13, 13); return true; } diff --git a/setup/tools/sqlgen/spawns.func.php b/setup/tools/sqlgen/spawns.func.php index d3796491..e7822799 100644 --- a/setup/tools/sqlgen/spawns.func.php +++ b/setup/tools/sqlgen/spawns.func.php @@ -19,31 +19,31 @@ SqlGen::register(new class extends SetupScript private $querys = array( 1 => ['SELECT c.guid, 1 AS "type", c.id AS typeId, c.spawntimesecs AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, IFNULL(ca.path_id, 0) AS pathId, c.position_y AS `posX`, c.position_x AS `posY` ' . 'FROM creature c LEFT JOIN creature_addon ca ON ca.guid = c.guid', - ' - assembling creature spawns', TYPE_NPC], + ' - assembling creature spawns', Type::NPC], 2 => ['SELECT c.guid, 2 AS "type", c.id AS typeId, ABS(c.spawntimesecs) AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, 0 as pathId, c.position_y AS `posX`, c.position_x AS `posY` ' . 'FROM gameobject c', - ' - assembling gameobject spawns', TYPE_OBJECT], + ' - assembling gameobject spawns', Type::OBJECT], 3 => ['SELECT id AS "guid", 19 AS "type", soundId AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' . 'FROM dbc_soundemitters', - ' - assembling sound emitter spawns', TYPE_SOUND], + ' - assembling sound emitter spawns', Type::SOUND], 4 => ['SELECT id AS "guid", 503 AS "type", id AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' . 'FROM dbc_areatrigger', - ' - assembling areatrigger spawns', TYPE_AREATRIGGER], + ' - assembling areatrigger spawns', Type::AREATRIGGER], 5 => ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, w.waittime AS "wait", w.location_y AS `posX`, w.location_x AS `posY` ' . 'FROM creature c JOIN script_waypoint w ON c.id = w.entry', - ' - assembling waypoints from table script_waypoint', TYPE_NPC], + ' - assembling waypoints from table script_waypoint', Type::NPC], 6 => ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, 0 AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' . 'FROM creature c JOIN waypoints w ON c.id = w.entry', - ' - assembling waypoints from table waypoints', TYPE_NPC], + ' - assembling waypoints from table waypoints', Type::NPC], 7 => ['SELECT c.guid, -w.id AS "npcOrPath", w.point, c.zoneId AS areaId, c.map, w.delay AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' . 'FROM creature c JOIN creature_addon ca ON ca.guid = c.guid JOIN waypoint_data w ON w.id = ca.path_id WHERE ca.path_id <> 0', - ' - assembling waypoints from table waypoint_data', TYPE_NPC] + ' - assembling waypoints from table waypoint_data', Type::NPC] ); public function generate(array $ids = []) : bool @@ -202,9 +202,9 @@ SqlGen::register(new class extends SetupScript { $vehicles = []; if ($data['guid']) // vehicle already spawned - $vehicles = DB::Aowow()->select('SELECT s.areaId, s.posX, s.posY, s.floor FROM ?_spawns s WHERE s.guid = ?d AND s.type = ?d', $data['guid'], TYPE_NPC); + $vehicles = DB::Aowow()->select('SELECT s.areaId, s.posX, s.posY, s.floor FROM ?_spawns s WHERE s.guid = ?d AND s.type = ?d', $data['guid'], Type::NPC); else if ($data['entry']) // vehicle on unspawned vehicle action - $vehicles = DB::Aowow()->select('SELECT s.areaId, s.posX, s.posY, s.floor FROM ?_spawns s WHERE s.typeId = ?d AND s.type = ?d', $data['entry'], TYPE_NPC); + $vehicles = DB::Aowow()->select('SELECT s.areaId, s.posX, s.posY, s.floor FROM ?_spawns s WHERE s.typeId = ?d AND s.type = ?d', $data['entry'], Type::NPC); if ($vehicles) { @@ -213,7 +213,7 @@ SqlGen::register(new class extends SetupScript for ($i = 0; $i < $data['nSeats']; $i++) DB::Aowow()->query(' REPLACE INTO ?_spawns (`guid`, `type`, `typeId`, `respawn`, `spawnMask`, `phaseMask`, `areaId`, `floor`, `posX`, `posY`, `pathId`) VALUES - (?d, ?d, ?d, 0, 0, 1, ?d, ?d, ?f, ?f, 0)', --$vGuid, TYPE_NPC, $data['typeId'], $v['areaId'], $v['floor'], $v['posX'], $v['posY']); + (?d, ?d, ?d, 0, 0, 1, ?d, ?d, ?f, ?f, 0)', --$vGuid, Type::NPC, $data['typeId'], $v['areaId'], $v['floor'], $v['posX'], $v['posY']); unset($accessories[$idx]); } diff --git a/setup/tools/sqlgen/spell.func.php b/setup/tools/sqlgen/spell.func.php index 9771e19d..0cd8dec5 100644 --- a/setup/tools/sqlgen/spell.func.php +++ b/setup/tools/sqlgen/spell.func.php @@ -726,7 +726,7 @@ SqlGen::register(new class extends SetupScript // hide unused glyphs DB::Aowow()->query('UPDATE ?_spell SET skillLine1 = 0, iconIdAlt = 0, cuFlags = cuFlags | ?d WHERE id IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, [60460, 58166, 58239, 58240, 58261, 58262, 54910]); - $this->reapplyCCFlags('spell', TYPE_SPELL); + $this->reapplyCCFlags('spell', Type::SPELL); return true; } diff --git a/setup/tools/sqlgen/titles.func.php b/setup/tools/sqlgen/titles.func.php index 2b5ee48b..76dd28c9 100644 --- a/setup/tools/sqlgen/titles.func.php +++ b/setup/tools/sqlgen/titles.func.php @@ -94,7 +94,7 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query('UPDATE ?_titles SET side = 2 WHERE id <= 28 OR id IN (118, 119, 116, 117, 110, 127)'); DB::Aowow()->query('UPDATE ?_titles SET side = 1 WHERE id <= 14 OR id IN (111, 115, 112, 114, 126)'); - $this->reapplyCCFlags('titles', TYPE_TITLE); + $this->reapplyCCFlags('titles', Type::TITLE); return true; } diff --git a/setup/tools/sqlgen/zones.func.php b/setup/tools/sqlgen/zones.func.php index d2c45337..4df691a1 100644 --- a/setup/tools/sqlgen/zones.func.php +++ b/setup/tools/sqlgen/zones.func.php @@ -173,30 +173,30 @@ SqlGen::register(new class extends SetupScript if ($req['reqItemN'] && ($entries = explode(' ', $req['reqItemN']))) foreach ($entries as $_) - $aN[TYPE_ITEM][] = $_; + $aN[Type::ITEM][] = $_; if ($req['reqItemH'] && ($entries = explode(' ', $req['reqItemH']))) - if ($entries = array_diff($entries, $aN[TYPE_ITEM] ?? [])) + if ($entries = array_diff($entries, $aN[Type::ITEM] ?? [])) foreach ($entries as $_) - $aH[TYPE_ITEM][] = $_; + $aH[Type::ITEM][] = $_; if ($req['reqQuestN'] && ($entries = explode(' ', $req['reqQuestN']))) foreach ($entries as $_) - $aN[TYPE_QUEST][] = $_; + $aN[Type::QUEST][] = $_; if ($req['reqQuestH'] && ($entries = explode(' ', $req['reqQuestH']))) - if ($entries = array_diff($entries, $aN[TYPE_QUEST] ?? [])) + if ($entries = array_diff($entries, $aN[Type::QUEST] ?? [])) foreach ($entries as $_) - $aH[TYPE_QUEST][] = $_; + $aH[Type::QUEST][] = $_; if ($req['reqAchievementN'] && ($entries = explode(' ', $req['reqAchievementN']))) foreach ($entries as $_) - $aN[TYPE_ACHIEVEMENT][] = $_; + $aN[Type::ACHIEVEMENT][] = $_; if ($req['reqAchievementH'] && ($entries = explode(' ', $req['reqAchievementH']))) - if ($entries = array_diff($entries, $aN[TYPE_ACHIEVEMENT] ?? [])) + if ($entries = array_diff($entries, $aN[Type::ACHIEVEMENT] ?? [])) foreach ($entries as $_) - $aH[TYPE_ACHIEVEMENT][] = $_; + $aH[Type::ACHIEVEMENT][] = $_; if ($aN) { @@ -217,7 +217,7 @@ SqlGen::register(new class extends SetupScript DB::Aowow()->query('UPDATE ?_zones SET ?a WHERE mapId = ?d', $update, $mapId); } - $this->reapplyCCFlags('zones', TYPE_ZONE); + $this->reapplyCCFlags('zones', Type::ZONE); return true; } diff --git a/template/bricks/lvTabs.tpl.php b/template/bricks/lvTabs.tpl.php index 46c0f83c..2793bdda 100644 --- a/template/bricks/lvTabs.tpl.php +++ b/template/bricks/lvTabs.tpl.php @@ -27,7 +27,7 @@ if (!empty($this->lvTabs) || !empty($this->user['characterData']) || !empty($thi endif; if ($isTabbed): - echo " var ".$tabVar." = new Tabs({parent: \$WH.ge('tabs-generic')".(isset($this->type) ? ", trackable: '".ucfirst(Util::$typeStrings[$this->type]."'") : null)."});\n"; + echo " var ".$tabVar." = new Tabs({parent: \$WH.ge('tabs-generic')".(isset($this->type) ? ", trackable: '".ucfirst(Type::getFileString($this->type)."'") : null)."});\n"; endif; foreach ($this->lvTabs as $lv): diff --git a/template/bricks/mapper.tpl.php b/template/bricks/mapper.tpl.php index 95bafcf1..696cf40e 100644 --- a/template/bricks/mapper.tpl.php +++ b/template/bricks/mapper.tpl.php @@ -2,18 +2,18 @@ if (isset($this->map) && empty($this->map)): echo Lang::zone('noMap'); elseif (!empty($this->map['data'])): - if ($this->type == TYPE_QUEST) : + if ($this->type == Type::QUEST) : echo "
\n"; - elseif ($this->type != TYPE_ZONE): + elseif ($this->type != Type::ZONE): echo '
'; - if ($this->type == TYPE_OBJECT): + if ($this->type == Type::OBJECT): echo Lang::gameObject('foundIn'); - elseif ($this->type == TYPE_SOUND): + elseif ($this->type == Type::SOUND): echo Lang::sound('foundIn'); - elseif ($this->type == TYPE_NPC): + elseif ($this->type == Type::NPC): echo Lang::npc('foundIn'); - elseif ($this->type == TYPE_AREATRIGGER): + elseif ($this->type == Type::AREATRIGGER): echo Lang::areatrigger('foundIn'); else: echo "UNKNOWN TYPE"; @@ -74,7 +74,7 @@ elseif (!empty($this->map['data'])): echo " new ShowOnMap(".Util::toJSON($this->map['som']).");\n"; endif; - if ($this->type != TYPE_ZONE && $this->type != TYPE_QUEST): + if ($this->type != Type::ZONE && $this->type != Type::QUEST): echo " \$WH.gE(\$WH.ge('mapper-zone-generic'), 'a')[0].onclick();\n"; endif; diff --git a/template/bricks/reagentList.tpl.php b/template/bricks/reagentList.tpl.php index 641376de..f59828db 100644 --- a/template/bricks/reagentList.tpl.php +++ b/template/bricks/reagentList.tpl.php @@ -185,7 +185,7 @@ foreach ($reagents as $k => $itr): echo '
 
'; endif; - echo ''.$itr['name'].''.($itr['qty'] > 1 ? ' ('.$itr['qty'].')' : null)."\n"; + echo ''.$itr['name'].''.($itr['qty'] > 1 ? ' ('.$itr['qty'].')' : null)."\n"; endforeach; ?> diff --git a/template/pages/admin/screenshots.tpl.php b/template/pages/admin/screenshots.tpl.php index 54aa19a6..638099d1 100644 --- a/template/pages/admin/screenshots.tpl.php +++ b/template/pages/admin/screenshots.tpl.php @@ -23,8 +23,8 @@ $this->brick('pageTemplate');