Skip to content

Commit

Permalink
Merge pull request #135 from TrinityCore/master
Browse files Browse the repository at this point in the history
Update 03.15.24
  • Loading branch information
KamiliaBlow authored Mar 14, 2024
2 parents cb5632d + 783f9c0 commit daaa44a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/server/game/Entities/Object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ class TC_GAME_API Object
inline bool IsWorldObject() const { return isType(TYPEMASK_WORLDOBJECT); }
static WorldObject* ToWorldObject(Object* o) { return o ? o->ToWorldObject() : nullptr; }
static WorldObject const* ToWorldObject(Object const* o) { return o ? o->ToWorldObject() : nullptr; }
WorldObject* ToWorldObject() { if (IsUnit()) return reinterpret_cast<WorldObject*>(this); else return nullptr; }
WorldObject const* ToWorldObject() const { if (IsUnit()) return reinterpret_cast<WorldObject const*>(this); else return nullptr; }
WorldObject* ToWorldObject() { if (IsWorldObject()) return reinterpret_cast<WorldObject*>(this); else return nullptr; }
WorldObject const* ToWorldObject() const { if (IsWorldObject()) return reinterpret_cast<WorldObject const*>(this); else return nullptr; }

inline bool IsItem() const { return isType(TYPEMASK_ITEM); }
static Item* ToItem(Object* o) { return o ? o->ToItem() : nullptr; }
Expand Down
18 changes: 2 additions & 16 deletions src/server/game/Maps/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
*/

#include "Map.h"
#include "BattlefieldMgr.h"
#include "Battleground.h"
#include "CellImpl.h"
#include "CharacterPackets.h"
#include "Containers.h"
#include "Conversation.h"
#include "DatabaseEnv.h"
#include "DB2Stores.h"
#include "DatabaseEnv.h"
#include "DynamicTree.h"
#include "GameObjectModel.h"
#include "GameTime.h"
Expand All @@ -43,20 +42,19 @@
#include "ObjectAccessor.h"
#include "ObjectGridLoader.h"
#include "ObjectMgr.h"
#include "OutdoorPvPMgr.h"
#include "Pet.h"
#include "PhasingHandler.h"
#include "PoolMgr.h"
#include "ScriptMgr.h"
#include "SpellAuras.h"
#include "TerrainMgr.h"
#include "Transport.h"
#include "Vehicle.h"
#include "VMapFactory.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
#include "VMapManager2.h"
#include "Vehicle.h"
#include "Vignette.h"
#include "VignettePackets.h"
#include "Weather.h"
Expand Down Expand Up @@ -93,10 +91,6 @@ struct RespawnInfoWithHandle : RespawnInfo

Map::~Map()
{
// UnloadAll must be called before deleting the map

sScriptMgr->OnDestroyMap(this);

// Delete all waiting spawns, else there will be a memory leak
// This doesn't delete from database.
UnloadAllRespawnInfos();
Expand All @@ -113,9 +107,6 @@ Map::~Map()
if (!m_scriptSchedule.empty())
sMapMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());

sOutdoorPvPMgr->DestroyOutdoorPvPForMap(this);
sBattlefieldMgr->DestroyBattlefieldsForMap(this);

m_terrain->UnloadMMapInstance(GetId(), GetInstanceId());
}

Expand Down Expand Up @@ -176,11 +167,6 @@ i_scriptLock(false), _respawnTimes(std::make_unique<RespawnListContainer>()), _r
m_terrain->LoadMMapInstance(GetId(), GetInstanceId());

_worldStateValues = sWorldStateMgr->GetInitialWorldStatesForMap(this);

sOutdoorPvPMgr->CreateOutdoorPvPForMap(this);
sBattlefieldMgr->CreateBattlefieldsForMap(this);

sScriptMgr->OnCreateMap(this);
}

void Map::InitVisibilityDistance()
Expand Down
16 changes: 16 additions & 0 deletions src/server/game/Maps/MapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "MapManager.h"
#include "BattlefieldMgr.h"
#include "Battleground.h"
#include "Containers.h"
#include "DatabaseEnv.h"
Expand All @@ -25,6 +26,7 @@
#include "InstanceLockMgr.h"
#include "Log.h"
#include "Map.h"
#include "OutdoorPvPMgr.h"
#include "Player.h"
#include "ScenarioMgr.h"
#include "ScriptMgr.h"
Expand Down Expand Up @@ -267,6 +269,10 @@ Map* MapManager::CreateMap(uint32 mapId, Player* player)
{
ptr.reset(map);
map->SetWeakPtr(ptr);

sScriptMgr->OnCreateMap(map);
sOutdoorPvPMgr->CreateOutdoorPvPForMap(map);
sBattlefieldMgr->CreateBattlefieldsForMap(map);
}
}

Expand Down Expand Up @@ -363,6 +369,10 @@ bool MapManager::DestroyMap(Map* map)
if (map->HavePlayers())
return false;

sOutdoorPvPMgr->DestroyOutdoorPvPForMap(map);
sBattlefieldMgr->DestroyBattlefieldsForMap(map);
sScriptMgr->OnDestroyMap(map);

map->UnloadAll();

// Free up the instance id and allow it to be reused for normal dungeons, bgs and arenas
Expand All @@ -382,8 +392,14 @@ void MapManager::UnloadAll()
{
// first unload maps
for (auto iter = i_maps.begin(); iter != i_maps.end(); ++iter)
{
iter->second->UnloadAll();

sOutdoorPvPMgr->DestroyOutdoorPvPForMap(iter->second.get());
sBattlefieldMgr->DestroyBattlefieldsForMap(iter->second.get());
sScriptMgr->OnDestroyMap(iter->second.get());
}

// then delete them
i_maps.clear();

Expand Down

0 comments on commit daaa44a

Please sign in to comment.