diff options
| author | Shauren <shauren.trinity@gmail.com> | 2024-04-19 15:16:17 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2024-04-19 15:16:17 +0200 |
| commit | e1f43900d110e50a2021d605c61cfe7c436bcc54 (patch) | |
| tree | 6c79a4d74f8c91eb1e3683f5bdc77d13d30662bf /src/server/game/Movement | |
| parent | ff9db332f5436fca0a9b14c15951cd8454ecdfb0 (diff) | |
Core/Movement: Store delay in WaypointNode as Milliseconds instead of raw integer and revert c5097114d1d08d6d6f7d2adc9f5f3f52f75c5818
Diffstat (limited to 'src/server/game/Movement')
3 files changed, 14 insertions, 22 deletions
diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 0ae4b44cbc9..c8545090156 100644 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -293,22 +293,10 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature* owner) ASSERT(_currentNode < path->Nodes.size(), "WaypointMovementGenerator::OnArrived: tried to reference a node id (%u) which is not included in path (%u)", _currentNode, path->Id); WaypointNode const& waypoint = path->Nodes[_currentNode]; - Milliseconds delay = [&] - { - if (!_isReturningToStart) - return Milliseconds(waypoint.Delay); - - // when traversing the path backwards, use delays from "next" waypoint to make sure pauses happen between the same points as in forward direction - if (_currentNode > 0) - return Milliseconds(path->Nodes[_currentNode - 1].Delay); - - return 0ms; - }(); - - if (delay > 0ms) + if (waypoint.Delay) { owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE); - _nextMoveTime.Reset(delay); + _nextMoveTime.Reset(*waypoint.Delay); } if (_waitTimeRangeAtPathEnd && IsFollowingPathBackwardsFromEndToStart() @@ -414,7 +402,7 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature* owner, bool relaun init.MoveTo(waypoint.X, waypoint.Y, waypoint.Z, _generatePath); - if (waypoint.Orientation.has_value() && (waypoint.Delay > 0 || _currentNode == path->Nodes.size() - 1)) + if (waypoint.Orientation.has_value() && (waypoint.Delay || _currentNode == path->Nodes.size() - 1)) init.SetFacing(*waypoint.Orientation); switch (path->MoveType) diff --git a/src/server/game/Movement/Waypoints/WaypointDefines.h b/src/server/game/Movement/Waypoints/WaypointDefines.h index ebd31ea3da7..2d897c0eb09 100644 --- a/src/server/game/Movement/Waypoints/WaypointDefines.h +++ b/src/server/game/Movement/Waypoints/WaypointDefines.h @@ -19,11 +19,12 @@ #define TRINITY_WAYPOINTDEFINES_H #include "Define.h" +#include "Duration.h" #include "EnumFlag.h" #include "Optional.h" #include <vector> -#define WAYPOINT_PATH_FLAG_FOLLOW_PATH_BACKWARDS_MINIMUM_NODES 2 +static inline constexpr std::size_t WAYPOINT_PATH_FLAG_FOLLOW_PATH_BACKWARDS_MINIMUM_NODES = 2; enum class WaypointMoveType : uint8 { @@ -45,8 +46,8 @@ DEFINE_ENUM_FLAG(WaypointPathFlags); struct WaypointNode { - WaypointNode() : Id(0), X(0.f), Y(0.f), Z(0.f), Delay(0), MoveType(WaypointMoveType::Walk) { } - WaypointNode(uint32 id, float x, float y, float z, Optional<float> orientation = { }, uint32 delay = 0) + WaypointNode() : Id(0), X(0.f), Y(0.f), Z(0.f), MoveType(WaypointMoveType::Walk) { } + WaypointNode(uint32 id, float x, float y, float z, Optional<float> orientation = { }, Optional<Milliseconds> delay = {}) { Id = id; X = x; @@ -62,7 +63,7 @@ struct WaypointNode float Y; float Z; Optional<float> Orientation; - uint32 Delay; + Optional<Milliseconds> Delay; WaypointMoveType MoveType; }; diff --git a/src/server/game/Movement/Waypoints/WaypointManager.cpp b/src/server/game/Movement/Waypoints/WaypointManager.cpp index dd21721a66c..40106ecb2e4 100644 --- a/src/server/game/Movement/Waypoints/WaypointManager.cpp +++ b/src/server/game/Movement/Waypoints/WaypointManager.cpp @@ -80,7 +80,6 @@ void WaypointMgr::_LoadPathNodes() while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded {} waypoint path nodes in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - DoPostLoadingChecks(); } void WaypointMgr::LoadPathFromDB(Field* fields) @@ -89,7 +88,7 @@ void WaypointMgr::LoadPathFromDB(Field* fields) WaypointPath& path = _pathStore[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)); @@ -128,10 +127,14 @@ void WaypointMgr::LoadPathNodesFromDB(Field* fields) if (!fields[5].IsNull()) o = fields[5].GetFloat(); + Optional<Milliseconds> delay; + if (uint32 delayMs = fields[6].GetUInt32()) + delay.emplace(delayMs); + Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(y); - path->Nodes.emplace_back(fields[1].GetUInt32(), x, y, z, o, fields[6].GetUInt32()); + path->Nodes.emplace_back(fields[1].GetUInt32(), x, y, z, o, delay); } void WaypointMgr::DoPostLoadingChecks() |
