1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 20:49:56 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp
Koncord 690211ad99 [General] Extract BaseEvent & BasePlayer from packets to functions
Move Send and Read functions to BasePacket
2017-03-06 18:40:07 +08:00

42 lines
989 B
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerSpellbook.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerSpellbook::PacketPlayerSpellbook(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_SPELLBOOK;
}
void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->spellbookChanges.action, send);
if (!send)
player->spellbookChanges.spells.clear();
else
player->spellbookChanges.count = (unsigned int) (player->spellbookChanges.spells.size());
RW(player->spellbookChanges.count, send);
for (unsigned int i = 0; i < player->spellbookChanges.count; i++)
{
ESM::Spell spell;
if (send)
{
spell = player->spellbookChanges.spells.at(i);
}
RW(spell.mId, send);
if (!send)
{
player->spellbookChanges.spells.push_back(spell);
}
}
}