2019-09-09 07:28:35 +00:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2019-12-04 08:17:33 +00:00
|
|
|
void PacketClientScriptSettings::Packet(RakNet::BitStream *newBitstream, bool send)
|
2019-09-09 07:28:35 +00:00
|
|
|
{
|
2019-12-04 08:17:33 +00:00
|
|
|
WorldstatePacket::Packet(newBitstream, send);
|
2019-09-09 07:28:35 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-12-04 09:01:50 +00:00
|
|
|
RW(clientScriptId, send, true);
|
2019-09-09 07:28:35 +00:00
|
|
|
}
|
2019-09-14 06:37:19 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-12-04 09:01:50 +00:00
|
|
|
RW(clientGlobalId, send, true);
|
2019-09-14 06:37:19 +00:00
|
|
|
}
|
2019-09-09 07:28:35 +00:00
|
|
|
}
|