AzeorthCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SystemMgr Class Reference

#include "ScriptSystem.h"

Public Types

typedef std::unordered_map< uint32, ScriptPointVectorPointMoveMap
 

Public Member Functions

void LoadScriptWaypoints ()
 
ScriptPointVector const & GetPointMoveList (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
 

Detailed Description

Member Typedef Documentation

◆ PointMoveMap

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

Constructor & Destructor Documentation

◆ SystemMgr()

SystemMgr::SystemMgr ( )
inlineprivate
63{}

◆ ~SystemMgr()

SystemMgr::~SystemMgr ( )
inlineprivate
64{}

Member Function Documentation

◆ GetPointMoveList()

ScriptPointVector const & SystemMgr::GetPointMoveList ( uint32  creatureEntry) const
inline
75 {
76 PointMoveMap::const_iterator itr = m_mPointMoveMap.find(creatureEntry);
77
78 if (itr == m_mPointMoveMap.end())
79 return _empty;
80
81 return itr->second;
82 }
PointMoveMap m_mPointMoveMap
Definition: ScriptSystem.h:85
static ScriptPointVector const _empty
Definition: ScriptSystem.h:88

References _empty, and m_mPointMoveMap.

◆ instance()

SystemMgr * SystemMgr::instance ( )
static
25{
26 static SystemMgr instance;
27 return &instance;
28}
Definition: ScriptSystem.h:62
static SystemMgr * instance()
Definition: ScriptSystem.cpp:24

References instance().

Referenced by instance().

◆ LoadScriptWaypoints()

void SystemMgr::LoadScriptWaypoints ( )
31{
32 uint32 oldMSTime = getMSTime();
33
34 // Drop Existing Waypoint list
35 m_mPointMoveMap.clear();
36
37 uint64 uiCreatureCount = 0;
38
39 // Load Waypoints
40 QueryResult result = WorldDatabase.Query("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
41 if (result)
42 uiCreatureCount = result->GetRowCount();
43
44 LOG_INFO("server.loading", "Loading Script Waypoints For {} Creature(s)...", uiCreatureCount);
45
46 // 0 1 2 3 4 5
47 result = WorldDatabase.Query("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
48
49 if (!result)
50 {
51 LOG_WARN("server.loading", ">> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty.");
52 LOG_INFO("server.loading", " ");
53 return;
54 }
55
56 uint32 count = 0;
57
58 do
59 {
60 Field* pFields = result->Fetch();
61 ScriptPointMove temp;
62
63 temp.uiCreatureEntry = pFields[0].Get<uint32>();
64 uint32 uiEntry = temp.uiCreatureEntry;
65 temp.uiPointId = pFields[1].Get<uint32>();
66 temp.fX = pFields[2].Get<float>();
67 temp.fY = pFields[3].Get<float>();
68 temp.fZ = pFields[4].Get<float>();
69 temp.uiWaitTime = pFields[5].Get<uint32>();
70
71 CreatureTemplate const* pCInfo = sObjectMgr->GetCreatureTemplate(temp.uiCreatureEntry);
72
73 if (!pCInfo)
74 {
75 LOG_ERROR("sql.sql", "DB table script_waypoint has waypoint for non-existant creature entry {}", temp.uiCreatureEntry);
76 continue;
77 }
78
79 if (!pCInfo->ScriptID)
80 LOG_ERROR("sql.sql", "DB table script_waypoint has waypoint for creature entry {}, but creature does not have ScriptName defined and then useless.", temp.uiCreatureEntry);
81
82 m_mPointMoveMap[uiEntry].push_back(temp);
83 ++count;
84 } while (result->NextRow());
85
86 LOG_INFO("server.loading", ">> Loaded {} Script Waypoint nodes in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
87}
std::uint32_t uint32
Definition: Define.h:108
std::uint64_t uint64
Definition: Define.h:107
#define LOG_INFO(filterType__,...)
Definition: Log.h:167
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
#define LOG_WARN(filterType__,...)
Definition: Log.h:163
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
#define sObjectMgr
Definition: ObjectMgr.h:1606
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Definition: CreatureData.h:176
Definition: ScriptSystem.h:50
float fZ
Definition: ScriptSystem.h:55
uint32 uiWaitTime
Definition: ScriptSystem.h:56
float fX
Definition: ScriptSystem.h:53
float fY
Definition: ScriptSystem.h:54
uint32 uiCreatureEntry
Definition: ScriptSystem.h:51
uint32 uiPointId
Definition: ScriptSystem.h:52

References ScriptPointMove::fX, ScriptPointMove::fY, ScriptPointMove::fZ, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, m_mPointMoveMap, sObjectMgr, ScriptPointMove::uiCreatureEntry, ScriptPointMove::uiPointId, ScriptPointMove::uiWaitTime, and WorldDatabase.

Member Data Documentation

◆ _empty

ScriptPointVector const SystemMgr::_empty
staticprivate

Referenced by GetPointMoveList().

◆ m_mPointMoveMap

PointMoveMap SystemMgr::m_mPointMoveMap
protected