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