Movement packets cleanup.

This commit is contained in:
tomrus88 2010-02-01 17:02:00 +03:00
parent 60f8b3874d
commit b85417df73
16 changed files with 436 additions and 485 deletions

View file

@ -1651,18 +1651,13 @@ 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_seat = -1;
m_movementInfo.t_time = 0;
m_movementInfo.SetTransportData(0, 0.0f, 0.0f, 0.0f, 0.0f, 0, -1);
}
// The player was ported to another map and looses the duel immediately.
// We have to perform this check before the teleport, otherwise the
// ObjectAccessor won't find the flag.
if (duel && GetMapId()!=mapid)
if (duel && GetMapId() != mapid)
{
GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER));
if (obj)
@ -1670,7 +1665,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
}
// reset movement flags at teleport, because player will continue move with these flags after teleport
m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE);
m_movementInfo.SetMovementFlags(MOVEFLAG_NONE);
if ((GetMapId() == mapid) && (!m_transport))
{
@ -1692,7 +1687,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!(options & TELE_TO_NOT_UNSUMMON_PET))
{
//same map, only remove pet if out of range for new position
if(pet && !pet->IsWithinDist3d(x,y,z,GetMap()->GetVisibilityDistance()))
if(pet && !pet->IsWithinDist3d(x, y, z, GetMap()->GetVisibilityDistance()))
UnsummonPetTemporaryIfAny();
}
@ -1784,18 +1779,27 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
data << uint32(mapid);
if (m_transport)
{
data << m_transport->GetEntry() << GetMapId();
data << uint32(m_transport->GetEntry());
data << uint32(GetMapId());
}
GetSession()->SendPacket(&data);
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);
data << float(m_movementInfo.GetTransportPos()->x);
data << float(m_movementInfo.GetTransportPos()->y);
data << float(m_movementInfo.GetTransportPos()->z);
data << float(m_movementInfo.GetTransportPos()->o);
}
else
{
data << (uint32)mapid << (float)x << (float)y << (float)z << (float)orientation;
data << uint32(mapid);
data << float(x);
data << float(y);
data << float(z);
data << float(orientation);
}
GetSession()->SendPacket( &data );
SendSavedInstances();
@ -1813,15 +1817,15 @@ 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.GetTransportPos()->x;
final_y += m_movementInfo.GetTransportPos()->y;
final_z += m_movementInfo.GetTransportPos()->z;
final_o += m_movementInfo.GetTransportPos()->o;
}
m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
SetFallInformation(0, final_z);
// if the player is saved before worldportack (at logout for example)
// if the player is saved before worldport ack (at logout for example)
// this will be used instead of the current location in SaveToDB
// move packet sent by client always after far teleport
@ -14721,12 +14725,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
transGUID = 0;
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_time = 0;
m_movementInfo.t_seat = -1;
m_movementInfo.SetTransportData(0, 0.0f, 0.0f, 0.0f, 0.0f, 0, -1);
}
_LoadBGData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBGDATA));
@ -14780,29 +14779,21 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if (transGUID != 0)
{
m_movementInfo.t_x = fields[27].GetFloat();
m_movementInfo.t_y = fields[28].GetFloat();
m_movementInfo.t_z = fields[29].GetFloat();
m_movementInfo.t_o = fields[30].GetFloat();
m_movementInfo.SetTransportData(transGUID, fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat(), fields[30].GetFloat(), 0, -1);
if( !MaNGOS::IsValidMapCoord(
GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y,
GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o) ||
GetPositionX() + m_movementInfo.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y,
GetPositionZ() + m_movementInfo.GetTransportPos()->z, GetOrientation() + m_movementInfo.GetTransportPos()->o) ||
// transport size limited
m_movementInfo.t_x > 50 || m_movementInfo.t_y > 50 || m_movementInfo.t_z > 50 )
m_movementInfo.GetTransportPos()->x > 50 || m_movementInfo.GetTransportPos()->y > 50 || m_movementInfo.GetTransportPos()->z > 50 )
{
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.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y,
GetPositionZ() + m_movementInfo.GetTransportPos()->z, GetOrientation() + m_movementInfo.GetTransportPos()->o);
RelocateToHomebind();
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_time = 0;
m_movementInfo.t_seat = -1;
m_movementInfo.SetTransportData(0, 0.0f, 0.0f, 0.0f, 0.0f, 0, -1);
transGUID = 0;
}
@ -14836,12 +14827,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
RelocateToHomebind();
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_time = 0;
m_movementInfo.t_seat = -1;
m_movementInfo.SetTransportData(0, 0.0f, 0.0f, 0.0f, 0.0f, 0, -1);
transGUID = 0;
}
@ -16199,10 +16185,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.GetTransportPos()->x) << ", ";
ss << finiteAlways(m_movementInfo.GetTransportPos()->y) << ", ";
ss << finiteAlways(m_movementInfo.GetTransportPos()->z) << ", ";
ss << finiteAlways(m_movementInfo.GetTransportPos()->o) << ", ";
if (m_transport)
ss << m_transport->GetGUIDLow();
else
@ -18883,7 +18869,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
// set fly flag if in fly form or taxi flight to prevent visually drop at ground in showup moment
if(HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || HasAuraType(SPELL_AURA_FLY) || isInFlight())
m_movementInfo.AddMovementFlag(MOVEMENTFLAG_FLYING);
m_movementInfo.AddMovementFlag(MOVEFLAG_FLYING);
m_mover = this;
}
@ -20182,7 +20168,7 @@ void Player::EnterVehicle(Vehicle *vehicle)
data.Initialize(MSG_MOVE_TELEPORT_ACK, 30);
data.append(GetPackGUID());
data << uint32(0); // counter?
data << uint32(MOVEMENTFLAG_ONTRANSPORT); // transport
data << uint32(MOVEFLAG_ONTRANSPORT); // transport
data << uint16(0); // special flags
data << uint32(getMSTime()); // time
data << vehicle->GetPositionX(); // x
@ -20231,7 +20217,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
WorldPacket data(MSG_MOVE_TELEPORT_ACK, 30);
data.append(GetPackGUID());
data << uint32(0); // counter?
data << uint32(MOVEMENTFLAG_FLY_UNK1); // fly unk
data << uint32(MOVEFLAG_FLY_UNK1); // fly unk
data << uint16(0x40); // special flags
data << uint32(getMSTime()); // time
data << vehicle->GetPositionX(); // x
@ -20244,7 +20230,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
RemovePetActionBar();
// maybe called at dummy aura remove?
// CastSpell(this, 45472, true); // Parachute
// CastSpell(this, 45472, true); // Parachute
}
bool Player::isTotalImmune()
@ -20616,7 +20602,7 @@ uint8 Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_s
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.GetPos()->z;
sLog.outDebug("zDiff = %f", z_diff);
//Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored
@ -20634,8 +20620,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.GetPos()->z;
UpdateGroundPositionZ(movementInfo.GetPos()->x, movementInfo.GetPos()->y, height);
if (damage > 0)
{
@ -20656,7 +20642,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.GetPos()->z, height, GetPositionZ(), movementInfo.GetFallTime(), height, damage, safe_fall);
}
}
}
@ -20920,16 +20906,16 @@ void Player::UpdateKnownCurrencies(uint32 itemId, bool apply)
if(CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemId))
{
if(apply)
SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES,(UI64LIT(1) << (ctEntry->BitIndex-1)));
SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES, (UI64LIT(1) << (ctEntry->BitIndex - 1)));
else
RemoveFlag64(PLAYER_FIELD_KNOWN_CURRENCIES,(UI64LIT(1) << (ctEntry->BitIndex-1)));
RemoveFlag64(PLAYER_FIELD_KNOWN_CURRENCIES, (UI64LIT(1) << (ctEntry->BitIndex - 1)));
}
}
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.GetFallTime() || m_lastFallZ <= minfo.GetPos()->z || opcode == MSG_MOVE_FALL_LAND)
SetFallInformation(minfo.GetFallTime(), minfo.GetPos()->z);
}
void Player::UnsummonPetTemporaryIfAny()