mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Crash fix] Fix race condition on BattlegroundData
This commit is contained in:
@@ -165,6 +165,13 @@ RandomPlayerbotMgr::RandomPlayerbotMgr() : PlayerbotHolder(), processTicks(0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BattlegroundData.clear();
|
BattlegroundData.clear();
|
||||||
|
for (int bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
|
||||||
|
{
|
||||||
|
for (int queueType = BATTLEGROUND_QUEUE_AV; queueType < MAX_BATTLEGROUND_QUEUE_TYPES; ++queueType)
|
||||||
|
{
|
||||||
|
BattlegroundData[queueType][bracket] = BattlegroundInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
BgCheckTimer = 0;
|
BgCheckTimer = 0;
|
||||||
LfgCheckTimer = 0;
|
LfgCheckTimer = 0;
|
||||||
PlayersCheckTimer = 0;
|
PlayersCheckTimer = 0;
|
||||||
@@ -341,19 +348,19 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
|
|||||||
if (sPlayerbotAIConfig->syncLevelWithPlayers && !players.empty())
|
if (sPlayerbotAIConfig->syncLevelWithPlayers && !players.empty())
|
||||||
{
|
{
|
||||||
if (time(nullptr) > (PlayersCheckTimer + 60))
|
if (time(nullptr) > (PlayersCheckTimer + 60))
|
||||||
activateCheckPlayersThread();
|
sRandomPlayerbotMgr->CheckPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sPlayerbotAIConfig->randomBotJoinBG /* && !players.empty()*/)
|
if (sPlayerbotAIConfig->randomBotJoinBG /* && !players.empty()*/)
|
||||||
{
|
{
|
||||||
if (time(nullptr) > (BgCheckTimer + 30))
|
if (time(nullptr) > (BgCheckTimer + 30))
|
||||||
activateCheckBgQueueThread();
|
sRandomPlayerbotMgr->CheckBgQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sPlayerbotAIConfig->randomBotJoinLfg /* && !players.empty()*/)
|
if (sPlayerbotAIConfig->randomBotJoinLfg /* && !players.empty()*/)
|
||||||
{
|
{
|
||||||
if (time(nullptr) > (LfgCheckTimer + 30))
|
if (time(nullptr) > (LfgCheckTimer + 30))
|
||||||
activateCheckLfgQueueThread();
|
sRandomPlayerbotMgr->CheckLfgQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 updateBots = sPlayerbotAIConfig->randomBotsPerInterval * onlineBotFocus / 100;
|
uint32 updateBots = sPlayerbotAIConfig->randomBotsPerInterval * onlineBotFocus / 100;
|
||||||
@@ -594,6 +601,14 @@ void RandomPlayerbotMgr::CheckBgQueue()
|
|||||||
|
|
||||||
BattlegroundData.clear();
|
BattlegroundData.clear();
|
||||||
|
|
||||||
|
for (int bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
|
||||||
|
{
|
||||||
|
for (int queueType = BATTLEGROUND_QUEUE_AV; queueType < MAX_BATTLEGROUND_QUEUE_TYPES; ++queueType)
|
||||||
|
{
|
||||||
|
BattlegroundData[queueType][bracket] = BattlegroundInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Player* player : players)
|
for (Player* player : players)
|
||||||
{
|
{
|
||||||
if (!player->InBattlegroundQueue())
|
if (!player->InBattlegroundQueue())
|
||||||
@@ -840,7 +855,8 @@ void RandomPlayerbotMgr::LogBattlegroundInfo()
|
|||||||
for (const auto& bracketIdPair : queueTypePair.second)
|
for (const auto& bracketIdPair : queueTypePair.second)
|
||||||
{
|
{
|
||||||
auto& bgInfo = bracketIdPair.second;
|
auto& bgInfo = bracketIdPair.second;
|
||||||
|
if (bgInfo.minLevel == 0)
|
||||||
|
continue;
|
||||||
LOG_INFO("playerbots",
|
LOG_INFO("playerbots",
|
||||||
"ARENA:{} {}: Player (Skirmish:{}, Rated:{}) Bots (Skirmish:{}, Rated:{}) Total (Skirmish:{} "
|
"ARENA:{} {}: Player (Skirmish:{}, Rated:{}) Bots (Skirmish:{}, Rated:{}) Total (Skirmish:{} "
|
||||||
"Rated:{}), Instances (Skirmish:{} Rated:{})",
|
"Rated:{}), Instances (Skirmish:{} Rated:{})",
|
||||||
@@ -889,6 +905,8 @@ void RandomPlayerbotMgr::LogBattlegroundInfo()
|
|||||||
for (const auto& bracketIdPair : queueTypePair.second)
|
for (const auto& bracketIdPair : queueTypePair.second)
|
||||||
{
|
{
|
||||||
auto& bgInfo = bracketIdPair.second;
|
auto& bgInfo = bracketIdPair.second;
|
||||||
|
if (bgInfo.minLevel == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
LOG_INFO("playerbots", "BG:{} {}: Player ({}:{}) Bot ({}:{}) Total (A:{} H:{}), Instances {}", _bgType,
|
LOG_INFO("playerbots", "BG:{} {}: Player ({}:{}) Bot ({}:{}) Total (A:{} H:{}), Instances {}", _bgType,
|
||||||
std::to_string(bgInfo.minLevel) + "-" + std::to_string(bgInfo.maxLevel),
|
std::to_string(bgInfo.minLevel) + "-" + std::to_string(bgInfo.maxLevel),
|
||||||
|
|||||||
Reference in New Issue
Block a user