aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-08-10 14:10:57 +0200
committerShauren <shauren.trinity@gmail.com>2012-08-10 14:10:57 +0200
commit9538fb6d5a508adbebc9dd94ce25cbca6bd48789 (patch)
treee604080395845db3826549230689c299b83824c0 /src/server/game/Entities
parent5e1e9bb4dd10979c3bdf8debafc4e669355d4586 (diff)
Core/Movement: Ensured object orientation is always within 0-2pi range, this fixes movement.
Diffstat (limited to 'src/server/game/Entities')
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.cpp2
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.h4
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.cpp1
-rw-r--r--src/server/game/Entities/Object/Object.cpp9
-rwxr-xr-xsrc/server/game/Entities/Transport/Transport.cpp4
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp19
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h8
7 files changed, 30 insertions, 17 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index c46fc0d91d5..de5d0a0303c 100755
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -249,6 +249,7 @@ void Creature::RemoveCorpse(bool setSpawnTime)
float x, y, z, o;
GetRespawnPosition(x, y, z, &o);
+ o = MapManager::NormalizeOrientation(o);
SetHomePosition(x, y, z, o);
GetMap()->CreatureRelocation(this, x, y, z, o);
}
@@ -2464,6 +2465,7 @@ void Creature::SetPosition(float x, float y, float z, float o)
return;
}
+ o = MapManager::NormalizeOrientation(o);
GetMap()->CreatureRelocation(ToCreature(), x, y, z, o);
if (IsVehicle())
GetVehicleKit()->RelocatePassengers(x, y, z, o);
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index f58e49b9e14..5f933bc6ca1 100755
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -673,8 +673,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos); }
- void GetHomePosition(float &x, float &y, float &z, float &ori) { m_homePosition.GetPosition(x, y, z, ori); }
- Position GetHomePosition() { return m_homePosition; }
+ void GetHomePosition(float &x, float &y, float &z, float &ori) const { m_homePosition.GetPosition(x, y, z, ori); }
+ Position GetHomePosition() const { return m_homePosition; }
void SetTransportHomePosition(float x, float y, float z, float o) { m_transportHomePosition.Relocate(x, y, z, o); }
void SetTransportHomePosition(const Position &pos) { m_transportHomePosition.Relocate(pos); }
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 00b98ce2cc1..a59dcd7d950 100755
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -167,6 +167,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
ASSERT(map);
SetMap(map);
+ ang = MapManager::NormalizeOrientation(ang);
Relocate(x, y, z, ang);
if (!IsPositionValid())
{
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 264672fc5c9..153dad8e447 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -315,7 +315,6 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
data->WriteBit(flags & UPDATEFLAG_UNK5);
data->WriteBit(0);
data->WriteBit(flags & UPDATEFLAG_TRANSPORT);
- bool fullSpline = false;
if (flags & UPDATEFLAG_LIVING)
{
@@ -323,6 +322,8 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
ObjectGuid guid = GetGUID();
uint32 movementFlags = self->m_movementInfo.GetMovementFlags();
uint16 movementFlagsExtra = self->m_movementInfo.GetExtraMovementFlags();
+ if (GetTypeId() == TYPEID_UNIT)
+ movementFlags &= MOVEMENTFLAG_MASK_CREATURE_ALLOWED;
data->WriteBit(!movementFlags);
data->WriteBit(G3D::fuzzyEq(self->GetOrientation(), 0.0f)); // Has Orientation
@@ -359,7 +360,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
data->WriteBit(guid[4]);
if (self->IsSplineEnabled())
- Movement::PacketBuilder::WriteCreateBits(*self->movespline, *data, fullSpline);
+ Movement::PacketBuilder::WriteCreateBits(*self->movespline, *data);
data->WriteBit(guid[6]);
if (movementFlagsExtra & MOVEMENTFLAG2_INTERPOLATED_TURNING)
@@ -421,6 +422,8 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
ObjectGuid guid = GetGUID();
uint32 movementFlags = self->m_movementInfo.GetMovementFlags();
uint16 movementFlagsExtra = self->m_movementInfo.GetExtraMovementFlags();
+ if (GetTypeId() == TYPEID_UNIT)
+ movementFlags &= MOVEMENTFLAG_MASK_CREATURE_ALLOWED;
data->WriteByteSeq(guid[4]);
*data << self->GetSpeed(MOVE_RUN_BACK);
@@ -442,7 +445,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
*data << float(self->m_movementInfo.splineElevation);
if (self->IsSplineEnabled())
- Movement::PacketBuilder::WriteCreateData(*self->movespline, *data, fullSpline);
+ Movement::PacketBuilder::WriteCreateData(*self->movespline, *data);
*data << float(self->GetPositionZMinusOffset());
data->WriteByteSeq(guid[5]);
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index aa5c33d8c67..02a6f261e98 100755
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -711,7 +711,7 @@ void Transport::UpdateNPCPositions()
void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float& o)
{
float inx = x, iny = y, inz = z, ino = o;
- o = GetOrientation() + ino;
+ o = MapManager::NormalizeOrientation(GetOrientation() + ino);
x = GetPositionX() + (inx * cos(GetOrientation()) + iny * sin(GetOrientation() + M_PI));
y = GetPositionY() + (iny * cos(GetOrientation()) + inx * sin(GetOrientation()));
z = GetPositionZ() + inz;
@@ -720,7 +720,7 @@ void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float&
//! This method transforms supplied global coordinates into local offsets
void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o)
{
- o -= GetOrientation();
+ o = MapManager::NormalizeOrientation(o - GetOrientation());
z -= GetPositionZ();
y -= GetPositionY(); // y = searchedY * cos(o) + searchedX * sin(o)
x -= GetPositionX(); // x = searchedX * cos(o) + searchedY * sin(o + pi)
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index cedf38cb676..9ca0d23006c 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -16257,20 +16257,20 @@ void Unit::SendMoveRoot(uint32 value)
data.WriteBit(guid[4]);
data.WriteBit(guid[1]);
data.WriteBit(guid[3]);
-
+
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[5]);
-
+
data << uint32(value);
-
-
+
+
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[6]);
-
+
SendMessageToSet(&data, true);
}
@@ -16286,19 +16286,19 @@ void Unit::SendMoveUnroot(uint32 value)
data.WriteBit(guid[2]);
data.WriteBit(guid[4]);
data.WriteBit(guid[6]);
-
+
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[1]);
-
+
data << uint32(value);
-
+
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[5]);
-
+
SendMessageToSet(&data, true);
}
@@ -17849,6 +17849,7 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
return false;
}
+ orientation = MapManager::NormalizeOrientation(orientation);
bool turn = (GetOrientation() != orientation);
bool relocated = (teleport || GetPositionX() != x || GetPositionY() != y || GetPositionZ() != z);
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index de95b7d9842..7a0b97b90ef 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -711,6 +711,12 @@ enum MovementFlags
MOVEMENTFLAG_MASK_MOVING_FLY =
MOVEMENTFLAG_FLYING | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING,
+ // Movement flags allowed for creature in CreateObject - we need to keep all other enabled serverside
+ // to properly calculate all movement
+ MOVEMENTFLAG_MASK_CREATURE_ALLOWED =
+ MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_ROOT | MOVEMENTFLAG_SWIMMING |
+ MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_WATERWALKING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_HOVER,
+
//! TODO if needed: add more flags to this masks that are exclusive to players
MOVEMENTFLAG_MASK_PLAYER_ONLY =
MOVEMENTFLAG_FLYING,
@@ -1407,7 +1413,7 @@ class Unit : public WorldObject
MountCapabilityEntry const* GetMountCapability(uint32 mountType) const;
void SendDurabilityLoss(Player* receiver, uint32 percent);
-
+
uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
void DealDamageMods(Unit* victim, uint32 &damage, uint32* absorb);
uint32 DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDamage = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = NULL, bool durabilityLoss = true);