Core/Players: Fixed crashes when accessing ActivePlayerData::PvpInfo

Port From (https://github.com/TrinityCore/TrinityCore/commit/55091ff4bcf4500d0ebe9701e6dc121f5e6a3bb2)
This commit is contained in:
hondacrx
2023-01-06 16:21:45 -05:00
parent 5a5feca121
commit b7e2c1d84a
2 changed files with 32 additions and 13 deletions
+22 -3
View File
@@ -18,7 +18,6 @@
using Framework.Constants;
using Framework.Database;
using Game.Arenas;
using Game.BattleFields;
using Game.BattleGrounds;
using Game.Cache;
using Game.DataStorage;
@@ -753,10 +752,30 @@ namespace Game.Entities
}
}
public uint GetArenaTeamId(byte slot) { return 0; }
public uint GetArenaPersonalRating(byte slot) { return m_activePlayerData.PvpInfo[slot].Rating; }
public void SetArenaTeamIdInvited(uint ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
public uint GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
public uint GetRBGPersonalRating() { return m_activePlayerData.PvpInfo[3].Rating; }
public uint GetRBGPersonalRating() { return GetArenaPersonalRating(3); }
public uint GetArenaPersonalRating(byte slot)
{
PVPInfo pvpInfo = GetPvpInfoForBracket(slot);
if (pvpInfo != null)
return pvpInfo.Rating;
return 0;
}
public PVPInfo GetPvpInfoForBracket(byte bracket)
{
int index = m_activePlayerData.PvpInfo.FindIndexIf(pvpInfo =>
{
return pvpInfo.Bracket == bracket && !pvpInfo.Disqualified;
});
if (index >= 0)
return m_activePlayerData.PvpInfo[index];
return null;
}
//OutdoorPVP
public bool IsOutdoorPvPActive()