mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 08:00:48 +01:00
Core/Movement: waypoint movement (#20121)
Following the work done in #19361 this is the cleanup and improvement of the related logic of waypoint management. Ref28050f3#18020 (taking the good parts and ignoring the incomplete work) (cherry picked from commit7fff83d675)
This commit is contained in:
@@ -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;
|
||||
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();
|
||||
|
||||
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)
|
||||
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 });
|
||||
|
||||
Reference in New Issue
Block a user