コード例 #1
0
void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "MSG_MOVE_TELEPORT_ACK");

    BitStream mask = recv_data.ReadBitStream(8);

    uint32 flags, time;
    recv_data >> flags >> time;

    ByteBuffer bytes(8, true);
    recv_data.ReadXorByte(mask[6], bytes[1]);
    recv_data.ReadXorByte(mask[0], bytes[3]);
    recv_data.ReadXorByte(mask[1], bytes[2]);
    recv_data.ReadXorByte(mask[7], bytes[0]);
    recv_data.ReadXorByte(mask[5], bytes[6]);
    recv_data.ReadXorByte(mask[3], bytes[4]);
    recv_data.ReadXorByte(mask[2], bytes[7]);
    recv_data.ReadXorByte(mask[4], bytes[5]);

    uint64 guid = BitConverter::ToUInt64(bytes);

    sLog->outStaticDebug("Guid " UI64FMTD, guid);
    sLog->outStaticDebug("Flags %u, time %u", flags, time/IN_MILLISECONDS);

    Unit* mover = _player->_mover;
    Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;

    if (!plMover || !plMover->IsBeingTeleportedNear())
        return;

    if (guid != plMover->GetGUID())
        return;

    plMover->SetSemaphoreTeleportNear(false);

    uint32 old_zone = plMover->GetZoneId();

    WorldLocation const& dest = plMover->GetTeleportDest();

    plMover->UpdatePosition(dest, true);

    uint32 newzone, newarea;
    plMover->GetZoneAndAreaId(newzone, newarea);
    plMover->UpdateZone(newzone, newarea);

    // new zone
    if (old_zone != newzone)
    {
        // honorless target
        if (plMover->pvpInfo.inHostileArea)
            plMover->CastSpell(plMover, 2479, true);

        // in friendly area
        else if (plMover->IsPvP() && !plMover->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
            plMover->UpdatePvP(false, false);
    }

    // resummon pet
    GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();

    //lets process all delayed operations on successful teleport
    GetPlayer()->ProcessDelayedOperations();
}