2016-11-21 00:28:05 +00:00
|
|
|
#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);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
|
|
|
RW(player->spellbook.action, send);
|
|
|
|
|
|
|
|
if (!send)
|
|
|
|
player->spellbook.spells.clear();
|
|
|
|
else
|
|
|
|
player->spellbook.count = (unsigned int) (player->spellbook.spells.size());
|
2016-11-21 21:40:50 +00:00
|
|
|
|
2016-11-21 04:07:29 +00:00
|
|
|
RW(player->spellbook.count, send);
|
|
|
|
|
2016-12-21 08:02:08 +00:00
|
|
|
for (unsigned int i = 0; i < player->spellbook.count; i++)
|
2016-11-21 04:07:29 +00:00
|
|
|
{
|
|
|
|
Spell spell;
|
|
|
|
|
|
|
|
if (send)
|
|
|
|
{
|
|
|
|
spell = player->spellbook.spells[i];
|
|
|
|
RW(spell.id, send);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RW(spell.id, send);
|
|
|
|
player->spellbook.spells.push_back(spell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-21 00:28:05 +00:00
|
|
|
}
|