diff options
author | Anubisss <none@none> | 2010-05-13 00:08:30 +0200 |
---|---|---|
committer | Anubisss <none@none> | 2010-05-13 00:08:30 +0200 |
commit | 4a448eca37a5a5409d39d4036db3793cfa27edf8 (patch) | |
tree | 62c1cb0ec5962173ad0cfafa36a3d513846e813f /src | |
parent | 8223af6576f17e4e402600bae844c5e7c6d74bda (diff) |
Make WaypointMgr to singleton.
Move global waypoint_map variable to WaypointMgr's private variable.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Level2.cpp | 2 | ||||
-rw-r--r-- | src/game/Map.cpp | 2 | ||||
-rw-r--r-- | src/game/WaypointManager.cpp | 3 | ||||
-rw-r--r-- | src/game/WaypointManager.h | 9 | ||||
-rw-r--r-- | src/game/WaypointMovementGenerator.cpp | 2 | ||||
-rw-r--r-- | src/game/World.cpp | 2 |
6 files changed, 11 insertions, 9 deletions
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 14c549b0f1f..4f299c932e8 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -2433,7 +2433,7 @@ bool ChatHandler::HandleReloadAllPaths(const char* args) return false; PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id); - WaypointMgr.UpdatePath(id); + sWaypointMgr->UpdatePath(id); return true; } diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 712ab099198..0a669d9b828 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -3555,7 +3555,7 @@ void Map::ScriptsProcess() break; } - if (!WaypointMgr.GetPath(step.script->datalong)) + if (!sWaypointMgr->GetPath(step.script->datalong)) { sLog.outError("SCRIPT_COMMAND_START_MOVE source mover has an invallid path, skipping.", step.script->datalong2); break; diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp index 9077dfb36a8..bd052306992 100644 --- a/src/game/WaypointManager.cpp +++ b/src/game/WaypointManager.cpp @@ -24,9 +24,6 @@ #include "ProgressBar.h" #include "MapManager.h" -UNORDERED_MAP<uint32, WaypointPath*> waypoint_map; -WaypointStore WaypointMgr; - void WaypointStore::Free() { waypoint_map.clear(); diff --git a/src/game/WaypointManager.h b/src/game/WaypointManager.h index 20a5dcc256f..b70d07a9b9b 100644 --- a/src/game/WaypointManager.h +++ b/src/game/WaypointManager.h @@ -21,6 +21,8 @@ #ifndef TRINITY_WAYPOINTMANAGER_H #define TRINITY_WAYPOINTMANAGER_H +#include <ace/Singleton.h> +#include <ace/Null_Mutex.h> #include <vector> struct WaypointData @@ -34,14 +36,17 @@ struct WaypointData }; typedef std::vector<WaypointData*> WaypointPath; -extern UNORDERED_MAP<uint32, WaypointPath*> waypoint_map; class WaypointStore { private : uint32 records; + UNORDERED_MAP<uint32, WaypointPath*> waypoint_map; public: + // Null Mutex is OK because WaypointMgr is initialized in the World thread before World is initialized + static WaypointStore* instance() { return ACE_Singleton<WaypointStore, ACE_Null_Mutex>::instance(); } + void UpdatePath(uint32 id); void Load(); void Free(); @@ -56,7 +61,7 @@ class WaypointStore inline uint32 GetRecordsCount() { return records; } }; -extern WaypointStore WaypointMgr; +#define sWaypointMgr WaypointStore::instance() #endif diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index e0ab491f2e1..d2e4c515a04 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -103,7 +103,7 @@ WaypointMovementGenerator<Creature>::Initialize(Creature &u) StopedByPlayer = false; if (!path_id) path_id = u.GetWaypointPath(); - waypoints = WaypointMgr.GetPath(path_id); + waypoints = sWaypointMgr->GetPath(path_id); i_currentNode = 0; if (waypoints && waypoints->size()) { diff --git a/src/game/World.cpp b/src/game/World.cpp index 0ef07e143ba..dced43596a4 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1562,7 +1562,7 @@ void World::SetInitialWorldSettings() objmgr.LoadTrainerSpell(); // must be after load CreatureTemplate sLog.outString("Loading Waypoints..."); - WaypointMgr.Load(); + sWaypointMgr->Load(); sLog.outString("Loading Creature Formations..."); formation_mgr.LoadCreatureFormations(); |