Core/Players: Fixed crashes when accessing ActivePlayerData::PvpInfo
Port From (https://github.com/TrinityCore/TrinityCore/commit/55091ff4bcf4500d0ebe9701e6dc121f5e6a3bb2)
This commit is contained in:
@@ -2880,11 +2880,11 @@ namespace Game.Achievements
|
||||
if (pvpTier == null)
|
||||
return false;
|
||||
|
||||
if (pvpTier.BracketID >= referencePlayer.m_activePlayerData.PvpInfo.Size())
|
||||
PVPInfo pvpInfo = referencePlayer.GetPvpInfoForBracket((byte)pvpTier.BracketID);
|
||||
if (pvpInfo == null)
|
||||
return false;
|
||||
|
||||
var pvpInfo = referencePlayer.m_activePlayerData.PvpInfo[pvpTier.BracketID];
|
||||
if (pvpTier.Id != pvpInfo.PvpTierID || pvpInfo.Disqualified)
|
||||
if (pvpTier.Id != pvpInfo.PvpTierID)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
@@ -2918,10 +2918,10 @@ namespace Game.Achievements
|
||||
}
|
||||
case ModifierTreeType.PlayerPvpTierInBracketEqualOrGreaterThan: // 239
|
||||
{
|
||||
if (secondaryAsset >= referencePlayer.m_activePlayerData.PvpInfo.Size())
|
||||
PVPInfo pvpInfo = referencePlayer.GetPvpInfoForBracket((byte)secondaryAsset);
|
||||
if (pvpInfo == null)
|
||||
return false;
|
||||
|
||||
var pvpInfo = referencePlayer.m_activePlayerData.PvpInfo[secondaryAsset];
|
||||
var pvpTier = CliDB.PvpTierStorage.LookupByKey(pvpInfo.PvpTierID);
|
||||
if (pvpTier == null)
|
||||
return false;
|
||||
@@ -3475,21 +3475,21 @@ namespace Game.Achievements
|
||||
if (pvpTier == null)
|
||||
return false;
|
||||
|
||||
if (pvpTier.BracketID >= referencePlayer.m_activePlayerData.PvpInfo.Size())
|
||||
PVPInfo pvpInfo = referencePlayer.GetPvpInfoForBracket((byte)pvpTier.BracketID);
|
||||
if (pvpInfo == null)
|
||||
return false;
|
||||
|
||||
var pvpInfo = referencePlayer.m_activePlayerData.PvpInfo[pvpTier.BracketID];
|
||||
if (pvpTier.Id != pvpInfo.WeeklyBestWinPvpTierID || pvpInfo.Disqualified)
|
||||
if (pvpTier.Id != pvpInfo.WeeklyBestWinPvpTierID)
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
case ModifierTreeType.PlayerBestWeeklyWinPvpTierInBracketEqualOrGreaterThan: // 325
|
||||
{
|
||||
if (secondaryAsset >= referencePlayer.m_activePlayerData.PvpInfo.Size())
|
||||
PVPInfo pvpInfo = referencePlayer.GetPvpInfoForBracket((byte)secondaryAsset);
|
||||
if (pvpInfo == null)
|
||||
return false;
|
||||
|
||||
var pvpInfo = referencePlayer.m_activePlayerData.PvpInfo[secondaryAsset];
|
||||
var pvpTier = CliDB.PvpTierStorage.LookupByKey(pvpInfo.WeeklyBestWinPvpTierID);
|
||||
if (pvpTier == null)
|
||||
return false;
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user