diff options
| author | QAston <none@none> | 2010-08-04 14:39:45 +0200 |
|---|---|---|
| committer | QAston <none@none> | 2010-08-04 14:39:45 +0200 |
| commit | 6353e7dd8cd189a80fc6773bf653f159fc3a41d3 (patch) | |
| tree | 841ca8df929325ef8338c62f3b6c3b06cb06df5c /src/server/game/Entities | |
| parent | 850868c8a33550b60ad1ae0c92f7985409d17bdc (diff) | |
*Update movement enums - thanks to Zor for info.
*Add functions for position data streaming.
--HG--
branch : trunk
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 8 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/CreatureGroups.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 39 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.h | 102 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 50 | ||||
| -rw-r--r-- | src/server/game/Entities/Transport/Transport.cpp | 23 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 48 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 198 | ||||
| -rw-r--r-- | src/server/game/Entities/Vehicle/Vehicle.cpp | 16 |
9 files changed, 279 insertions, 207 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 7ad8eb8b10c..57802f058c4 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -420,7 +420,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data) // TODO: In fact monster move flags should be set - not movement flags. if (cInfo->InhabitType & INHABIT_AIR) - AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING); + AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING); if (cInfo->InhabitType & INHABIT_WATER) AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); @@ -784,7 +784,7 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, if (GetCreatureInfo()->InhabitType & INHABIT_AIR) { if (GetDefaultMovementType() == IDLE_MOTION_TYPE) - AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE); + AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); else SetFlying(true); } @@ -1515,9 +1515,9 @@ void Creature::setDeathState(DeathState s) SetLootRecipient(NULL); ResetPlayerDamageReq(); CreatureInfo const *cinfo = GetCreatureInfo(); - AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + AddUnitMovementFlag(MOVEMENTFLAG_WALKING); if (GetCreatureInfo()->InhabitType & INHABIT_AIR) - AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING); + AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING); if (GetCreatureInfo()->InhabitType & INHABIT_WATER) AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag); diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index 7bd05123ec5..97414c35529 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -246,7 +246,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z) if (member->IsWithinDist(m_leader, dist + MAX_DESYNC)) member->SetUnitMovementFlags(m_leader->GetUnitMovementFlags()); else - member->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + member->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); member->GetMotionMaster()->MovePoint(0, dx, dy, dz); member->SetHomePosition(dx, dy, dz, pathangle); diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 7f9bf42b5fd..203b6a3e1b6 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -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); diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 61a6ef516b3..e7f50f312ff 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -117,43 +117,8 @@ 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; } -}; +typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType; class Object { @@ -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 diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 9a8e11b8556..952dcdf5204 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1851,10 +1851,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati { m_transport->RemovePassenger(this); m_transport = NULL; - m_movementInfo.t_x = 0.0f; - m_movementInfo.t_y = 0.0f; - m_movementInfo.t_z = 0.0f; - m_movementInfo.t_o = 0.0f; + m_movementInfo.t_pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f); m_movementInfo.t_time = 0; m_movementInfo.t_seat = -1; } @@ -1990,7 +1987,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati data.Initialize(SMSG_NEW_WORLD, (20)); if (m_transport) - data << (uint32)mapid << m_movementInfo.t_x << m_movementInfo.t_y << m_movementInfo.t_z << m_movementInfo.t_o; + data << (uint32)mapid << m_movementInfo.t_pos.PositionXYZOStream(); else data << (uint32)mapid << (float)x << (float)y << (float)z << (float)orientation; @@ -2010,10 +2007,10 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (m_transport) { - final_x += m_movementInfo.t_x; - final_y += m_movementInfo.t_y; - final_z += m_movementInfo.t_z; - final_o += m_movementInfo.t_o; + final_x += m_movementInfo.t_pos.GetPositionX(); + final_y += m_movementInfo.t_pos.GetPositionY(); + final_z += m_movementInfo.t_pos.GetPositionZ(); + final_o += m_movementInfo.t_pos.GetOrientation(); } m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o); @@ -16057,20 +16054,17 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) instanceId = 0; m_movementInfo.t_guid = MAKE_NEW_GUID(transGUID, 0, HIGHGUID_TRANSPORT); - m_movementInfo.t_x = fields[26].GetFloat(); - m_movementInfo.t_y = fields[27].GetFloat(); - m_movementInfo.t_z = fields[28].GetFloat(); - m_movementInfo.t_o = fields[29].GetFloat(); + m_movementInfo.t_pos.Relocate(fields[26].GetFloat(), fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat()); if (!Trinity::IsValidMapCoord( - GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y, - GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o) || + GetPositionX()+m_movementInfo.t_pos.m_positionX,GetPositionY()+m_movementInfo.t_pos.m_positionY, + GetPositionZ()+m_movementInfo.t_pos.m_positionZ,GetOrientation()+m_movementInfo.t_pos.m_orientation) || // transport size limited - m_movementInfo.t_x > 250 || m_movementInfo.t_y > 250 || m_movementInfo.t_z > 250) + m_movementInfo.t_pos.m_positionX > 250 || m_movementInfo.t_pos.m_positionY > 250 || m_movementInfo.t_pos.m_positionZ > 250) { sLog.outError("Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", - guid,GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y, - GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o); + guid,GetPositionX()+m_movementInfo.t_pos.m_positionX,GetPositionY()+m_movementInfo.t_pos.m_positionY, + GetPositionZ()+m_movementInfo.t_pos.m_positionZ,GetOrientation()+m_movementInfo.t_pos.m_orientation); RelocateToHomebind(); } @@ -17675,10 +17669,10 @@ void Player::SaveToDB() ss << m_resetTalentsCost << ", "; ss << (uint64)m_resetTalentsTime << ", "; - ss << finiteAlways(m_movementInfo.t_x) << ", "; - ss << finiteAlways(m_movementInfo.t_y) << ", "; - ss << finiteAlways(m_movementInfo.t_z) << ", "; - ss << finiteAlways(m_movementInfo.t_o) << ", "; + ss << finiteAlways(m_movementInfo.t_pos.GetPositionX()) << ", "; + ss << finiteAlways(m_movementInfo.t_pos.GetPositionY()) << ", "; + ss << finiteAlways(m_movementInfo.t_pos.GetPositionZ()) << ", "; + ss << finiteAlways(m_movementInfo.t_pos.GetOrientation()) << ", "; if (m_transport) ss << m_transport->GetGUIDLow(); else @@ -22845,7 +22839,7 @@ uint8 Player::CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 except_sl void Player::HandleFall(MovementInfo const& movementInfo) { // calculate total z distance of the fall - float z_diff = m_lastFallZ - movementInfo.z; + float z_diff = m_lastFallZ - movementInfo.pos.GetPositionZ(); //sLog.outDebug("zDiff = %f", z_diff); //Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored @@ -22863,8 +22857,8 @@ void Player::HandleFall(MovementInfo const& movementInfo) { uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL)); - float height = movementInfo.z; - UpdateGroundPositionZ(movementInfo.x,movementInfo.y,height); + float height = movementInfo.t_pos.m_positionZ; + UpdateGroundPositionZ(movementInfo.pos.m_positionX,movementInfo.pos.m_positionY,height); if (damage > 0) { @@ -22885,7 +22879,7 @@ void Player::HandleFall(MovementInfo const& movementInfo) } //Z given by moveinfo, LastZ, FallTime, WaterZ, MapZ, Damage, Safefall reduction - DEBUG_LOG("FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d" , movementInfo.z, height, GetPositionZ(), movementInfo.fallTime, height, damage, safe_fall); + DEBUG_LOG("FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d" , movementInfo.pos.GetPositionZ(), height, GetPositionZ(), movementInfo.fallTime, height, damage, safe_fall); } } RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LANDING); // No fly zone - Parachute @@ -23165,8 +23159,8 @@ void Player::UpdateKnownCurrencies(uint32 itemId, bool apply) void Player::UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode) { - if (m_lastFallTime >= minfo.fallTime || m_lastFallZ <= minfo.z || opcode == MSG_MOVE_FALL_LAND) - SetFallInformation(minfo.fallTime, minfo.z); + if (m_lastFallTime >= minfo.fallTime || m_lastFallZ <= minfo.pos.GetPositionZ() || opcode == MSG_MOVE_FALL_LAND) + SetFallInformation(minfo.fallTime, minfo.pos.GetPositionZ()); } void Player::UnsummonPetTemporaryIfAny() diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 715e0a309b5..e1036436af0 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -644,17 +644,14 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, pCreature->SetTransport(this); pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); pCreature->m_movementInfo.guid = GetGUID(); - pCreature->m_movementInfo.t_x = x; - pCreature->m_movementInfo.t_y = y; - pCreature->m_movementInfo.t_z = z; - pCreature->m_movementInfo.t_o = o; + pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o); pCreature->setActive(true); if (anim > 0) pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE,anim); pCreature->Relocate( - GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + 3.14159f)), + GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + M_PI)), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ() , o + GetOrientation()); @@ -684,10 +681,10 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, void Transport::UpdatePosition(MovementInfo* mi) { - float transport_o = mi->o - mi->t_o; - float transport_x = mi->x - (mi->t_x*cos(transport_o) - mi->t_y*sin(transport_o)); - float transport_y = mi->y - (mi->t_y*cos(transport_o) + mi->t_x*sin(transport_o)); - float transport_z = mi->z - mi->t_z; + float transport_o = mi->pos.m_orientation - mi->t_pos.m_orientation; + float transport_x = mi->pos.m_positionX - (mi->t_pos.m_positionX * cos(transport_o) - mi->t_pos.m_positionY*sin(transport_o)); + float transport_y = mi->pos.m_positionY - (mi->t_pos.m_positionY * cos(transport_o) + mi->t_pos.m_positionX*sin(transport_o)); + float transport_z = mi->pos.m_positionZ - mi->t_pos.m_positionZ; Relocate(transport_x,transport_y,transport_z,transport_o); UpdateNPCPositions(); @@ -707,10 +704,10 @@ void Transport::UpdateNPCPositions() if (Creature* npc = Creature::GetCreature(*this, guid)) { float x, y, z, o; - o = GetOrientation() + npc->m_movementInfo.t_o; - x = GetPositionX() + (npc->m_movementInfo.t_x * cos(GetOrientation()) + npc->m_movementInfo.t_y * sin(GetOrientation() + 3.14159f)); - y = GetPositionY() + (npc->m_movementInfo.t_y * cos(GetOrientation()) + npc->m_movementInfo.t_x * sin(GetOrientation())); - z = GetPositionZ() + npc->m_movementInfo.t_z; + o = GetOrientation() + npc->m_movementInfo.t_pos.m_orientation; + x = GetPositionX() + (npc->m_movementInfo.t_pos.m_positionX * cos(GetOrientation()) + npc->m_movementInfo.t_pos.m_positionY * sin(GetOrientation() + M_PI)); + y = GetPositionY() + (npc->m_movementInfo.t_pos.m_positionY * cos(GetOrientation()) + npc->m_movementInfo.t_pos.m_positionX * sin(GetOrientation())); + z = GetPositionZ() + npc->m_movementInfo.t_pos.m_positionZ; npc->SetPosition(x, y, z,o); npc->SetHomePosition(x,y,z,o); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 7c6ae61455d..c8ce0fe502c 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -326,7 +326,7 @@ void Unit::SendMonsterStop(bool on_death) if (on_death == true) { data << uint8(0); - data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? MOVEFLAG_FLY : MOVEFLAG_WALK); + data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? SPLINEFLAG_FLYING : SPLINEFLAG_WALKING); data << uint32(0); // Time in between points data << uint32(1); // 1 single waypoint data << GetPositionX() << GetPositionY() << GetPositionZ(); @@ -349,7 +349,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 T data << getMSTime(); data << uint8(0); - data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? MOVEFLAG_FLY : MOVEFLAG_WALK); + data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? SPLINEFLAG_FLYING : SPLINEFLAG_WALKING); data << Time; // Time in between points data << uint32(1); // 1 single waypoint data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B @@ -374,7 +374,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M data << uint8(0); data << MoveFlags; - if (MoveFlags & MOVEFLAG_JUMP) + if (MoveFlags & SPLINEFLAG_TRAJECTORY) { data << time; data << speedZ; @@ -452,7 +452,7 @@ void Unit::SendMonsterMoveTransport(Unit *vehicleOwner) data << uint32(getMSTime()); data << uint8(4); data << GetTransOffsetO(); - data << uint32(MOVEFLAG_ENTER_TRANSPORT); + data << uint32(SPLINEFLAG_TRANSPORT); data << uint32(0);// move time data << uint32(0);//GetTransOffsetX(); data << uint32(0);//GetTransOffsetY(); @@ -9752,9 +9752,9 @@ void Unit::SetCharm(Unit* charm, bool apply) if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) sLog.outCrash("Unit %u is being charmed, but it already has a charmer %u", charm->GetEntry(), charm->GetCharmerGUID()); - if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) + if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING)) { - charm->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + charm->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); charm->SendMovementFlagUpdate(); } @@ -16411,10 +16411,7 @@ void Unit::ExitVehicle() SetControlled(false, UNIT_STAT_ROOT); RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); - m_movementInfo.t_x = 0; - m_movementInfo.t_y = 0; - m_movementInfo.t_z = 0; - m_movementInfo.t_o = 0; + m_movementInfo.t_pos.Relocate(0, 0, 0, 0); m_movementInfo.t_time = 0; m_movementInfo.t_seat = 0; @@ -16446,17 +16443,17 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const break; case TYPEID_PLAYER: // remove unknown, unused etc flags for now - const_cast<Unit*>(this)->RemoveUnitMovementFlag(MOVEMENTFLAG_SPLINE2); + const_cast<Unit*>(this)->RemoveUnitMovementFlag(MOVEMENTFLAG_SPLINE_ENABLED); if (isInFlight()) { WPAssert(const_cast<Unit*>(this)->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE); - const_cast<Unit*>(this)->AddUnitMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_SPLINE2); + const_cast<Unit*>(this)->AddUnitMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_SPLINE_ENABLED); } break; } *data << uint32(GetUnitMovementFlags()); // movement flags - *data << uint16(m_movementInfo.unk1); // 2.3.0 + *data << uint16(m_movementInfo.flags2); // 2.3.0 *data << uint32(getMSTime()); // time *data << GetPositionX(); *data << GetPositionY(); @@ -16485,8 +16482,8 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const // 0x02200000 if ((GetUnitMovementFlags() & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) - || (m_movementInfo.unk1 & 0x20)) - *data << (float)m_movementInfo.s_pitch; + || (m_movementInfo.flags2 & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING)) + *data << (float)m_movementInfo.pitch; *data << (uint32)m_movementInfo.fallTime; @@ -16500,8 +16497,8 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const } // 0x04000000 - if (GetUnitMovementFlags() & MOVEMENTFLAG_SPLINE) - *data << (float)m_movementInfo.u_unk1; + if (GetUnitMovementFlags() & MOVEMENTFLAG_SPLINE_ELEVATION) + *data << (float)m_movementInfo.splineElevation; /*if (GetTypeId() == TYPEID_PLAYER) { @@ -16510,30 +16507,17 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const }*/ } -void Unit::OutMovementInfo() const -{ - sLog.outString("MovementInfo for %u: Flag %u, Unk1 %u, Time %u, Pos %f %f %f %f, Fall %u", GetEntry(), m_movementInfo.flags, (uint32)m_movementInfo.unk1, m_movementInfo.time, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), m_movementInfo.fallTime); - if (m_movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT) - sLog.outString("Transport: GUID " UI64FMTD ", Pos %f %f %f %f, Time %u, Seat %d", m_movementInfo.t_guid, m_movementInfo.t_x, m_movementInfo.t_y, m_movementInfo.t_z, m_movementInfo.t_o, m_movementInfo.t_time, (int32)m_movementInfo.t_seat); - if ((m_movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (m_movementInfo.unk1 & 0x20)) - sLog.outString("Pitch: %f", m_movementInfo.s_pitch); - if (m_movementInfo.flags & MOVEMENTFLAG_JUMPING) - sLog.outString("Jump: speedz %f, sin %f, cos %f, speedxy %f", m_movementInfo.j_zspeed, m_movementInfo.j_sinAngle, m_movementInfo.j_cosAngle, m_movementInfo.j_xyspeed); - if (m_movementInfo.flags & MOVEMENTFLAG_SPLINE) - sLog.outString("Spline: %f", m_movementInfo.u_unk1); -} - void Unit::SetFlying(bool apply) { if (apply) { SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02); - AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING); + AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING); } else { RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02); - RemoveUnitMovementFlag(MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING); + RemoveUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING); } } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index fe163da99c1..de919cccec2 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -636,91 +636,128 @@ enum NPCFlags UNIT_NPC_FLAG_OUTDOORPVP = 0x20000000, // custom flag for outdoor pvp creatures }; -enum MoveFlags -{ - MOVEFLAG_JUMP = 0x00000800, - MOVEFLAG_WALK = 0x00001000, - MOVEFLAG_FLY = 0x00002000, - MOVEFLAG_GLIDE = 0x00003000, // dragon - MOVEFLAG_ENTER_TRANSPORT = 0x00800000, -}; - enum MovementFlags { - MOVEMENTFLAG_NONE = 0x00000000, - MOVEMENTFLAG_FORWARD = 0x00000001, - MOVEMENTFLAG_BACKWARD = 0x00000002, - MOVEMENTFLAG_STRAFE_LEFT = 0x00000004, - MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008, - MOVEMENTFLAG_LEFT = 0x00000010, - MOVEMENTFLAG_RIGHT = 0x00000020, - MOVEMENTFLAG_PITCH_UP = 0x00000040, - MOVEMENTFLAG_PITCH_DOWN = 0x00000080, - MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking - MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures - MOVEMENTFLAG_LEVITATING = 0x00000400, - MOVEMENTFLAG_ROOT = 0x00000800, - MOVEMENTFLAG_JUMPING = 0x00001000, - MOVEMENTFLAG_FALL_DAMAGE = 0x00002000, // newZ < oldZ - MOVEMENTFLAG_FALLING = 0x00004000, - // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000 - MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also - MOVEMENTFLAG_ASCEND = 0x00400000, // press "space" when flying - MOVEMENTFLAG_CAN_FLY = 0x00800000, - MOVEMENTFLAG_FLY_MODE = 0x01000000, // can fly - MOVEMENTFLAG_FLYING = 0x02000000, // hover - MOVEMENTFLAG_SPLINE = 0x04000000, // used for flight paths - MOVEMENTFLAG_SPLINE2 = 0x08000000, // used for flight paths - MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water - MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive) - MOVEMENTFLAG_HOVER = 0x40000000, // hover, cannot jump + MOVEMENTFLAG_NONE = 0x00000000, + MOVEMENTFLAG_FORWARD = 0x00000001, + MOVEMENTFLAG_BACKWARD = 0x00000002, + MOVEMENTFLAG_STRAFE_LEFT = 0x00000004, + MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008, + MOVEMENTFLAG_LEFT = 0x00000010, + MOVEMENTFLAG_RIGHT = 0x00000020, + MOVEMENTFLAG_PITCH_UP = 0x00000040, + MOVEMENTFLAG_PITCH_DOWN = 0x00000080, + MOVEMENTFLAG_WALKING = 0x00000100, // Walking + MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures + MOVEMENTFLAG_LEVITATING = 0x00000400, + MOVEMENTFLAG_ROOT = 0x00000800, + MOVEMENTFLAG_JUMPING = 0x00001000, + MOVEMENTFLAG_FALLING = 0x00002000, // damage dealt on that type of falling + MOVEMENTFLAG_PENDING_STOP = 0x00004000, + MOVEMENTFLAG_PENDING_STRAFE_STOP = 0x00008000, + MOVEMENTFLAG_PENDING_FORWARD = 0x00010000, + MOVEMENTFLAG_PENDING_BACKWARD = 0x00020000, + MOVEMENTFLAG_PENDING_STRAFE_LEFT = 0x00040000, + MOVEMENTFLAG_PENDING_STRAFE_RIGHT = 0x00080000, + MOVEMENTFLAG_PENDING_ROOT = 0x00100000, + MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also + MOVEMENTFLAG_ASCENDING = 0x00400000, // press "space" when flying + MOVEMENTFLAG_DESCENDING = 0x00800000, + MOVEMENTFLAG_CAN_FLY = 0x01000000, // can fly + MOVEMENTFLAG_FLYING = 0x02000000, // hover + MOVEMENTFLAG_SPLINE_ELEVATION = 0x04000000, // used for flight paths + MOVEMENTFLAG_SPLINE_ENABLED = 0x08000000, // used for flight paths + MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water + MOVEMENTFLAG_FALLING_SLOW = 0x20000000, // active rogue safe fall spell (passive) + MOVEMENTFLAG_HOVER = 0x40000000, // hover, cannot jump MOVEMENTFLAG_MOVING = MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT| - MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FALL_DAMAGE| - MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_ASCEND | - MOVEMENTFLAG_SPLINE, + MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_JUMPING + |MOVEMENTFLAG_FALLING|MOVEMENTFLAG_ASCENDING| MOVEMENTFLAG_SPLINE_ELEVATION, MOVEMENTFLAG_TURNING = MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT, }; +enum MovementFlags2 +{ + MOVEMENTFLAG2_NONE = 0x00000000, + MOVEMENTFLAG2_UNK1 = 0x00000001, + MOVEMENTFLAG2_UNK2 = 0x00000002, + MOVEMENTFLAG2_UNK3 = 0x00000004, + MOVEMENTFLAG2_FULL_SPEED_TURNING = 0x00000008, + MOVEMENTFLAG2_FULL_SPEED_PITCHING = 0x00000010, + MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING = 0x00000020, + MOVEMENTFLAG2_UNK7 = 0x00000040, + MOVEMENTFLAG2_UNK8 = 0x00000080, + MOVEMENTFLAG2_UNK9 = 0x00000100, + MOVEMENTFLAG2_UNK10 = 0x00000200, + MOVEMENTFLAG2_INTERPOLATED_MOVEMENT = 0x00000400, + MOVEMENTFLAG2_INTERPOLATED_TURNING = 0x00000800, + MOVEMENTFLAG2_INTERPOLATED_PITCHING = 0x00001000, + MOVEMENTFLAG2_UNK14 = 0x00002000, + MOVEMENTFLAG2_UNK15 = 0x00004000, + MOVEMENTFLAG2_UNK16 = 0x00008000, + + // player only? + MOVEMENTFLAG2_INTERPOLATED = + MOVEMENTFLAG2_INTERPOLATED_MOVEMENT | + MOVEMENTFLAG2_INTERPOLATED_TURNING | + MOVEMENTFLAG2_INTERPOLATED_PITCHING +}; +enum SplineFlags +{ + SPLINEFLAG_NONE = 0x00000000, + SPLINEFLAG_FORWARD = 0x00000001, + SPLINEFLAG_BACKWARD = 0x00000002, + SPLINEFLAG_STRAFE_LEFT = 0x00000004, + SPLINEFLAG_STRAFE_RIGHT = 0x00000008, + SPLINEFLAG_LEFT = 0x00000010, + SPLINEFLAG_RIGHT = 0x00000020, + SPLINEFLAG_PITCH_UP = 0x00000040, + SPLINEFLAG_PITCH_DOWN = 0x00000080, + SPLINEFLAG_DONE = 0x00000100, + SPLINEFLAG_FALLING = 0x00000200, + SPLINEFLAG_NO_SPLINE = 0x00000400, + SPLINEFLAG_TRAJECTORY = 0x00000800, + SPLINEFLAG_WALKING = 0x00001000, + SPLINEFLAG_FLYING = 0x00002000, + SPLINEFLAG_KNOCKBACK = 0x00004000, + SPLINEFLAG_FINAL_POINT = 0x00008000, + SPLINEFLAG_FINAL_TARGET = 0x00010000, + SPLINEFLAG_FINAL_FACING = 0x00020000, + SPLINEFLAG_CATMULL_ROM = 0x00040000, + SPLINEFLAG_UNKNOWN20 = 0x00080000, + SPLINEFLAG_UNKNOWN21 = 0x00100000, + SPLINEFLAG_UNKNOWN22 = 0x00200000, + SPLINEFLAG_UNKNOWN23 = 0x00400000, + SPLINEFLAG_TRANSPORT = 0x00800000, + SPLINEFLAG_UNKNOWN25 = 0x01000000, + SPLINEFLAG_UNKNOWN26 = 0x02000000, + SPLINEFLAG_UNKNOWN27 = 0x04000000, + SPLINEFLAG_UNKNOWN28 = 0x08000000, + SPLINEFLAG_UNKNOWN29 = 0x10000000, + SPLINEFLAG_ANIMATION = 0x20000000, + SPLINEFLAG_UNKNOWN31 = 0x40000000, + SPLINEFLAG_UNKNOWN32 = 0x80000000, + + SPLINEFLAG_GLIDE = SPLINEFLAG_WALKING | SPLINEFLAG_FLYING, +}; -/* -enum MonsterMovementFlags +enum SplineMode +{ + SPLINEMODE_LINEAR = 0, + SPLINEMODE_CATMULL_ROM = 1, + SPLINEMODE_BEZIER3 = 2 +}; + +enum SplineType { - MONSTER_MOVE_NONE = 0x00000000, - MONSTER_MOVE_FORWARD = 0x00000001, - MONSTER_MOVE_BACKWARD = 0x00000002, - MONSTER_MOVE_STRAFE_LEFT = 0x00000004, - MONSTER_MOVE_STRAFE_RIGHT = 0x00000008, - MONSTER_MOVE_LEFT = 0x00000010, // turn - MONSTER_MOVE_RIGHT = 0x00000020, // turn - MONSTER_MOVE_PITCH_UP = 0x00000040, - MONSTER_MOVE_PITCH_DOWN = 0x00000080, - MONSTER_MOVE_TELEPORT = 0x00000100, - MONSTER_MOVE_TELEPORT2 = 0x00000200, - MONSTER_MOVE_LEVITATING = 0x00000400, - MONSTER_MOVE_UNK1 = 0x00000800, // float+uint32 - MONSTER_MOVE_WALK = 0x00001000, // run2? - MONSTER_MOVE_SPLINE = 0x00002000, // spline n*(float x,y,z) - // 0x4000, 0x8000, 0x10000, 0x20000 run - MONSTER_MOVE_SPLINE2 = 0x00040000, // spline n*(float x,y,z) - MONSTER_MOVE_UNK2 = 0x00080000, // used for flying mobs - MONSTER_MOVE_UNK3 = 0x00100000, // used for flying mobs - MONSTER_MOVE_UNK4 = 0x00200000, // uint8+uint32 - MONSTER_MOVE_UNK5 = 0x00400000, // run in place, then teleport to final point - MONSTER_MOVE_UNK6 = 0x00800000, // teleport - MONSTER_MOVE_UNK7 = 0x01000000, // run - MONSTER_MOVE_FLY = 0x02000000, // swimming/flying (depends on mob?) - MONSTER_MOVE_UNK9 = 0x04000000, // run - MONSTER_MOVE_UNK10 = 0x08000000, // run - MONSTER_MOVE_UNK11 = 0x10000000, // run - MONSTER_MOVE_UNK12 = 0x20000000, // run - MONSTER_MOVE_UNK13 = 0x40000000, // levitating - - // masks - MONSTER_MOVE_SPLINE_FLY = 0x00003000, // fly by points + SPLINETYPE_NORMAL = 0, + SPLINETYPE_STOP = 1, + SPLINETYPE_FACING_SPOT = 2, + SPLINETYPE_FACING_TARGET = 3, + SPLINETYPE_FACING_ANGLE = 4 }; -*/ enum UnitTypeMask { @@ -1424,7 +1461,6 @@ class Unit : public WorldObject void SendThreatListUpdate(); void BuildHeartBeatMsg(WorldPacket *data) const; - void OutMovementInfo() const; bool isAlive() const { return (m_deathState == ALIVE); }; bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); }; @@ -1913,10 +1949,10 @@ class Unit : public WorldObject bool IsOnVehicle(const Unit *vehicle) const { return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); } Unit *GetVehicleBase() const; Creature *GetVehicleCreatureBase() const; - float GetTransOffsetX() const { return m_movementInfo.t_x; } - float GetTransOffsetY() const { return m_movementInfo.t_y; } - float GetTransOffsetZ() const { return m_movementInfo.t_z; } - float GetTransOffsetO() const { return m_movementInfo.t_o; } + float GetTransOffsetX() const { return m_movementInfo.t_pos.GetPositionX(); } + float GetTransOffsetY() const { return m_movementInfo.t_pos.GetPositionY(); } + float GetTransOffsetZ() const { return m_movementInfo.t_pos.GetPositionZ(); } + float GetTransOffsetO() const { return m_movementInfo.t_pos.GetOrientation(); } uint32 GetTransTime() const { return m_movementInfo.t_time; } int8 GetTransSeat() const { return m_movementInfo.t_seat; } @@ -1932,7 +1968,7 @@ class Unit : public WorldObject bool isMoving() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MOVING); } bool isTurning() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_TURNING); } - bool canFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLY_MODE); } + bool canFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING); } void SetFlying(bool apply); @@ -2111,7 +2147,7 @@ inline void Unit::SendMonsterMoveByPath(Path<Elem,Node> const& path, uint32 star data << GetPositionZ(); data << uint32(getMSTime()); data << uint8(0); - data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight()) ? (MOVEFLAG_FLY|MOVEFLAG_WALK) : MOVEFLAG_WALK); + data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight()) ? (SPLINEFLAG_FLYING|SPLINEFLAG_WALKING) : SPLINEFLAG_WALKING); data << uint32(traveltime); data << uint32(pathSize); diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 038c3aa302f..67d8b4ce92c 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -291,10 +291,10 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId) unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); VehicleSeatEntry const *veSeat = seat->second.seatInfo; - unit->m_movementInfo.t_x = veSeat->m_attachmentOffsetX; - unit->m_movementInfo.t_y = veSeat->m_attachmentOffsetY; - unit->m_movementInfo.t_z = veSeat->m_attachmentOffsetZ; - unit->m_movementInfo.t_o = 0; + unit->m_movementInfo.t_pos.m_positionX = veSeat->m_attachmentOffsetX; + unit->m_movementInfo.t_pos.m_positionY = veSeat->m_attachmentOffsetY; + unit->m_movementInfo.t_pos.m_positionZ = veSeat->m_attachmentOffsetZ; + unit->m_movementInfo.t_pos.m_orientation = 0; unit->m_movementInfo.t_time = 0; // 1 for player unit->m_movementInfo.t_seat = seat->first; @@ -378,10 +378,10 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang) for (SeatMap::const_iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr) if (Unit *passenger = itr->second.passenger) { - float px = x + passenger->m_movementInfo.t_x; - float py = y + passenger->m_movementInfo.t_y; - float pz = z + passenger->m_movementInfo.t_z; - float po = ang + passenger->m_movementInfo.t_o; + float px = x + passenger->m_movementInfo.t_pos.m_positionX; + float py = y + passenger->m_movementInfo.t_pos.m_positionY; + float pz = z + passenger->m_movementInfo.t_pos.m_positionZ; + float po = ang + passenger->m_movementInfo.t_pos.m_orientation; passenger->SetPosition(px, py, pz, po); } |
