2017-02-04 12:25:43 +00:00
|
|
|
#include "PacketPlayerAttribute.hpp"
|
2018-04-19 14:26:20 +00:00
|
|
|
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-02-04 12:25:43 +00:00
|
|
|
PacketPlayerAttribute::PacketPlayerAttribute(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-02-04 12:25:43 +00:00
|
|
|
packetID = ID_PLAYER_ATTRIBUTE;
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 09:44:08 +00:00
|
|
|
void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-03-06 09:44:08 +00:00
|
|
|
PlayerPacket::Packet(bs, send);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2018-04-26 18:56:14 +00:00
|
|
|
RW(player->exchangeFullInfo, send);
|
2018-04-19 14:26:20 +00:00
|
|
|
|
2018-04-26 18:56:14 +00:00
|
|
|
if (player->exchangeFullInfo)
|
2018-04-19 14:26:20 +00:00
|
|
|
{
|
2018-04-26 18:56:14 +00:00
|
|
|
RW(player->creatureStats.mAttributes, send);
|
|
|
|
RW(player->npcStats.mSkillIncrease, send);
|
2018-04-19 20:28:03 +00:00
|
|
|
}
|
2018-04-26 18:56:14 +00:00
|
|
|
else
|
2018-04-19 20:28:03 +00:00
|
|
|
{
|
2018-04-26 18:56:14 +00:00
|
|
|
uint32_t count;
|
|
|
|
|
|
|
|
if (send)
|
|
|
|
count = static_cast<uint32_t>(player->attributeIndexChanges.size());
|
|
|
|
|
|
|
|
RW(count, send);
|
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
|
|
|
player->attributeIndexChanges.clear();
|
|
|
|
player->attributeIndexChanges.resize(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &&attributeIndex : player->attributeIndexChanges)
|
|
|
|
{
|
|
|
|
RW(attributeIndex, send);
|
2018-04-19 12:18:38 +00:00
|
|
|
|
2018-04-26 18:56:14 +00:00
|
|
|
RW(player->creatureStats.mAttributes[attributeIndex], send);
|
|
|
|
RW(player->npcStats.mSkillIncrease[attributeIndex], send);
|
|
|
|
}
|
2018-04-19 14:26:20 +00:00
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|