diff --git a/src/game/MapManager.h b/src/game/MapManager.h index 2fede2d1d..3aa383945 100644 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -114,21 +114,6 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::SingletonGetSpeed(MOVE_TURN_RATE)); if (hasOrientation) - *data << float(unit->GetOrientation()); + *data << float(NormalizeOrientation(unit->GetOrientation())); *data << float(unit->GetSpeed(MOVE_RUN)); @@ -460,7 +460,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const if (updateFlags & UPDATEFLAG_VEHICLE) { - *data << float(((WorldObject*)this)->GetOrientation()); + *data << float(NormalizeOrientation(((WorldObject*)this)->GetOrientation())); *data << uint32(((Unit*)this)->GetVehicleInfo()->GetEntry()->m_ID); // vehicle id } @@ -513,7 +513,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const if (updateFlags & UPDATEFLAG_HAS_POSITION) { - *data << float(((WorldObject*)this)->GetOrientation()); + *data << float(NormalizeOrientation(((WorldObject*)this)->GetOrientation())); *data << float(((WorldObject*)this)->GetPositionX()); *data << float(((WorldObject*)this)->GetPositionY()); *data << float(((WorldObject*)this)->GetPositionZ()); @@ -1364,13 +1364,13 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const float arc = arcangle; // move arc to range 0.. 2*pi - arc = MapManager::NormalizeOrientation(arc); + arc = NormalizeOrientation(arc); float angle = GetAngle(obj); angle -= m_position.o; // move angle to range -pi ... +pi - angle = MapManager::NormalizeOrientation(angle); + angle = NormalizeOrientation(angle); if (angle > M_PI_F) angle -= 2.0f * M_PI_F; @@ -1736,7 +1736,7 @@ namespace MaNGOS { public: NearUsedPosDo(WorldObject const& obj, WorldObject const* searcher, float absAngle, ObjectPosSelector& selector) - : i_object(obj), i_searcher(searcher), i_absAngle(MapManager::NormalizeOrientation(absAngle)), i_selector(selector) {} + : i_object(obj), i_searcher(searcher), i_absAngle(NormalizeOrientation(absAngle)), i_selector(selector) {} void operator()(Corpse*) const {} void operator()(DynamicObject*) const {} diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp index 009c3d974..d57e57450 100644 --- a/src/game/Opcodes.cpp +++ b/src/game/Opcodes.cpp @@ -284,7 +284,7 @@ void InitializeOpcodes() OPCODE(CMSG_MOVE_SET_FACING, STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleMovementOpcodes ); OPCODE(CMSG_MOVE_SET_PITCH, STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleMovementOpcodes ); //OPCODE(MSG_MOVE_WORLDPORT_ACK, STATUS_TRANSFER, PROCESS_THREADUNSAFE, &WorldSession::HandleMoveWorldportAckOpcode ); - //OPCODE(SMSG_MONSTER_MOVE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); + OPCODE(SMSG_MONSTER_MOVE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); //OPCODE(SMSG_MOVE_WATER_WALK, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); //OPCODE(SMSG_MOVE_LAND_WALK, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); //OPCODE(CMSG_MOVE_CHARM_PORT_CHEAT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL ); @@ -389,7 +389,7 @@ void InitializeOpcodes() //OPCODE(MSG_CHANNEL_UPDATE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL ); //OPCODE(CMSG_CANCEL_CHANNELLING, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleCancelChanneling ); //OPCODE(SMSG_AI_REACTION, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); - //OPCODE(CMSG_SET_SELECTION, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleSetSelectionOpcode ); + OPCODE(CMSG_SET_SELECTION, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleSetSelectionOpcode ); //OPCODE(CMSG_DELETEEQUIPMENT_SET, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleEquipmentSetDeleteOpcode ); //OPCODE(CMSG_INSTANCE_LOCK_RESPONSE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL ); //OPCODE(CMSG_DEBUG_PASSIVE_AURA, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL ); diff --git a/src/game/Opcodes.h b/src/game/Opcodes.h index ca4f77624..eaff239e7 100644 --- a/src/game/Opcodes.h +++ b/src/game/Opcodes.h @@ -374,7 +374,7 @@ enum Opcodes MSG_CHANNEL_UPDATE = 0x113B, CMSG_CANCEL_CHANNELLING = 0x113C, SMSG_AI_REACTION = 0x113D, - CMSG_SET_SELECTION = 0x113E, + CMSG_SET_SELECTION = 0x0506, // 4.3.4 15595 CMSG_DELETEEQUIPMENT_SET = 0x113F, CMSG_INSTANCE_LOCK_RESPONSE = 0x1140, CMSG_DEBUG_PASSIVE_AURA = 0x1141, diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 46c073161..e354afe3f 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -362,7 +362,7 @@ void MovementInfo::Write(ByteBuffer& data, uint16 opcode) const break; case MSEPositionO: if (si.hasOrientation) - data << float(pos.o); + data << float(NormalizeOrientation(pos.o)); break; case MSEPitch: if (si.hasPitch) @@ -401,7 +401,7 @@ void MovementInfo::Write(ByteBuffer& data, uint16 opcode) const break; case MSETransportPositionO: if (hasTransportData) - data << float(t_pos.o); + data << float(NormalizeOrientation(t_pos.o)); break; case MSETransportPositionX: if (hasTransportData) diff --git a/src/game/movement/packet_builder.cpp b/src/game/movement/packet_builder.cpp index 6c091bcca..bbeac944d 100644 --- a/src/game/movement/packet_builder.cpp +++ b/src/game/movement/packet_builder.cpp @@ -18,10 +18,10 @@ #include "packet_builder.h" #include "MoveSpline.h" +#include "Util.h" #include "WorldPacket.h" #include "../Creature.h" - namespace Movement { inline void operator << (ByteBuffer& b, const Vector3& v) @@ -69,7 +69,7 @@ namespace Movement break; case MoveSplineFlag::Final_Angle: data << uint8(MonsterMoveFacingAngle); - data << move_spline.facing.angle; + data << NormalizeOrientation(move_spline.facing.angle); break; case MoveSplineFlag::Final_Point: data << uint8(MonsterMoveFacingSpot); @@ -201,7 +201,7 @@ namespace Movement data << int32(move_spline.timePassed()); if (move_spline.splineflags & MoveSplineFlag::Final_Angle) - data << float(move_spline.facing.angle); + data << float(NormalizeOrientation(move_spline.facing.angle)); else if (move_spline.splineflags & MoveSplineFlag::Final_Target) data.WriteGuidBytes<5, 3, 7, 1, 6, 4, 2, 0>(ObjectGuid(move_spline.facing.target)); diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index 571bbc4bd..f85069454 100644 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -145,6 +145,21 @@ float GetFloatValueFromArray(Tokens const& data, uint16 index) return result; } +// modulos a radian orientation to the range of 0..2PI +float NormalizeOrientation(float o) +{ + // fmod only supports positive numbers. Thus we have + // to emulate negative numbers + if (o < 0) + { + float mod = o * -1; + mod = fmod(mod, 2.0f * M_PI_F); + mod = -mod + 2.0f * M_PI_F; + return mod; + } + return fmod(o, 2.0f * M_PI_F); +} + void stripLineInvisibleChars(std::string& str) { static std::string invChars = " \t\7\n"; diff --git a/src/shared/Util.h b/src/shared/Util.h index d00b71122..2f129d2d0 100644 --- a/src/shared/Util.h +++ b/src/shared/Util.h @@ -30,6 +30,8 @@ Tokens StrSplit(const std::string& src, const std::string& sep); uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index); float GetFloatValueFromArray(Tokens const& data, uint16 index); +float NormalizeOrientation(float o); + void stripLineInvisibleChars(std::string& src); std::string secsToTimeString(time_t timeInSecs, bool shortText = false, bool hoursOnly = false); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2db3dd65e..3e2b42392 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "0047" + #define REVISION_NR "0048" #endif // __REVISION_NR_H__