*Update movement enums - thanks to Zor for info.
*Add functions for position data streaming. --HG-- branch : trunk
This commit is contained in:
@@ -301,7 +301,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const
|
||||
|
||||
FlightPathMovementGenerator *fmg = (FlightPathMovementGenerator*)(player->GetMotionMaster()->top());
|
||||
|
||||
uint32 flags3 = MOVEFLAG_GLIDE;
|
||||
uint32 flags3 = SPLINEFLAG_GLIDE;
|
||||
|
||||
*data << uint32(flags3); // splines flag?
|
||||
|
||||
@@ -1144,6 +1144,37 @@ bool Position::HasInLine(const Unit * const target, float distance, float width)
|
||||
return abs(sin(angle)) * GetExactDist2d(target->GetPositionX(), target->GetPositionY()) < width;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer)
|
||||
{
|
||||
float x, y, z, o;
|
||||
buf >> x >> y >> z >> o;
|
||||
streamer.m_pos->Relocate(x, y, z, o);
|
||||
return buf;
|
||||
}
|
||||
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer)
|
||||
{
|
||||
float x, y, z;
|
||||
streamer.m_pos->GetPosition(x, y, z);
|
||||
buf << x << y << z;
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer)
|
||||
{
|
||||
float x, y, z;
|
||||
buf >> x >> y >> z;
|
||||
streamer.m_pos->Relocate(x, y, z);
|
||||
return buf;
|
||||
}
|
||||
|
||||
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer)
|
||||
{
|
||||
float x, y, z, o;
|
||||
streamer.m_pos->GetPosition(x, y, z, o);
|
||||
buf << x << y << z << o;
|
||||
return buf;
|
||||
}
|
||||
|
||||
WorldObject::WorldObject()
|
||||
: WorldLocation(), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_currMap(NULL)
|
||||
, m_zoneScript(NULL)
|
||||
@@ -1241,12 +1272,12 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
|
||||
|
||||
if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUIDLow() == m_transport->GetGUIDLow())
|
||||
{
|
||||
float dtx = m_movementInfo.t_x - obj->m_movementInfo.t_x;
|
||||
float dty = m_movementInfo.t_y - obj->m_movementInfo.t_y;
|
||||
float dtx = m_movementInfo.t_pos.m_positionX - obj->m_movementInfo.t_pos.m_positionX;
|
||||
float dty = m_movementInfo.t_pos.m_positionY - obj->m_movementInfo.t_pos.m_positionY;
|
||||
float disttsq = dtx * dtx + dty * dty;
|
||||
if (is3D)
|
||||
{
|
||||
float dtz = m_movementInfo.t_z - obj->m_movementInfo.t_z;
|
||||
float dtz = m_movementInfo.t_pos.m_positionZ - obj->m_movementInfo.t_pos.m_positionZ;
|
||||
disttsq += dtz * dtz;
|
||||
}
|
||||
return disttsq < (maxdist * maxdist);
|
||||
|
||||
@@ -117,44 +117,9 @@ class ZoneScript;
|
||||
class Unit;
|
||||
class Transport;
|
||||
|
||||
|
||||
typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
|
||||
|
||||
struct MovementInfo
|
||||
{
|
||||
// common
|
||||
uint64 guid;
|
||||
uint32 flags;
|
||||
uint16 unk1;
|
||||
uint32 time;
|
||||
float x, y, z, o;
|
||||
// transport
|
||||
uint64 t_guid;
|
||||
float t_x, t_y, t_z, t_o;
|
||||
uint32 t_time;
|
||||
int8 t_seat;
|
||||
// swimming and unknown
|
||||
float s_pitch;
|
||||
// last fall time
|
||||
uint32 fallTime;
|
||||
// jumping
|
||||
float j_zspeed, j_sinAngle, j_cosAngle, j_xyspeed;
|
||||
// spline
|
||||
float u_unk1;
|
||||
|
||||
MovementInfo()
|
||||
{
|
||||
flags = 0;
|
||||
time = t_time = fallTime = 0;
|
||||
unk1 = 0;
|
||||
x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_zspeed = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f;
|
||||
t_guid = 0;
|
||||
}
|
||||
|
||||
uint32 GetMovementFlags() { return flags; }
|
||||
void AddMovementFlag(uint32 flag) { flags |= flag; }
|
||||
bool HasMovementFlag(uint32 flag) const { return flags & flag; }
|
||||
};
|
||||
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
@@ -405,6 +370,18 @@ class Object
|
||||
|
||||
struct Position
|
||||
{
|
||||
struct PositionXYZStreamer
|
||||
{
|
||||
explicit PositionXYZStreamer(Position& pos) : m_pos(&pos) {}
|
||||
Position* m_pos;
|
||||
};
|
||||
|
||||
struct PositionXYZOStreamer
|
||||
{
|
||||
explicit PositionXYZOStreamer(Position& pos) : m_pos(&pos) {}
|
||||
Position* m_pos;
|
||||
};
|
||||
|
||||
float m_positionX;
|
||||
float m_positionY;
|
||||
float m_positionZ;
|
||||
@@ -440,6 +417,15 @@ struct Position
|
||||
pos->Relocate(m_positionX, m_positionY, m_positionZ, m_orientation);
|
||||
}
|
||||
|
||||
Position::PositionXYZStreamer PositionXYZStream()
|
||||
{
|
||||
return Position::PositionXYZStreamer(*this);
|
||||
}
|
||||
Position::PositionXYZOStreamer PositionXYZOStream()
|
||||
{
|
||||
return Position::PositionXYZOStreamer(*this);
|
||||
}
|
||||
|
||||
bool IsPositionValid() const;
|
||||
|
||||
float GetExactDist2dSq(float x, float y) const
|
||||
@@ -477,6 +463,50 @@ struct Position
|
||||
bool HasInArc(float arcangle, const Position *pos) const;
|
||||
bool HasInLine(const Unit *target, float distance, float width) const;
|
||||
};
|
||||
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer);
|
||||
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer);
|
||||
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer);
|
||||
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer);
|
||||
|
||||
struct MovementInfo
|
||||
{
|
||||
// common
|
||||
uint64 guid;
|
||||
uint32 flags;
|
||||
uint16 flags2;
|
||||
Position pos;
|
||||
uint32 time;
|
||||
// transport
|
||||
uint64 t_guid;
|
||||
Position t_pos;
|
||||
uint32 t_time;
|
||||
uint32 t_time2;
|
||||
int8 t_seat;
|
||||
// swimming/flying
|
||||
float pitch;
|
||||
// falling
|
||||
uint32 fallTime;
|
||||
// jumping
|
||||
float j_zspeed, j_sinAngle, j_cosAngle, j_xyspeed;
|
||||
// spline
|
||||
float splineElevation;
|
||||
|
||||
MovementInfo()
|
||||
{
|
||||
guid = 0;
|
||||
flags = 0;
|
||||
flags2 = 0;
|
||||
time = t_time = fallTime = 0;
|
||||
splineElevation = 0;
|
||||
pitch = j_zspeed = j_sinAngle = j_cosAngle = j_xyspeed = 0.0f;
|
||||
t_guid = 0;
|
||||
t_seat = -1;
|
||||
}
|
||||
|
||||
uint32 GetMovementFlags() { return flags; }
|
||||
void AddMovementFlag(uint32 flag) { flags |= flag; }
|
||||
bool HasMovementFlag(uint32 flag) const { return flags & flag; }
|
||||
};
|
||||
|
||||
#define MAPID_INVALID 0xFFFFFFFF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user