2016-11-21 00:28:05 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
2017-02-05 07:01:33 +00:00
|
|
|
#include "PacketPlayerSpellbook.hpp"
|
2016-11-21 00:28:05 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-02-05 07:01:33 +00:00
|
|
|
PacketPlayerSpellbook::PacketPlayerSpellbook(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
2016-11-21 00:28:05 +00:00
|
|
|
{
|
2017-02-05 07:01:33 +00:00
|
|
|
packetID = ID_PLAYER_SPELLBOOK;
|
2016-11-21 00:28:05 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 09:44:08 +00:00
|
|
|
void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
|
2016-11-21 00:28:05 +00:00
|
|
|
{
|
2017-03-06 09:44:08 +00:00
|
|
|
PlayerPacket::Packet(bs, send);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
RW(player->spellbookChanges.action, send);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
|
|
|
if (!send)
|
2017-01-20 10:43:05 +00:00
|
|
|
player->spellbookChanges.spells.clear();
|
2016-11-21 04:07:29 +00:00
|
|
|
else
|
2017-01-20 10:43:05 +00:00
|
|
|
player->spellbookChanges.count = (unsigned int) (player->spellbookChanges.spells.size());
|
2016-11-21 21:40:50 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
RW(player->spellbookChanges.count, send);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
for (unsigned int i = 0; i < player->spellbookChanges.count; i++)
|
2016-11-21 04:07:29 +00:00
|
|
|
{
|
2016-12-29 13:19:26 +00:00
|
|
|
ESM::Spell spell;
|
2016-11-21 04:07:29 +00:00
|
|
|
|
|
|
|
if (send)
|
|
|
|
{
|
2017-02-05 17:01:06 +00:00
|
|
|
spell = player->spellbookChanges.spells.at(i);
|
2016-11-21 04:07:29 +00:00
|
|
|
}
|
2017-02-05 12:56:27 +00:00
|
|
|
|
|
|
|
RW(spell.mId, send);
|
|
|
|
|
|
|
|
if (!send)
|
2016-11-21 04:07:29 +00:00
|
|
|
{
|
2017-01-20 10:43:05 +00:00
|
|
|
player->spellbookChanges.spells.push_back(spell);
|
2016-11-21 04:07:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-21 00:28:05 +00:00
|
|
|
}
|