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

42 lines
985 B
C++
Raw Normal View History

#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->packetSpells.action, send);
if (!send)
player->packetSpells.spells.clear();
else
player->packetSpells.count = (unsigned int) (player->packetSpells.spells.size());
2016-11-21 21:40:50 +00:00
RW(player->packetSpells.count, send);
for (unsigned int i = 0; i < player->packetSpells.count; i++)
{
2016-12-29 13:19:26 +00:00
ESM::Spell spell;
if (send)
{
spell = player->packetSpells.spells[i];
2016-12-29 13:19:26 +00:00
RW(spell.mId, send);
}
else
{
2016-12-29 13:19:26 +00:00
RW(spell.mId, send);
player->packetSpells.spells.push_back(spell);
}
}
}