42 QueryResult resultMeta =
WorldDatabase.Query(
"SELECT entry, chainId, splineId, expectedDuration, msUntilNext, velocity FROM script_spline_chain_meta ORDER BY entry asc, chainId asc, splineId asc");
44 QueryResult resultWP =
WorldDatabase.Query(
"SELECT entry, chainId, splineId, wpId, x, y, z FROM script_spline_chain_waypoints ORDER BY entry asc, chainId asc, splineId asc, wpId asc");
45 if (!resultMeta || !resultWP)
47 TC_LOG_INFO(
"server.loading",
">> Loaded spline chain data for 0 chains, consisting of 0 splines with 0 waypoints. DB tables `script_spline_chain_meta` and `script_spline_chain_waypoints` are empty.");
51 uint32 chainCount = 0, splineCount = 0, wpCount = 0;
54 Field* fieldsMeta = resultMeta->Fetch();
60 if (splineId != chain.size())
62 TC_LOG_WARN(
"server.loading",
"Creature #{}: Chain {} has orphaned spline {}, skipped.", entry, chainId, splineId);
68 float velocity = fieldsMeta[5].
GetFloat();
69 chain.emplace_back(expectedDuration, msUntilNext, velocity);
74 }
while (resultMeta->NextRow());
78 Field* fieldsWP = resultWP->Fetch();
86 TC_LOG_WARN(
"server.loading",
"Creature #{} has waypoint data for spline chain {}. No such chain exists - entry skipped.", entry, chainId);
89 std::vector<SplineChainLink>& chain = it->second;
90 if (splineId >= chain.size())
92 TC_LOG_WARN(
"server.loading",
"Creature #{} has waypoint data for spline ({},{}). The specified chain does not have a spline with this index - entry skipped.", entry, chainId, splineId);
96 if (wpId != spline.
Points.size())
98 TC_LOG_WARN(
"server.loading",
"Creature #{} has orphaned waypoint data in spline ({},{}) at index {}. Skipped.", entry, chainId, splineId, wpId);
101 spline.
Points.emplace_back(posX, posY, posZ);
103 }
while (resultWP->NextRow());
105 TC_LOG_INFO(
"server.loading",
">> Loaded spline chain data for {} chains, consisting of {} splines with {} waypoints in {} ms", chainCount, splineCount, wpCount,
GetMSTimeDiffToNow(oldMSTime));
std::shared_ptr< ResultSet > QueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
#define TC_LOG_WARN(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Class used to access individual fields of database query result.
void LoadScriptSplineChains()
std::unordered_map< ChainKeyType, std::vector< SplineChainLink > > m_mSplineChainsMap
static SystemMgr * instance()
std::vector< SplineChainLink > const * GetSplineChain(uint32 entry, uint16 chainId) const
Movement::PointsArray Points