Make WaypointMgr to singleton.
Move global waypoint_map variable to WaypointMgr's private variable. --HG-- branch : trunk
This commit is contained in:
+1
-1
@@ -2433,7 +2433,7 @@ bool ChatHandler::HandleReloadAllPaths(const char* args)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id);
|
PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id);
|
||||||
WaypointMgr.UpdatePath(id);
|
sWaypointMgr->UpdatePath(id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3555,7 +3555,7 @@ void Map::ScriptsProcess()
|
|||||||
break;
|
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);
|
sLog.outError("SCRIPT_COMMAND_START_MOVE source mover has an invallid path, skipping.", step.script->datalong2);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -24,9 +24,6 @@
|
|||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
#include "MapManager.h"
|
#include "MapManager.h"
|
||||||
|
|
||||||
UNORDERED_MAP<uint32, WaypointPath*> waypoint_map;
|
|
||||||
WaypointStore WaypointMgr;
|
|
||||||
|
|
||||||
void WaypointStore::Free()
|
void WaypointStore::Free()
|
||||||
{
|
{
|
||||||
waypoint_map.clear();
|
waypoint_map.clear();
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef TRINITY_WAYPOINTMANAGER_H
|
#ifndef TRINITY_WAYPOINTMANAGER_H
|
||||||
#define TRINITY_WAYPOINTMANAGER_H
|
#define TRINITY_WAYPOINTMANAGER_H
|
||||||
|
|
||||||
|
#include <ace/Singleton.h>
|
||||||
|
#include <ace/Null_Mutex.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct WaypointData
|
struct WaypointData
|
||||||
@@ -34,14 +36,17 @@ struct WaypointData
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<WaypointData*> WaypointPath;
|
typedef std::vector<WaypointData*> WaypointPath;
|
||||||
extern UNORDERED_MAP<uint32, WaypointPath*> waypoint_map;
|
|
||||||
|
|
||||||
class WaypointStore
|
class WaypointStore
|
||||||
{
|
{
|
||||||
private :
|
private :
|
||||||
uint32 records;
|
uint32 records;
|
||||||
|
UNORDERED_MAP<uint32, WaypointPath*> waypoint_map;
|
||||||
|
|
||||||
public:
|
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 UpdatePath(uint32 id);
|
||||||
void Load();
|
void Load();
|
||||||
void Free();
|
void Free();
|
||||||
@@ -56,7 +61,7 @@ class WaypointStore
|
|||||||
inline uint32 GetRecordsCount() { return records; }
|
inline uint32 GetRecordsCount() { return records; }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WaypointStore WaypointMgr;
|
#define sWaypointMgr WaypointStore::instance()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ WaypointMovementGenerator<Creature>::Initialize(Creature &u)
|
|||||||
StopedByPlayer = false;
|
StopedByPlayer = false;
|
||||||
if (!path_id)
|
if (!path_id)
|
||||||
path_id = u.GetWaypointPath();
|
path_id = u.GetWaypointPath();
|
||||||
waypoints = WaypointMgr.GetPath(path_id);
|
waypoints = sWaypointMgr->GetPath(path_id);
|
||||||
i_currentNode = 0;
|
i_currentNode = 0;
|
||||||
if (waypoints && waypoints->size())
|
if (waypoints && waypoints->size())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -1562,7 +1562,7 @@ void World::SetInitialWorldSettings()
|
|||||||
objmgr.LoadTrainerSpell(); // must be after load CreatureTemplate
|
objmgr.LoadTrainerSpell(); // must be after load CreatureTemplate
|
||||||
|
|
||||||
sLog.outString("Loading Waypoints...");
|
sLog.outString("Loading Waypoints...");
|
||||||
WaypointMgr.Load();
|
sWaypointMgr->Load();
|
||||||
|
|
||||||
sLog.outString("Loading Creature Formations...");
|
sLog.outString("Loading Creature Formations...");
|
||||||
formation_mgr.LoadCreatureFormations();
|
formation_mgr.LoadCreatureFormations();
|
||||||
|
|||||||
Reference in New Issue
Block a user