1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 05:49:56 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Worldstate/PacketWorldKillCount.cpp
David Cernat d163f1b6da [General] Turn WorldKillCount into a Worldstate packet
Rename the old WorldKillCount that was a Player packet into PlayerPlaceholder. Rename the unused CellCreate that was a Worldstate packet into WorldKillCount. On the server, move kill count-related script functions from QuestFunctions to WorldstateFunctions.
2019-10-08 11:09:08 +03:00

34 lines
835 B
C++

#include "PacketWorldKillCount.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace mwmp;
PacketWorldKillCount::PacketWorldKillCount(RakNet::RakPeerInterface *peer) : WorldstatePacket(peer)
{
packetID = ID_WORLD_KILL_COUNT;
orderChannel = CHANNEL_SYSTEM;
}
void PacketWorldKillCount::Packet(RakNet::BitStream *bs, bool send)
{
WorldstatePacket::Packet(bs, send);
uint32_t killChangesCount;
if (send)
killChangesCount = static_cast<uint32_t>(worldstate->killChanges.size());
RW(killChangesCount, send);
if (!send)
{
worldstate->killChanges.clear();
worldstate->killChanges.resize(killChangesCount);
}
for (auto &&killChange : worldstate->killChanges)
{
RW(killChange.refId, send, true);
RW(killChange.number, send);
}
}