<commit_before>/*
Copyright (c) 2014-2020 AscEmu Team <http://www.ascemu.org>
This file is released under the MIT license. See README-MIT for more information.
*/

#pragma once
#include <cstdint>

#include "ManagedPacket.h"

namespace AscEmu::Packets
{
    class SmsgSetPhaseShift : public ManagedPacket
    {
#if VERSION_STRING > TBC
    public:
        uint32_t phaseId;
        WoWGuid guid;
        uint32_t phaseFlags;
        uint32_t mapId;

        SmsgSetPhaseShift() : SmsgSetPhaseShift(0, WoWGuid())
        {
        }

        SmsgSetPhaseShift(uint32_t phaseId, WoWGuid guid, uint32_t phaseFlags = 0, uint32_t mapId = 0) :
            ManagedPacket(SMSG_SET_PHASE_SHIFT, 4),
            phaseId(phaseId),
            guid(guid),
            phaseFlags(phaseFlags),
            mapId(mapId)
        {
        }

    protected:
        size_t expectedSize() const override { return m_minimum_size; }

        bool internalSerialise(WorldPacket& packet) override
        {
#if VERSION_STRING < Cata
            packet << phaseId;

#elif VERSION_STRING == Cata
            packet.writeBit(guid[2]);
            packet.writeBit(guid[3]);
            packet.writeBit(guid[1]);
            packet.writeBit(guid[6]);
            packet.writeBit(guid[4]);
            packet.writeBit(guid[5]);
            packet.writeBit(guid[0]);
            packet.writeBit(guid[7]);

            packet.WriteByteSeq(guid[7]);
            packet.WriteByteSeq(guid[4]);

            packet << uint32_t(0);              // size AreaId swaps

            packet.WriteByteSeq(guid[1]);

            packet << uint32_t(phaseFlags);     // flags

            packet.WriteByteSeq(guid[2]);
            packet.WriteByteSeq(guid[6]);

            packet << uint32_t(0);              // unknown

            packet << uint32_t(1);              // size phaseIds
            packet << uint16_t(phaseId);

            packet.WriteByteSeq(guid[3]);
            packet.WriteByteSeq(guid[0]);

            packet << uint32_t(1);              // size visible mapIds
            packet << uint16_t(mapId);

            packet.WriteByteSeq(guid[5]);

#elif VERSION_STRING == Mop
            packet.writeBit(guid[0]);
            packet.writeBit(guid[3]);
            packet.writeBit(guid[1]);
            packet.writeBit(guid[4]);
            packet.writeBit(guid[6]);
            packet.writeBit(guid[2]);
            packet.writeBit(guid[7]);<commit_msg>Update SmsgSetPhaseShift.h<commit_after>/*
Copyright (c) 2014-2020 AscEmu Team <http://www.ascemu.org>
This file is released under the MIT license. See README-MIT for more information.
*/

#pragma once
#include <cstdint>

#include "ManagedPacket.h"

namespace AscEmu::Packets
{
    class SmsgSetPhaseShift : public ManagedPacket
    {
#if VERSION_STRING > TBC
    public:
        uint32_t phaseId;
        WoWGuid guid;
        uint32_t phaseFlags;
        uint32_t mapId;

        SmsgSetPhaseShift() : SmsgSetPhaseShift(0, WoWGuid())
        {
        }

        SmsgSetPhaseShift(uint32_t phaseId, WoWGuid guid, uint32_t phaseFlags = 0, uint32_t mapId = 0) :
            ManagedPacket(SMSG_SET_PHASE_SHIFT, 4),
            phaseId(phaseId),
            guid(guid),
            phaseFlags(phaseFlags),
            mapId(mapId)
        {
        }

    protected:
        size_t expectedSize() const override { return m_minimum_size; }

        bool internalSerialise(WorldPacket& packet) override
        {
#if VERSION_STRING < Cata
            packet << phaseId;

#elif VERSION_STRING == Cata
            packet.writeBit(guid[2]);
            packet.writeBit(guid[3]);
            packet.writeBit(guid[1]);
            packet.writeBit(guid[6]);
            packet.writeBit(guid[4]);
            packet.writeBit(guid[5]);
            packet.writeBit(guid[0]);
            packet.writeBit(guid[7]);

            packet.WriteByteSeq(guid[7]);
            packet.WriteByteSeq(guid[4]);

            packet << uint32_t(0);              // size AreaId swaps

            packet.WriteByteSeq(guid[1]);

            packet << uint32_t(phaseFlags);     // flags

            packet.WriteByteSeq(guid[2]);
            packet.WriteByteSeq(guid[6]);

            packet << uint32_t(0);              // unknown

            packet << uint32_t(1 * 2);          // size phaseIds
            packet << uint16_t(phaseId);

            packet.WriteByteSeq(guid[3]);
            packet.WriteByteSeq(guid[0]);

            packet << uint32_t(1);              // size visible mapIds
            packet << uint16_t(mapId);

            packet.WriteByteSeq(guid[5]);

#elif VERSION_STRING == Mop
            packet.writeBit(guid[0]);
            packet.writeBit(guid[3]);
            packet.writeBit(guid[1]);
            packet.writeBit(guid[4]);
            packet.writeBit(guid[6]);
            packet.writeBit(guid[2]);
            packet.writeBit(guid[7]);
{'fraction_non_alphanumeric': 0.11501334976381188, 'fraction_numerical': 0.026904908605463133, 'mean_word_length': 1.9179149191132414, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4254439', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1445, 'n_words': 265}