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

Port From (https://github.com/TrinityCore/TrinityCore/commit/84486ded67efc4e779412ff865c66ca8b9cee7ea)
This commit is contained in:
hondacrx
2022-05-31 12:07:04 -04:00
parent 5d315fd84d
commit 036c565f69
10 changed files with 83 additions and 54 deletions
+1
View File
@@ -2828,6 +2828,7 @@ namespace Game.Entities
currentBg.EventPlayerLoggedIn(this);
SetInviteForBattlegroundQueueType(bgQueueTypeId, currentBg.GetInstanceID());
SetMercenaryForBattlegroundQueueType(bgQueueTypeId, currentBg.IsPlayerMercenaryInBattleground(GetGUID()));
}
// Bg was not found - go to Entry Point
else
@@ -554,6 +554,7 @@ namespace Game.Entities
public BattlegroundQueueTypeId bgQueueTypeId;
public uint invitedToInstance;
public uint joinTime;
public bool mercenary;
}
// Holder for Battlegrounddata
+17
View File
@@ -448,6 +448,7 @@ namespace Game.Entities
m_bgBattlegroundQueueID[i].bgQueueTypeId = val;
m_bgBattlegroundQueueID[i].invitedToInstance = 0;
m_bgBattlegroundQueueID[i].joinTime = (uint)GameTime.GetGameTime();
m_bgBattlegroundQueueID[i].mercenary = HasAura(PlayerConst.SpellMercenaryContractHorde) || HasAura(PlayerConst.SpellMercenaryContractAlliance);
return i;
}
}
@@ -471,6 +472,7 @@ namespace Game.Entities
m_bgBattlegroundQueueID[i].bgQueueTypeId = default;
m_bgBattlegroundQueueID[i].invitedToInstance = 0;
m_bgBattlegroundQueueID[i].joinTime = 0;
m_bgBattlegroundQueueID[i].mercenary = false;
return;
}
}
@@ -491,6 +493,21 @@ namespace Game.Entities
return false;
}
void SetMercenaryForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, bool mercenary)
{
for (byte i = 0; i < SharedConst.MaxPlayerBGQueues; ++i)
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
m_bgBattlegroundQueueID[i].mercenary = mercenary;
}
public bool IsMercenaryForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId)
{
for (byte i = 0; i < SharedConst.MaxPlayerBGQueues; ++i)
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
return m_bgBattlegroundQueueID[i].mercenary;
return false;
}
public WorldLocation GetBattlegroundEntryPoint() { return m_bgData.joinPos; }
public bool InBattleground() { return m_bgData.bgInstanceID != 0; }
-11
View File
@@ -3524,17 +3524,6 @@ namespace Game.Entities
m_team = (m_team == Team.Alliance) ? Team.Horde : Team.Alliance;
}
public Team GetBgQueueTeam()
{
if (HasAura(PlayerConst.SpellMercenaryContractHorde))
return Team.Horde;
if (HasAura(PlayerConst.SpellMercenaryContractAlliance))
return Team.Alliance;
return GetTeam();
}
public Team GetNativeTeam() { return TeamForRace(GetRace()); }
public uint GetNativeTeamId() { return TeamIdForRace(GetRace()); }