aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Server/Packets/WorldStatePackets.cpp
blob: f085e52e5ef0e39929bcf8c021fad9a6fa933876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "WorldStatePackets.h"
#include "PacketOperators.h"

namespace WorldPackets::WorldState
{
WorldPacket const* InitWorldStates::Write()
{
    _worldPacket.reserve(16 + Worldstates.size() * 8);

    _worldPacket << int32(MapID);
    _worldPacket << int32(AreaID);
    _worldPacket << int32(SubareaID);

    _worldPacket << Size<uint32>(Worldstates);
    for (WorldStateInfo const& wsi : Worldstates)
    {
        _worldPacket << int32(wsi.VariableID);
        _worldPacket << int32(wsi.Value);
    }

    return &_worldPacket;
}

WorldPacket const* UpdateWorldState::Write()
{
    _worldPacket << uint32(VariableID);
    _worldPacket << int32(Value);
    _worldPacket << Bits<1>(Hidden);
    _worldPacket.FlushBits();

    return &_worldPacket;
}
}