48{
50
52 {
53 for (WPPath::iterator pathItr = itr->second->begin(); pathItr != itr->second->end(); ++pathItr)
54 delete pathItr->second;
55
56 delete itr->second;
57 }
58
60
63
64 if (!result)
65 {
66 LOG_WARN(
"server.loading",
">> Loaded 0 SmartAI Waypoint Paths. DB table `waypoints` is empty.");
68 return;
69 }
70
75
76 do
77 {
78 Field* fields = result->Fetch();
81 float x = fields[2].
Get<
float>();
82 float y = fields[3].
Get<
float>();
83 float z = fields[4].
Get<
float>();
85 if (!fields[5].IsNull())
86 o = fields[5].Get<float>();
88
89 if (last_entry != entry)
90 {
92 last_id = 1;
93 count++;
94 }
95
96 if (last_id != id)
97 LOG_ERROR(
"sql.sql",
"SmartWaypointMgr::LoadFromDB: Path entry {}, unexpected point id {}, expected {}.", entry,
id, last_id);
98
99 last_id++;
101
102 last_entry = entry;
103 total++;
104 } while (result->NextRow());
105
106 LOG_INFO(
"server.loading",
">> Loaded {} SmartAI waypoint paths (total {} waypoints) in {} ms", count, total,
GetMSTimeDiffToNow(oldMSTime));
108}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::uint32_t uint32
Definition Define.h:107
#define LOG_INFO(filterType__,...)
Definition Log.h:165
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
#define LOG_WARN(filterType__,...)
Definition Log.h:161
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:24
std::unordered_map< uint32, WayPoint * > WPPath
Definition SmartScriptMgr.h:1999
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
@ WORLD_SEL_SMARTAI_WP
Definition WorldDatabase.h:36
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
Definition PreparedStatement.h:157
Definition SmartScriptMgr.h:33