TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SystemMgr Class Reference

#include <ScriptSystem.h>

Public Types

typedef std::unordered_map
< uint32, ScriptPointVector
PointMoveMap
 

Public Member Functions

void LoadScriptWaypoints ()
 
ScriptPointVector constGetPointMoveList (uint32 creatureEntry) const
 

Static Public Member Functions

static SystemMgrinstance ()
 

Protected Attributes

PointMoveMap m_mPointMoveMap
 

Private Member Functions

 SystemMgr ()
 
 ~SystemMgr ()
 

Static Private Attributes

static ScriptPointVector const _empty
 

Member Typedef Documentation

typedef std::unordered_map<uint32, ScriptPointVector> SystemMgr::PointMoveMap

Constructor & Destructor Documentation

SystemMgr::SystemMgr ( )
inlineprivate
65 { }
SystemMgr::~SystemMgr ( )
inlineprivate
66 { }

Member Function Documentation

ScriptPointVector const& SystemMgr::GetPointMoveList ( uint32  creatureEntry) const
inline
77  {
78  PointMoveMap::const_iterator itr = m_mPointMoveMap.find(creatureEntry);
79 
80  if (itr == m_mPointMoveMap.end())
81  return _empty;
82 
83  return itr->second;
84  }
PointMoveMap m_mPointMoveMap
Definition: ScriptSystem.h:87
static ScriptPointVector const _empty
Definition: ScriptSystem.h:90
SystemMgr * SystemMgr::instance ( )
static
27 {
28  static SystemMgr instance;
29  return &instance;
30 }
static SystemMgr * instance()
Definition: ScriptSystem.cpp:26
Definition: ScriptSystem.h:62
void SystemMgr::LoadScriptWaypoints ( )
33 {
34  uint32 oldMSTime = getMSTime();
35 
36  // Drop Existing Waypoint list
37  m_mPointMoveMap.clear();
38 
39  uint64 uiCreatureCount = 0;
40 
41  // Load Waypoints
42  QueryResult result = WorldDatabase.Query("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
43  if (result)
44  uiCreatureCount = result->GetRowCount();
45 
46  TC_LOG_INFO("server.loading", "Loading Script Waypoints for " UI64FMTD " creature(s)...", uiCreatureCount);
47 
48  // 0 1 2 3 4 5
49  result = WorldDatabase.Query("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
50 
51  if (!result)
52  {
53  TC_LOG_INFO("server.loading", ">> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty.");
54  return;
55  }
56 
57  uint32 count = 0;
58 
59  do
60  {
61  Field* pFields = result->Fetch();
62  ScriptPointMove temp;
63 
64  temp.uiCreatureEntry = pFields[0].GetUInt32();
65  uint32 uiEntry = temp.uiCreatureEntry;
66  temp.uiPointId = pFields[1].GetUInt32();
67  temp.fX = pFields[2].GetFloat();
68  temp.fY = pFields[3].GetFloat();
69  temp.fZ = pFields[4].GetFloat();
70  temp.uiWaitTime = pFields[5].GetUInt32();
71 
72  CreatureTemplate const* pCInfo = sObjectMgr->GetCreatureTemplate(temp.uiCreatureEntry);
73 
74  if (!pCInfo)
75  {
76  TC_LOG_ERROR("sql.sql", "TSCR: DB table script_waypoint has waypoint for non-existant creature entry %u", temp.uiCreatureEntry);
77  continue;
78  }
79 
80  if (!pCInfo->ScriptID)
81  TC_LOG_ERROR("sql.sql", "TSCR: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", temp.uiCreatureEntry);
82 
83  m_mPointMoveMap[uiEntry].push_back(temp);
84  ++count;
85  }
86  while (result->NextRow());
87 
88  TC_LOG_INFO("server.loading", ">> Loaded %u Script Waypoint nodes in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
89 }
float fZ
Definition: ScriptSystem.h:56
float GetFloat() const
Definition: Field.h:222
Class used to access individual fields of database query result.
Definition: Field.h:56
PointMoveMap m_mPointMoveMap
Definition: ScriptSystem.h:87
uint32 getMSTime()
Definition: Timer.h:24
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
#define sObjectMgr
Definition: ObjectMgr.h:1567
float fY
Definition: ScriptSystem.h:55
float fX
Definition: ScriptSystem.h:54
Definition: ScriptSystem.h:50
uint32 uiPointId
Definition: ScriptSystem.h:53
#define UI64FMTD
Definition: Define.h:137
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 uiCreatureEntry
Definition: ScriptSystem.h:52
uint32 GetUInt32() const
Definition: Field.h:146
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 uiWaitTime
Definition: ScriptSystem.h:57
uint32 ScriptID
Definition: Creature.h:143
Definition: Creature.h:79

+ Here is the call graph for this function:

Member Data Documentation

TC_GAME_API ScriptPointVector const SystemMgr::_empty
staticprivate
PointMoveMap SystemMgr::m_mPointMoveMap
protected

The documentation for this class was generated from the following files: