Skip to content

Commit

Permalink
feat(Config): replace old api (azerothcore#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Winfidonarleyan authored Dec 2, 2021
1 parent eeac029 commit 630e1bc
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions modules/mod-arena-solo-3v3/src/Solo3v3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ void Solo3v3::CheckStartSolo3v3Arena(Battleground* bg)

if (plr->GetInstanceId() != bg->GetInstanceID())
{
if (sConfigMgr->GetBoolDefault("Solo.3v3.CastDeserterOnAfk", true))
if (sConfigMgr->GetOption<bool>("Solo.3v3.CastDeserterOnAfk", true))
plr->CastSpell(plr, 26013, true); // Deserter

someoneNotInArena = true;
}
}
}

if (someoneNotInArena && sConfigMgr->GetBoolDefault("Solo.3v3.StopGameIncomplete", true))
if (someoneNotInArena && sConfigMgr->GetOption<bool>("Solo.3v3.StopGameIncomplete", true))
{
bg->SetRated(false);
bg->EndBattleground(TEAM_NEUTRAL);
Expand All @@ -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<bool>("Solo.3v3.FilterTalents", false);

for (int teamId = 0; teamId < 2; teamId++) // BG_QUEUE_PREMADE_ALLIANCE and BG_QUEUE_PREMADE_HORDE
{
Expand Down Expand Up @@ -313,7 +313,7 @@ bool Solo3v3::Arena1v1CheckTalents(Player* player)
if (!player)
return false;

if (sConfigMgr->GetBoolDefault("Arena.1v1.BlockForbiddenTalents", false) == false)
if (sConfigMgr->GetOption<bool>("Arena.1v1.BlockForbiddenTalents", false) == false)
return true;

uint32 count = 0;
Expand Down Expand Up @@ -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<bool>("Solo.3v3.FilterTalents", false))
return MELEE;

uint32 count[MAX_TALENT_CAT];
Expand Down
20 changes: 10 additions & 10 deletions modules/mod-arena-solo-3v3/src/Solo3v3_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("Solo.3v3.Enable", true) == false)
{
ChatHandler(player->GetSession()).SendSysMessage("Arena disabled!");
return true;
Expand All @@ -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<bool>("Solo.3v3.FilterTalents", false))
{
infoQueue << "\n\n";
infoQueue << "Queued Melees: " << cache3v3Queue[MELEE] << " (Longer Queues!)" << "\n";
Expand All @@ -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<uint32>("Solo.3v3.Cost", 1);

if (sAZTH->GetAZTHPlayer(player)->isPvP())
cost = 0;
Expand Down Expand Up @@ -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<uint32>("Solo.3v3.MinLevel", 80) <= player->getLevel())
{
int cost = sConfigMgr->GetIntDefault("Solo.3v3.Cost", 1);
int cost = sConfigMgr->GetOption<uint32>("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<uint32>("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<uint32>("Solo.3v3.MinLevel", 80));
}

CloseGossipMenuFor(player);
Expand All @@ -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<bool>("Solo.3v3.CastDeserterOnAfk", true) || sConfigMgr->GetOption<bool>("Solo.3v3.CastDeserterOnLeave", true)))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
Expand Down Expand Up @@ -199,7 +199,7 @@ class npc_solo3v3 : public CreatureScript
if (!player)
return false;

if (!sConfigMgr->GetBoolDefault("Arena.CheckEquipAndTalents", true))
if (!sConfigMgr->GetOption<bool>("Arena.CheckEquipAndTalents", true))
return true;

std::stringstream err;
Expand Down Expand Up @@ -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<uint32>("Solo.3v3.MinLevel", 80) > player->getLevel())
return false;

uint8 arenaslot = ArenaTeam::GetSlotByType(ARENA_TEAM_SOLO_3v3);
Expand Down
2 changes: 1 addition & 1 deletion modules/mod-as-common/src/plugins/AzthPlayerPlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("Azth.LevelBonus.10.Enable", false))
// sAZTH->SendGameMail(player, "Well done!", "You reached level 10, a small present for you by AzerothShard!", 10 * GOLD);
// }

Expand Down
14 changes: 7 additions & 7 deletions modules/mod-as-platform/src/AZTH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("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<float>("PvPRank.Rate.ExtraHonor", 1);

// External Mail
_IsExternalMailEnable = sConfigMgr->GetBoolDefault("ExternalMail", 0);
_ExternalMailInterval = sConfigMgr->GetIntDefault("ExternalMailInterval", 1) * MINUTE * IN_MILLISECONDS;
_IsExternalMailEnable = sConfigMgr->GetOption<bool>("ExternalMail", 0);
_ExternalMailInterval = sConfigMgr->GetOption<uint32>("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<uint32>("Player.customXP.security", 0);
_CustomXPMax = sConfigMgr->GetOption<float>("Player.customXP.maxValue", 1);
_CustomXPShowOnLogin = sConfigMgr->GetOption<bool>("Player.customXP.showOnLogin", false);

if (!reload)
LoadContainers();
Expand Down
6 changes: 3 additions & 3 deletions modules/mod-as-platform/src/AZTH_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>("Azth.Rate.Arena1v1", 0.40f);

if (team->GetType() == ARENA_TEAM_SOLO_3v3)
points *= sConfigMgr->GetFloatDefault("Solo.3v3.ArenaPointsMulti", 0.88f);
points *= sConfigMgr->GetOption<float>("Solo.3v3.ArenaPointsMulti", 0.88f);
}

bool CanSaveToDB(ArenaTeam* team) override
Expand Down Expand Up @@ -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<bool>("Azth.Multiplies.Drop.Enable", false))
return;

//Dangerous since it can drops multiple quest items
Expand Down
8 changes: 4 additions & 4 deletions modules/mod-challenge-mode/src/scripts/ChallengeModeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32>("ChallengeMode.noReward.deltaLevelHigher", 0);
this->deltaLevelLower = sConfigMgr->GetOption<uint32>("ChallengeMode.noReward.deltaLevelLower", 0);
this->startLevelHigher = sConfigMgr->GetOption<uint32>("ChallengeMode.noReward.startLevelHigher", 0);
this->startLevelLower = sConfigMgr->GetOption<uint32>("ChallengeMode.noReward.startLevelLower", 0);
}

bool ChallengeModeMgr::isEligibleForReward(Player const *player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("Azth.Multiplies.Drop.Enable", false))
// return;

//Dangerous since it can drops multiple quest items
Expand Down
2 changes: 1 addition & 1 deletion modules/mod-smartstone/src/scripts/AzthSmartStone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("Azth.Smartstone.Teleport.Enable", false))
{
if (!sAZTH->GetAZTHPlayer(player)->isInBlackMarket())
{
Expand Down

0 comments on commit 630e1bc

Please sign in to comment.