2017-05-16 16:25:31 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include "PacketPlayerFaction.hpp"
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
|
|
|
PacketPlayerFaction::PacketPlayerFaction(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
|
|
|
{
|
|
|
|
packetID = ID_PLAYER_FACTION;
|
|
|
|
}
|
|
|
|
|
2019-12-04 08:17:33 +00:00
|
|
|
void PacketPlayerFaction::Packet(RakNet::BitStream *newBitstream, bool send)
|
2017-05-16 16:25:31 +00:00
|
|
|
{
|
2019-12-04 08:17:33 +00:00
|
|
|
PlayerPacket::Packet(newBitstream, send);
|
2017-05-18 16:27:20 +00:00
|
|
|
|
2017-07-05 04:05:52 +00:00
|
|
|
RW(player->factionChanges.action, send);
|
|
|
|
|
2019-10-26 08:42:40 +00:00
|
|
|
uint32_t count;
|
|
|
|
|
2017-05-24 18:43:34 +00:00
|
|
|
if (send)
|
2019-10-26 08:42:40 +00:00
|
|
|
count = static_cast<uint32_t>(player->factionChanges.factions.size());
|
2017-05-18 16:27:20 +00:00
|
|
|
|
2019-10-26 08:42:40 +00:00
|
|
|
RW(count, send);
|
2017-05-18 16:27:20 +00:00
|
|
|
|
2019-10-26 08:42:40 +00:00
|
|
|
if (!send)
|
2017-05-18 16:27:20 +00:00
|
|
|
{
|
2019-10-26 08:42:40 +00:00
|
|
|
player->factionChanges.factions.clear();
|
|
|
|
player->factionChanges.factions.resize(count);
|
|
|
|
}
|
2017-05-18 16:27:20 +00:00
|
|
|
|
2019-10-26 08:42:40 +00:00
|
|
|
for (auto &&faction : player->factionChanges.factions)
|
|
|
|
{
|
2018-07-02 18:50:21 +00:00
|
|
|
RW(faction.factionId, send, true);
|
2017-07-05 04:05:52 +00:00
|
|
|
|
2017-07-08 09:27:48 +00:00
|
|
|
if (player->factionChanges.action == FactionChanges::RANK)
|
2017-07-05 04:05:52 +00:00
|
|
|
RW(faction.rank, send);
|
|
|
|
|
2017-07-08 09:27:48 +00:00
|
|
|
if (player->factionChanges.action == FactionChanges::EXPULSION)
|
2017-07-07 05:12:48 +00:00
|
|
|
RW(faction.isExpelled, send);
|
2017-05-18 16:27:20 +00:00
|
|
|
|
2017-07-13 10:36:00 +00:00
|
|
|
if (player->factionChanges.action == FactionChanges::REPUTATION)
|
|
|
|
RW(faction.reputation, send);
|
2017-05-18 16:27:20 +00:00
|
|
|
}
|
2017-05-16 16:25:31 +00:00
|
|
|
}
|