Core/Misc: Fix various crashes, also related to multithreading
Port From (https://github.com/TrinityCore/TrinityCore/commit/ad008c43b75080ec59aa973f1e2e4424332c34a4)
This commit is contained in:
@@ -104,7 +104,7 @@ namespace Game.Entities
|
||||
Player member = refe.GetSource();
|
||||
if (member)
|
||||
{
|
||||
if (member.IsAlive() && member.IsAtGroupRewardDistance(_victim))
|
||||
if (_killer == member || (member.IsAtGroupRewardDistance(_victim) && member.IsAlive()))
|
||||
{
|
||||
uint lvl = member.getLevel();
|
||||
// 2.1. _count - number of alive group members within reward distance;
|
||||
@@ -254,7 +254,8 @@ namespace Game.Entities
|
||||
Player member = refe.GetSource();
|
||||
if (member)
|
||||
{
|
||||
if (member.IsAtGroupRewardDistance(_victim))
|
||||
// Killer may not be at reward distance, check directly
|
||||
if (_killer == member || member.IsAtGroupRewardDistance(_victim))
|
||||
{
|
||||
_RewardPlayer(member, isDungeon);
|
||||
member.UpdateCriteria(CriteriaTypes.SpecialPvpKill, 1, 0, 0, _victim);
|
||||
|
||||
@@ -1525,6 +1525,10 @@ namespace Game.Entities
|
||||
stmt.AddValue(2, GetGUID().GetCounter());
|
||||
trans.Append(stmt);
|
||||
|
||||
RemoveTradeableItem(item);
|
||||
RemoveEnchantmentDurationsReferences(item);
|
||||
RemoveItemDurations(item);
|
||||
|
||||
// also THIS item should be somewhere else, cheat attempt
|
||||
item.FSetState(ItemUpdateState.Removed); // we are IN updateQueue right now, can't use SetState which modifies the queue
|
||||
DeleteRefundReference(item.GetGUID());
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Game.Entities
|
||||
|
||||
// @todo Should also be sent when anyone has recently left combat, with an aprox ~5 seconds timer.
|
||||
for (GroupReference refe = grp.GetFirstMember(); refe != null; refe = refe.next())
|
||||
if (refe.GetSource() && refe.GetSource().IsInCombat())
|
||||
if (refe.GetSource() && refe.GetSource().IsInMap(this) && refe.GetSource().IsInCombat())
|
||||
return PartyResult.PartyLfgBootInCombat;
|
||||
|
||||
/* Missing support for these types
|
||||
@@ -192,15 +192,13 @@ namespace Game.Entities
|
||||
|
||||
public bool IsAtGroupRewardDistance(WorldObject pRewardSource)
|
||||
{
|
||||
if (!pRewardSource)
|
||||
if (!pRewardSource || !IsInMap(pRewardSource))
|
||||
return false;
|
||||
|
||||
WorldObject player = GetCorpse();
|
||||
if (!player || IsAlive())
|
||||
player = this;
|
||||
|
||||
if (player.GetMapId() != pRewardSource.GetMapId() || player.GetInstanceId() != pRewardSource.GetInstanceId())
|
||||
return false;
|
||||
|
||||
if (player.GetMap().IsDungeon())
|
||||
return true;
|
||||
|
||||
|
||||
@@ -967,6 +967,16 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveEnchantmentDurationsReferences(Item item)
|
||||
{
|
||||
foreach (var enchantDuration in m_enchantDuration)
|
||||
{
|
||||
if (enchantDuration.item == item)
|
||||
m_enchantDuration.Remove(enchantDuration);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveArenaEnchantments(EnchantmentSlot slot)
|
||||
{
|
||||
// remove enchantments from equipped items first to clean up the m_enchantDuration list
|
||||
@@ -1043,7 +1053,12 @@ namespace Game.Entities
|
||||
}
|
||||
// from spell cases (m_lastPotionId set in Spell.SendSpellCooldown)
|
||||
else
|
||||
GetSpellHistory().SendCooldownEvent(spell.m_spellInfo, m_lastPotionId, spell);
|
||||
{
|
||||
if (spell.IsIgnoringCooldowns())
|
||||
return;
|
||||
else
|
||||
GetSpellHistory().SendCooldownEvent(spell.m_spellInfo, m_lastPotionId, spell);
|
||||
}
|
||||
|
||||
m_lastPotionId = 0;
|
||||
}
|
||||
|
||||
@@ -862,6 +862,7 @@ namespace Game.Entities
|
||||
StopCastingCharm();
|
||||
StopCastingBindSight();
|
||||
UnsummonPetTemporaryIfAny();
|
||||
ClearComboPoints();
|
||||
Global.OutdoorPvPMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
||||
Global.BattleFieldMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
||||
}
|
||||
@@ -7031,15 +7032,13 @@ namespace Game.Entities
|
||||
|
||||
bool IsAtRecruitAFriendDistance(WorldObject pOther)
|
||||
{
|
||||
if (!pOther)
|
||||
if (!pOther || !IsInMap(pOther))
|
||||
return false;
|
||||
|
||||
WorldObject player = GetCorpse();
|
||||
if (!player || IsAlive())
|
||||
player = this;
|
||||
|
||||
if (player.GetMapId() != pOther.GetMapId() || player.GetInstanceId() != pOther.GetInstanceId())
|
||||
return false;
|
||||
|
||||
return pOther.GetDistance(player) <= WorldConfig.GetFloatValue(WorldCfg.MaxRecruitAFriendDistance);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user