mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[7533] Redirect movement packet in proper way to controlled target.
* In creature case ignore fall/etc damage * In player case apply fall damage/etc to controlled player, apply other movement effect to it also.
This commit is contained in:
parent
f4482f247f
commit
cc11ff40fe
2 changed files with 48 additions and 55 deletions
|
|
@ -190,6 +190,9 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
|
|||
if (!MaNGOS::IsValidMapCoord(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o))
|
||||
return;
|
||||
|
||||
Unit *mover = _player->m_mover;
|
||||
Player *plMover = mover->GetTypeId()==TYPEID_PLAYER ? (Player*)mover : NULL;
|
||||
|
||||
/* handle special cases */
|
||||
if (movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT)
|
||||
{
|
||||
|
|
@ -203,24 +206,24 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
|
|||
return;
|
||||
|
||||
// if we boarded a transport, add us to it
|
||||
if (!GetPlayer()->m_transport)
|
||||
if (plMover && plMover->m_transport)
|
||||
{
|
||||
// elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
|
||||
for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
|
||||
{
|
||||
if ((*iter)->GetGUID() == movementInfo.t_guid)
|
||||
{
|
||||
GetPlayer()->m_transport = (*iter);
|
||||
(*iter)->AddPassenger(GetPlayer());
|
||||
plMover->m_transport = (*iter);
|
||||
(*iter)->AddPassenger(plMover);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GetPlayer()->m_transport) // if we were on a transport, leave
|
||||
else if (plMover && plMover->m_transport) // if we were on a transport, leave
|
||||
{
|
||||
GetPlayer()->m_transport->RemovePassenger(GetPlayer());
|
||||
GetPlayer()->m_transport = NULL;
|
||||
plMover->m_transport->RemovePassenger(plMover);
|
||||
plMover->m_transport = NULL;
|
||||
movementInfo.t_x = 0.0f;
|
||||
movementInfo.t_y = 0.0f;
|
||||
movementInfo.t_z = 0.0f;
|
||||
|
|
@ -230,78 +233,68 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
|
|||
}
|
||||
|
||||
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
|
||||
if (opcode == MSG_MOVE_FALL_LAND && !GetPlayer()->isInFlight())
|
||||
GetPlayer()->HandleFall(movementInfo);
|
||||
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->isInFlight())
|
||||
plMover->HandleFall(movementInfo);
|
||||
|
||||
if(((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != GetPlayer()->IsInWater())
|
||||
if (plMover && ((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != plMover->IsInWater())
|
||||
{
|
||||
// now client not include swimming flag in case jumping under water
|
||||
GetPlayer()->SetInWater( !GetPlayer()->IsInWater() || GetPlayer()->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z) );
|
||||
plMover->SetInWater( !plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z) );
|
||||
}
|
||||
|
||||
/*----------------------*/
|
||||
|
||||
/* process position-change */
|
||||
Unit *mover = _player->m_mover;
|
||||
recv_data.put<uint32>(6, getMSTime()); // fix time, offset flags(4) + unk(2)
|
||||
WorldPacket data(recv_data.GetOpcode(), (mover->GetPackGUID().size()+recv_data.size()));
|
||||
data.append(mover->GetPackGUID()); // use mover guid
|
||||
data.append(recv_data.contents(), recv_data.size());
|
||||
GetPlayer()->SendMessageToSet(&data, false);
|
||||
|
||||
if(!_player->GetCharmGUID()) // nothing is charmed
|
||||
if(plMover) // nothing is charmed, or player charmed
|
||||
{
|
||||
_player->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
|
||||
_player->m_movementInfo = movementInfo;
|
||||
_player->SetUnitMovementFlags(movementInfo.flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mover->GetTypeId() != TYPEID_PLAYER) // unit, creature, pet, vehicle...
|
||||
{
|
||||
if(Map *map = mover->GetMap())
|
||||
map->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
|
||||
mover->SetUnitMovementFlags(movementInfo.flags);
|
||||
}
|
||||
else // player
|
||||
{
|
||||
((Player*)mover)->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
|
||||
((Player*)mover)->m_movementInfo = movementInfo;
|
||||
((Player*)mover)->SetUnitMovementFlags(movementInfo.flags);
|
||||
}
|
||||
}
|
||||
plMover->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
|
||||
plMover->m_movementInfo = movementInfo;
|
||||
plMover->SetUnitMovementFlags(movementInfo.flags);
|
||||
|
||||
GetPlayer()->UpdateFallInformationIfNeed(movementInfo,MSG_MOVE_FALL_LAND);
|
||||
plMover->UpdateFallInformationIfNeed(movementInfo,recv_data.GetOpcode());
|
||||
|
||||
if(GetPlayer()->isMovingOrTurning())
|
||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||
if(plMover->isMovingOrTurning())
|
||||
plMover->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||
|
||||
if(movementInfo.z < -500.0f)
|
||||
{
|
||||
if(GetPlayer()->InBattleGround()
|
||||
&& GetPlayer()->GetBattleGround()
|
||||
&& GetPlayer()->GetBattleGround()->HandlePlayerUnderMap(_player))
|
||||
if(movementInfo.z < -500.0f)
|
||||
{
|
||||
// do nothing, the handle already did if returned true
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: this is actually called many times while falling
|
||||
// even after the player has been teleported away
|
||||
// TODO: discard movement packets after the player is rooted
|
||||
if(GetPlayer()->isAlive())
|
||||
if(plMover->InBattleGround()
|
||||
&& plMover->GetBattleGround()
|
||||
&& plMover->GetBattleGround()->HandlePlayerUnderMap(_player))
|
||||
{
|
||||
GetPlayer()->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth());
|
||||
// change the death state to CORPSE to prevent the death timer from
|
||||
// starting in the next player update
|
||||
GetPlayer()->KillPlayer();
|
||||
GetPlayer()->BuildPlayerRepop();
|
||||
// do nothing, the handle already did if returned true
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: this is actually called many times while falling
|
||||
// even after the player has been teleported away
|
||||
// TODO: discard movement packets after the player is rooted
|
||||
if(plMover->isAlive())
|
||||
{
|
||||
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth());
|
||||
// change the death state to CORPSE to prevent the death timer from
|
||||
// starting in the next player update
|
||||
plMover->KillPlayer();
|
||||
plMover->BuildPlayerRepop();
|
||||
}
|
||||
|
||||
// cancel the death timer here if started
|
||||
GetPlayer()->RepopAtGraveyard();
|
||||
// cancel the death timer here if started
|
||||
plMover->RepopAtGraveyard();
|
||||
}
|
||||
}
|
||||
}
|
||||
else // creature charmed
|
||||
{
|
||||
if(Map *map = mover->GetMap())
|
||||
map->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
|
||||
mover->SetUnitMovementFlags(movementInfo.flags);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7532"
|
||||
#define REVISION_NR "7533"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue