diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Entities/Creature/Creature.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Entities/GameObject/GameObject.cpp | 1 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 16 | ||||
-rwxr-xr-x | src/server/game/Entities/Object/Object.h | 26 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 10 | ||||
-rwxr-xr-x | src/server/game/Entities/Transport/Transport.cpp | 6 | ||||
-rwxr-xr-x | src/server/game/Entities/Unit/Unit.cpp | 3 | ||||
-rwxr-xr-x | src/server/game/Entities/Vehicle/Vehicle.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Handlers/MovementHandler.cpp | 8 | ||||
-rwxr-xr-x | src/server/game/Maps/MapManager.h | 15 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 2 | ||||
-rwxr-xr-x | src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp | 1 | ||||
-rw-r--r-- | src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp | 2 |
14 files changed, 46 insertions, 52 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 642c7e45a74..6e2fc197a5f 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -249,7 +249,6 @@ 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); } @@ -2465,7 +2464,6 @@ 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/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 2e9780fb87e..d11795b1ae8 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -166,7 +166,6 @@ 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 153dad8e447..edbc40767f9 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1664,7 +1664,7 @@ void Position::RelocateOffset(const Position & offset) m_positionX = GetPositionX() + (offset.GetPositionX() * cos(GetOrientation()) + offset.GetPositionY() * sin(GetOrientation() + M_PI)); m_positionY = GetPositionY() + (offset.GetPositionY() * cos(GetOrientation()) + offset.GetPositionX() * sin(GetOrientation())); m_positionZ = GetPositionZ() + offset.GetPositionZ(); - m_orientation = GetOrientation() + offset.GetOrientation(); + SetOrientation(GetOrientation() + offset.GetOrientation()); } void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const @@ -1675,7 +1675,7 @@ void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset retOffset.m_positionX = dx * cos(GetOrientation()) + dy * sin(GetOrientation()); retOffset.m_positionY = dy * cos(GetOrientation()) - dx * sin(GetOrientation()); retOffset.m_positionZ = endPos.GetPositionZ() - GetPositionZ(); - retOffset.m_orientation = endPos.GetOrientation() - GetOrientation(); + retOffset.SetOrientation(endPos.GetOrientation() - GetOrientation()); } float Position::GetAngle(const Position* obj) const @@ -1723,13 +1723,13 @@ bool Position::HasInArc(float arc, const Position* obj) const return true; // move arc to range 0.. 2*pi - arc = MapManager::NormalizeOrientation(arc); + arc = NormalizeOrientation(arc); float angle = GetAngle(obj); angle -= m_orientation; // move angle to range -pi ... +pi - angle = MapManager::NormalizeOrientation(angle); + angle = NormalizeOrientation(angle); if (angle > M_PI) angle -= 2.0f*M_PI; @@ -2916,7 +2916,7 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float void WorldObject::MovePosition(Position &pos, float dist, float angle) { - angle += m_orientation; + angle += GetOrientation(); float destx, desty, destz, ground, floor; destx = pos.m_positionX + dist * cos(angle); desty = pos.m_positionY + dist * sin(angle); @@ -2956,12 +2956,12 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle) Trinity::NormalizeMapCoord(pos.m_positionX); Trinity::NormalizeMapCoord(pos.m_positionY); UpdateGroundPositionZ(pos.m_positionX, pos.m_positionY, pos.m_positionZ); - pos.m_orientation = m_orientation; + pos.SetOrientation(GetOrientation()); } void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float angle) { - angle += m_orientation; + angle += GetOrientation(); float destx, desty, destz, ground, floor; pos.m_positionZ += 2.0f; destx = pos.m_positionX + dist * cos(angle); @@ -3024,7 +3024,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float Trinity::NormalizeMapCoord(pos.m_positionX); Trinity::NormalizeMapCoord(pos.m_positionY); UpdateAllowedPositionZ(pos.m_positionX, pos.m_positionY, pos.m_positionZ); - pos.m_orientation = m_orientation; + pos.SetOrientation(GetOrientation()); } void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 3829e2f75f2..e3d940360f2 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -444,21 +444,24 @@ struct Position float m_positionX; float m_positionY; float m_positionZ; +// Better to limit access to m_orientation field, but this will be hard to achieve with many scripts using array initialization for this structure +//private: float m_orientation; +//public: void Relocate(float x, float y) { m_positionX = x; m_positionY = y;} void Relocate(float x, float y, float z) { m_positionX = x; m_positionY = y; m_positionZ = z; } void Relocate(float x, float y, float z, float orientation) - { m_positionX = x; m_positionY = y; m_positionZ = z; m_orientation = orientation; } + { m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation); } void Relocate(const Position &pos) - { m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; m_orientation = pos.m_orientation; } + { m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation); } void Relocate(const Position* pos) - { m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; m_orientation = pos->m_orientation; } + { m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation); } void RelocateOffset(const Position &offset); void SetOrientation(float orientation) - { m_orientation = orientation; } + { m_orientation = NormalizeOrientation(orientation); } float GetPositionX() const { return m_positionX; } float GetPositionY() const { return m_positionY; } @@ -525,6 +528,21 @@ struct Position bool HasInArc(float arcangle, const Position* pos) const; bool HasInLine(WorldObject const* target, float width) const; std::string ToString() const; + + // modulos a radian orientation to the range of 0..2PI + static 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 * static_cast<float>(M_PI)); + mod = -mod + 2.0f * static_cast<float>(M_PI); + return mod; + } + return fmod(o, 2.0f * static_cast<float>(M_PI)); + } }; ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer); ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 1e85afd47b1..1c164fffe3c 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2106,8 +2106,6 @@ void Player::SendTeleportPacket(Position &oldPos) bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options) { - orientation = MapManager::NormalizeOrientation(orientation); - if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) { sLog->outError(LOG_FILTER_MAPS, "TeleportTo: invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting player (GUID: %u, name: %s, map: %d, X: %f, Y: %f, Z: %f, O: %f).", @@ -16683,9 +16681,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) // init saved position, and fix it later if problematic uint32 transGUID = uint32(fields[31].GetUInt32()); - // used orientation 0-2pi range. Check for safe. - float orientation = MapManager::NormalizeOrientation(fields[16].GetFloat()); - Relocate(fields[12].GetFloat(), fields[13].GetFloat(), fields[14].GetFloat(), orientation); + Relocate(fields[12].GetFloat(), fields[13].GetFloat(), fields[14].GetFloat(), fields[16].GetFloat()); uint32 mapId = fields[15].GetUInt16(); uint32 instanceId = fields[54].GetUInt32(); @@ -16793,13 +16789,13 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) if (!Trinity::IsValidMapCoord( 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) || + GetPositionZ()+m_movementInfo.t_pos.m_positionZ, GetOrientation()+m_movementInfo.t_pos.GetOrientation()) || // transport size limited m_movementInfo.t_pos.m_positionX > 250 || m_movementInfo.t_pos.m_positionY > 250 || m_movementInfo.t_pos.m_positionZ > 250) { sLog->outError(LOG_FILTER_PLAYER, "Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to bind location.", 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); + GetPositionZ()+m_movementInfo.t_pos.m_positionZ, GetOrientation()+m_movementInfo.t_pos.GetOrientation()); RelocateToHomebind(); } diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 528784c018f..d5163d04297 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -678,7 +678,7 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, void Transport::UpdatePosition(MovementInfo* mi) { - float transport_o = mi->pos.m_orientation - mi->t_pos.m_orientation; + float transport_o = mi->pos.GetOrientation() - mi->t_pos.GetOrientation(); 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; @@ -707,7 +707,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 = MapManager::NormalizeOrientation(GetOrientation() + ino); + o = GetOrientation() + ino; x = GetPositionX() + (inx * cos(GetOrientation()) + iny * sin(GetOrientation() + M_PI)); y = GetPositionY() + (iny * cos(GetOrientation()) + inx * sin(GetOrientation())); z = GetPositionZ() + inz; @@ -716,7 +716,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 = MapManager::NormalizeOrientation(o - GetOrientation()); + o = 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 2319438c14a..727262d2e17 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -407,7 +407,7 @@ void Unit::UpdateSplinePosition() pos.m_positionX = loc.x; pos.m_positionY = loc.y; pos.m_positionZ = loc.z; - pos.m_orientation = loc.orientation; + pos.SetOrientation(loc.orientation); if (Unit* vehicle = GetVehicleBase()) { loc.x += vehicle->GetPositionX(); @@ -16722,7 +16722,6 @@ 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/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 3d36f6ccda5..50370ba48de 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -346,7 +346,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId) 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_pos.SetOrientation(0); unit->m_movementInfo.t_time = 0; // 1 for player unit->m_movementInfo.t_seat = seat->first; unit->m_movementInfo.t_guid = _me->GetGUID(); @@ -448,7 +448,7 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang) 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; + float po = ang + passenger->m_movementInfo.t_pos.GetOrientation(); passenger->UpdatePosition(px, py, pz, po); } diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index dbdc4ac04fe..193135c5067 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -748,7 +748,7 @@ void WorldSession::ReadMovementInfo(WorldPacket& data, MovementInfo* mi) break; case MSEOrientation: if (hasOrientation) - data >> mi->pos.m_orientation; + mi->pos.SetOrientation(data.read<float>()); break; case MSETransportPositionX: if (hasTransportData) @@ -764,7 +764,7 @@ void WorldSession::ReadMovementInfo(WorldPacket& data, MovementInfo* mi) break; case MSETransportOrientation: if (hasTransportData) - data >> mi->t_pos.m_orientation; + mi->pos.SetOrientation(data.read<float>()); break; case MSETransportSeat: if (hasTransportData) @@ -1023,7 +1023,7 @@ void WorldSession::WriteMovementInfo(WorldPacket &data, MovementInfo* mi) break; case MSEOrientation: if (hasOrientation) - data << mi->pos.m_orientation; + data << mi->pos.GetOrientation(); break; case MSETransportPositionX: if (hasTransportData) @@ -1039,7 +1039,7 @@ void WorldSession::WriteMovementInfo(WorldPacket &data, MovementInfo* mi) break; case MSETransportOrientation: if (hasTransportData) - data << mi->t_pos.m_orientation; + data << mi->t_pos.GetOrientation(); break; case MSETransportSeat: if (hasTransportData) diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h index aa07eef2204..8f5c3799161 100755 --- a/src/server/game/Maps/MapManager.h +++ b/src/server/game/Maps/MapManager.h @@ -104,21 +104,6 @@ class MapManager return IsValidMapCoord(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation()); } - // modulos a radian orientation to the range of 0..2PI - static 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 * static_cast<float>(M_PI)); - mod = -mod + 2.0f * static_cast<float>(M_PI); - return mod; - } - return fmod(o, 2.0f * static_cast<float>(M_PI)); - } - void DoDelayedMovesAndRemoves(); void LoadTransports(); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index ce41a776826..cbbc96b99d7 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -6053,7 +6053,7 @@ void Spell::EffectBind(SpellEffIndex effIndex) loc.m_positionX = st->target_X; loc.m_positionY = st->target_Y; loc.m_positionZ = st->target_Z; - loc.m_orientation = st->target_Orientation; + loc.SetOrientation(st->target_Orientation); area_id = player->GetAreaId(); } else diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index 479d234e27c..89a26bde6ff 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -303,7 +303,6 @@ class npc_coldflame : public CreatureScript { Position const* ownerPos = marrowgarAI->GetLastColdflamePosition(); float ang = me->GetAngle(ownerPos) - static_cast<float>(M_PI); - ang = MapManager::NormalizeOrientation(ang); me->SetOrientation(ang); owner->GetNearPosition(pos, 2.5f, 0.0f); } diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp index 6d9450daf21..aab54785213 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp @@ -121,7 +121,7 @@ public: coreEnergizeOrientation = me->GetOrientation(); firstCoreEnergize = true; } else - coreEnergizeOrientation = MapManager::NormalizeOrientation(coreEnergizeOrientation - 2.0f); + coreEnergizeOrientation = Position::NormalizeOrientation(coreEnergizeOrientation - 2.0f); DoCast(me, SPELL_ENERGIZE_CORES_VISUAL); events.ScheduleEvent(EVENT_ENERGIZE_CORES_VISUAL, 5000); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index 24a9171e29f..b414a3fcdcb 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -488,7 +488,7 @@ class spell_ulduar_squeezed_lifeless : public SpellScriptLoader pos.m_positionX = 1756.25f + irand(-3, 3); pos.m_positionY = -8.3f + irand(-3, 3); pos.m_positionZ = 448.8f; - pos.m_orientation = M_PI; + pos.SetOrientation(M_PI); GetHitPlayer()->DestroyForNearbyPlayers(); GetHitPlayer()->ExitVehicle(&pos); GetHitPlayer()->UpdateObjectVisibility(false); |