openmw-tes3coop/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp
Koncord 690211ad99 [General] Extract BaseEvent & BasePlayer from packets to functions
Move Send and Read functions to BasePacket
2017-03-06 18:40:07 +08:00

39 lines
968 B
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketScriptGlobalShort.hpp"
using namespace mwmp;
PacketScriptGlobalShort::PacketScriptGlobalShort(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
{
packetID = ID_SCRIPT_GLOBAL_SHORT;
}
void PacketScriptGlobalShort::Packet(RakNet::BitStream *bs, bool send)
{
WorldPacket::Packet(bs, send);
if (!send)
event->objectChanges.objects.clear();
else
event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size());
RW(event->objectChanges.count, send);
WorldObject worldObject;
for (unsigned int i = 0; i < event->objectChanges.count; i++)
{
if (send)
{
worldObject = event->objectChanges.objects.at(i);
}
RW(worldObject.varName, send);
RW(worldObject.shortVal, send);
if (!send)
{
event->objectChanges.objects.push_back(worldObject);
}
}
}