diff options
author | ccrs <ccrs@users.noreply.github.com> | 2017-08-12 01:40:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-12 01:40:25 +0200 |
commit | 7fff83d67526efff63867d41b9e036a19a9287b3 (patch) | |
tree | 0462cb16ac0099318ab9ce07dc6cc099e141375e /src/server/game/Scripting/ScriptSystem.cpp | |
parent | 00329fe9a505c437af0b7591d8321bf3b77ad7fb (diff) |
Core/Movement: waypoint movement (#20121)
Following the work done in #19361 this is the cleanup and improvement of the related logic of waypoint management.
Ref 28050f3 #18020
(taking the good parts and ignoring the incomplete work)
Diffstat (limited to 'src/server/game/Scripting/ScriptSystem.cpp')
-rw-r--r-- | src/server/game/Scripting/ScriptSystem.cpp | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp index 1b4ad6b98d5..b814229151a 100644 --- a/src/server/game/Scripting/ScriptSystem.cpp +++ b/src/server/game/Scripting/ScriptSystem.cpp @@ -37,17 +37,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"); @@ -61,29 +61,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()); @@ -163,6 +162,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 }); |