You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw-tes3coop/components/openmw-mp/Packets/Player/PacketPlayerStatsDynamic.cpp

49 lines
1.2 KiB
C++

#include "PacketPlayerStatsDynamic.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace mwmp;
PacketPlayerStatsDynamic::PacketPlayerStatsDynamic(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_STATS_DYNAMIC;
}
void PacketPlayerStatsDynamic::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->exchangeFullInfo, send);
if (player->exchangeFullInfo)
{
RW(player->creatureStats.mDynamic, send);
}
else
{
uint32_t count;
if (send)
count = static_cast<uint32_t>(player->statsDynamicIndexChanges.size());
RW(count, send);
if (!send)
{
player->statsDynamicIndexChanges.clear();
player->statsDynamicIndexChanges.resize(count);
}
for (auto &&statsDynamicIndex : player->statsDynamicIndexChanges)
{
RW(statsDynamicIndex, send);
if (statsDynamicIndex >= 3)
{
packetValid = false;
return;
}
RW(player->creatureStats.mDynamic[statsDynamicIndex], send);
}
}
}