*Fix some crash bugs.
--HG-- branch : trunk
This commit is contained in:
@@ -120,6 +120,15 @@ class TRINITY_DLL_DECL Grid
|
|||||||
*/
|
*/
|
||||||
template<class SPECIFIC_OBJECT> bool RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { return i_container.template remove<SPECIFIC_OBJECT>(obj, hdl); }
|
template<class SPECIFIC_OBJECT> bool RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { return i_container.template remove<SPECIFIC_OBJECT>(obj, hdl); }
|
||||||
|
|
||||||
|
bool NoWorldObjectInGrid() const
|
||||||
|
{
|
||||||
|
return i_objects.GetElements().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NoGridObjectInGrid() const
|
||||||
|
{
|
||||||
|
return i_container.GetElements().isEmpty();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef typename ThreadModel::Lock Guard;
|
typedef typename ThreadModel::Lock Guard;
|
||||||
|
|||||||
@@ -1662,7 +1662,8 @@ void Creature::setDeathState(DeathState s)
|
|||||||
{
|
{
|
||||||
SetUInt64Value (UNIT_FIELD_TARGET,0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
|
SetUInt64Value (UNIT_FIELD_TARGET,0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
|
||||||
SetUInt32Value(UNIT_NPC_FLAGS, 0);
|
SetUInt32Value(UNIT_NPC_FLAGS, 0);
|
||||||
setActive(false);
|
if(!isPet())
|
||||||
|
setActive(false);
|
||||||
|
|
||||||
if(!isPet() && GetCreatureInfo()->SkinLootId)
|
if(!isPet() && GetCreatureInfo()->SkinLootId)
|
||||||
if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) )
|
if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) )
|
||||||
@@ -1675,8 +1676,8 @@ void Creature::setDeathState(DeathState s)
|
|||||||
}
|
}
|
||||||
if(s == JUST_ALIVED)
|
if(s == JUST_ALIVED)
|
||||||
{
|
{
|
||||||
if(isPet())
|
//if(isPet())
|
||||||
setActive(true);
|
// setActive(true);
|
||||||
SetHealth(GetMaxHealth());
|
SetHealth(GetMaxHealth());
|
||||||
SetLootRecipient(NULL);
|
SetLootRecipient(NULL);
|
||||||
Unit::setDeathState(ALIVE);
|
Unit::setDeathState(ALIVE);
|
||||||
|
|||||||
+31
-18
@@ -51,7 +51,7 @@ GridState* si_GridStates[MAX_GRID_STATE];
|
|||||||
|
|
||||||
Map::~Map()
|
Map::~Map()
|
||||||
{
|
{
|
||||||
UnloadAll(true);
|
UnloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Map::ExistMap(uint32 mapid,int x,int y)
|
bool Map::ExistMap(uint32 mapid,int x,int y)
|
||||||
@@ -1019,30 +1019,43 @@ bool Map::CreatureRespawnRelocation(Creature *c)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce)
|
bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool unloadAll)
|
||||||
{
|
{
|
||||||
NGridType *grid = getNGrid(x, y);
|
NGridType *grid = getNGrid(x, y);
|
||||||
assert( grid != NULL);
|
assert( grid != NULL);
|
||||||
|
|
||||||
{
|
{
|
||||||
if(!pForce && PlayersNearGrid(x, y) )
|
if(!unloadAll)
|
||||||
return false;
|
{
|
||||||
|
if(ActiveObjectsNearGrid(x, y))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
assert(!PlayersNearGrid(x, y));
|
||||||
|
|
||||||
DEBUG_LOG("Unloading grid[%u,%u] for map %u", x,y, i_id);
|
DEBUG_LOG("Unloading grid[%u,%u] for map %u", x,y, i_id);
|
||||||
ObjectGridUnloader unloader(*grid);
|
ObjectGridUnloader unloader(*grid);
|
||||||
|
|
||||||
// Finish creature moves, remove and delete all creatures with delayed remove before moving to respawn grids
|
if(!unloadAll)
|
||||||
// Must know real mob position before move
|
{
|
||||||
DoDelayedMovesAndRemoves();
|
// Finish creature moves, remove and delete all creatures with delayed remove before moving to respawn grids
|
||||||
|
// Must know real mob position before move
|
||||||
|
DoDelayedMovesAndRemoves();
|
||||||
|
|
||||||
// move creatures to respawn grids if this is diff.grid or to remove list
|
// move creatures to respawn grids if this is diff.grid or to remove list
|
||||||
unloader.MoveToRespawnN();
|
unloader.MoveToRespawnN();
|
||||||
|
|
||||||
// Finish creature moves, remove and delete all creatures with delayed remove before unload
|
// Finish creature moves, remove and delete all creatures with delayed remove before unload
|
||||||
DoDelayedMovesAndRemoves();
|
DoDelayedMovesAndRemoves();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
RemoveAllObjectsInRemoveList();
|
||||||
|
|
||||||
|
assert(grid.NoWorldObjectInGrid());
|
||||||
unloader.UnloadN();
|
unloader.UnloadN();
|
||||||
delete getNGrid(x, y);
|
assert(grid.NoWorldObjectInGrid());
|
||||||
|
assert(grid.NoGridObjectInGrid());
|
||||||
|
delete grid;
|
||||||
setNGrid(NULL, x, y);
|
setNGrid(NULL, x, y);
|
||||||
}
|
}
|
||||||
int gx=63-x;
|
int gx=63-x;
|
||||||
@@ -1065,7 +1078,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map::UnloadAll(bool pForce)
|
void Map::UnloadAll()
|
||||||
{
|
{
|
||||||
// clear all delayed moves, useless anyway do this moves before map unload.
|
// clear all delayed moves, useless anyway do this moves before map unload.
|
||||||
i_creaturesToMove.clear();
|
i_creaturesToMove.clear();
|
||||||
@@ -1074,7 +1087,7 @@ void Map::UnloadAll(bool pForce)
|
|||||||
{
|
{
|
||||||
NGridType &grid(*i->getSource());
|
NGridType &grid(*i->getSource());
|
||||||
++i;
|
++i;
|
||||||
UnloadGrid(grid.getX(), grid.getY(), pForce); // deletes the grid and removes it from the GridRefManager
|
UnloadGrid(grid.getX(), grid.getY(), true); // deletes the grid and removes it from the GridRefManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1935,7 +1948,7 @@ time_t InstanceMap::GetResetTime()
|
|||||||
return save ? save->GetDifficulty() : DIFFICULTY_NORMAL;
|
return save ? save->GetDifficulty() : DIFFICULTY_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceMap::UnloadAll(bool pForce)
|
void InstanceMap::UnloadAll()
|
||||||
{
|
{
|
||||||
if(HavePlayers())
|
if(HavePlayers())
|
||||||
{
|
{
|
||||||
@@ -1950,7 +1963,7 @@ void InstanceMap::UnloadAll(bool pForce)
|
|||||||
if(m_resetAfterUnload == true)
|
if(m_resetAfterUnload == true)
|
||||||
objmgr.DeleteRespawnTimeForInstance(GetInstanceId());
|
objmgr.DeleteRespawnTimeForInstance(GetInstanceId());
|
||||||
|
|
||||||
Map::UnloadAll(pForce);
|
Map::UnloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceMap::SendResetWarnings(uint32 timeLeft) const
|
void InstanceMap::SendResetWarnings(uint32 timeLeft) const
|
||||||
@@ -2023,7 +2036,7 @@ void BattleGroundMap::SetUnload()
|
|||||||
m_unloadTimer = MIN_UNLOAD_DELAY;
|
m_unloadTimer = MIN_UNLOAD_DELAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGroundMap::UnloadAll(bool pForce)
|
void BattleGroundMap::UnloadAll()
|
||||||
{
|
{
|
||||||
while(HavePlayers())
|
while(HavePlayers())
|
||||||
{
|
{
|
||||||
@@ -2035,7 +2048,7 @@ void BattleGroundMap::UnloadAll(bool pForce)
|
|||||||
plr->GetMapRef().unlink();
|
plr->GetMapRef().unlink();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map::UnloadAll(pForce);
|
Map::UnloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------TRINITY-------------------------*/
|
/*--------------------------TRINITY-------------------------*/
|
||||||
|
|||||||
+3
-3
@@ -172,7 +172,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
|
|||||||
void SetUnloadFlag(const GridPair &p, bool unload) { getNGrid(p.x_coord, p.y_coord)->setUnloadFlag(unload); }
|
void SetUnloadFlag(const GridPair &p, bool unload) { getNGrid(p.x_coord, p.y_coord)->setUnloadFlag(unload); }
|
||||||
void LoadGrid(float x, float y);
|
void LoadGrid(float x, float y);
|
||||||
bool UnloadGrid(const uint32 &x, const uint32 &y, bool pForce);
|
bool UnloadGrid(const uint32 &x, const uint32 &y, bool pForce);
|
||||||
virtual void UnloadAll(bool pForce);
|
virtual void UnloadAll();
|
||||||
|
|
||||||
void ResetGridExpiry(NGridType &grid, float factor = 1) const
|
void ResetGridExpiry(NGridType &grid, float factor = 1) const
|
||||||
{
|
{
|
||||||
@@ -367,7 +367,7 @@ class TRINITY_DLL_SPEC InstanceMap : public Map
|
|||||||
InstanceData* GetInstanceData() { return i_data; }
|
InstanceData* GetInstanceData() { return i_data; }
|
||||||
void PermBindAllPlayers(Player *player);
|
void PermBindAllPlayers(Player *player);
|
||||||
time_t GetResetTime();
|
time_t GetResetTime();
|
||||||
void UnloadAll(bool pForce);
|
void UnloadAll();
|
||||||
bool CanEnter(Player* player);
|
bool CanEnter(Player* player);
|
||||||
void SendResetWarnings(uint32 timeLeft) const;
|
void SendResetWarnings(uint32 timeLeft) const;
|
||||||
void SetResetSchedule(bool on);
|
void SetResetSchedule(bool on);
|
||||||
@@ -388,7 +388,7 @@ class TRINITY_DLL_SPEC BattleGroundMap : public Map
|
|||||||
void Remove(Player *, bool);
|
void Remove(Player *, bool);
|
||||||
bool CanEnter(Player* player);
|
bool CanEnter(Player* player);
|
||||||
void SetUnload();
|
void SetUnload();
|
||||||
void UnloadAll(bool pForce);
|
void UnloadAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*inline
|
/*inline
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ bool MapInstanced::RemoveBones(uint64 guid, float x, float y)
|
|||||||
return remove_result || Map::RemoveBones(guid,x,y);
|
return remove_result || Map::RemoveBones(guid,x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapInstanced::UnloadAll(bool pForce)
|
void MapInstanced::UnloadAll()
|
||||||
{
|
{
|
||||||
// Unload instanced maps
|
// Unload instanced maps
|
||||||
for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
|
for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
|
||||||
i->second->UnloadAll(pForce);
|
i->second->UnloadAll();
|
||||||
|
|
||||||
// Delete the maps only after everything is unloaded to prevent crashes
|
// Delete the maps only after everything is unloaded to prevent crashes
|
||||||
for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
|
for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
|
||||||
@@ -102,7 +102,7 @@ void MapInstanced::UnloadAll(bool pForce)
|
|||||||
m_InstancedMaps.clear();
|
m_InstancedMaps.clear();
|
||||||
|
|
||||||
// Unload own grids (just dummy(placeholder) grids, neccesary to unload GridMaps!)
|
// Unload own grids (just dummy(placeholder) grids, neccesary to unload GridMaps!)
|
||||||
Map::UnloadAll(pForce);
|
Map::UnloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -259,14 +259,14 @@ void MapInstanced::DestroyInstance(uint32 InstanceId)
|
|||||||
// increments the iterator after erase
|
// increments the iterator after erase
|
||||||
void MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
|
void MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
|
||||||
{
|
{
|
||||||
itr->second->UnloadAll(true);
|
itr->second->UnloadAll();
|
||||||
// should only unload VMaps if this is the last instance and grid unloading is enabled
|
// should only unload VMaps if this is the last instance and grid unloading is enabled
|
||||||
if(m_InstancedMaps.size() <= 1 && sWorld.getConfig(CONFIG_GRID_UNLOAD))
|
if(m_InstancedMaps.size() <= 1 && sWorld.getConfig(CONFIG_GRID_UNLOAD))
|
||||||
{
|
{
|
||||||
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(itr->second->GetId());
|
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(itr->second->GetId());
|
||||||
// in that case, unload grids of the base map, too
|
// in that case, unload grids of the base map, too
|
||||||
// so in the next map creation, (EnsureGridCreated actually) VMaps will be reloaded
|
// so in the next map creation, (EnsureGridCreated actually) VMaps will be reloaded
|
||||||
Map::UnloadAll(true);
|
Map::UnloadAll();
|
||||||
}
|
}
|
||||||
// erase map
|
// erase map
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class TRINITY_DLL_DECL MapInstanced : public Map
|
|||||||
void MoveAllCreaturesInMoveList();
|
void MoveAllCreaturesInMoveList();
|
||||||
void RemoveAllObjectsInRemoveList();
|
void RemoveAllObjectsInRemoveList();
|
||||||
bool RemoveBones(uint64 guid, float x, float y);
|
bool RemoveBones(uint64 guid, float x, float y);
|
||||||
void UnloadAll(bool pForce);
|
void UnloadAll();
|
||||||
bool CanEnter(Player* player);
|
bool CanEnter(Player* player);
|
||||||
|
|
||||||
Map* GetInstance(const WorldObject* obj);
|
Map* GetInstance(const WorldObject* obj);
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ bool MapManager::IsValidMAP(uint32 mapid)
|
|||||||
void MapManager::UnloadAll()
|
void MapManager::UnloadAll()
|
||||||
{
|
{
|
||||||
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
|
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
|
||||||
iter->second->UnloadAll(true);
|
iter->second->UnloadAll();
|
||||||
|
|
||||||
while(!i_maps.empty())
|
while(!i_maps.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -1538,7 +1538,7 @@ Map const* WorldObject::GetBaseMap() const
|
|||||||
|
|
||||||
void WorldObject::AddObjectToRemoveList()
|
void WorldObject::AddObjectToRemoveList()
|
||||||
{
|
{
|
||||||
Map* map = GetMap();
|
Map* map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId());
|
||||||
if(!map)
|
if(!map)
|
||||||
{
|
{
|
||||||
sLog.outError("Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).",GetTypeId(),GetEntry(),GetGUIDLow(),GetMapId());
|
sLog.outError("Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).",GetTypeId(),GetEntry(),GetGUIDLow(),GetMapId());
|
||||||
|
|||||||
@@ -1101,7 +1101,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool isPossessing(Unit* u) const { return u->isPossessed() && GetCharmGUID() == u->GetGUID(); }
|
bool isPossessing(Unit* u) const { return u->isPossessed() && GetCharmGUID() == u->GetGUID(); }
|
||||||
bool isPossessingCreature() const { return isPossessing() && IS_CREATURE_GUID(GetCharmGUID()); }
|
|
||||||
|
|
||||||
CharmInfo* GetCharmInfo() { return m_charmInfo; }
|
CharmInfo* GetCharmInfo() { return m_charmInfo; }
|
||||||
CharmInfo* InitCharmInfo(Unit* charm);
|
CharmInfo* InitCharmInfo(Unit* charm);
|
||||||
|
|||||||
Reference in New Issue
Block a user