aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsilver1ce <none@none>2010-01-18 21:51:45 +0200
committersilver1ce <none@none>2010-01-18 21:51:45 +0200
commitcfca61b176f1e262e71fa3ba2372ddd631d36c58 (patch)
tree3d948de297d9268adadfc49af40a0646bb04cb28
parentf920a3c57b716712a4eaf2530aae8b6005dc3cfb (diff)
Auras with turn/move interrupt flags are now removed for creatures when they turn/move, cleanup
--HG-- branch : trunk
-rw-r--r--src/game/Map.cpp3
-rw-r--r--src/game/MovementHandler.cpp18
-rw-r--r--src/game/Player.cpp22
-rw-r--r--src/game/Player.h2
-rw-r--r--src/game/Traveller.h2
-rw-r--r--src/game/Unit.cpp36
-rw-r--r--src/game/Unit.h2
-rw-r--r--src/game/Vehicle.cpp22
8 files changed, 51 insertions, 56 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index a9219d0f624..247bf7efafa 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -1048,9 +1048,6 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang
AddNotifier<Creature>(creature);
}
- if (creature->IsVehicle())
- creature->GetVehicleKit()->RelocatePassengers(x,y,z,ang);
-
assert(CheckGridIntegrity(creature,true));
}
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index d2e87926c0b..a3a2c536dd3 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -215,7 +215,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
WorldLocation const& dest = plMover->GetTeleportDest();
- plMover->SetPosition(dest, true);
+ plMover->SetPosition(dest);
uint32 newzone, newarea;
plMover->GetZoneAndAreaId(newzone, newarea);
@@ -365,20 +365,6 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
plMover->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
- // If on vehicle, update carried players
- if (Vehicle *vehicle=plMover->GetVehicleKit())
- {
- if (plMover->IsVehicle())
- {
- for (int i=0; i < 8; ++i)
- {
- if (Unit *passenger = vehicle->GetPassenger(i))
- if (passenger != NULL && passenger->GetTypeId() == TYPEID_PLAYER)
- ((Player*)passenger)->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
- }
- }
- }
-
if (movementInfo.z < -500.0f)
{
if (plMover->InBattleGround()
@@ -412,7 +398,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
}
else // creature charmed
{
- mover->GetMap()->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
+ mover->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
/*if(mover->canFly())
{
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 4bbd4fbbac7..b1db9d75107 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -5978,12 +5978,8 @@ void Player::removeActionButton(uint8 button)
bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport)
{
- // prevent crash when a bad coord is sent by the client
- if (!Trinity::IsValidMapCoord(x,y,z,orientation))
- {
- sLog.outDebug("Player::SetPosition(%f, %f, %f, %f, %d) .. bad coordinates for player %d!",x,y,z,orientation,teleport,GetGUIDLow());
+ if (!Unit::SetPosition(x, y, z, orientation, teleport))
return false;
- }
//if(movementInfo.flags & MOVEMENTFLAG_MOVING)
// mover->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE);
@@ -5991,22 +5987,10 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele
// mover->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING);
//AURA_INTERRUPT_FLAG_JUMP not sure
- bool turn = (GetOrientation() != orientation);
bool move2d = (teleport || GetPositionX() != x || GetPositionY() != y);
- if (turn)
- RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING);
-
if (move2d || GetPositionZ() != z)
{
- RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE);
-
- // move and update visible state if need
- GetMap()->PlayerRelocation(this, x, y, z, orientation);
-
- // reread after Map::Relocation
- GetPosition(x, y, z);
-
// group update
if (move2d && GetGroup())
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
@@ -6014,13 +5998,11 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele
// code block for underwater state update
UpdateUnderwaterState(GetMap(), x, y, z);
- if(GetTrader() && !IsWithinDistInMap(GetTrader(), 5))
+ if(GetTrader() && !IsWithinDistInMap(GetTrader(), INTERACTION_DISTANCE))
GetSession()->SendCancelTrade();
CheckExploreSystem();
}
- else if(turn)
- SetOrientation(orientation);
return true;
}
diff --git a/src/game/Player.h b/src/game/Player.h
index f399a26ca8b..208f5d990d4 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1790,8 +1790,8 @@ class TRINITY_DLL_SPEC Player : public Unit, public GridObject<Player>
void SendResetInstanceFailed(uint32 reason, uint32 MapId);
void SendResetFailedNotify(uint32 mapid);
+ virtual bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
bool SetPosition(const Position &pos, bool teleport = false) { return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
- bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
void UpdateUnderwaterState( Map * m, float x, float y, float z );
void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet
diff --git a/src/game/Traveller.h b/src/game/Traveller.h
index 61f3b17513d..3eb63879d80 100644
--- a/src/game/Traveller.h
+++ b/src/game/Traveller.h
@@ -88,7 +88,7 @@ inline float Traveller<Creature>::Speed()
template<>
inline void Traveller<Creature>::Relocation(float x, float y, float z, float orientation)
{
- i_traveller.GetMap()->CreatureRelocation(&i_traveller, x, y, z, orientation);
+ i_traveller.SetPosition(x, y, z, orientation);
}
template<>
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 232438ebf40..2d2db26ef89 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -15902,7 +15902,7 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca
// FIXME: this interrupts spell visual
DestroyForNearbyPlayers();
- GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation);
+ SetPosition(x, y, z, orientation, true);
//ObjectAccessor::UpdateObjectVisibility(this);
//WorldPacket data;
@@ -15913,6 +15913,40 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca
}
}
+bool Unit::SetPosition(float x, float y, float z, float orientation, bool teleport)
+{
+ // prevent crash when a bad coord is sent by the client
+ if (!Trinity::IsValidMapCoord(x,y))
+ {
+ sLog.outDebug("Unit::SetPosition(%f, %f, %f) .. bad coordinates!",x,y,z);
+ return false;
+ }
+
+ bool turn = (GetOrientation() != orientation);
+ bool relocated = (teleport || GetPositionX() != x || GetPositionY() != y || GetPositionZ() != z);
+
+ if (turn)
+ RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING);
+
+ if (relocated)
+ {
+ RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE);
+
+ // move and update visible state if need
+ if(GetTypeId() == TYPEID_PLAYER)
+ GetMap()->PlayerRelocation((Player*)this, x, y, z, orientation);
+ else
+ GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation);
+ }
+ else if(turn)
+ SetOrientation(orientation);
+
+ if ((relocated || turn) && IsVehicle())
+ GetVehicleKit()->RelocatePassengers(x,y,z,orientation);
+
+ return true;
+}
+
void Unit::SendThreatListUpdate()
{
if (uint32 count = getThreatManager().getThreatList().size())
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 592922ee6c4..f9c0116b256 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1425,6 +1425,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo);
void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false);
+ virtual bool SetPosition(float x, float y, float z, float ang, bool teleport = false);
+ bool SetPosition(const Position &pos, bool teleport = false) { return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
void KnockbackFrom(float x, float y, float speedXY, float speedZ);
void JumpTo(float speedXY, float speedZ, bool forward = true);
diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
index d7ad2d31baa..2ff217e912e 100644
--- a/src/game/Vehicle.cpp
+++ b/src/game/Vehicle.cpp
@@ -321,8 +321,8 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
if(((Creature*)me)->IsAIEnabled)
((Creature*)me)->AI()->PassengerBoarded(unit, seat->first, true);
- // move self = move all passengers
- me->GetMap()->CreatureRelocation((Creature*)me, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
+ // update all passenger's positions
+ RelocatePassengers(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
}
}
@@ -385,18 +385,12 @@ 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)
{
- if (passenger->GetTypeId() == TYPEID_PLAYER)
- map->PlayerRelocation((Player*)passenger,
- x + passenger->m_movementInfo.t_x,
- y + passenger->m_movementInfo.t_y,
- z + passenger->m_movementInfo.t_z,
- ang + passenger->m_movementInfo.t_o);
- else
- map->CreatureRelocation((Creature*)passenger,
- x + passenger->m_movementInfo.t_x,
- y + passenger->m_movementInfo.t_y,
- z + passenger->m_movementInfo.t_z,
- ang + passenger->m_movementInfo.t_o);
+ 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;
+
+ passenger->SetPosition(px, py, pz, po);
}
}