1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketPlayerAttribute.cpp

36 lines
873 B
C++
Raw Permalink Normal View History

#include "PacketPlayerAttribute.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace mwmp;
PacketPlayerAttribute::PacketPlayerAttribute(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_ATTRIBUTE;
}
void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
2017-11-28 14:10:27 +00:00
uint32_t count;
if (send)
count = static_cast<uint32_t>(player->attributeIndexChanges.size());
2017-11-28 13:37:46 +00:00
RW(count, send);
2017-11-29 11:00:22 +00:00
if (!send)
{
player->attributeIndexChanges.clear();
player->attributeIndexChanges.resize(count);
2017-11-28 13:37:46 +00:00
}
for (auto &&attributeIndex : player->attributeIndexChanges)
2017-11-28 13:37:46 +00:00
{
RW(attributeIndex, send);
2017-11-28 13:37:46 +00:00
RW(player->creatureStats.mAttributes[attributeIndex], send);
RW(player->npcStats.mSkillIncrease[attributeIndex], send);
}
}