Core/Movement: allow waypoints to have orientation values of 0

This commit is contained in:
Ovahlord
2021-02-05 10:38:05 +01:00
parent ebc037e1eb
commit c20838ceaa
4 changed files with 20 additions and 9 deletions

View File

@@ -0,0 +1,2 @@
ALTER TABLE `waypoint_data` CHANGE `orientation` `orientation` FLOAT DEFAULT NULL NULL;
UPDATE `waypoint_data` SET `orientation`= NULL WHERE `orientation`= 0;

View File

@@ -214,9 +214,8 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature* creature, bool rel
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 > 0)
init.SetFacing(waypoint.Orientation);
if (waypoint.Orientation.is_initialized() && waypoint.Delay > 0)
init.SetFacing(*waypoint.Orientation);
switch (waypoint.MoveType)
{

View File

@@ -20,6 +20,7 @@
#include "Define.h"
#include "G3D/Vector3.h"
#include "Optional.h"
#include <vector>
enum WaypointMoveType
@@ -34,7 +35,7 @@ enum WaypointMoveType
struct WaypointNode
{
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() : Id(0), X(0.f), Y(0.f), Z(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)
{
@@ -44,7 +45,8 @@ struct WaypointNode
}
uint32 Id;
float X, Y, Z, Orientation;
float X, Y, Z;
Optional<float> Orientation;
float Velocity;
int32 Delay;
uint32 EventId;

View File

@@ -43,7 +43,10 @@ void WaypointMgr::Load()
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
float z = fields[4].GetFloat();
float o = fields[5].GetFloat();
Optional<float> o;
if (!fields[5].IsNull())
o = fields[5].GetFloat();
float velocity = fields[6].GetFloat();
Trinity::NormalizeMapCoord(x);
@@ -54,7 +57,8 @@ void WaypointMgr::Load()
waypoint.X = x;
waypoint.Y = y;
waypoint.Z = z;
waypoint.Orientation = o;
if (o.is_initialized())
waypoint.Orientation = o;
waypoint.Velocity = velocity;
waypoint.MoveType = fields[7].GetUInt32();
@@ -163,7 +167,10 @@ void WaypointMgr::ReloadPath(uint32 id)
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
float o = fields[4].GetFloat();
Optional<float> o;
if (!fields[4].IsNull())
o = fields[4].GetFloat();
float velocity = fields[5].GetFloat();
Trinity::NormalizeMapCoord(x);
@@ -174,7 +181,8 @@ void WaypointMgr::ReloadPath(uint32 id)
waypoint.X = x;
waypoint.Y = y;
waypoint.Z = z;
waypoint.Orientation = o;
if (o.is_initialized())
waypoint.Orientation = o;
waypoint.Velocity = velocity;
waypoint.MoveType = fields[6].GetUInt32();