mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Locale
* detatch from User and Util and move to its own enum class * added definitions for all locales the 12340 client could in theory have * this is incompatble with the Intl extension * version bump and php requirement bump
This commit is contained in:
@@ -74,14 +74,14 @@ CLISetup::registerSetup('sql', new class extends SetupScript
|
||||
|
||||
CLI::write('[achievement] - serverside achievement data');
|
||||
|
||||
$serverAchievements = DB::World()->select('SELECT ID AS "id", IF(requiredFaction = -1, 3, IF(requiredFaction = 0, 2, 1)) AS "faction", mapID AS "map", points, flags, count AS "reqCriteriaCount", refAchievement FROM achievement_dbc{ WHERE id IN (?a)}',
|
||||
$serverAchievements = DB::World()->select('SELECT `ID` AS "id", IF(`requiredFaction` = -1, 3, IF(`requiredFaction` = 0, 2, 1)) AS "faction", `mapID` AS "map", `points`, `flags`, `count` AS "reqCriteriaCount", `refAchievement` FROM achievement_dbc{ WHERE `id` IN (?a)}',
|
||||
$ids ?: DBSIMPLE_SKIP
|
||||
);
|
||||
|
||||
foreach ($serverAchievements as &$sa)
|
||||
{
|
||||
$sa['cuFlags'] = CUSTOM_SERVERSIDE;
|
||||
foreach (Util::$localeStrings as $i => $_)
|
||||
foreach (CLISetup::$locales as $i => $_)
|
||||
if ($_)
|
||||
$sa['name_loc'.$i] = 'Serverside - #'.$sa['id'];
|
||||
}
|
||||
@@ -98,11 +98,11 @@ CLISetup::registerSetup('sql', new class extends SetupScript
|
||||
|
||||
CLI::write('[achievement] - linking achievements to chain');
|
||||
|
||||
$parents = DB::Aowow()->selectCol('SELECT a.id FROM dbc_achievement a JOIN dbc_achievement b ON b.previous = a.id WHERE a.previous = 0');
|
||||
$parents = DB::Aowow()->selectCol('SELECT a.`id` FROM dbc_achievement a JOIN dbc_achievement b ON b.`previous` = a.`id` WHERE a.`previous` = 0');
|
||||
foreach ($parents as $chainId => $next)
|
||||
{
|
||||
$tree = [null, $next];
|
||||
while ($next = DB::Aowow()->selectCell('SELECT id FROM dbc_achievement WHERE previous = ?d', $next))
|
||||
while ($next = DB::Aowow()->selectCell('SELECT `id` FROM dbc_achievement WHERE `previous` = ?d', $next))
|
||||
$tree[] = $next;
|
||||
|
||||
foreach ($tree as $idx => $aId)
|
||||
@@ -110,7 +110,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript
|
||||
if (!$aId)
|
||||
continue;
|
||||
|
||||
DB::Aowow()->query('UPDATE ?_achievement SET cuFlags = cuFlags | ?d, chainId = ?d, chainPos = ?d WHERE id = ?d',
|
||||
DB::Aowow()->query('UPDATE ?_achievement SET `cuFlags` = `cuFlags` | ?d, `chainId` = ?d, `chainPos` = ?d WHERE `id` = ?d',
|
||||
$idx == 1 ? ACHIEVEMENT_CU_FIRST_SERIES : (count($tree) == $idx + 1 ? ACHIEVEMENT_CU_LAST_SERIES : 0),
|
||||
$chainId + 1,
|
||||
$idx,
|
||||
@@ -126,8 +126,8 @@ CLISetup::registerSetup('sql', new class extends SetupScript
|
||||
|
||||
CLI::write('[achievement] - disabling disabled achievements from table disables');
|
||||
|
||||
if ($criteria = DB::World()->selectCol('SELECT entry FROM disables WHERE sourceType = 4'))
|
||||
DB::Aowow()->query('UPDATE ?_achievement a JOIN ?_achievementcriteria ac ON a.id = ac.refAchievementId SET a.cuFlags = ?d WHERE ac.id IN (?a)', CUSTOM_DISABLED, $criteria);
|
||||
if ($criteria = DB::World()->selectCol('SELECT `entry` FROM disables WHERE `sourceType` = 4'))
|
||||
DB::Aowow()->query('UPDATE ?_achievement a JOIN ?_achievementcriteria ac ON a.`id` = ac.`refAchievementId` SET a.`cuFlags` = ?d WHERE ac.`id` IN (?a)', CUSTOM_DISABLED, $criteria);
|
||||
|
||||
$this->reapplyCCFlags('achievement', Type::ACHIEVEMENT);
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
|
||||
if ($x = array_diff_key(CLISetup::$locales, $locPath))
|
||||
{
|
||||
$locs = array_intersect_key(CLISetup::$locales, array_flip($x));
|
||||
CLI::write('[emotes] '.sprintf($globStrPath, CLI::bold('['.implode('/,', $locs).'/]')) . ' not found!', CLI::LOG_WARN);
|
||||
$locs = array_intersect_key(CLISetup::$locales, $x);
|
||||
CLI::write('[emotes] '.sprintf($globStrPath, '[' . Lang::concat($locs, callback: fn($x) => CLI::bold(implode('/, ', $x->gameDirs()) . '/')) . ']') . ' not found!', CLI::LOG_WARN);
|
||||
CLI::write(' Emote aliasses can not be generated for affected locales!', CLI::LOG_WARN);
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
12 female others no 4 -
|
||||
*/
|
||||
|
||||
$this->textData = DB::Aowow()->select('SELECT id AS ARRAY_KEY, text_loc0 AS "0", text_loc2 AS "2", text_loc3 AS "3", text_loc4 AS "4", text_loc6 AS "6", text_loc8 AS "8" FROM dbc_emotestextdata');
|
||||
$this->textData = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `text_loc0` AS "0", `text_loc2` AS "2", `text_loc3` AS "3", `text_loc4` AS "4", `text_loc6` AS "6", `text_loc8` AS "8" FROM dbc_emotestextdata');
|
||||
|
||||
$texts = DB::Aowow()->select('SELECT et.id AS ARRAY_KEY, LOWER(command) AS `cmd`, IF(e.animationId, 1, 0) AS `anim`, -emoteId AS "parent", e.soundId, etd0, etd1, etd2, etd4, etd6, etd8, etd9, etd12 FROM dbc_emotestext et LEFT JOIN dbc_emotes e ON e.id = et.emoteId');
|
||||
$texts = DB::Aowow()->select('SELECT et.`id` AS ARRAY_KEY, LOWER(`command`) AS "cmd", IF(e.`animationId`, 1, 0) AS "anim", -`emoteId` AS "parent", e.`soundId`, `etd0`, `etd1`, `etd2`, `etd4`, `etd6`, `etd8`, `etd9`, `etd12` FROM dbc_emotestext et LEFT JOIN dbc_emotes e ON e.`id` = et.`emoteId`');
|
||||
foreach ($texts AS $id => $t)
|
||||
{
|
||||
DB::Aowow()->query(
|
||||
@@ -68,12 +68,12 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
VALUES
|
||||
(?d, ?, ?d, ?d, ?d, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
$id, $t['cmd'], $t['anim'], $t['parent'], $t['soundId'],
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], LOCALE_EN), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], LOCALE_EN), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], LOCALE_EN), $this->textData[$t['etd2']][LOCALE_EN] ?? '', $this->textData[$t['etd6']][LOCALE_EN] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], LOCALE_FR), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], LOCALE_FR), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], LOCALE_FR), $this->textData[$t['etd2']][LOCALE_FR] ?? '', $this->textData[$t['etd6']][LOCALE_FR] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], LOCALE_DE), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], LOCALE_DE), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], LOCALE_DE), $this->textData[$t['etd2']][LOCALE_DE] ?? '', $this->textData[$t['etd6']][LOCALE_DE] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], LOCALE_CN), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], LOCALE_CN), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], LOCALE_CN), $this->textData[$t['etd2']][LOCALE_CN] ?? '', $this->textData[$t['etd6']][LOCALE_CN] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], LOCALE_ES), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], LOCALE_ES), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], LOCALE_ES), $this->textData[$t['etd2']][LOCALE_ES] ?? '', $this->textData[$t['etd6']][LOCALE_ES] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], LOCALE_RU), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], LOCALE_RU), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], LOCALE_RU), $this->textData[$t['etd2']][LOCALE_RU] ?? '', $this->textData[$t['etd6']][LOCALE_RU] ?? ''
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], Locale::EN), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], Locale::EN), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], Locale::EN), $this->textData[$t['etd2']][Locale::EN->value] ?? '', $this->textData[$t['etd6']][Locale::EN->value] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], Locale::FR), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], Locale::FR), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], Locale::FR), $this->textData[$t['etd2']][Locale::FR->value] ?? '', $this->textData[$t['etd6']][Locale::FR->value] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], Locale::DE), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], Locale::DE), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], Locale::DE), $this->textData[$t['etd2']][Locale::DE->value] ?? '', $this->textData[$t['etd6']][Locale::DE->value] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], Locale::CN), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], Locale::CN), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], Locale::CN), $this->textData[$t['etd2']][Locale::CN->value] ?? '', $this->textData[$t['etd6']][Locale::CN->value] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], Locale::ES), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], Locale::ES), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], Locale::ES), $this->textData[$t['etd2']][Locale::ES->value] ?? '', $this->textData[$t['etd6']][Locale::ES->value] ?? '',
|
||||
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], Locale::RU), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], Locale::RU), $this->mergeGenderedStrings($t['etd4'], $t['etd12'], Locale::RU), $this->textData[$t['etd2']][Locale::RU->value] ?? '', $this->textData[$t['etd6']][Locale::RU->value] ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,10 +114,10 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
return $allOK;
|
||||
}
|
||||
|
||||
private function mergeGenderedStrings(int $maleTextId, int $femaleTextId, int $locale) : string
|
||||
private function mergeGenderedStrings(int $maleTextId, int $femaleTextId, Locale $loc) : string
|
||||
{
|
||||
$maleText = $this->textData[$maleTextId][$locale] ?? '';
|
||||
$femaleText = $this->textData[$femaleTextId][$locale] ?? '';
|
||||
$maleText = $this->textData[$maleTextId][$loc->value] ?? '';
|
||||
$femaleText = $this->textData[$femaleTextId][$loc->value] ?? '';
|
||||
|
||||
if (!$maleText && !$femaleText)
|
||||
return '';
|
||||
|
||||
@@ -79,16 +79,17 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
29 => [901, 900, 899, 898, 897, 896, 895, 894, 893, 892, 891, 890, 889, 888, 887, 886, 885, 884, 883]
|
||||
);
|
||||
|
||||
// well .. fuck
|
||||
private $tagsByNamePart = array(
|
||||
17 => ['gladiator'], // "Arena Season 1 Set",
|
||||
19 => ['merciless'], // "Arena Season 2 Set",
|
||||
20 => ['vengeful'], // "Arena Season 3 Set",
|
||||
22 => ['brutal'], // "Arena Season 4 Set",
|
||||
24 => ['deadly', 'hateful', 'savage'], // "Arena Season 5 Set",
|
||||
26 => ['furious'], // "Arena Season 6 Set",
|
||||
28 => ['relentless'], // "Arena Season 7 Set",
|
||||
30 => ['wrathful'] // "Arena Season 8 Set",
|
||||
// in pvp we hope nobody fucked with the item level
|
||||
private $tagsByItemlevel = array(
|
||||
123 => 17, // "Arena Season 1 Set"
|
||||
136 => 19, // "Arena Season 2 Set"
|
||||
146 => 20, // "Arena Season 3 Set"
|
||||
159 => 22, // "Arena Season 4 Set"
|
||||
200 => 24, // "Arena Season 5 Set"
|
||||
213 => 24, //
|
||||
232 => 26, // "Arena Season 6 Set"
|
||||
251 => 28, // "Arena Season 7 Set"
|
||||
270 => 30 // "Arena Season 8 Set"
|
||||
);
|
||||
|
||||
private function getSetType(array $items) : int
|
||||
@@ -113,11 +114,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
{
|
||||
switch ($item['subclass'])
|
||||
{
|
||||
case 0: $type = 8; break; // 1H-Axe
|
||||
case 4: $type = 9; break; // 1H-Mace
|
||||
case 7: $type = 10; break; // 1H-Sword
|
||||
case 13: $type = 7; break; // Fist Weapon
|
||||
case 15: $type = 5; break; // Dagger
|
||||
case ITEM_SUBCLASS_1H_AXE: $type = 8; break;
|
||||
case ITEM_SUBCLASS_1H_MACE: $type = 9; break;
|
||||
case ITEM_SUBCLASS_1H_SWORD: $type = 10; break;
|
||||
case ITEM_SUBCLASS_FIST_WEAPON: $type = 7; break;
|
||||
case ITEM_SUBCLASS_DAGGER: $type = 5; break;
|
||||
}
|
||||
}
|
||||
else if ($item['class'] == ITEM_CLASS_ARMOR)
|
||||
@@ -150,11 +151,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
return $tag;
|
||||
|
||||
// try arena set
|
||||
if ($item['ItemLevel'] >= 120 && $item['AllowableClass'] && ($item['AllowableClass'] & CLASS_MASK_ALL) != CLASS_MASK_ALL)
|
||||
foreach ($this->tagsByNamePart as $tag => $strings)
|
||||
foreach ($strings as $str)
|
||||
if (stripos($item['name'], $str) === 0)
|
||||
return $tag;
|
||||
if ($item['AllowableClass'] && ($item['AllowableClass'] & CLASS_MASK_ALL) != CLASS_MASK_ALL)
|
||||
return $this->tagsByItemlevel[$item['ItemLevel']] ?? 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -188,14 +186,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
public function generate(array $ids = []) : bool
|
||||
{
|
||||
// find events associated with holidayIds
|
||||
if ($pairs = DB::World()->selectCol('SELECT holiday AS ARRAY_KEY, eventEntry FROM game_event WHERE holiday IN (?a)', array_values($this->setToHoliday)))
|
||||
if ($pairs = DB::World()->selectCol('SELECT `holiday` AS ARRAY_KEY, `eventEntry` FROM game_event WHERE `holiday` IN (?a)', array_values($this->setToHoliday)))
|
||||
foreach ($this->setToHoliday as &$hId)
|
||||
$hId = !empty($pairs[$hId]) ? $pairs[$hId] : 0;
|
||||
|
||||
DB::Aowow()->query('TRUNCATE TABLE ?_itemset');
|
||||
|
||||
$virtualId = 0;
|
||||
$sets = DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM dbc_itemset');
|
||||
$sets = DB::Aowow()->select('SELECT *, `id` AS ARRAY_KEY FROM dbc_itemset');
|
||||
|
||||
foreach ($sets as $setId => $setData)
|
||||
{
|
||||
@@ -237,22 +235,22 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
|
||||
$descText = [];
|
||||
|
||||
foreach (Util::mask2bits(Cfg::get('LOCALES')) as $loc)
|
||||
foreach (CLISetup::$locales as $locId => $loc)
|
||||
{
|
||||
User::useLocale($loc);
|
||||
Lang::load($loc);
|
||||
|
||||
$row['name_loc'.$loc] = Util::localizedString($setData, 'name');
|
||||
$row['name_loc'.$locId] = Util::localizedString($setData, 'name');
|
||||
|
||||
foreach ($bonusSpells->iterate() as $__)
|
||||
{
|
||||
if (!isset($descText[$loc]))
|
||||
$descText[$loc] = '';
|
||||
if (!isset($descText[$locId]))
|
||||
$descText[$locId] = '';
|
||||
|
||||
$descText[$loc] .= $bonusSpells->parseText()[0]."\n";
|
||||
$descText[$locId] .= $bonusSpells->parseText()[0]."\n";
|
||||
}
|
||||
|
||||
// strip rating blocks - e.g. <!--rtg19-->14 <small>(<!--rtg%19-->0.30% @ L<!--lvl-->80)</small>
|
||||
$row['bonusText_loc'.$loc] = preg_replace('/<!--rtg\d+-->(\d+) .*?<\/small>/i', '\1', $descText[$loc]);
|
||||
$row['bonusText_loc'.$locId] = preg_replace('/<!--rtg\d+-->(\d+) .*?<\/small>/i', '\1', $descText[$locId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +258,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
/* determine type and reuse from pieces */
|
||||
/****************************************/
|
||||
|
||||
$pieces = DB::World()->select('SELECT entry, name, class, subclass, Quality, AllowableClass, ItemLevel, RequiredLevel, itemset, IF (Flags & ?d, 1, 0) AS heroic, IF(InventoryType = 15, 26, IF(InventoryType = 5, 20, InventoryType)) AS slot, entry AS ARRAY_KEY FROM item_template WHERE itemset = ?d', ITEM_FLAG_HEROIC, $setId);
|
||||
$pieces = DB::World()->select('SELECT `entry`, `name`, `class`, `subclass`, `Quality`, `AllowableClass`, `ItemLevel`, `RequiredLevel`, `itemset`, IF (`Flags` & ?d, 1, 0) AS "heroic", IF(`InventoryType` = 15, 26, IF(`InventoryType` = 5, 20, `InventoryType`)) AS "slot", `entry` AS ARRAY_KEY FROM item_template WHERE `itemset` = ?d', ITEM_FLAG_HEROIC, $setId);
|
||||
|
||||
/*
|
||||
possible cases:
|
||||
@@ -294,7 +292,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
|
||||
else if (in_array($data['slot'], [INVTYPE_WEAPON, INVTYPE_FINGER, INVTYPE_TRINKET]))
|
||||
$sorted[$k][-$data['slot']] = $data;
|
||||
// slot confict. If item is being sold, replace old item (imperfect solution :/)
|
||||
else if (DB::World()->selectCell('SELECT SUM(n) FROM (SELECT COUNT(1) AS n FROM npc_vendor WHERE item = ?d UNION SELECT COUNT(1) AS n FROM game_event_npc_vendor WHERE item = ?d) x', $data['entry'], $data['entry']))
|
||||
else if (DB::World()->selectCell('SELECT SUM(`n`) FROM (SELECT COUNT(1) AS "n" FROM npc_vendor WHERE `item` = ?d UNION SELECT COUNT(1) AS "n" FROM game_event_npc_vendor WHERE `item` = ?d) x', $data['entry'], $data['entry']))
|
||||
$sorted[$k][$data['slot']] = $data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user