1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-24 09:23:51 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Worldstate/PacketClientScriptSettings.cpp
David Cernat 3acfbad55d [General] Implement ClientScriptSettings packet, part 1
For starters, the new packet can set which client scripts have all of their variables synchronized between players. The previous hardcoded list of IDs for synchronized scripts has been removed.
2019-09-09 10:28:35 +03:00

33 lines
900 B
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 *bs, bool send)
{
WorldstatePacket::Packet(bs, 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);
}
}