aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-06-02 18:55:42 +0200
committerShauren <shauren.trinity@gmail.com>2016-06-02 18:55:42 +0200
commitfa1c4991504d22d46bea800cd99a7ec12138e065 (patch)
tree1f78ebc9500907709abb1832653dd8fc1ac07629 /src
parentcc03d7ca24f15b900269a87d07e2d1b89f708aad (diff)
Core/PacketIO: Fixed starting spline movement with 0 length segments
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp2
-rw-r--r--src/server/game/Movement/Spline/MoveSpline.cpp29
-rw-r--r--src/server/game/Movement/Spline/MoveSpline.h1
-rw-r--r--src/server/game/Movement/Spline/MoveSplineInitArgs.h2
-rw-r--r--src/server/game/Server/Packets/MovementPackets.cpp6
5 files changed, 13 insertions, 27 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 60035178292..8f0c1ff8b15 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1826,7 +1826,7 @@ void ObjectMgr::LoadCreatures()
}
else if (data.movementType == RANDOM_MOTION_TYPE)
{
- if (data.spawndist == 0.0f)
+ if (G3D::fuzzyEq(data.spawndist, 0.0f))
{
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD " Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).", guid, data.id);
data.movementType = IDLE_MOTION_TYPE;
diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp
index c0faf1867b7..c58cc3d9e55 100644
--- a/src/server/game/Movement/Spline/MoveSpline.cpp
+++ b/src/server/game/Movement/Spline/MoveSpline.cpp
@@ -165,6 +165,7 @@ void MoveSpline::Initialize(MoveSplineInitArgs const& args)
time_passed = 0;
vertical_acceleration = 0.f;
effect_start_time = 0;
+ splineIsFacingOnly = args.path.size() == 2 && args.flags & MoveSplineFlag::Mask_Final_Facing && ((args.path[1] - args.path[0]).length() < 0.1f);
// Check if its a stop spline
if (args.flags.done)
@@ -190,7 +191,7 @@ void MoveSpline::Initialize(MoveSplineInitArgs const& args)
MoveSpline::MoveSpline() : m_Id(0), time_passed(0),
vertical_acceleration(0.f), initialOrientation(0.f), effect_start_time(0), point_Idx(0), point_Idx_offset(0),
- onTransport(false)
+ onTransport(false), splineIsFacingOnly(false)
{
splineflags.done = true;
}
@@ -208,32 +209,18 @@ bool MoveSplineInitArgs::Validate(Unit* unit) const
CHECK(path.size() > 1);
CHECK(velocity > 0.1f);
CHECK(time_perc >= 0.f && time_perc <= 1.f);
- //CHECK(_checkPathBounds());
+ CHECK(_checkPathLengths());
return true;
#undef CHECK
}
-// MONSTER_MOVE packet format limitation for not CatmullRom movement:
-// each vertex offset packed into 11 bytes
-bool MoveSplineInitArgs::_checkPathBounds() const
+// check path lengths - why are we even starting such short movement?
+bool MoveSplineInitArgs::_checkPathLengths() const
{
- if (!(flags & MoveSplineFlag::Catmullrom) && path.size() > 2)
- {
- enum{
- MAX_OFFSET = (1 << 11) / 2
- };
- Vector3 middle = (path.front()+path.back()) / 2;
- Vector3 offset;
- for (uint32 i = 1; i < path.size()-1; ++i)
- {
- offset = path[i] - middle;
- if (std::fabs(offset.x) >= MAX_OFFSET || std::fabs(offset.y) >= MAX_OFFSET || std::fabs(offset.z) >= MAX_OFFSET)
- {
- TC_LOG_ERROR("misc", "MoveSplineInitArgs::_checkPathBounds check failed");
+ if (path.size() > 2 || !(flags & MoveSplineFlag::Mask_Final_Facing))
+ for (uint32 i = 0; i < path.size() - 1; ++i)
+ if ((path[i + 1] - path[i]).length() < 0.1f)
return false;
- }
- }
- }
return true;
}
diff --git a/src/server/game/Movement/Spline/MoveSpline.h b/src/server/game/Movement/Spline/MoveSpline.h
index 24a6d85fcbc..f4f1e07cbe0 100644
--- a/src/server/game/Movement/Spline/MoveSpline.h
+++ b/src/server/game/Movement/Spline/MoveSpline.h
@@ -134,6 +134,7 @@ namespace Movement
int32 currentPathIdx() const;
bool onTransport;
+ bool splineIsFacingOnly;
std::string ToString() const;
};
}
diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h
index e6e1198aa07..0b1851f2a1a 100644
--- a/src/server/game/Movement/Spline/MoveSplineInitArgs.h
+++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h
@@ -63,7 +63,7 @@ namespace Movement
bool Validate(Unit* unit) const;
private:
- bool _checkPathBounds() const;
+ bool _checkPathLengths() const;
};
}
diff --git a/src/server/game/Server/Packets/MovementPackets.cpp b/src/server/game/Server/Packets/MovementPackets.cpp
index 0270526576b..f0eecb3a16d 100644
--- a/src/server/game/Server/Packets/MovementPackets.cpp
+++ b/src/server/game/Server/Packets/MovementPackets.cpp
@@ -277,10 +277,10 @@ void WorldPackets::Movement::CommonMovement::WriteCreateObjectSplineDataBlock(::
else
data << G3D::Vector3::zero();
- data.WriteBit(!moveSpline.Finalized());
+ bool hasSplineMove = data.WriteBit(!moveSpline.Finalized() && !moveSpline.splineIsFacingOnly);
data.FlushBits();
- if (!moveSpline.Finalized()) // MovementSplineMove
+ if (hasSplineMove) // MovementSplineMove
{
::Movement::MoveSplineFlag const& splineFlags = moveSpline.splineflags;
@@ -348,8 +348,6 @@ void WorldPackets::Movement::CommonMovement::WriteCreateObjectSplineDataBlock(::
// data << uint32();
//}
}
- else
- data.FlushBits();
}
void WorldPackets::Movement::MonsterMove::InitializeSplineData(::Movement::MoveSpline const& moveSpline)