From 630e1bcd0c4c640b9a891fc0d9a1190a0c8b8d66 Mon Sep 17 00:00:00 2001 From: Kargatum Date: Fri, 3 Dec 2021 04:08:51 +0700 Subject: [PATCH] feat(Config): replace old api (#17) --- modules/mod-arena-solo-3v3/src/Solo3v3.cpp | 10 +++++----- modules/mod-arena-solo-3v3/src/Solo3v3_SC.cpp | 20 +++++++++---------- .../src/plugins/AzthPlayerPlg.cpp | 2 +- modules/mod-as-platform/src/AZTH.cpp | 14 ++++++------- modules/mod-as-platform/src/AZTH_SC.cpp | 6 +++--- .../src/scripts/ChallengeModeMgr.cpp | 8 ++++---- .../src/scripts/ChallengeModeScript.cpp | 2 +- .../src/scripts/AzthSmartStone.cpp | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/modules/mod-arena-solo-3v3/src/Solo3v3.cpp b/modules/mod-arena-solo-3v3/src/Solo3v3.cpp index 782f0aa..479244e 100644 --- a/modules/mod-arena-solo-3v3/src/Solo3v3.cpp +++ b/modules/mod-arena-solo-3v3/src/Solo3v3.cpp @@ -176,7 +176,7 @@ void Solo3v3::CheckStartSolo3v3Arena(Battleground* bg) if (plr->GetInstanceId() != bg->GetInstanceID()) { - if (sConfigMgr->GetBoolDefault("Solo.3v3.CastDeserterOnAfk", true)) + if (sConfigMgr->GetOption("Solo.3v3.CastDeserterOnAfk", true)) plr->CastSpell(plr, 26013, true); // Deserter someoneNotInArena = true; @@ -184,7 +184,7 @@ void Solo3v3::CheckStartSolo3v3Arena(Battleground* bg) } } - if (someoneNotInArena && sConfigMgr->GetBoolDefault("Solo.3v3.StopGameIncomplete", true)) + if (someoneNotInArena && sConfigMgr->GetOption("Solo.3v3.StopGameIncomplete", true)) { bg->SetRated(false); bg->EndBattleground(TEAM_NEUTRAL); @@ -204,7 +204,7 @@ bool Solo3v3::CheckSolo3v3Arena(BattlegroundQueue* queue, BattlegroundBracketId uint32 MinPlayersPerTeam = sBattlegroundMgr->isArenaTesting() ? 1 : 3; - bool filterTalents = sConfigMgr->GetBoolDefault("Solo.3v3.FilterTalents", false); + bool filterTalents = sConfigMgr->GetOption("Solo.3v3.FilterTalents", false); for (int teamId = 0; teamId < 2; teamId++) // BG_QUEUE_PREMADE_ALLIANCE and BG_QUEUE_PREMADE_HORDE { @@ -313,7 +313,7 @@ bool Solo3v3::Arena1v1CheckTalents(Player* player) if (!player) return false; - if (sConfigMgr->GetBoolDefault("Arena.1v1.BlockForbiddenTalents", false) == false) + if (sConfigMgr->GetOption("Arena.1v1.BlockForbiddenTalents", false) == false) return true; uint32 count = 0; @@ -349,7 +349,7 @@ bool Solo3v3::Arena1v1CheckTalents(Player* player) Solo3v3TalentCat Solo3v3::GetTalentCatForSolo3v3(Player* player) { - if (!player || !sConfigMgr->GetBoolDefault("Solo.3v3.FilterTalents", false)) + if (!player || !sConfigMgr->GetOption("Solo.3v3.FilterTalents", false)) return MELEE; uint32 count[MAX_TALENT_CAT]; diff --git a/modules/mod-arena-solo-3v3/src/Solo3v3_SC.cpp b/modules/mod-arena-solo-3v3/src/Solo3v3_SC.cpp index e8a9f8e..2b9b7e5 100644 --- a/modules/mod-arena-solo-3v3/src/Solo3v3_SC.cpp +++ b/modules/mod-arena-solo-3v3/src/Solo3v3_SC.cpp @@ -31,7 +31,7 @@ class npc_solo3v3 : public CreatureScript if (!player || !me) return true; - if (sConfigMgr->GetBoolDefault("Solo.3v3.Enable", true) == false) + if (sConfigMgr->GetOption("Solo.3v3.Enable", true) == false) { ChatHandler(player->GetSession()).SendSysMessage("Arena disabled!"); return true; @@ -42,7 +42,7 @@ class npc_solo3v3 : public CreatureScript infoQueue << "Solo 3vs3 Arena\n"; infoQueue << "Queued Players: " << (cache3v3Queue[MELEE] + cache3v3Queue[RANGE] + cache3v3Queue[HEALER]); - if (sConfigMgr->GetBoolDefault("Solo.3v3.FilterTalents", false)) + if (sConfigMgr->GetOption("Solo.3v3.FilterTalents", false)) { infoQueue << "\n\n"; infoQueue << "Queued Melees: " << cache3v3Queue[MELEE] << " (Longer Queues!)" << "\n"; @@ -55,7 +55,7 @@ class npc_solo3v3 : public CreatureScript if (!player->GetArenaTeamId(ArenaTeam::GetSlotByType(ARENA_TEAM_SOLO_3v3))) { - uint32 cost = sConfigMgr->GetIntDefault("Solo.3v3.Cost", 1); + uint32 cost = sConfigMgr->GetOption("Solo.3v3.Cost", 1); if (sAZTH->GetAZTHPlayer(player)->isPvP()) cost = 0; @@ -94,19 +94,19 @@ class npc_solo3v3 : public CreatureScript { case 1: // Create new Arenateam { - if (sConfigMgr->GetIntDefault("Solo.3v3.MinLevel", 80) <= player->getLevel()) + if (sConfigMgr->GetOption("Solo.3v3.MinLevel", 80) <= player->getLevel()) { - int cost = sConfigMgr->GetIntDefault("Solo.3v3.Cost", 1); + int cost = sConfigMgr->GetOption("Solo.3v3.Cost", 1); if (sAZTH->GetAZTHPlayer(player)->isPvP()) cost = 0; if (cost >= 0 && player->GetMoney() >= uint32(cost) && CreateArenateam(player, me)) - player->ModifyMoney(sConfigMgr->GetIntDefault("Solo.3v3.Cost", 1) * -1); + player->ModifyMoney(sConfigMgr->GetOption("Solo.3v3.Cost", 1) * -1); } else { - ChatHandler(player->GetSession()).PSendSysMessage("You need level %u+ to create an arena team.", sConfigMgr->GetIntDefault("Solo.3v3.MinLevel", 80)); + ChatHandler(player->GetSession()).PSendSysMessage("You need level %u+ to create an arena team.", sConfigMgr->GetOption("Solo.3v3.MinLevel", 80)); } CloseGossipMenuFor(player); @@ -117,7 +117,7 @@ class npc_solo3v3 : public CreatureScript case 2: // 3v3 Join Queue Arena (rated) { // check Deserter debuff - if (player->HasAura(26013) && (sConfigMgr->GetBoolDefault("Solo.3v3.CastDeserterOnAfk", true) || sConfigMgr->GetBoolDefault("Solo.3v3.CastDeserterOnLeave", true))) + if (player->HasAura(26013) && (sConfigMgr->GetOption("Solo.3v3.CastDeserterOnAfk", true) || sConfigMgr->GetOption("Solo.3v3.CastDeserterOnLeave", true))) { WorldPacket data; sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS); @@ -199,7 +199,7 @@ class npc_solo3v3 : public CreatureScript if (!player) return false; - if (!sConfigMgr->GetBoolDefault("Arena.CheckEquipAndTalents", true)) + if (!sConfigMgr->GetOption("Arena.CheckEquipAndTalents", true)) return true; std::stringstream err; @@ -234,7 +234,7 @@ class npc_solo3v3 : public CreatureScript if (!player || !me) return false; - if (sConfigMgr->GetIntDefault("Solo.3v3.MinLevel", 80) > player->getLevel()) + if (sConfigMgr->GetOption("Solo.3v3.MinLevel", 80) > player->getLevel()) return false; uint8 arenaslot = ArenaTeam::GetSlotByType(ARENA_TEAM_SOLO_3v3); diff --git a/modules/mod-as-common/src/plugins/AzthPlayerPlg.cpp b/modules/mod-as-common/src/plugins/AzthPlayerPlg.cpp index 8d79c7b..c37a7df 100644 --- a/modules/mod-as-common/src/plugins/AzthPlayerPlg.cpp +++ b/modules/mod-as-common/src/plugins/AzthPlayerPlg.cpp @@ -65,7 +65,7 @@ class AzthPlayerPlg : public PlayerScript // if (!player) // return; - // if (oldLevel == 9 && !sAZTH->GetAZTHPlayer(player)->isTimeWalking() && sConfigMgr->GetBoolDefault("Azth.LevelBonus.10.Enable", false)) + // if (oldLevel == 9 && !sAZTH->GetAZTHPlayer(player)->isTimeWalking() && sConfigMgr->GetOption("Azth.LevelBonus.10.Enable", false)) // sAZTH->SendGameMail(player, "Well done!", "You reached level 10, a small present for you by AzerothShard!", 10 * GOLD); // } diff --git a/modules/mod-as-platform/src/AZTH.cpp b/modules/mod-as-platform/src/AZTH.cpp index d4d604c..061aa9d 100644 --- a/modules/mod-as-platform/src/AZTH.cpp +++ b/modules/mod-as-platform/src/AZTH.cpp @@ -21,20 +21,20 @@ AZTH* AZTH::instance() void AZTH::LoadConfig(bool reload) { // PvP Ranks - Tokenizer PvPRankList(sConfigMgr->GetStringDefault("PvPRank.HKPerRank", "10,50,100,200,450,750,1300,2000,3500,6000,9500,15000,21000,30000"), ','); + Tokenizer PvPRankList(sConfigMgr->GetOption("PvPRank.HKPerRank", "10,50,100,200,450,750,1300,2000,3500,6000,9500,15000,21000,30000"), ','); for (uint8 i = 0; i < PvPRankList.size(); i++) _PvP_Ranks[i] = atoi(PvPRankList[i]); - _RatePvPRankExtraHonor = sConfigMgr->GetFloatDefault("PvPRank.Rate.ExtraHonor", 1); + _RatePvPRankExtraHonor = sConfigMgr->GetOption("PvPRank.Rate.ExtraHonor", 1); // External Mail - _IsExternalMailEnable = sConfigMgr->GetBoolDefault("ExternalMail", 0); - _ExternalMailInterval = sConfigMgr->GetIntDefault("ExternalMailInterval", 1) * MINUTE * IN_MILLISECONDS; + _IsExternalMailEnable = sConfigMgr->GetOption("ExternalMail", 0); + _ExternalMailInterval = sConfigMgr->GetOption("ExternalMailInterval", 1) * MINUTE * IN_MILLISECONDS; // Custom XP - _CustomXPSecurity = sConfigMgr->GetIntDefault("Player.customXP.security", 0); - _CustomXPMax = sConfigMgr->GetFloatDefault("Player.customXP.maxValue", 1); - _CustomXPShowOnLogin = sConfigMgr->GetBoolDefault("Player.customXP.showOnLogin", false); + _CustomXPSecurity = sConfigMgr->GetOption("Player.customXP.security", 0); + _CustomXPMax = sConfigMgr->GetOption("Player.customXP.maxValue", 1); + _CustomXPShowOnLogin = sConfigMgr->GetOption("Player.customXP.showOnLogin", false); if (!reload) LoadContainers(); diff --git a/modules/mod-as-platform/src/AZTH_SC.cpp b/modules/mod-as-platform/src/AZTH_SC.cpp index 9035644..f2dc2c9 100644 --- a/modules/mod-as-platform/src/AZTH_SC.cpp +++ b/modules/mod-as-platform/src/AZTH_SC.cpp @@ -67,10 +67,10 @@ class Arena_SC : public ArenaScript return; if (team->GetType() == ARENA_TEAM_1v1) - points *= sConfigMgr->GetFloatDefault("Azth.Rate.Arena1v1", 0.40f); + points *= sConfigMgr->GetOption("Azth.Rate.Arena1v1", 0.40f); if (team->GetType() == ARENA_TEAM_SOLO_3v3) - points *= sConfigMgr->GetFloatDefault("Solo.3v3.ArenaPointsMulti", 0.88f); + points *= sConfigMgr->GetOption("Solo.3v3.ArenaPointsMulti", 0.88f); } bool CanSaveToDB(ArenaTeam* team) override @@ -1002,7 +1002,7 @@ class Misc_SC : public MiscScript void OnAfterLootTemplateProcess(Loot* loot, LootTemplate const* tab, LootStore const& store, Player* lootOwner, bool /* personal */, bool /* noEmptyError */, uint16 lootMode) override { - if (!sConfigMgr->GetBoolDefault("Azth.Multiplies.Drop.Enable", false)) + if (!sConfigMgr->GetOption("Azth.Multiplies.Drop.Enable", false)) return; //Dangerous since it can drops multiple quest items diff --git a/modules/mod-challenge-mode/src/scripts/ChallengeModeMgr.cpp b/modules/mod-challenge-mode/src/scripts/ChallengeModeMgr.cpp index 602b2d8..b73677b 100644 --- a/modules/mod-challenge-mode/src/scripts/ChallengeModeMgr.cpp +++ b/modules/mod-challenge-mode/src/scripts/ChallengeModeMgr.cpp @@ -10,10 +10,10 @@ ChallengeModeMgr* ChallengeModeMgr::instance() void ChallengeModeMgr::LoadConfig(bool /* reload */) { - this->deltaLevelHigher = sConfigMgr->GetIntDefault("ChallengeMode.noReward.deltaLevelHigher", 0); - this->deltaLevelLower = sConfigMgr->GetIntDefault("ChallengeMode.noReward.deltaLevelLower", 0); - this->startLevelHigher = sConfigMgr->GetIntDefault("ChallengeMode.noReward.startLevelHigher", 0); - this->startLevelLower = sConfigMgr->GetIntDefault("ChallengeMode.noReward.startLevelLower", 0); + this->deltaLevelHigher = sConfigMgr->GetOption("ChallengeMode.noReward.deltaLevelHigher", 0); + this->deltaLevelLower = sConfigMgr->GetOption("ChallengeMode.noReward.deltaLevelLower", 0); + this->startLevelHigher = sConfigMgr->GetOption("ChallengeMode.noReward.startLevelHigher", 0); + this->startLevelLower = sConfigMgr->GetOption("ChallengeMode.noReward.startLevelLower", 0); } bool ChallengeModeMgr::isEligibleForReward(Player const *player) { diff --git a/modules/mod-challenge-mode/src/scripts/ChallengeModeScript.cpp b/modules/mod-challenge-mode/src/scripts/ChallengeModeScript.cpp index bae66c9..6882e7c 100644 --- a/modules/mod-challenge-mode/src/scripts/ChallengeModeScript.cpp +++ b/modules/mod-challenge-mode/src/scripts/ChallengeModeScript.cpp @@ -28,7 +28,7 @@ class ChallengeModeMisc : public MiscScript void OnAfterLootTemplateProcess(Loot* /* loot */, LootTemplate const* /* tab */, LootStore const& /* store */, Player* /* lootOwner */, bool /* personal */, bool /* noEmptyError */, uint16 /* lootMode */) override { - // if (!sConfigMgr->GetBoolDefault("Azth.Multiplies.Drop.Enable", false)) + // if (!sConfigMgr->GetOption("Azth.Multiplies.Drop.Enable", false)) // return; //Dangerous since it can drops multiple quest items diff --git a/modules/mod-smartstone/src/scripts/AzthSmartStone.cpp b/modules/mod-smartstone/src/scripts/AzthSmartStone.cpp index 668fd9a..0abfb8d 100644 --- a/modules/mod-smartstone/src/scripts/AzthSmartStone.cpp +++ b/modules/mod-smartstone/src/scripts/AzthSmartStone.cpp @@ -240,7 +240,7 @@ class azth_smart_stone : public ItemScript // black market teleport id 1 SmartStoneCommand teleport = sSmartStone->getCommandById(SMRTST_BLACK_MARKET); - if (sConfigMgr->GetBoolDefault("Azth.Smartstone.Teleport.Enable", false)) + if (sConfigMgr->GetOption("Azth.Smartstone.Teleport.Enable", false)) { if (!sAZTH->GetAZTHPlayer(player)->isInBlackMarket()) {