From d4a8c4abab31de5718f46db7b0d1ad6aaaca2373 Mon Sep 17 00:00:00 2001 From: bash <31279994+hermensbas@users.noreply.github.com> Date: Sat, 2 Aug 2025 17:06:28 +0200 Subject: [PATCH] Optimize code --- src/Playerbots.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Playerbots.cpp b/src/Playerbots.cpp index 0169461a..ca92711c 100644 --- a/src/Playerbots.cpp +++ b/src/Playerbots.cpp @@ -209,13 +209,19 @@ public: void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override { + // when default no XP scaling. + if (sPlayerbotAIConfig->randomBotXPRate == 1.0) + return; + + // when player is no bot. if (!player->GetSession()->IsBot()) return; - + + // when player is no bot, double check. if (!sRandomPlayerbotMgr->IsRandomBot(player)) return; - // if player in group check leader is real player. + // when bot has group where leader is a real player. if (Group* group = player->GetGroup()) { Player* leader = group->GetLeader(); @@ -229,10 +235,8 @@ public: } } - if (sPlayerbotAIConfig->randomBotXPRate != 1.0) - { - amount = static_cast(std::round(static_cast(amount) * sPlayerbotAIConfig->randomBotXPRate)); - } + // otherwise apply bot XP scaling. + amount = static_cast(std::round(static_cast(amount) * sPlayerbotAIConfig->randomBotXPRate)); } };