Safer way to check the leader is real player.

This commit is contained in:
bash
2025-08-07 01:18:54 +02:00
committed by GitHub
parent 3bc576f7fb
commit 687d996643

View File

@@ -213,29 +213,25 @@ public:
if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !player) if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !player)
return; return;
// when player is no bot. // no XP multiplier, when player is no bot.
if (!player->GetSession()->IsBot()) if (!player->GetSession()->IsBot() || !sRandomPlayerbotMgr->IsRandomBot(player))
return; return;
// when player is no bot, double check. // no XP multiplier, when bot has group where leader is a real player.
if (!sRandomPlayerbotMgr->IsRandomBot(player))
return;
// when bot has group where leader is a real player.
if (Group* group = player->GetGroup()) if (Group* group = player->GetGroup())
{ {
Player* leader = group->GetLeader(); Player* leader = group->GetLeader();
if (leader != player) if (leader != player)
{ {
if (!leader->GetSession()->IsBot()) if (PlayerbotAI* leaderBotAI = GET_PLAYERBOT_AI(leader))
return; {
if (leaderBotAI->HasRealPlayerMaster())
if (!sRandomPlayerbotMgr->IsRandomBot(leader)) return;
return; }
} }
} }
// otherwise apply bot XP scaling. // otherwise apply bot XP multiplier.
amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate)); amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate));
} }
}; };