Rename "SetPosition" to "UpdatePosition".

Replace CreatureRelocation in scripts with new Creature::SetPosition.
This commit is contained in:
megamage
2011-10-10 17:08:01 -04:00
parent 76c9c30c2b
commit d156e066cf
33 changed files with 74 additions and 59 deletions
+16 -1
View File
@@ -2387,6 +2387,7 @@ const char* Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const
return GetName();
}
//TODO: This may cause crash. Creature must be removed from the original grid and added to the new grid.
void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
{
InterruptNonMeleeSpells(true);
@@ -2401,7 +2402,21 @@ void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
SetMap(map);
AddToWorld();
SetPosition(X, Y, Z, O, true);
UpdatePosition(X, Y, Z, O, true);
}
void Creature::SetPosition(float x, float y, float z, float o)
{
// prevent crash when a bad coord is sent by the client
if (!Trinity::IsValidMapCoord(x, y, z, o))
{
sLog->outDebug(LOG_FILTER_UNITS, "Creature::SetPosition(%f, %f, %f) .. bad coordinates!", x, y, z);
return;
}
GetMap()->CreatureRelocation(ToCreature(), x, y, z, o);
if (IsVehicle())
GetVehicleKit()->RelocatePassengers(x, y, z, o);
}
bool Creature::IsDungeonBoss() const
@@ -664,6 +664,9 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
return m_charmInfo->GetCharmSpell(pos)->GetAction();
}
void SetPosition(float x, float y, float z, float o);
void SetPosition(const Position &pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
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); }
+3 -3
View File
@@ -6727,9 +6727,9 @@ ActionButton const* Player::GetActionButton(uint8 button)
return &buttonItr->second;
}
bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport)
bool Player::UpdatePosition(float x, float y, float z, float orientation, bool teleport)
{
if (!Unit::SetPosition(x, y, z, orientation, teleport))
if (!Unit::UpdatePosition(x, y, z, orientation, teleport))
return false;
//if (movementInfo.flags & MOVEMENTFLAG_MOVING)
@@ -6743,7 +6743,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
// code block for underwater state update
// Unit::SetPosition() checks for validity and updates our coordinates
// Unit::UpdatePosition() checks for validity and updates our coordinates
// so we re-fetch them instead of using "raw" coordinates from function params
UpdateUnderwaterState(GetMap(), GetPositionX(), GetPositionY(), GetPositionZ());
+2 -2
View File
@@ -1937,8 +1937,8 @@ class 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); }
virtual bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false);
bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
void UpdateUnderwaterState(Map* m, float x, float y, float z);
void SendMessageToSet(WorldPacket* data, bool self) {SendMessageToSetInRange(data, GetVisibilityRange(), self); };// overwrite Object::SendMessageToSet
+3 -3
View File
@@ -17151,16 +17151,16 @@ void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool cas
{
// FIXME: this interrupts spell visual
DestroyForNearbyPlayers();
SetPosition(x, y, z, orientation, true);
UpdatePosition(x, y, z, orientation, true);
}
}
bool Unit::SetPosition(float x, float y, float z, float orientation, bool teleport)
bool Unit::UpdatePosition(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(LOG_FILTER_UNITS, "Unit::SetPosition(%f, %f, %f) .. bad coordinates!", x, y, z);
sLog->outDebug(LOG_FILTER_UNITS, "Unit::UpdatePosition(%f, %f, %f) .. bad coordinates!", x, y, z);
return false;
}
+2 -2
View File
@@ -1600,9 +1600,9 @@ class Unit : public WorldObject
void SendSpellDamageImmune(Unit* target, uint32 spellId);
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);
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false);
// returns true if unit's position really changed
bool SetPosition(const Position &pos, bool teleport = false) { return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(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);
+1 -1
View File
@@ -445,7 +445,7 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang)
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);
passenger->UpdatePosition(px, py, pz, po);
}
}