aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-03-12 11:49:42 +0100
committerShauren <shauren.trinity@gmail.com>2024-03-12 11:49:42 +0100
commita8cc8725b13ec1eba9fb5ff5957f9e4da46e6f15 (patch)
treef9ac93ef3acbb467093b222c3fce0b1cc4474d8d /src
parent5d29fc0b99fc00026b366fbec18fe13b7537a9b8 (diff)
Core/Movement: Minor refactor for WaypointManager data loading
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Movement/Waypoints/WaypointDefines.h8
-rw-r--r--src/server/game/Movement/Waypoints/WaypointManager.cpp12
2 files changed, 9 insertions, 11 deletions
diff --git a/src/server/game/Movement/Waypoints/WaypointDefines.h b/src/server/game/Movement/Waypoints/WaypointDefines.h
index d801531b316..af47ccfd0db 100644
--- a/src/server/game/Movement/Waypoints/WaypointDefines.h
+++ b/src/server/game/Movement/Waypoints/WaypointDefines.h
@@ -68,18 +68,18 @@ struct WaypointNode
struct WaypointPath
{
- WaypointPath() : Id(0), MoveType(WaypointMoveType::Walk), Flags(WaypointPathFlags::None) { }
+ WaypointPath() = default;
WaypointPath(uint32 id, std::vector<WaypointNode>&& nodes, WaypointMoveType moveType = WaypointMoveType::Walk, WaypointPathFlags flags = WaypointPathFlags::None)
{
Id = id;
- Nodes = nodes;
+ Nodes = std::move(nodes);
Flags = flags;
MoveType = moveType;
}
std::vector<WaypointNode> Nodes;
- uint32 Id;
- WaypointMoveType MoveType;
+ uint32 Id = 0;
+ WaypointMoveType MoveType = WaypointMoveType::Walk;
EnumFlag<WaypointPathFlags> Flags = WaypointPathFlags::None;
};
diff --git a/src/server/game/Movement/Waypoints/WaypointManager.cpp b/src/server/game/Movement/Waypoints/WaypointManager.cpp
index cb282e6ec30..eec635bf6d1 100644
--- a/src/server/game/Movement/Waypoints/WaypointManager.cpp
+++ b/src/server/game/Movement/Waypoints/WaypointManager.cpp
@@ -89,14 +89,14 @@ void WaypointMgr::LoadPathFromDB(Field* fields)
WaypointPath& path = _pathStore[pathId];
path.Id = pathId;
- path.MoveType = (WaypointMoveType)fields[1].GetUInt8();
+ path.MoveType = WaypointMoveType(fields[1].GetUInt8());
if (path.MoveType >= WaypointMoveType::Max)
{
TC_LOG_ERROR("sql.sql", "PathId {} in `waypoint_path` has invalid MoveType {}, ignoring", pathId, AsUnderlyingType(path.MoveType));
return;
}
- path.Flags = (WaypointPathFlags)fields[2].GetUInt8();
+ path.Flags = WaypointPathFlags(fields[2].GetUInt8());
path.Nodes.clear();
}
@@ -104,7 +104,8 @@ void WaypointMgr::LoadPathNodesFromDB(Field* fields)
{
uint32 pathId = fields[0].GetUInt32();
- if (_pathStore.find(pathId) == _pathStore.end())
+ WaypointPath* path = Trinity::Containers::MapGetValuePtr(_pathStore, pathId);
+ if (!path)
{
TC_LOG_ERROR("sql.sql", "PathId {} in `waypoint_path_node` does not exist in `waypoint_path`, ignoring", pathId);
return;
@@ -120,10 +121,7 @@ void WaypointMgr::LoadPathNodesFromDB(Field* fields)
Trinity::NormalizeMapCoord(x);
Trinity::NormalizeMapCoord(y);
- WaypointNode waypoint(fields[1].GetUInt32(), x, y, z, o, fields[6].GetUInt32());
-
- WaypointPath& path = _pathStore[pathId];
- path.Nodes.push_back(std::move(waypoint));
+ path->Nodes.emplace_back(fields[1].GetUInt32(), x, y, z, o, fields[6].GetUInt32());
}
void WaypointMgr::DoPostLoadingChecks()