mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 15:19:55 +00:00
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#include "PacketClientScriptSettings.hpp"
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
using namespace mwmp;
|
|
|
|
PacketClientScriptSettings::PacketClientScriptSettings(RakNet::RakPeerInterface *peer) : WorldstatePacket(peer)
|
|
{
|
|
packetID = ID_CLIENT_SCRIPT_SETTINGS;
|
|
orderChannel = CHANNEL_WORLDSTATE;
|
|
}
|
|
|
|
void PacketClientScriptSettings::Packet(RakNet::BitStream *newBitstream, bool send)
|
|
{
|
|
WorldstatePacket::Packet(newBitstream, send);
|
|
|
|
uint32_t clientScriptsCount;
|
|
|
|
if (send)
|
|
clientScriptsCount = static_cast<uint32_t>(worldstate->synchronizedClientScriptIds.size());
|
|
|
|
RW(clientScriptsCount, send);
|
|
|
|
if (!send)
|
|
{
|
|
worldstate->synchronizedClientScriptIds.clear();
|
|
worldstate->synchronizedClientScriptIds.resize(clientScriptsCount);
|
|
}
|
|
|
|
for (auto &&clientScriptId : worldstate->synchronizedClientScriptIds)
|
|
{
|
|
RW(clientScriptId, send, true);
|
|
}
|
|
|
|
uint32_t clientGlobalsCount;
|
|
|
|
if (send)
|
|
clientGlobalsCount = static_cast<uint32_t>(worldstate->synchronizedClientGlobalIds.size());
|
|
|
|
RW(clientGlobalsCount, send);
|
|
|
|
if (!send)
|
|
{
|
|
worldstate->synchronizedClientGlobalIds.clear();
|
|
worldstate->synchronizedClientGlobalIds.resize(clientGlobalsCount);
|
|
}
|
|
|
|
for (auto &&clientGlobalId : worldstate->synchronizedClientGlobalIds)
|
|
{
|
|
RW(clientGlobalId, send, true);
|
|
}
|
|
}
|