2017-04-16 06:00:18 +00:00
|
|
|
#include "PacketPlayerStatsDynamic.hpp"
|
2018-04-26 18:56:14 +00:00
|
|
|
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-04-16 06:00:18 +00:00
|
|
|
PacketPlayerStatsDynamic::PacketPlayerStatsDynamic(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-04-16 06:00:18 +00:00
|
|
|
packetID = ID_PLAYER_STATS_DYNAMIC;
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 08:17:33 +00:00
|
|
|
void PacketPlayerStatsDynamic::Packet(RakNet::BitStream *newBitstream, bool send)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2019-12-04 08:17:33 +00:00
|
|
|
PlayerPacket::Packet(newBitstream, send);
|
2018-04-20 21:43:49 +00:00
|
|
|
|
2018-04-26 18:56:14 +00:00
|
|
|
RW(player->exchangeFullInfo, send);
|
2018-04-20 21:43:49 +00:00
|
|
|
|
2018-04-26 18:56:14 +00:00
|
|
|
if (player->exchangeFullInfo)
|
2018-04-20 21:43:49 +00:00
|
|
|
{
|
2018-04-26 18:56:14 +00:00
|
|
|
RW(player->creatureStats.mDynamic, send);
|
2018-04-20 21:43:49 +00:00
|
|
|
}
|
2018-04-26 18:56:14 +00:00
|
|
|
else
|
2018-04-20 21:43:49 +00:00
|
|
|
{
|
2018-04-26 18:56:14 +00:00
|
|
|
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);
|
2018-07-03 10:40:11 +00:00
|
|
|
if (statsDynamicIndex >= 3)
|
|
|
|
{
|
|
|
|
packetValid = false;
|
|
|
|
return;
|
|
|
|
}
|
2018-04-26 18:56:14 +00:00
|
|
|
RW(player->creatureStats.mDynamic[statsDynamicIndex], send);
|
|
|
|
}
|
2018-04-20 21:43:49 +00:00
|
|
|
}
|
2017-01-26 04:17:29 +00:00
|
|
|
}
|