Core/Misc: Various crash fixes (#19059)
* Replaced some FindPlayer calls with GetPlayer Fixed some more crashes * Correction (cherrypicked from 14dfc377b48bc909894396e65d4e4ce89d9708b6)
This commit is contained in:
@@ -605,7 +605,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (IsUnit(*itr))
|
||||
if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit())
|
||||
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
|
||||
if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger.Guid))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*(*itr), it->second.Passenger.Guid))
|
||||
player->AreaExploredOrEventHappens(e.action.quest.quest);
|
||||
|
||||
if (IsPlayer(*itr))
|
||||
@@ -702,7 +702,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
case SMART_ACTION_INVOKER_CAST:
|
||||
{
|
||||
Unit* tempLastInvoker = GetLastInvoker();
|
||||
Unit* tempLastInvoker = GetLastInvoker(unit);
|
||||
if (!tempLastInvoker)
|
||||
break;
|
||||
|
||||
@@ -955,7 +955,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
// Special handling for vehicles
|
||||
if (Vehicle* vehicle = unit->GetVehicleKit())
|
||||
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
|
||||
if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger.Guid))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*unit, it->second.Passenger.Guid))
|
||||
player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
|
||||
break;
|
||||
}
|
||||
@@ -1099,7 +1099,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
else if (IsUnit(*itr)) // Special handling for vehicles
|
||||
if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit())
|
||||
for (SeatMap::iterator seatItr = vehicle->Seats.begin(); seatItr != vehicle->Seats.end(); ++seatItr)
|
||||
if (Player* player = ObjectAccessor::FindPlayer(seatItr->second.Passenger.Guid))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*(*itr), seatItr->second.Passenger.Guid))
|
||||
player->KilledMonsterCredit(e.action.killedMonster.creature);
|
||||
}
|
||||
|
||||
@@ -4115,14 +4115,14 @@ void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry)
|
||||
}
|
||||
}
|
||||
|
||||
Unit* SmartScript::GetLastInvoker()
|
||||
Unit* SmartScript::GetLastInvoker(Unit* invoker)
|
||||
{
|
||||
WorldObject* lookupRoot = me;
|
||||
if (!lookupRoot)
|
||||
lookupRoot = go;
|
||||
// Look for invoker only on map of base object... Prevents multithreaded crashes
|
||||
if (WorldObject* baseObject = GetBaseObject())
|
||||
return ObjectAccessor::GetUnit(*baseObject, mLastInvoker);
|
||||
// used for area triggers invoker cast
|
||||
else if (invoker)
|
||||
return ObjectAccessor::GetUnit(*invoker, mLastInvoker);
|
||||
|
||||
if (lookupRoot)
|
||||
return ObjectAccessor::GetUnit(*lookupRoot, mLastInvoker);
|
||||
|
||||
return ObjectAccessor::FindPlayer(mLastInvoker);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class TC_GAME_API SmartScript
|
||||
|
||||
//TIMED_ACTIONLIST (script type 9 aka script9)
|
||||
void SetScript9(SmartScriptHolder& e, uint32 entry);
|
||||
Unit* GetLastInvoker();
|
||||
Unit* GetLastInvoker(Unit* invoker = nullptr);
|
||||
ObjectGuid mLastInvoker;
|
||||
typedef std::unordered_map<uint32, uint32> CounterMap;
|
||||
CounterMap mCounterList;
|
||||
|
||||
@@ -441,7 +441,8 @@ void ThreatManager::doAddThreat(Unit* victim, float threat)
|
||||
{
|
||||
float redirectThreat = CalculatePct(threat, redirectThreadPct);
|
||||
threat -= redirectThreat;
|
||||
_addThreat(redirectTarget, redirectThreat);
|
||||
if (ThreatCalcHelper::isValidProcess(redirectTarget, GetOwner()))
|
||||
_addThreat(redirectTarget, redirectThreat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1387,7 +1387,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*
|
||||
@param[in] guid Group guid
|
||||
@param[in] dungeonId Dungeonid
|
||||
*/
|
||||
void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId)
|
||||
void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* currMap)
|
||||
{
|
||||
uint32 gDungeonId = GetDungeon(gguid);
|
||||
if (gDungeonId != dungeonId)
|
||||
@@ -1431,7 +1431,7 @@ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId)
|
||||
}
|
||||
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
if (!player)
|
||||
if (!player || player->FindMap() != currMap)
|
||||
{
|
||||
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %s, Player: %s not found in world", gguid.ToString().c_str(), guid.ToString().c_str());
|
||||
continue;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
class Group;
|
||||
class Player;
|
||||
class Quest;
|
||||
class Map;
|
||||
struct LFGDungeonsEntry;
|
||||
enum Difficulty : uint8;
|
||||
|
||||
@@ -323,7 +324,7 @@ class TC_GAME_API LFGMgr
|
||||
|
||||
// World.cpp
|
||||
/// Finish the dungeon for the given group. All check are performed using internal lfg data
|
||||
void FinishDungeon(ObjectGuid gguid, uint32 dungeonId);
|
||||
void FinishDungeon(ObjectGuid gguid, uint32 dungeonId, Map const* currMap);
|
||||
/// Loads rewards for random dungeons
|
||||
void LoadRewards();
|
||||
/// Loads dungeons from dbc and adds teleport coords
|
||||
|
||||
@@ -1655,7 +1655,7 @@ void WorldObject::AddObjectToRemoveList()
|
||||
map->AddObjectToRemoveList(this);
|
||||
}
|
||||
|
||||
TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= NULL*/, uint32 duration /*= 0*/, Unit* summoner /*= NULL*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
|
||||
TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, Unit* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
|
||||
{
|
||||
uint32 mask = UNIT_MASK_SUMMON;
|
||||
if (properties)
|
||||
|
||||
@@ -1744,6 +1744,9 @@ void Player::RemoveFromWorld()
|
||||
StopCastingBindSight();
|
||||
UnsummonPetTemporaryIfAny();
|
||||
ClearComboPoints();
|
||||
ObjectGuid lootGuid = GetLootGUID();
|
||||
if (!lootGuid.IsEmpty())
|
||||
m_session->DoLootRelease(lootGuid);
|
||||
sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
||||
sBattlefieldMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
void WorldSession::HandleInspectOpcode(WorldPackets::Inspect::Inspect& inspect)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(inspect.Target);
|
||||
Player* player = ObjectAccessor::GetPlayer(*_player, inspect.Target);
|
||||
if (!player)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WorldSession::HandleInspectOpcode: Target %s not found.", inspect.Target.ToString().c_str());
|
||||
@@ -77,7 +77,7 @@ void WorldSession::HandleInspectOpcode(WorldPackets::Inspect::Inspect& inspect)
|
||||
|
||||
void WorldSession::HandleQueryInspectAchievements(WorldPackets::Inspect::QueryInspectAchievements& inspect)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(inspect.Guid);
|
||||
Player* player = ObjectAccessor::GetPlayer(*_player, inspect.Guid);
|
||||
if (!player)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WorldSession::HandleQueryInspectAchievements: [%s] inspected unknown Player [%s]", GetPlayer()->GetGUID().ToString().c_str(), inspect.Guid.ToString().c_str());
|
||||
|
||||
@@ -462,7 +462,8 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
Player* target = ObjectAccessor::FindPlayer(target_playerguid);
|
||||
// player on other map
|
||||
Player* target = ObjectAccessor::GetPlayer(*_player, target_playerguid);
|
||||
if (!target)
|
||||
{
|
||||
_player->SendLootError(lootguid, ObjectGuid::Empty, LOOT_ERROR_PLAYER_NOT_FOUND);
|
||||
|
||||
@@ -122,7 +122,7 @@ void WorldSession::HandleRequestVehicleSwitchSeat(WorldPackets::Vehicle::Request
|
||||
|
||||
void WorldSession::HandleRideVehicleInteract(WorldPackets::Vehicle::RideVehicleInteract& rideVehicleInteract)
|
||||
{
|
||||
if (Player* player = ObjectAccessor::FindPlayer(rideVehicleInteract.Vehicle))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*_player, rideVehicleInteract.Vehicle))
|
||||
{
|
||||
if (!player->GetVehicleKit())
|
||||
return;
|
||||
@@ -130,6 +130,9 @@ void WorldSession::HandleRideVehicleInteract(WorldPackets::Vehicle::RideVehicleI
|
||||
return;
|
||||
if (!player->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
|
||||
return;
|
||||
// Dont' allow players to enter player vehicle on arena
|
||||
if (!_player->FindMap() || _player->FindMap()->IsBattleArena())
|
||||
return;
|
||||
|
||||
_player->EnterVehicle(player);
|
||||
}
|
||||
|
||||
@@ -749,7 +749,7 @@ void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 credi
|
||||
if (Group* grp = player->GetGroup())
|
||||
if (grp->isLFGGroup())
|
||||
{
|
||||
sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId);
|
||||
sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId, instance);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3925,6 +3925,11 @@ Conversation* Map::GetConversation(ObjectGuid const& guid)
|
||||
return _objectsStore.Find<Conversation>(guid);
|
||||
}
|
||||
|
||||
Player* Map::GetPlayer(ObjectGuid const& guid)
|
||||
{
|
||||
return ObjectAccessor::GetPlayer(this, guid);
|
||||
}
|
||||
|
||||
Corpse* Map::GetCorpse(ObjectGuid const& guid)
|
||||
{
|
||||
return _objectsStore.Find<Corpse>(guid);
|
||||
|
||||
@@ -446,10 +446,11 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
|
||||
void UpdateIteratorBack(Player* player);
|
||||
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = NULL, uint32 duration = 0, Unit* summoner = NULL, uint32 spellId = 0, uint32 vehId = 0, bool visibleOnlyBySummoner = false);
|
||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = NULL);
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0, bool visibleOnlyBySummoner = false);
|
||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
|
||||
AreaTrigger* GetAreaTrigger(ObjectGuid const& guid);
|
||||
Conversation* GetConversation(ObjectGuid const& guid);
|
||||
Player* GetPlayer(ObjectGuid const& guid);
|
||||
Corpse* GetCorpse(ObjectGuid const& guid);
|
||||
Creature* GetCreature(ObjectGuid const& guid);
|
||||
DynamicObject* GetDynamicObject(ObjectGuid const& guid);
|
||||
|
||||
@@ -310,7 +310,7 @@ void Map::ScriptsProcess()
|
||||
switch (step.sourceGUID.GetHigh())
|
||||
{
|
||||
case HighGuid::Item: // as well as HIGHGUID_CONTAINER
|
||||
if (Player* player = HashMapHolder<Player>::Find(step.ownerGUID))
|
||||
if (Player* player = GetPlayer(step.ownerGUID))
|
||||
source = player->GetItemByGuid(step.sourceGUID);
|
||||
break;
|
||||
case HighGuid::Creature:
|
||||
@@ -321,7 +321,7 @@ void Map::ScriptsProcess()
|
||||
source = GetPet(step.sourceGUID);
|
||||
break;
|
||||
case HighGuid::Player:
|
||||
source = HashMapHolder<Player>::Find(step.sourceGUID);
|
||||
source = GetPlayer(step.sourceGUID);
|
||||
break;
|
||||
case HighGuid::GameObject:
|
||||
case HighGuid::Transport:
|
||||
@@ -350,7 +350,7 @@ void Map::ScriptsProcess()
|
||||
target = GetPet(step.targetGUID);
|
||||
break;
|
||||
case HighGuid::Player:
|
||||
target = HashMapHolder<Player>::Find(step.targetGUID);
|
||||
target = GetPlayer(step.targetGUID);
|
||||
break;
|
||||
case HighGuid::GameObject:
|
||||
case HighGuid::Transport:
|
||||
|
||||
@@ -1005,7 +1005,8 @@ bool Aura::CanBeSaved() const
|
||||
if (IsPassive())
|
||||
return false;
|
||||
|
||||
if (GetCasterGUID() != GetOwner()->GetGUID())
|
||||
// Check if aura is single target, not only spell info
|
||||
if (GetCasterGUID() != GetOwner()->GetGUID() || IsSingleTarget())
|
||||
if (GetSpellInfo()->IsSingleTarget())
|
||||
return false;
|
||||
|
||||
@@ -1017,6 +1018,18 @@ bool Aura::CanBeSaved() const
|
||||
if (HasEffectType(SPELL_AURA_CONTROL_VEHICLE))
|
||||
return false;
|
||||
|
||||
// do not save bind sight auras
|
||||
if (HasEffectType(SPELL_AURA_BIND_SIGHT))
|
||||
return false;
|
||||
|
||||
// no charming auras (taking direct control)
|
||||
if (HasEffectType(SPELL_AURA_MOD_POSSESS) || HasEffectType(SPELL_AURA_MOD_POSSESS_PET))
|
||||
return false;
|
||||
|
||||
// no charming auras can be saved
|
||||
if (HasEffectType(SPELL_AURA_MOD_CHARM) || HasEffectType(SPELL_AURA_AOE_CHARM))
|
||||
return false;
|
||||
|
||||
// Incanter's Absorbtion - considering the minimal duration and problems with aura stacking
|
||||
// we skip saving this aura
|
||||
// Also for some reason other auras put as MultiSlot crash core on keeping them after restart,
|
||||
|
||||
@@ -444,8 +444,7 @@ bool SpellEffectInfo::IsFarUnitTargetEffect() const
|
||||
{
|
||||
return (Effect == SPELL_EFFECT_SUMMON_PLAYER)
|
||||
|| (Effect == SPELL_EFFECT_SUMMON_RAF_FRIEND)
|
||||
|| (Effect == SPELL_EFFECT_RESURRECT)
|
||||
|| (Effect == SPELL_EFFECT_SKIN_PLAYER_CORPSE);
|
||||
|| (Effect == SPELL_EFFECT_RESURRECT);
|
||||
}
|
||||
|
||||
bool SpellEffectInfo::IsFarDestTargetEffect() const
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@ public:
|
||||
{
|
||||
if (Group* group = players.begin()->GetSource()->GetGroup())
|
||||
if (group->isLFGGroup())
|
||||
sLFGMgr->FinishDungeon(group->GetGUID(), 287);
|
||||
sLFGMgr->FinishDungeon(group->GetGUID(), 287, me->GetMap());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -581,7 +581,7 @@ public:
|
||||
{
|
||||
if (Group* group = players.begin()->GetSource()->GetGroup())
|
||||
if (group->isLFGGroup())
|
||||
sLFGMgr->FinishDungeon(group->GetGUID(), 285);
|
||||
sLFGMgr->FinishDungeon(group->GetGUID(), 285, me->GetMap());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
{
|
||||
if (Group* group = players.begin()->GetSource()->GetGroup())
|
||||
if (group->isLFGGroup())
|
||||
sLFGMgr->FinishDungeon(group->GetGUID(), 286);
|
||||
sLFGMgr->FinishDungeon(group->GetGUID(), 286, me->GetMap());
|
||||
}
|
||||
|
||||
_JustDied();
|
||||
|
||||
Reference in New Issue
Block a user