openmw-tes3coop/components/openmw-mp/Packets/Player/PacketPlayerAttribute.cpp

36 lines
920 B
C++
Raw 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)
2017-11-28 14:10:27 +00:00
count = static_cast<uint32_t>(player->attributeChanges.attributeIndexes.size());
2017-11-28 13:37:46 +00:00
RW(count, send);
2017-11-28 13:37:46 +00:00
if(!send)
{
2017-11-28 13:37:46 +00:00
player->attributeChanges.attributeIndexes.clear();
player->attributeChanges.attributeIndexes.resize(count);
}
2017-11-28 13:37:46 +00:00
for (auto &&attributeIndex : player->attributeChanges.attributeIndexes)
{
RW(attributeIndex, send);
2017-11-28 13:37:46 +00:00
RW(player->creatureStats.mAttributes[attributeIndex], send);
RW(player->npcStats.mSkillIncrease[attributeIndex], send);
}
}