mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 00:58:33 +00:00
[Revert] Threading leftover which belonged to other related PRs's (once green needs be merged) (#1583)
* Revert "Correct side effects of mergef5ef5bd1c2(#1512)" This reverts commit966bf1d6af. * Revert "Fix ACCESS_VIOLATION in mod-playerbots: purge stale AIs, add thread-safety, and harden HasRealPlayerMaster (#1507)" This reverts commitf5ef5bd1c2.
This commit is contained in:
@@ -4124,37 +4124,15 @@ bool IsAlliance(uint8 race)
|
||||
|
||||
bool PlayerbotAI::HasRealPlayerMaster()
|
||||
{
|
||||
// if (master)
|
||||
// {
|
||||
// PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master);
|
||||
// return !masterBotAI || masterBotAI->IsRealPlayer();
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
|
||||
// Removes a long-standing crash (0xC0000005 ACCESS_VIOLATION)
|
||||
/* 1) The "master" pointer can be null if the bot was created
|
||||
without a master player or if the master was just removed. */
|
||||
if (!master)
|
||||
return false;
|
||||
|
||||
/* 2) Is the master player still present in the world?
|
||||
If FindPlayer fails, we invalidate "master" and stop here. */
|
||||
if (!ObjectAccessor::FindPlayer(master->GetGUID()))
|
||||
if (master)
|
||||
{
|
||||
master = nullptr; // avoids repeating the check on the next tick
|
||||
return false;
|
||||
PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master);
|
||||
return !masterBotAI || masterBotAI->IsRealPlayer();
|
||||
}
|
||||
|
||||
/* 3) If the master is a bot, we check that it is itself controlled
|
||||
by a real player. Otherwise, it's already a real player → true. */
|
||||
if (PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master))
|
||||
return masterBotAI->IsRealPlayer(); // bot controlled by a player?
|
||||
|
||||
return true; // master = real player
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool PlayerbotAI::HasActivePlayerMaster() { return master && !GET_PLAYERBOT_AI(master); }
|
||||
|
||||
bool PlayerbotAI::IsAlt() { return HasRealPlayerMaster() && !sRandomPlayerbotMgr->IsRandomBot(bot); }
|
||||
|
||||
Reference in New Issue
Block a user