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

44 lines
1 KiB
C++
Raw Normal View History

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerFaction.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerFaction::PacketPlayerFaction(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_FACTION;
}
void PacketPlayerFaction::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
2017-11-28 13:37:46 +00:00
uint32_t count;
if (send)
2017-11-28 13:37:46 +00:00
count = static_cast<uint32_t>(player->factionChanges.factions.size());
2017-11-28 13:37:46 +00:00
RW(count, send);
2017-11-29 11:00:22 +00:00
if (!send)
{
2017-11-28 13:37:46 +00:00
player->factionChanges.factions.clear();
player->factionChanges.factions.resize(count);
}
2017-11-28 13:37:46 +00:00
for (auto &&faction : player->factionChanges.factions)
{
2018-01-20 11:45:24 +00:00
RW(faction.changes, send, true);
2017-11-28 13:37:46 +00:00
RW(faction.factionId, send, true);
2018-01-20 11:45:24 +00:00
if (faction.isRankChanged())
RW(faction.rank, send);
2018-01-20 11:45:24 +00:00
if (faction.isExpulsionChanged())
RW(faction.isExpelled, send);
2018-01-20 11:45:24 +00:00
if (faction.isReputationChanged())
RW(faction.reputation, send);
}
}