Core/Config

* convert configuration from list of constants to object
 * fixes config changes not applying on cli whithout closing and reopening again
 * config variables are no longer embedded in localization text
This commit is contained in:
Sarjuuk
2024-05-28 15:41:44 +02:00
parent 454e09cc78
commit f77d676a19
94 changed files with 1094 additions and 922 deletions

View File

@@ -83,7 +83,7 @@ if (!CLI)
$enchIds = array_column($enchantSpells, 'effect1MiscValue');
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
$enchantments = new EnchantmentList(array(['id', $enchIds], Cfg::get('SQL_LIMIT_NONE')));
if ($enchantments->error)
{
CLI::write('Required table ?_itemenchantment seems to be empty! Leaving enchants()...', CLI::LOG_ERROR);
@@ -91,7 +91,7 @@ if (!CLI)
return false;
}
$castItems = new ItemList(array(['spellId1', array_keys($enchantSpells)], ['src.typeId', null, '!'], CFG_SQL_LIMIT_NONE));
$castItems = new ItemList(array(['spellId1', array_keys($enchantSpells)], ['src.typeId', null, '!'], Cfg::get('SQL_LIMIT_NONE')));
foreach (CLISetup::$localeIds as $lId)
{

View File

@@ -53,7 +53,7 @@ if (!CLI)
foreach ($gems as $pop)
$enchIds[] = $pop['enchId'];
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
$enchantments = new EnchantmentList(array(['id', $enchIds], Cfg::get('SQL_LIMIT_NONE')));
if ($enchantments->error)
{
CLI::write('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLI::LOG_ERROR);

View File

@@ -48,7 +48,7 @@ if (!CLI)
if (!CLISetup::writeDir('datasets/'.$dir))
$success = false;
$glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE));
$glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], Cfg::get('SQL_LIMIT_NONE')));
foreach (CLISetup::$localeIds as $lId)
{

View File

@@ -69,9 +69,9 @@ if (!CLI)
$mods = DB::Aowow()->selectCol('SELECT idx - 1 AS ARRAY_KEY, ratio FROM dbc_gtoctclasscombatratingscalar WHERE idx IN (?a)', $offsets);
foreach ($data as $itemMod => &$val)
$val = CFG_DEBUG ? $base[$val].' / '.$mods[$val] : $base[$val] / $mods[$val];
$val = Cfg::get('DEBUG') ? $base[$val].' / '.$mods[$val] : $base[$val] / $mods[$val];
if (!CFG_DEBUG)
if (!Cfg::get('DEBUG'))
return Util::toJSON($data);
$buff = [];
@@ -97,7 +97,7 @@ if (!CLI)
foreach ($data as &$d)
$d = array_values($d); // strip indizes
return CFG_DEBUG ? debugify($data) : Util::toJSON($data);
return Cfg::get('DEBUG') ? debugify($data) : Util::toJSON($data);
}
function itemScalingSD()
@@ -109,7 +109,6 @@ if (!CLI)
array_splice($row, 0, 1);
}
return CFG_DEBUG ? debugify($data) : Util::toJSON($data);
return Cfg::get('DEBUG') ? debugify($data) : Util::toJSON($data);
}
?>

View File

@@ -63,7 +63,7 @@ if (!CLI)
$questorder = [];
$questtotal = [];
$condition = [
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
'AND',
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW | CUSTOM_UNAVAILABLE | CUSTOM_DISABLED, '&'], 0],
[['flags', QUEST_FLAG_DAILY | QUEST_FLAG_WEEKLY | QUEST_FLAG_REPEATABLE | QUEST_FLAG_AUTO_REWARDED, '&'], 0],
@@ -151,7 +151,7 @@ if (!CLI)
{
$success = true;
$condition = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
);
$titlez = new TitleList($condition);
@@ -193,7 +193,7 @@ if (!CLI)
{
$success = true;
$condition = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
['typeCat', -5],
['castTime', 0, '!']
@@ -253,7 +253,7 @@ if (!CLI)
{
$success = true;
$condition = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
['typeCat', -6]
);
@@ -297,7 +297,7 @@ if (!CLI)
{
$success = true;
$condition = array( // todo (med): exclude non-gaining reputation-header
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]
);
$factionz = new FactionList($condition);
@@ -331,7 +331,7 @@ if (!CLI)
$skills = array_merge(SKILLS_TRADE_PRIMARY, [[185, 129, 356]]);
$success = true;
$baseCnd = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
['effect1Id', [6, 45, 57, 127, 33, 158, 99, 28, 95], '!'], // aura, tradeSkill, Tracking, Prospecting, Decipher, Milling, Disenchant, Summon (Engineering), Skinning
['effect2Id', [118, 60], '!'], // not the skill itself
@@ -397,7 +397,7 @@ if (!CLI)
{
$success = true;
$condition = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
[['flags', 1, '&'], 0], // no statistics
);

View File

@@ -42,8 +42,8 @@ if (!CLI)
$set = 0x0;
$menu = [
// skip usage of battlegroup
// ['us', Lang::profiler('regions', 'us'), null,[[Profiler::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subUS]]],
// ['eu', Lang::profiler('regions', 'eu'), null,[[Profiler::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subEU]]]
// ['us', Lang::profiler('regions', 'us'), null,[[Profiler::urlize(Cfg::get('BATTLEGROUP')), Cfg::get('BATTLEGROUP'), null, &$subUS]]],
// ['eu', Lang::profiler('regions', 'eu'), null,[[Profiler::urlize(Cfg::get('BATTLEGROUP')), Cfg::get('BATTLEGROUP'), null, &$subEU]]]
];
foreach (Util::$regions as $idx => $n)

View File

@@ -33,7 +33,7 @@ if (!CLI)
CLI::write(' - realms: Auth-DB not set up .. static data g_realms will be empty', CLI::LOG_WARN);
// else
// foreach ($realms as &$r)
// $r['battlegroup'] = CFG_BATTLEGROUP;
// $r['battlegroup'] = Cfg::get('BATTLEGROUP');
// remove access column
array_walk($realms, function (&$x) { unset($x['access']); });

View File

@@ -31,7 +31,7 @@ if (!CLI)
function talentCalc()
{
$success = true;
$spellMods = (new SpellList(array(['typeCat', -2], CFG_SQL_LIMIT_NONE)))->getProfilerMods();
$spellMods = (new SpellList(array(['typeCat', -2], Cfg::get('SQL_LIMIT_NONE'))))->getProfilerMods();
$buildTree = function ($class) use (&$petFamIcons, &$tSpells, $spellMods)
{
@@ -171,7 +171,7 @@ if (!CLI)
$success = false;
$tSpellIds = DB::Aowow()->selectCol('SELECT rank1 FROM dbc_talent UNION SELECT rank2 FROM dbc_talent UNION SELECT rank3 FROM dbc_talent UNION SELECT rank4 FROM dbc_talent UNION SELECT rank5 FROM dbc_talent');
$tSpells = new SpellList(array(['s.id', $tSpellIds], CFG_SQL_LIMIT_NONE));
$tSpells = new SpellList(array(['s.id', $tSpellIds], Cfg::get('SQL_LIMIT_NONE')));
foreach (CLISetup::$localeIds as $lId)
{