Core/Battlegrounds: Store mercenary status separately from the aura obtained from gossip as it can be removed at any time

This commit is contained in:
Shauren
2022-04-14 23:31:17 +02:00
parent 15fe4e09d4
commit 84486ded67
10 changed files with 78 additions and 47 deletions

View File

@@ -1864,7 +1864,7 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed)
}
}
GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(Battleground const* bgOrTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 /*MaxPlayerCount*/, bool isRated, uint32 arenaSlot, ObjectGuid& errorGuid)
GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(Battleground const* bgOrTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 /*MaxPlayerCount*/, bool isRated, uint32 arenaSlot, ObjectGuid& errorGuid) const
{
// check if this group is LFG group
if (isLFGGroup())
@@ -1892,10 +1892,11 @@ GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(Battleground const*
uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot);
uint32 team = reference->GetTeam();
bool isMercenary = reference->HasAura(SPELL_MERCENARY_CONTRACT_HORDE) || reference->HasAura(SPELL_MERCENARY_CONTRACT_ALLIANCE);
// check every member of the group to be able to join
memberscount = 0;
for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next(), ++memberscount)
for (GroupReference const* itr = GetFirstMember(); itr != nullptr; itr = itr->next(), ++memberscount)
{
Player* member = itr->GetSource();
// offline member? don't let join
@@ -1940,6 +1941,8 @@ GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(Battleground const*
// check Freeze debuff
if (member->HasAura(9454))
return ERR_BATTLEGROUND_JOIN_FAILED;
if (isMercenary != (member->HasAura(SPELL_MERCENARY_CONTRACT_HORDE) || member->HasAura(SPELL_MERCENARY_CONTRACT_ALLIANCE)))
return ERR_BATTLEGROUND_JOIN_MERCENARY;
}
// only check for MinPlayerCount since MinPlayerCount == MaxPlayerCount for arenas...