diff --git a/sql/updates/world/4.3.4/2020_09_24_00_world.sql b/sql/updates/world/4.3.4/2020_09_24_00_world.sql new file mode 100644 index 0000000000..310480aa05 --- /dev/null +++ b/sql/updates/world/4.3.4/2020_09_24_00_world.sql @@ -0,0 +1,2 @@ +-- +ALTER TABLE `waypoint_data` ADD COLUMN `velocity` FLOAT DEFAULT 0 NOT NULL AFTER `orientation`; diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp index 12a039d629..0d0a32edeb 100644 --- a/src/server/database/Database/Implementation/WorldDatabase.cpp +++ b/src/server/database/Database/Implementation/WorldDatabase.cpp @@ -51,7 +51,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID, "UPDATE waypoint_data SET wpguid = ? WHERE id = ? and point = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_MAX_ID, "SELECT MAX(id) FROM waypoint_data", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_MAX_POINT, "SELECT MAX(point) FROM waypoint_data WHERE id = ?", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_WAYPOINT_DATA_BY_ID, "SELECT point, position_x, position_y, position_z, orientation, move_type, delay, action, action_chance FROM waypoint_data WHERE id = ? ORDER BY point", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_WAYPOINT_DATA_BY_ID, "SELECT point, position_x, position_y, position_z, orientation, velocity, move_type, delay, action, action_chance FROM waypoint_data WHERE id = ? ORDER BY point", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_BY_ID, "SELECT point, position_x, position_y, position_z FROM waypoint_data WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID, "SELECT position_x, position_y, position_z FROM waypoint_data WHERE point = 1 AND id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID, "SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE id = ? ORDER BY point DESC LIMIT 1", CONNECTION_SYNCH); diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index f1f59505e7..b2850abeb5 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -292,13 +292,13 @@ void EscortAI::MovementInform(uint32 type, uint32 id) } else if (type == WAYPOINT_MOTION_TYPE) { - ASSERT(id < _path.nodes.size(), "EscortAI::MovementInform: referenced movement id (%u) points to non-existing node in loaded path", id); - WaypointNode waypoint = _path.nodes[id]; + ASSERT(id < _path.Nodes.size(), "EscortAI::MovementInform: referenced movement id (%u) points to non-existing node in loaded path", id); + WaypointNode waypoint = _path.Nodes[id]; - TC_LOG_DEBUG("scripts", "EscortAI::MovementInform: waypoint node %u reached", waypoint.id); + TC_LOG_DEBUG("scripts", "EscortAI::MovementInform: waypoint node %u reached", waypoint.Id); // last point - if (id == _path.nodes.size() - 1) + if (id == _path.Nodes.size() - 1) { _started = false; _ended = true; @@ -320,16 +320,16 @@ void EscortAI::AddWaypoint(uint32 id, float x, float y, float z, float orientati Trinity::NormalizeMapCoord(y); WaypointNode waypoint; - waypoint.id = id; - waypoint.x = x; - waypoint.y = y; - waypoint.z = z; - waypoint.orientation = orientation; - waypoint.moveType = _running ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; - waypoint.delay = waitTime; - waypoint.eventId = 0; - waypoint.eventChance = 100; - _path.nodes.push_back(std::move(waypoint)); + waypoint.Id = id; + waypoint.X = x; + waypoint.Y = y; + waypoint.Z = z; + waypoint.Orientation = orientation; + waypoint.MoveType = _running ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; + waypoint.Delay = waitTime; + waypoint.EventId = 0; + waypoint.EventChance = 100; + _path.Nodes.push_back(std::move(waypoint)); _manualPath = true; } @@ -340,14 +340,14 @@ void EscortAI::FillPointMovementListForCreature() if (!path) return; - for (WaypointNode const& value : path->nodes) + for (WaypointNode const& value : path->Nodes) { WaypointNode node = value; - Trinity::NormalizeMapCoord(node.x); - Trinity::NormalizeMapCoord(node.y); - node.moveType = _running ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; + Trinity::NormalizeMapCoord(node.X); + Trinity::NormalizeMapCoord(node.Y); + node.MoveType = _running ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; - _path.nodes.push_back(std::move(node)); + _path.Nodes.push_back(std::move(node)); } } @@ -356,8 +356,8 @@ void EscortAI::SetRun(bool on) if (on == _running) return; - for (auto& node : _path.nodes) - node.moveType = on ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; + for (auto& node : _path.Nodes) + node.MoveType = on ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; me->SetWalk(!on); @@ -395,7 +395,7 @@ void EscortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */, if (!_manualPath && resetWaypoints) FillPointMovementListForCreature(); - if (_path.nodes.empty()) + if (_path.Nodes.empty()) { TC_LOG_ERROR("scripts", "EscortAI::Start: (script: %s, creature entry: %u) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: %u).", me->GetScriptName().c_str(), me->GetEntry(), quest ? quest->GetQuestId() : 0); return; @@ -422,7 +422,7 @@ void EscortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */, me->SetImmuneToNPC(false); } - TC_LOG_DEBUG("scripts", "EscortAI::Start: (script: %s, creature entry: %u) started with %u waypoints. ActiveAttacker = %d, Run = %d, Player = %s", me->GetScriptName().c_str(), me->GetEntry(), uint32(_path.nodes.size()), _activeAttacker, _running, _playerGUID.ToString().c_str()); + TC_LOG_DEBUG("scripts", "EscortAI::Start: (script: %s, creature entry: %u) started with %u waypoints. ActiveAttacker = %d, Run = %d, Player = %s", me->GetScriptName().c_str(), me->GetEntry(), uint32(_path.Nodes.size()), _activeAttacker, _running, _playerGUID.ToString().c_str()); // set initial speed me->SetWalk(!_running); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 15dd35dc65..07164e09a8 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -73,7 +73,7 @@ void SmartAI::StartPath(bool run/* = false*/, uint32 pathId/* = 0*/, bool repeat return; } - if (_path.nodes.empty()) + if (_path.Nodes.empty()) return; _currentWaypointNode = nodeId; @@ -101,19 +101,19 @@ bool SmartAI::LoadPath(uint32 entry) return false; WaypointPath const* path = sSmartWaypointMgr->GetPath(entry); - if (!path || path->nodes.empty()) + if (!path || path->Nodes.empty()) { GetScript()->SetPathId(0); return false; } - _path.id = path->id; - _path.nodes = path->nodes; - for (WaypointNode& waypoint : _path.nodes) + _path.Id = path->Id; + _path.Nodes = path->Nodes; + for (WaypointNode& waypoint : _path.Nodes) { - Trinity::NormalizeMapCoord(waypoint.x); - Trinity::NormalizeMapCoord(waypoint.y); - waypoint.moveType = _run ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; + Trinity::NormalizeMapCoord(waypoint.X); + Trinity::NormalizeMapCoord(waypoint.Y); + waypoint.MoveType = _run ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; } GetScript()->SetPathId(entry); @@ -197,7 +197,7 @@ void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail) void SmartAI::EndPath(bool fail) { RemoveEscortState(SMART_ESCORT_ESCORTING | SMART_ESCORT_PAUSED | SMART_ESCORT_RETURNING); - _path.nodes.clear(); + _path.Nodes.clear(); _waypointPauseTimer = 0; if (_escortNPCFlags) @@ -459,7 +459,7 @@ void SmartAI::WaypointReached(uint32 nodeId, uint32 pathId) } else if (HasEscortState(SMART_ESCORT_ESCORTING) && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) { - if (_currentWaypointNode == _path.nodes.size()) + if (_currentWaypointNode == _path.Nodes.size()) _waypointPathEnded = true; else SetRun(_run); @@ -790,8 +790,8 @@ void SmartAI::SetRun(bool run) me->SetWalk(!run); _run = run; - for (auto& node : _path.nodes) - node.moveType = run ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; + for (auto& node : _path.Nodes) + node.MoveType = run ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK; } void SmartAI::SetDisableGravity(bool fly) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 849a85d125..288123d27b 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2124,18 +2124,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (uint32 pathId : waypoints) { WaypointPath const* path = sSmartWaypointMgr->GetPath(pathId); - if (!path || path->nodes.empty()) + if (!path || path->Nodes.empty()) continue; - for (auto itr = path->nodes.begin(); itr != path->nodes.end(); ++itr) + for (auto itr = path->Nodes.begin(); itr != path->Nodes.end(); ++itr) { WaypointNode const waypoint = *itr; - float distamceToThisNode = creature->GetDistance(waypoint.x, waypoint.y, waypoint.z); + float distamceToThisNode = creature->GetDistance(waypoint.X, waypoint.Y, waypoint.Z); if (distamceToThisNode < distanceToClosest) { distanceToClosest = distamceToThisNode; closest.first = pathId; - closest.second = waypoint.id; + closest.second = waypoint.Id; } } } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index d8eb58a16c..1d32035e79 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -81,8 +81,8 @@ void SmartWaypointMgr::LoadFromDB() ++lastId; WaypointPath& path = _waypointStore[entry]; - path.id = entry; - path.nodes.emplace_back(id, x, y, z); + path.Id = entry; + path.Nodes.emplace_back(id, x, y, z); lastEntry = entry; ++total; @@ -1378,7 +1378,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_WP_START: { WaypointPath const* path = sSmartWaypointMgr->GetPath(e.action.wpStart.pathID); - if (!path || path->nodes.empty()) + if (!path || path->Nodes.empty()) { TC_LOG_ERROR("sql.sql", "SmartAIMgr: Creature %d Event %u Action %u uses non-existent WaypointPath id %u, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.wpStart.pathID); return false; diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 68a3091b95..5d509b0ffb 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -711,7 +711,7 @@ void MotionMaster::MovePath(uint32 pathId, bool repeatable) void MotionMaster::MovePath(WaypointPath& path, bool repeatable) { - TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePath: '%s', starts moving over path Id: %u (repeatable: %s)", _owner->GetGUID().ToString().c_str(), path.id, repeatable ? "YES" : "NO"); + TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePath: '%s', starts moving over path Id: %u (repeatable: %s)", _owner->GetGUID().ToString().c_str(), path.Id, repeatable ? "YES" : "NO"); Mutate(new WaypointMovementGenerator(path, repeatable), MOTION_SLOT_IDLE); } diff --git a/src/server/game/Movement/MovementGenerators/CyclicMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/CyclicMovementGenerator.cpp index 24b3d7e428..a25831a86e 100644 --- a/src/server/game/Movement/MovementGenerators/CyclicMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/CyclicMovementGenerator.cpp @@ -74,7 +74,7 @@ bool CyclicMovementGenerator::DoUpdate(Creature* creature, uint32 diff if (!creature || !creature->IsAlive()) return true; - if (!_path || _path->nodes.empty()) + if (!_path || _path->Nodes.empty()) return true; if (!CanMove(creature)) @@ -99,7 +99,7 @@ bool CyclicMovementGenerator::DoUpdate(Creature* creature, uint32 diff void CyclicMovementGenerator::StartMovement(Creature* creature) { - if (!creature || !creature->IsAlive() || !CanMove(creature) || !_path || _path->nodes.empty()) + if (!creature || !creature->IsAlive() || !CanMove(creature) || !_path || _path->Nodes.empty()) return; if (!CanMove(creature) || (creature->IsFormationLeader() && !creature->IsFormationLeaderMoveAllowed())) // if cannot move OR cannot move because of formation @@ -115,11 +115,11 @@ void CyclicMovementGenerator::StartMovement(Creature* creature) Movement::MoveSplineInit init(creature); Movement::PointsArray path; - path.reserve(_path->nodes.size() + 1); + path.reserve(_path->Nodes.size() + 1); path.push_back(PositionToVector3(creature->GetPosition())); - std::transform(_path->nodes.begin(), _path->nodes.end(), std::back_inserter(path), [](WaypointNode const& node) + std::transform(_path->Nodes.begin(), _path->Nodes.end(), std::back_inserter(path), [](WaypointNode const& node) { - return G3D::Vector3(node.x, node.y, node.z); + return G3D::Vector3(node.X, node.Y, node.Z); }); if (flying || (_enforceFlight.is_initialized() && *_enforceFlight)) @@ -130,6 +130,12 @@ void CyclicMovementGenerator::StartMovement(Creature* creature) if (_velocity.is_initialized()) init.SetVelocity(*_velocity); + else + { + float velocity = _path->Nodes.front().Velocity; + if (velocity > 0.f) + init.SetVelocity(velocity); + } if (_enforceWalk.is_initialized()) init.SetWalk(*_enforceWalk); diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 5c5ff9449b..a5b1a67f86 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -60,7 +60,7 @@ void WaypointMovementGenerator::DoInitialize(Creature* creature) // inform AI if (creature->IsAIEnabled) - creature->AI()->WaypointPathStarted(_path->id); + creature->AI()->WaypointPathStarted(_path->Id); } void WaypointMovementGenerator::DoFinalize(Creature* creature) @@ -83,38 +83,38 @@ void WaypointMovementGenerator::DoReset(Creature* creature) void WaypointMovementGenerator::OnArrived(Creature* creature) { - if (!_path || _path->nodes.empty()) + if (!_path || _path->Nodes.empty()) return; - 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.at(_currentNode); - if (waypoint.delay) + 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.at(_currentNode); + if (waypoint.Delay) { creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE); - _nextMoveTime.Reset(waypoint.delay); + _nextMoveTime.Reset(waypoint.Delay); } - if (waypoint.eventId && urand(0, 99) < waypoint.eventChance) + if (waypoint.EventId && urand(0, 99) < waypoint.EventChance) { - TC_LOG_DEBUG("maps.script", "Creature movement start script %u at point %u for %s.", waypoint.eventId, _currentNode, creature->GetGUID().ToString().c_str()); + TC_LOG_DEBUG("maps.script", "Creature movement start script %u at point %u for %s.", waypoint.EventId, _currentNode, creature->GetGUID().ToString().c_str()); creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE); - creature->GetMap()->ScriptsStart(sWaypointScripts, waypoint.eventId, creature, nullptr); + creature->GetMap()->ScriptsStart(sWaypointScripts, waypoint.EventId, creature, nullptr); } // inform AI if (creature->IsAIEnabled) { creature->AI()->MovementInform(WAYPOINT_MOTION_TYPE, _currentNode); - creature->AI()->WaypointReached(waypoint.id, _path->id); + creature->AI()->WaypointReached(waypoint.Id, _path->Id); } - creature->UpdateCurrentWaypointInfo(waypoint.id, _path->id); + creature->UpdateCurrentWaypointInfo(waypoint.Id, _path->Id); } void WaypointMovementGenerator::StartMove(Creature* creature, bool relaunch/* = false*/) { // sanity checks - if (!creature || !creature->IsAlive() || _done || !_path || _path->nodes.empty() || (relaunch && _isArrivalDone)) + if (!creature || !creature->IsAlive() || _done || !_path || _path->Nodes.empty() || (relaunch && _isArrivalDone)) return; if (!relaunch) // on relaunch, can avoid this since its only called on valid movement @@ -130,14 +130,14 @@ void WaypointMovementGenerator::StartMove(Creature* creature, bool rel if (_isArrivalDone) { - ASSERT(_currentNode < _path->nodes.size(), "WaypointMovementGenerator::StartMove: tried to reference a node id (%u) which is not included in path (%u)", _currentNode, _path->id); - WaypointNode const &waypoint = _path->nodes.at(_currentNode); + ASSERT(_currentNode < _path->Nodes.size(), "WaypointMovementGenerator::StartMove: tried to reference a node id (%u) which is not included in path (%u)", _currentNode, _path->Id); + WaypointNode const &waypoint = _path->Nodes.at(_currentNode); - if ((_currentNode == _path->nodes.size() - 1) && !_repeating) // If that's our last waypoint + if ((_currentNode == _path->Nodes.size() - 1) && !_repeating) // If that's our last waypoint { - float x = waypoint.x; - float y = waypoint.y; - float z = waypoint.z; + float x = waypoint.X; + float y = waypoint.Y; + float z = waypoint.Z; float o = creature->GetOrientation(); if (!transportPath) @@ -160,19 +160,19 @@ void WaypointMovementGenerator::StartMove(Creature* creature, bool rel // inform AI if (creature->IsAIEnabled) - creature->AI()->WaypointPathEnded(waypoint.id, _path->id); + creature->AI()->WaypointPathEnded(waypoint.Id, _path->Id); return; } - _currentNode = (_currentNode + 1) % _path->nodes.size(); + _currentNode = (_currentNode + 1) % _path->Nodes.size(); // inform AI if (creature->IsAIEnabled) - creature->AI()->WaypointStarted(waypoint.id, _path->id); + creature->AI()->WaypointStarted(waypoint.Id, _path->Id); } - ASSERT(_currentNode < _path->nodes.size(), "WaypointMovementGenerator::StartMove: tried to reference a node id (%u) which is not included in path (%u)", _currentNode, _path->id); - WaypointNode const &waypoint = _path->nodes[_currentNode]; + ASSERT(_currentNode < _path->Nodes.size(), "WaypointMovementGenerator::StartMove: tried to reference a node id (%u) which is not included in path (%u)", _currentNode, _path->Id); + WaypointNode const &waypoint = _path->Nodes[_currentNode]; _isArrivalDone = false; _recalculateSpeed = false; @@ -187,13 +187,13 @@ void WaypointMovementGenerator::StartMove(Creature* creature, bool rel //! Do not use formationDest here, MoveTo requires transport offsets due to DisableTransportPathTransformations() call //! but formationDest contains global coordinates - init.MoveTo(waypoint.x, waypoint.y, waypoint.z); + init.MoveTo(waypoint.X, waypoint.Y, waypoint.Z); //! Accepts angles such as 0.00001 and -0.00001, 0 must be ignored, default value in waypoint table - if (waypoint.orientation && waypoint.delay) - init.SetFacing(waypoint.orientation); + if (waypoint.Orientation && waypoint.Delay) + init.SetFacing(waypoint.Orientation); - switch (waypoint.moveType) + switch (waypoint.MoveType) { case WAYPOINT_MOVE_TYPE_LAND: init.SetAnimation(AnimationTier::Ground); @@ -211,6 +211,9 @@ void WaypointMovementGenerator::StartMove(Creature* creature, bool rel break; } + if (waypoint.Velocity > 0.f) + init.SetVelocity(waypoint.Velocity); + init.Launch(); // inform formation @@ -224,7 +227,7 @@ bool WaypointMovementGenerator::DoUpdate(Creature* creature, uint32 di if (!creature || !creature->IsAlive()) return true; - if (_done || !_path || _path->nodes.empty()) + if (_done || !_path || _path->Nodes.empty()) return true; if (_stalled || creature->HasUnitState(UNIT_STATE_NOT_MOVE) || creature->IsMovementPreventedByCasting()) @@ -279,15 +282,15 @@ void WaypointMovementGenerator::MovementInform(Creature* creature) bool WaypointMovementGenerator::GetResetPos(Creature*, float& x, float& y, float& z) { // prevent a crash at empty waypoint path. - if (!_path || _path->nodes.empty()) + if (!_path || _path->Nodes.empty()) return false; - ASSERT(_currentNode < _path->nodes.size(), "WaypointMovementGenerator::GetResetPos: tried to reference a node id (%u) which is not included in path (%u)", _currentNode, _path->id); - WaypointNode const &waypoint = _path->nodes.at(_currentNode); + ASSERT(_currentNode < _path->Nodes.size(), "WaypointMovementGenerator::GetResetPos: tried to reference a node id (%u) which is not included in path (%u)", _currentNode, _path->Id); + WaypointNode const &waypoint = _path->Nodes.at(_currentNode); - x = waypoint.x; - y = waypoint.y; - z = waypoint.z; + x = waypoint.X; + y = waypoint.Y; + z = waypoint.Z; return true; } diff --git a/src/server/game/Movement/Waypoints/WaypointDefines.h b/src/server/game/Movement/Waypoints/WaypointDefines.h index 3e6be268eb..0488cbfc4c 100644 --- a/src/server/game/Movement/Waypoints/WaypointDefines.h +++ b/src/server/game/Movement/Waypoints/WaypointDefines.h @@ -33,39 +33,35 @@ enum WaypointMoveType struct WaypointNode { - WaypointNode() : id(0), x(0.f), y(0.f), z(0.f), orientation(0.f), delay(0), eventId(0), moveType(WAYPOINT_MOVE_TYPE_RUN), eventChance(0) { } - WaypointNode(uint32 _id, float _x, float _y, float _z, float _orientation = 0.f, uint32 _delay = 0) + WaypointNode() : Id(0), X(0.f), Y(0.f), Z(0.f), Orientation(0.f), Velocity(0.f), Delay(0), EventId(0), MoveType(WAYPOINT_MOVE_TYPE_RUN), EventChance(0) { } + WaypointNode(uint32 id, float x, float y, float z, float orientation = 0.f, float velocity = 0.f, uint32 delay = 0) : + Id(id), X(x), Y(y), Z(z), Orientation(orientation), Velocity(velocity), Delay(delay) { - id = _id; - x = _x; - y = _y; - z = _z; - orientation = _orientation; - delay = _delay; - eventId = 0; - moveType = WAYPOINT_MOVE_TYPE_WALK; - eventChance = 100; + EventId = 0; + MoveType = WAYPOINT_MOVE_TYPE_WALK; + EventChance = 100; } - uint32 id; - float x, y, z, orientation; - uint32 delay; - uint32 eventId; - uint32 moveType; - uint8 eventChance; + uint32 Id; + float X, Y, Z, Orientation; + float Velocity; + uint32 Delay; + uint32 EventId; + uint32 MoveType; + uint8 EventChance; }; struct WaypointPath { - WaypointPath() : id(0) { } + WaypointPath() : Id(0) { } WaypointPath(uint32 _id, std::vector&& _nodes) { - id = _id; - nodes = _nodes; + Id = _id; + Nodes = _nodes; } - std::vector nodes; - uint32 id; + std::vector Nodes; + uint32 Id; }; #endif diff --git a/src/server/game/Movement/Waypoints/WaypointManager.cpp b/src/server/game/Movement/Waypoints/WaypointManager.cpp index c38c8ae531..21c3ee462f 100644 --- a/src/server/game/Movement/Waypoints/WaypointManager.cpp +++ b/src/server/game/Movement/Waypoints/WaypointManager.cpp @@ -25,8 +25,8 @@ void WaypointMgr::Load() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 4 5 6 7 8 9 - QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, orientation, move_type, delay, action, action_chance FROM waypoint_data ORDER BY id, point"); + // 0 1 2 3 4 5 6 7 8 9 10 + QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, orientation, velocity, move_type, delay, action, action_chance FROM waypoint_data ORDER BY id, point"); if (!result) { @@ -44,31 +44,33 @@ void WaypointMgr::Load() float y = fields[3].GetFloat(); float z = fields[4].GetFloat(); float o = fields[5].GetFloat(); + float velocity = fields[6].GetFloat(); Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(y); WaypointNode waypoint; - waypoint.id = fields[1].GetUInt32(); - waypoint.x = x; - waypoint.y = y; - waypoint.z = z; - waypoint.orientation = o; - waypoint.moveType = fields[6].GetUInt32(); + waypoint.Id = fields[1].GetUInt32(); + waypoint.X = x; + waypoint.Y = y; + waypoint.Z = z; + waypoint.Orientation = o; + waypoint.Velocity = velocity; + waypoint.MoveType = fields[7].GetUInt32(); - if (waypoint.moveType >= WAYPOINT_MOVE_TYPE_MAX) + if (waypoint.MoveType >= WAYPOINT_MOVE_TYPE_MAX) { - TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", waypoint.id); + TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", waypoint.Id); continue; } - waypoint.delay = fields[7].GetUInt32(); - waypoint.eventId = fields[8].GetUInt32(); - waypoint.eventChance = fields[9].GetInt16(); + waypoint.Delay = fields[8].GetUInt32(); + waypoint.EventId = fields[9].GetUInt32(); + waypoint.EventChance = fields[10].GetInt16(); WaypointPath& path = _waypointStore[pathId]; - path.id = pathId; - path.nodes.push_back(std::move(waypoint)); + path.Id = pathId; + path.Nodes.push_back(std::move(waypoint)); ++count; } while (result->NextRow()); @@ -105,27 +107,29 @@ void WaypointMgr::ReloadPath(uint32 id) float y = fields[2].GetFloat(); float z = fields[3].GetFloat(); float o = fields[4].GetFloat(); + float velocity = fields[5].GetFloat(); Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(y); WaypointNode waypoint; - waypoint.id = fields[0].GetUInt32(); - waypoint.x = x; - waypoint.y = y; - waypoint.z = z; - waypoint.orientation = o; - waypoint.moveType = fields[5].GetUInt32(); + waypoint.Id = fields[0].GetUInt32(); + waypoint.X = x; + waypoint.Y = y; + waypoint.Z = z; + waypoint.Orientation = o; + waypoint.Velocity = velocity; + waypoint.MoveType = fields[6].GetUInt32(); - if (waypoint.moveType >= WAYPOINT_MOVE_TYPE_MAX) + if (waypoint.MoveType >= WAYPOINT_MOVE_TYPE_MAX) { - TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", waypoint.id); + TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", waypoint.Id); continue; } - waypoint.delay = fields[6].GetUInt32(); - waypoint.eventId = fields[7].GetUInt32(); - waypoint.eventChance = fields[8].GetUInt8(); + waypoint.Delay = fields[7].GetUInt32(); + waypoint.EventId = fields[8].GetUInt32(); + waypoint.EventChance = fields[9].GetUInt8(); values.push_back(std::move(waypoint)); } diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp index 33cffb2ef7..413cb5fc34 100644 --- a/src/server/game/Scripting/ScriptSystem.cpp +++ b/src/server/game/Scripting/ScriptSystem.cpp @@ -79,8 +79,8 @@ void SystemMgr::LoadScriptWaypoints() TC_LOG_ERROR("sql.sql", "SystemMgr: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", entry); WaypointPath& path = _waypointStore[entry]; - path.id = entry; - path.nodes.emplace_back(id, x, y, z, 0.f, waitTime); + path.Id = entry; + path.Nodes.emplace_back(id, x, y, z, 0.f, 0.f, waitTime); ++count; } while (result->NextRow());