mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11137] Fixed crash at reset normal dungeon while map loaded.
* Map Persistent noe have direct pointer back to map if map loaded. That let simplify some code and avoid map search. * Crash showup in result changes in code logic related to reset processing. * Also fix more old bug with reset normal dungeon with not loaded map. * Reverse MapPersistentState::HasRespawnTimes and MapPersistentState::HasBounds() results to expected for function names and update related calls. Thanks to Schmoozerd for help in research problem.
This commit is contained in:
parent
5858aae4d9
commit
47060fe4b1
5 changed files with 30 additions and 23 deletions
|
|
@ -43,7 +43,7 @@ static uint32 resetEventTypeDelay[MAX_RESET_EVENT_TYPE] = { 0, 3600, 900, 300, 6
|
|||
|
||||
MapPersistentState::MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty)
|
||||
: m_instanceid(InstanceId), m_mapid(MapId),
|
||||
m_difficulty(difficulty), m_usedByMap(false)
|
||||
m_difficulty(difficulty), m_usedByMap(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ bool WorldPersistentState::CanBeUnload() const
|
|||
{
|
||||
// prevent unload if used for loaded map
|
||||
// prevent unload if respawn data still exist (will not prevent reset by scheduler)
|
||||
return MapPersistentState::CanBeUnload() && HasRespawnTimes();
|
||||
return MapPersistentState::CanBeUnload() && !HasRespawnTimes();
|
||||
}
|
||||
|
||||
//== DungeonPersistentState functions =====================
|
||||
|
|
@ -161,7 +161,7 @@ DungeonPersistentState::~DungeonPersistentState()
|
|||
bool DungeonPersistentState::CanBeUnload() const
|
||||
{
|
||||
// prevent unload if any bounded groups or online bounded player still exists
|
||||
return MapPersistentState::CanBeUnload() && HasBounds() && HasRespawnTimes();
|
||||
return MapPersistentState::CanBeUnload() && !HasBounds() && !HasRespawnTimes();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -172,7 +172,7 @@ void DungeonPersistentState::SaveToDB()
|
|||
// state instance data too
|
||||
std::string data;
|
||||
|
||||
if (Map *map = sMapMgr.FindMap(GetMapId(), GetInstanceId()))
|
||||
if (Map *map = GetMap())
|
||||
{
|
||||
InstanceData *iData = map->GetInstanceData();
|
||||
if(iData && iData->Save())
|
||||
|
|
@ -192,7 +192,7 @@ void DungeonPersistentState::DeleteRespawnTimes()
|
|||
CharacterDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", GetInstanceId());
|
||||
CharacterDatabase.CommitTransaction();
|
||||
|
||||
ClearRespawnTimes();
|
||||
ClearRespawnTimes(); // state can be deleted at call if only respawn data prevent unload
|
||||
}
|
||||
|
||||
void DungeonPersistentState::DeleteFromDB()
|
||||
|
|
@ -711,19 +711,25 @@ void MapPersistentStateManager::_ResetSave(PersistentStateMap& holder, Persisten
|
|||
|
||||
void MapPersistentStateManager::_ResetInstance(uint32 mapid, uint32 instanceId)
|
||||
{
|
||||
DEBUG_LOG("InstanceSaveMgr::_ResetInstance %u, %u", mapid, instanceId);
|
||||
Map * iMap = sMapMgr.FindMap(mapid, instanceId);
|
||||
if (!iMap || !iMap->Instanceable())
|
||||
return;
|
||||
DEBUG_LOG("MapPersistentStateManager::_ResetInstance %u, %u", mapid, instanceId);
|
||||
|
||||
PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.find(instanceId);
|
||||
if (itr != m_instanceSaveByInstanceId.end())
|
||||
{
|
||||
// delay reset until map unload for loaded map
|
||||
if (Map * iMap = itr->second->GetMap())
|
||||
{
|
||||
MANGOS_ASSERT(iMap->IsDungeon());
|
||||
|
||||
((DungeonMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
|
||||
return;
|
||||
}
|
||||
|
||||
_ResetSave(m_instanceSaveByInstanceId, itr);
|
||||
}
|
||||
|
||||
|
||||
DeleteInstanceFromDB(instanceId); // even if state not loaded
|
||||
|
||||
if (iMap->IsDungeon())
|
||||
((DungeonMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
|
||||
}
|
||||
|
||||
void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeLeft)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue