Core/Instances: Fixed crashes happening when trying to access already deleted players.

This commit is contained in:
Shauren
2011-04-10 21:17:46 +02:00
parent 3771798a2e
commit 553d8d7016
2 changed files with 6 additions and 7 deletions
+5 -6
View File
@@ -2360,7 +2360,7 @@ bool InstanceMap::Add(Player *player)
// for normal instances cancel the reset schedule when the // for normal instances cancel the reset schedule when the
// first player enters (no players yet) // first player enters (no players yet)
SetResetSchedule(false, player); SetResetSchedule(false);
sLog->outDetail("MAP: Player '%s' entered instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName()); sLog->outDetail("MAP: Player '%s' entered instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName());
// initialize unload state // initialize unload state
@@ -2394,7 +2394,7 @@ void InstanceMap::Remove(Player *player, bool remove)
m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY);
Map::Remove(player, remove); Map::Remove(player, remove);
// for normal instances schedule the reset after all players have left // for normal instances schedule the reset after all players have left
SetResetSchedule(true, player); SetResetSchedule(true);
} }
void InstanceMap::CreateInstanceData(bool load) void InstanceMap::CreateInstanceData(bool load)
@@ -2521,7 +2521,7 @@ void InstanceMap::SendResetWarnings(uint32 timeLeft) const
itr->getSource()->SendInstanceResetWarning(GetId(), itr->getSource()->GetDifficulty(IsRaid()), timeLeft); itr->getSource()->SendInstanceResetWarning(GetId(), itr->getSource()->GetDifficulty(IsRaid()), timeLeft);
} }
void InstanceMap::SetResetSchedule(bool on, Player* player) void InstanceMap::SetResetSchedule(bool on)
{ {
// only for normal instances // only for normal instances
// the reset time is only scheduled when there are no payers inside // the reset time is only scheduled when there are no payers inside
@@ -2531,9 +2531,8 @@ void InstanceMap::SetResetSchedule(bool on, Player* player)
if (InstanceSave *save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId())) if (InstanceSave *save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId()))
sInstanceSaveMgr->ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId())); sInstanceSaveMgr->ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId()));
else else
sLog->outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, there is no save information for instance (map [id: %u, name: %s], instance id: %u) due to player (GUID: %u, name: %s) %s", sLog->outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, there is no save information for instance (map [id: %u, name: %s], instance id: %u)",
on ? "on" : "off", GetId(), GetMapName(), GetInstanceId(), on ? "on" : "off", GetId(), GetMapName(), GetInstanceId());
player->GetGUIDLow(), player->GetName(), on ? "leave" : "entrance");
} }
} }
+1 -1
View File
@@ -595,7 +595,7 @@ class InstanceMap : public Map
void UnloadAll(); void UnloadAll();
bool CanEnter(Player* player); bool CanEnter(Player* player);
void SendResetWarnings(uint32 timeLeft) const; void SendResetWarnings(uint32 timeLeft) const;
void SetResetSchedule(bool on, Player* player); void SetResetSchedule(bool on);
uint32 GetMaxPlayers() const; uint32 GetMaxPlayers() const;
uint32 GetMaxResetDelay() const; uint32 GetMaxResetDelay() const;