aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Scripting/ScriptSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Scripting/ScriptSystem.cpp')
-rw-r--r--src/server/game/Scripting/ScriptSystem.cpp56
1 files changed, 32 insertions, 24 deletions
diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp
index e2641447086..0cb051b3cdf 100644
--- a/src/server/game/Scripting/ScriptSystem.cpp
+++ b/src/server/game/Scripting/ScriptSystem.cpp
@@ -36,17 +36,17 @@ void SystemMgr::LoadScriptWaypoints()
{
uint32 oldMSTime = getMSTime();
- // Drop Existing Waypoint list
- m_mPointMoveMap.clear();
+ // drop Existing Waypoint list
+ _waypointStore.clear();
- uint64 uiCreatureCount = 0;
+ uint64 entryCount = 0;
- // Load Waypoints
+ // load Waypoints
QueryResult result = WorldDatabase.Query("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
if (result)
- uiCreatureCount = result->GetRowCount();
+ entryCount = result->GetRowCount();
- TC_LOG_INFO("server.loading", "Loading Script Waypoints for " UI64FMTD " creature(s)...", uiCreatureCount);
+ TC_LOG_INFO("server.loading", "Loading Script Waypoints for " UI64FMTD " creature(s)...", entryCount);
// 0 1 2 3 4 5
result = WorldDatabase.Query("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
@@ -60,29 +60,28 @@ void SystemMgr::LoadScriptWaypoints()
do
{
- Field* pFields = result->Fetch();
- ScriptPointMove temp;
-
- temp.uiCreatureEntry = pFields[0].GetUInt32();
- uint32 uiEntry = temp.uiCreatureEntry;
- temp.uiPointId = pFields[1].GetUInt32();
- temp.fX = pFields[2].GetFloat();
- temp.fY = pFields[3].GetFloat();
- temp.fZ = pFields[4].GetFloat();
- temp.uiWaitTime = pFields[5].GetUInt32();
-
- CreatureTemplate const* pCInfo = sObjectMgr->GetCreatureTemplate(temp.uiCreatureEntry);
-
- if (!pCInfo)
+ Field* fields = result->Fetch();
+ uint32 entry = fields[0].GetUInt32();
+ uint32 id = fields[1].GetUInt32();
+ float x = fields[2].GetFloat();
+ float y = fields[3].GetFloat();
+ float z = fields[4].GetFloat();
+ uint32 waitTime = fields[5].GetUInt32();
+
+ CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(entry);
+ if (!info)
{
- TC_LOG_ERROR("sql.sql", "TSCR: DB table script_waypoint has waypoint for non-existant creature entry %u", temp.uiCreatureEntry);
+ TC_LOG_ERROR("sql.sql", "SystemMgr: DB table script_waypoint has waypoint for non-existant creature entry %u", entry);
continue;
}
- if (!pCInfo->ScriptID)
- 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);
+ if (!info->ScriptID)
+ TC_LOG_ERROR("sql.sql", "SystemMgr: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", entry);
+
+ WaypointPath& path = _waypointStore[entry];
+ path.id = entry;
+ path.nodes.emplace_back(id, x, y, z, 0.f, waitTime);
- m_mPointMoveMap[uiEntry].push_back(temp);
++count;
} while (result->NextRow());
@@ -162,6 +161,15 @@ void SystemMgr::LoadScriptSplineChains()
}
}
+WaypointPath const* SystemMgr::GetPath(uint32 creatureEntry) const
+{
+ auto itr = _waypointStore.find(creatureEntry);
+ if (itr == _waypointStore.end())
+ return nullptr;
+
+ return &itr->second;
+}
+
std::vector<SplineChainLink> const* SystemMgr::GetSplineChain(uint32 entry, uint16 chainId) const
{
auto it = m_mSplineChainsMap.find({ entry, chainId });