diff --git a/playerbot/RandomPlayerbotMgr.cpp b/playerbot/RandomPlayerbotMgr.cpp index c1fc349a..2d77746e 100644 --- a/playerbot/RandomPlayerbotMgr.cpp +++ b/playerbot/RandomPlayerbotMgr.cpp @@ -1152,44 +1152,12 @@ void RandomPlayerbotMgr::CheckBgQueue() BattleGroundBracketId bracketId = pvpDiff->GetBracketId(); #else - BattleGroundBracketId bracketId = player->GetBattleGroundBracketIdFromLevel(bgTypeId); + BattleGroundBracketId bracketId = sBattleGroundMgr.GetBattleGroundBracketIdFromLevel(bgTypeId, player->GetLevel()); #endif #endif -#ifndef MANGOSBOT_ZERO +#ifdef MANGOSBOT_TWO if (ArenaType arenaType = sServerFacade.BgArenaType(queueTypeId)) { -#ifdef MANGOS - BattleGroundQueue& bgQueue = sServerFacade.bgQueue(queueTypeId); - GroupQueueInfo ginfo; - uint32 tempT = TeamId; - - if (bgQueue.GetPlayerGroupInfoData(player->GetObjectGuid(), &ginfo)) - { - if (ginfo.IsRated) - { - for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot) - { - uint32 arena_team_id = player->GetArenaTeamId(arena_slot); - ArenaTeam* arenateam = sObjectMgr.GetArenaTeamById(arena_team_id); - if (!arenateam) - continue; - if (arenateam->GetType() != arenaType) - continue; - - Rating[queueTypeId][bracketId][1] = arenateam->GetRating(); - } - } - TeamId = ginfo.IsRated ? 1 : 0; - } - if (player->InArena()) - { - if (player->GetBattleGround()->isRated() && (ginfo.IsRated && ginfo.ArenaTeamId && ginfo.ArenaTeamRating && ginfo.OpponentsTeamRating)) - TeamId = 1; - else - TeamId = 0; - } -#endif -#ifdef CMANGOS BattleGroundQueue& bgQueue = sServerFacade.bgQueue(queueTypeId); GroupQueueInfo ginfo; uint32 tempT = TeamId; @@ -1219,11 +1187,50 @@ void RandomPlayerbotMgr::CheckBgQueue() else TeamId = 0; } -#endif ArenaBots[queueTypeId][bracketId][TeamId][tempT]++; - } + } #endif +#ifdef MANGOSBOT_ONE + if (ArenaType arenaType = sServerFacade.BgArenaType(queueTypeId)) + { + sWorld.GetBGQueue().GetMessager().AddMessage([queueTypeId, player = player, arenaType = arenaType, bracketId = bracketId, tempT = TeamId](BattleGroundQueue* bgQueue) + { + uint32 TeamId; + GroupQueueInfo ginfo; + + BattleGroundQueueItem queueItem = bgQueue->GetBattleGroundQueue(queueTypeId); + + if (queueItem.GetPlayerGroupInfoData(player->GetObjectGuid(), &ginfo)) + { + if (ginfo.isRated) + { + for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot) + { + uint32 arena_team_id = player->GetArenaTeamId(arena_slot); + ArenaTeam* arenateam = sObjectMgr.GetArenaTeamById(arena_team_id); + if (!arenateam) + continue; + if (arenateam->GetType() != arenaType) + continue; + + sRandomPlayerbotMgr.Rating[queueTypeId][bracketId][1] = arenateam->GetRating(); + } + } + TeamId = ginfo.isRated ? 1 : 0; + } + if (player->InArena()) + { + if (player->GetBattleGround()->IsRated()/* && (ginfo.isRated && ginfo.arenaTeamId && ginfo.arenaTeamRating && ginfo.opponentsTeamRating)*/) + TeamId = 1; + else + TeamId = 0; + } + sRandomPlayerbotMgr.ArenaBots[queueTypeId][bracketId][TeamId][tempT]++; + } + ); + } +#endif if (player->GetPlayerbotAI()) BgBots[queueTypeId][bracketId][TeamId]++; else @@ -1281,10 +1288,10 @@ void RandomPlayerbotMgr::CheckBgQueue() BattleGroundBracketId bracketId = pvpDiff->GetBracketId(); #else - BattleGroundBracketId bracketId = bot->GetBattleGroundBracketIdFromLevel(bgTypeId); + BattleGroundBracketId bracketId = sBattleGroundMgr.GetBattleGroundBracketIdFromLevel(bgTypeId, bot->GetLevel());; #endif -#ifndef MANGOSBOT_ZERO +#ifdef MANGOSBOT_TWO ArenaType arenaType = sServerFacade.BgArenaType(queueTypeId); if (arenaType != ARENA_TYPE_NONE) { @@ -1304,6 +1311,34 @@ void RandomPlayerbotMgr::CheckBgQueue() } ArenaBots[queueTypeId][bracketId][TeamId][tempT]++; } +#endif +#ifdef MANGOSBOT_ONE + ArenaType arenaType = sServerFacade.BgArenaType(queueTypeId); + if (arenaType != ARENA_TYPE_NONE) + { + sWorld.GetBGQueue().GetMessager().AddMessage([queueTypeId, bot = bot, arenaType = arenaType, bracketId = bracketId, tempT = TeamId](BattleGroundQueue* bgQueue) + { + uint32 TeamId; + GroupQueueInfo ginfo; + + BattleGroundQueueItem queueItem = bgQueue->GetBattleGroundQueue(queueTypeId); + + if (queueItem.GetPlayerGroupInfoData(bot->GetObjectGuid(), &ginfo)) + { + TeamId = ginfo.isRated ? 1 : 0; + } + if (bot->InArena()) + { + if (bot->GetBattleGround()->IsRated()/* && (ginfo.isRated && ginfo.arenaTeamId && ginfo.arenaTeamRating && ginfo.opponentsTeamRating)*/) + TeamId = 1; + else + TeamId = 0; + } + sRandomPlayerbotMgr.ArenaBots[queueTypeId][bracketId][TeamId][tempT]++; + + } + ); + } #endif BgBots[queueTypeId][bracketId][TeamId]++; } diff --git a/playerbot/ServerFacade.h b/playerbot/ServerFacade.h index 18a158a9..312fc4ae 100644 --- a/playerbot/ServerFacade.h +++ b/playerbot/ServerFacade.h @@ -261,8 +261,10 @@ class ServerFacade #ifdef MANGOS return sBattleGroundMgr.m_BattleGroundQueues[queueTypeId]; #endif -#ifdef CMANGOS - return sBattleGroundMgr.m_battleGroundQueues[queueTypeId]; +#ifndef MANGOSBOT_ONE + //return sBattleGroundMgr.m_battleGroundQueues[queueTypeId]; +#else + return BattleGroundQueue(); #endif } diff --git a/playerbot/strategy/actions/BattleGroundJoinAction.cpp b/playerbot/strategy/actions/BattleGroundJoinAction.cpp index 497e45b0..a2a1454d 100644 --- a/playerbot/strategy/actions/BattleGroundJoinAction.cpp +++ b/playerbot/strategy/actions/BattleGroundJoinAction.cpp @@ -57,6 +57,12 @@ bool BGJoinAction::Execute(Event& event) if (!bg) return false; +#ifdef MANGOSBOT_ZERO + bracketId = bot->GetBattleGroundBracketIdFromLevel(bgTypeId); +#endif +#ifdef MANGOSBOT_ONE + bracketId = sBattleGroundMgr.GetBattleGroundBracketIdFromLevel(bgTypeId, bot->GetLevel()); +#endif #ifdef MANGOSBOT_TWO uint32 mapId = bg->GetMapId(); PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, bot->GetLevel()); @@ -64,8 +70,6 @@ bool BGJoinAction::Execute(Event& event) return false; bracketId = pvpDiff->GetBracketId(); -#else - bracketId = bot->GetBattleGroundBracketIdFromLevel(bgTypeId); #endif // Find BattleMaster by Entry @@ -332,20 +336,25 @@ bool BGJoinAction::canJoinBg(Player* player, BattleGroundQueueTypeId queueTypeId return false; // check bracket -#ifdef MANGOSBOT_TWO - BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); - uint32 mapId = bg->GetMapId(); - PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, player->GetLevel()); - if (!pvpDiff) +#ifdef MANGOSBOT_ZERO + if (bracketId != bot->GetBattleGroundBracketIdFromLevel(bgTypeId); + return false; +#endif +#ifdef MANGOSBOT_ONE + if (sBattleGroundMgr.GetBattleGroundBracketIdFromLevel(bgTypeId, bot->GetLevel()) != bracketId) return false; +#endif +#ifdef MANGOSBOT_TWO + BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); + uint32 mapId = bg->GetMapId(); + PvPDifficultyEntry const* pvpDiff = GetBattlegroundBracketByLevel(mapId, player->GetLevel()); + if (!pvpDiff) + return false; - BattleGroundBracketId bracket_temp = pvpDiff->GetBracketId(); + BattleGroundBracketId bracket_temp = pvpDiff->GetBracketId(); - if (bracket_temp != bracketId) - return false; -#else - if (player->GetBattleGroundBracketIdFromLevel(bgTypeId) != bracketId) - return false; + if (bracket_temp != bracketId) + return false; #endif return true; } @@ -656,9 +665,13 @@ bool BGJoinAction::JoinQueue(uint32 type) return false; bracketId = pvpDiff->GetBracketId(); -#else +#endif +#ifdef MANGOSBOS_ZERO bracketId = bot->GetBattleGroundBracketIdFromLevel(bgTypeId); #endif +#ifdef MANGOSBOS_ONE + bracketId = sBattleGroundMgr.GetBattleGroundBracketIdFromLevel(bgTypeId, bot->GetLevel()); +#endif uint32 BracketSize = bg->GetMaxPlayers(); uint32 TeamSize = bg->GetMaxPlayersPerTeam(); @@ -1185,7 +1198,12 @@ bool BGStatusAction::Execute(Event& event) if (!queueTypeId) return false; -#ifdef CMANGOS +#ifdef MANGOSBOT_ZERO + bracketId = bot->GetBattleGroundBracketIdFromLevel(_bgTypeId); +#endif +#ifdef MANGOSBOT_ONE + bracketId = sBattleGroundMgr.GetBattleGroundBracketIdFromLevel(_bgTypeId, bot->GetLevel()); +#endif #ifdef MANGOSBOT_TWO BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(_bgTypeId); if (!bg) @@ -1197,10 +1215,6 @@ bool BGStatusAction::Execute(Event& event) return false; bracketId = pvpDiff->GetBracketId(); - -#else - bracketId = bot->GetBattleGroundBracketIdFromLevel(_bgTypeId); -#endif #endif bool isArena = false; @@ -1327,6 +1341,7 @@ bool BGStatusAction::Execute(Event& event) // temp fix for crash //return true; +#ifdef MANGOSBOT_TWO BattleGroundQueue& bgQueue = sServerFacade.bgQueue(queueTypeId); GroupQueueInfo ginfo; if (bgQueue.GetPlayerGroupInfoData(bot->GetObjectGuid(), &ginfo)) @@ -1339,13 +1354,8 @@ bool BGStatusAction::Execute(Event& event) #ifndef MANGOSBOT_ZERO if (isArena) { -#ifdef MANGOS - _bgTypeId = bg->GetTypeID(); -#endif -#ifdef CMANGOS _bgTypeId = bg->GetTypeId(); } -#endif #endif sLog.outBasic("Bot #%u %s:%d <%s>: Force join %s %s", bot->GetGUIDLow(), bot->GetTeam() == ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType.c_str()); @@ -1416,6 +1426,9 @@ bool BGStatusAction::Execute(Event& event) sRandomPlayerbotMgr.BgBots[queueTypeId][bracketId][TeamId]--; return true; } +#else + return true; +#endif } if (statusid == STATUS_IN_PROGRESS) // placeholder for Leave BG if it takes too long { @@ -1428,6 +1441,7 @@ bool BGStatusAction::Execute(Event& event) #ifndef MANGOSBOT_ZERO if (isArena) { +#ifdef MANGOSBOT_TWO isArena = true; BattleGroundQueue& bgQueue = sServerFacade.bgQueue(queueTypeId); GroupQueueInfo ginfo; @@ -1436,19 +1450,7 @@ bool BGStatusAction::Execute(Event& event) sLog.outError("Bot #%u %s:%d <%s>: Missing QueueInfo for %s %s", bot->GetGUIDLow(), bot->GetTeam() == ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType.c_str()); return false; } -#ifdef MANGOS - if (ginfo.IsInvitedToBGInstanceGUID) - { - BattleGround* bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, BATTLEGROUND_TYPE_NONE); - if (!bg) - { - return false; - } - _bgTypeId = bg->GetTypeID(); - } -#endif -#ifdef CMANGOS if (ginfo.isInvitedToBgInstanceGuid) { BattleGround* bg = sBattleGroundMgr.GetBattleGround(ginfo.isInvitedToBgInstanceGuid, BATTLEGROUND_TYPE_NONE); @@ -1460,8 +1462,8 @@ bool BGStatusAction::Execute(Event& event) _bgTypeId = bg->GetTypeId(); } - } #endif + } #endif ai->Unmount(); diff --git a/playerbot/strategy/triggers/PvpTriggers.cpp b/playerbot/strategy/triggers/PvpTriggers.cpp index 7aec1090..83561826 100644 --- a/playerbot/strategy/triggers/PvpTriggers.cpp +++ b/playerbot/strategy/triggers/PvpTriggers.cpp @@ -91,7 +91,7 @@ bool BgInviteActiveTrigger::IsActive() BattleGroundQueueTypeId queueTypeId = bot->GetBattleGroundQueueTypeId(i); if (queueTypeId == BATTLEGROUND_QUEUE_NONE) continue; - +#ifdef MANGOSBOT_TWO BattleGroundQueue& bgQueue = sServerFacade.bgQueue(queueTypeId); GroupQueueInfo ginfo; if (bgQueue.GetPlayerGroupInfoData(bot->GetObjectGuid(), &ginfo)) @@ -102,6 +102,11 @@ bool BgInviteActiveTrigger::IsActive() return true; } } +#endif +#ifdef MANGOSBOT_ONE + if (bot->IsInvitedForBattleGroundQueueType(queueTypeId)) + return true; +#endif } return false; }