1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 17:19:56 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketSpellbook.cpp

41 lines
949 B
C++

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