*Fix the bug that players get stuck after teleported out of bg.
*Do not delete the map immediately until all players are teleported. --HG-- branch : trunk
This commit is contained in:
+23
-12
@@ -1196,6 +1196,21 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool unloadAll)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Map::RemoveAllPlayers()
|
||||||
|
{
|
||||||
|
if(HavePlayers())
|
||||||
|
{
|
||||||
|
sLog.outError("Map::UnloadAll: there are still players in the instance at unload, should not happen!");
|
||||||
|
|
||||||
|
for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
|
||||||
|
{
|
||||||
|
Player* plr = itr->getSource();
|
||||||
|
if(!plr->IsBeingTeleportedFar())
|
||||||
|
plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Map::UnloadAll()
|
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.
|
||||||
@@ -2642,12 +2657,7 @@ void InstanceMap::PermBindAllPlayers(Player *player)
|
|||||||
|
|
||||||
void InstanceMap::UnloadAll()
|
void InstanceMap::UnloadAll()
|
||||||
{
|
{
|
||||||
while(HavePlayers())
|
assert(!HavePlayers());
|
||||||
{
|
|
||||||
sLog.outError("InstanceMap::UnloadAll: there are still players in the instance at unload, should not happen!");
|
|
||||||
Player *plr = m_mapRefManager.getFirst()->getSource();
|
|
||||||
plr->TeleportOutOfMap(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_resetAfterUnload == true)
|
if(m_resetAfterUnload == true)
|
||||||
objmgr.DeleteRespawnTimeForInstance(GetInstanceId());
|
objmgr.DeleteRespawnTimeForInstance(GetInstanceId());
|
||||||
@@ -2734,16 +2744,17 @@ void BattleGroundMap::SetUnload()
|
|||||||
m_unloadTimer = MIN_UNLOAD_DELAY;
|
m_unloadTimer = MIN_UNLOAD_DELAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGroundMap::UnloadAll()
|
void BattleGroundMap::RemoveAllPlayers()
|
||||||
{
|
{
|
||||||
while(HavePlayers())
|
if(HavePlayers())
|
||||||
{
|
{
|
||||||
Player *plr = m_mapRefManager.getFirst()->getSource();
|
for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
|
||||||
|
{
|
||||||
|
Player* plr = itr->getSource();
|
||||||
|
if(!plr->IsBeingTeleportedFar())
|
||||||
plr->TeleportTo(plr->GetBattleGroundEntryPoint());
|
plr->TeleportTo(plr->GetBattleGroundEntryPoint());
|
||||||
plr->TeleportOutOfMap(this);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Map::UnloadAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Put scripts in the execution queue
|
/// Put scripts in the execution queue
|
||||||
|
|||||||
+2
-1
@@ -355,6 +355,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
|||||||
virtual void MoveAllCreaturesInMoveList();
|
virtual void MoveAllCreaturesInMoveList();
|
||||||
virtual void RemoveAllObjectsInRemoveList();
|
virtual void RemoveAllObjectsInRemoveList();
|
||||||
virtual void RelocationNotify();
|
virtual void RelocationNotify();
|
||||||
|
virtual void RemoveAllPlayers();
|
||||||
|
|
||||||
bool CreatureRespawnRelocation(Creature *c); // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader
|
bool CreatureRespawnRelocation(Creature *c); // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader
|
||||||
|
|
||||||
@@ -610,7 +611,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();
|
void RemoveAllPlayers();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*inline
|
/*inline
|
||||||
|
|||||||
@@ -46,7 +46,10 @@ void MapInstanced::Update(const uint32& t)
|
|||||||
{
|
{
|
||||||
if(i->second->CanUnload(t))
|
if(i->second->CanUnload(t))
|
||||||
{
|
{
|
||||||
DestroyInstance(i); // iterator incremented
|
if(!DestroyInstance(i)) // iterator incremented
|
||||||
|
{
|
||||||
|
//m_unloadTimer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -203,16 +206,16 @@ BattleGroundMap* MapInstanced::CreateBattleGround(uint32 InstanceId)
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapInstanced::DestroyInstance(uint32 InstanceId)
|
// increments the iterator after erase
|
||||||
|
bool MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
|
||||||
{
|
{
|
||||||
InstancedMaps::iterator itr = m_InstancedMaps.find(InstanceId);
|
itr->second->RemoveAllPlayers();
|
||||||
if(itr != m_InstancedMaps.end())
|
if(itr->second->HavePlayers())
|
||||||
DestroyInstance(itr);
|
{
|
||||||
|
++itr;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// increments the iterator after erase
|
|
||||||
void MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
|
|
||||||
{
|
|
||||||
itr->second->UnloadAll();
|
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))
|
||||||
@@ -225,6 +228,7 @@ void MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
|
|||||||
// erase map
|
// erase map
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
m_InstancedMaps.erase(itr++);
|
m_InstancedMaps.erase(itr++);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapInstanced::CanEnter(Player *player)
|
bool MapInstanced::CanEnter(Player *player)
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ class TRINITY_DLL_DECL MapInstanced : public Map
|
|||||||
|
|
||||||
Map* CreateInstance(const uint32 mapId, Player * player, uint32 instanceId);
|
Map* CreateInstance(const uint32 mapId, Player * player, uint32 instanceId);
|
||||||
Map* FindMap(uint32 InstanceId) const { return _FindMap(InstanceId); }
|
Map* FindMap(uint32 InstanceId) const { return _FindMap(InstanceId); }
|
||||||
void DestroyInstance(uint32 InstanceId);
|
bool DestroyInstance(InstancedMaps::iterator &itr);
|
||||||
void DestroyInstance(InstancedMaps::iterator &itr);
|
|
||||||
|
|
||||||
void AddGridMapReference(const GridPair &p)
|
void AddGridMapReference(const GridPair &p)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -234,13 +234,6 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId)
|
|
||||||
{
|
|
||||||
Map *m = _createBaseMap(mapid);
|
|
||||||
if (m && m->Instanceable())
|
|
||||||
((MapInstanced*)m)->DestroyInstance(instanceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MapManager::RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y)
|
void MapManager::RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y)
|
||||||
{
|
{
|
||||||
bool remove_result = _createBaseMap(mapid)->RemoveBones(guid, x, y);
|
bool remove_result = _createBaseMap(mapid)->RemoveBones(guid, x, y);
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
|
|||||||
Map const* CreateBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_createBaseMap(id); }
|
Map const* CreateBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_createBaseMap(id); }
|
||||||
Map* FindMap(uint32 mapid, uint32 instanceId = 0) const;
|
Map* FindMap(uint32 mapid, uint32 instanceId = 0) const;
|
||||||
|
|
||||||
// only const version for outer users
|
|
||||||
void DeleteInstance(uint32 mapid, uint32 instanceId);
|
|
||||||
|
|
||||||
uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const
|
uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const
|
||||||
{
|
{
|
||||||
Map const* m = CreateBaseMap(mapid);
|
Map const* m = CreateBaseMap(mapid);
|
||||||
|
|||||||
Reference in New Issue
Block a user