mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Core/PacketIO: Fixed starting spline movement with 0 length segments
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace Movement
|
||||
int32 currentPathIdx() const;
|
||||
|
||||
bool onTransport;
|
||||
bool splineIsFacingOnly;
|
||||
std::string ToString() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Movement
|
||||
bool Validate(Unit* unit) const;
|
||||
|
||||
private:
|
||||
bool _checkPathBounds() const;
|
||||
bool _checkPathLengths() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user