当前位置: 首页>>代码示例>>C++>>正文


C++ MovementInfo::CorrectData方法代码示例

本文整理汇总了C++中MovementInfo::CorrectData方法的典型用法代码示例。如果您正苦于以下问题:C++ MovementInfo::CorrectData方法的具体用法?C++ MovementInfo::CorrectData怎么用?C++ MovementInfo::CorrectData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MovementInfo的用法示例。


在下文中一共展示了MovementInfo::CorrectData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleMoverRelocation

void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo)
{
    Unit *mover = _player->GetMover();
    movementInfo.CorrectData(mover);

    if (Player* plMover = mover->ToPlayer())
    {
        // ignore current relocation if needed
        if (plMover->IsNextRelocationIgnored())
        {
            plMover->DoIgnoreRelocation();
            return;
        }

        if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT))
        {
            GetPlayer()->GetCheatData()->OnTransport(plMover, movementInfo.GetTransportGuid());
            Unit* loadPetOnTransport = nullptr;
            if (!plMover->GetTransport())
                if (Transport* t = plMover->GetMap()->GetTransport(movementInfo.GetTransportGuid()))
                {
                    t->AddPassenger(plMover);
                    if (Pet* pet = plMover->GetPet())
                        if (pet->GetTransport() != t)
                            loadPetOnTransport = pet;
                }
            if (plMover->GetTransport())
            {
                movementInfo.pos.x = movementInfo.GetTransportPos()->x;
                movementInfo.pos.y = movementInfo.GetTransportPos()->y;
                movementInfo.pos.z = movementInfo.GetTransportPos()->z;
                movementInfo.pos.o = movementInfo.GetTransportPos()->o;
                plMover->GetTransport()->CalculatePassengerPosition(movementInfo.pos.x, movementInfo.pos.y, movementInfo.pos.z, &movementInfo.pos.o);
                if (loadPetOnTransport)
                {
                    loadPetOnTransport->NearTeleportTo(movementInfo.pos.x, movementInfo.pos.y, movementInfo.pos.z, movementInfo.pos.o);
                    plMover->GetTransport()->AddPassenger(loadPetOnTransport);
                }
            }
        }
        else if (plMover->GetTransport())
        {
            plMover->GetTransport()->RemovePassenger(plMover);
            if (Pet* pet = plMover->GetPet())
            {
                // If moving on transport, stop it.
                pet->DisableSpline();
                if (pet->GetTransport())
                {
                    pet->GetTransport()->RemovePassenger(pet);
                    pet->NearTeleportTo(movementInfo.pos.x, movementInfo.pos.y, movementInfo.pos.z, movementInfo.pos.o);
                }
            }
        }

        if (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING) != plMover->IsInWater())
        {
            // now client not include swimming flag in case jumping under water
            plMover->SetInWater(!plMover->IsInWater() || plMover->GetTerrain()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z));
        }

        plMover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
        plMover->m_movementInfo = movementInfo;

        // super smart decision; rework required
        if (ObjectGuid lootGuid = plMover->GetLootGuid())
            plMover->SendLootRelease(lootGuid);

        // Nostalrius - antiundermap1
        if (movementInfo.HasMovementFlag(MOVEFLAG_FALLINGFAR))
        {
            float hauteur = plMover->GetMap()->GetHeight(plMover->GetPositionX(), plMover->GetPositionY(), plMover->GetPositionZ(), true);
            bool undermap = false;
            // Undermap
            if ((plMover->GetPositionZ() + 100.0f) < hauteur)
                undermap = true;
            if (plMover->GetPositionZ() < 250.0f && plMover->GetMapId() == 489)
                undermap = true;

            if (undermap)
                if (plMover->UndermapRecall())
                    sLog.outInfo("[UNDERMAP] %s [GUID %u]. MapId:%u %f %f %f", plMover->GetName(), plMover->GetGUIDLow(), plMover->GetMapId(), plMover->GetPositionX(), plMover->GetPositionY(), plMover->GetPositionZ());
        }
        else if (plMover->CanFreeMove())
            plMover->SaveNoUndermapPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z + 3.0f);
        // Antiundermap2: teleportation au cimetiere
        if (movementInfo.GetPos()->z < -500.0f)
        {
            // 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())
            {
                // Nostalrius : pas mort quand on chute
                if (plMover->InBattleGround())
                    plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetHealth());
                else
                    plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetHealth() / 2);
                // pl can be alive if GM/etc
                if (!plMover->isAlive())
//.........这里部分代码省略.........
开发者ID:Maduse,项目名称:server,代码行数:101,代码来源:MovementHandler.cpp


注:本文中的MovementInfo::CorrectData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。