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 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
|
|
|
}
|
|
|
|
|
2019-12-04 08:17:33 +00:00
|
|
|
void PacketPlayerSpellbook::Packet(RakNet::BitStream *newBitstream, bool send)
|
2016-11-21 00:28:05 +00:00
|
|
|
{
|
2019-12-04 08:17:33 +00:00
|
|
|
PlayerPacket::Packet(newBitstream, 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
|
|
|
|
2019-10-24 16:27:37 +00:00
|
|
|
uint32_t count;
|
|
|
|
|
2017-05-24 19:09:35 +00:00
|
|
|
if (send)
|
2019-10-24 16:27:37 +00:00
|
|
|
count = static_cast<uint32_t>(player->spellbookChanges.spells.size());
|
2016-11-21 21:40:50 +00:00
|
|
|
|
2019-10-24 16:27:37 +00:00
|
|
|
RW(count, send);
|
2016-11-21 04:07:29 +00:00
|
|
|
|
2019-10-24 16:27:37 +00:00
|
|
|
if (!send)
|
2016-11-21 04:07:29 +00:00
|
|
|
{
|
2019-10-24 16:27:37 +00:00
|
|
|
player->spellbookChanges.spells.clear();
|
|
|
|
player->spellbookChanges.spells.resize(count);
|
|
|
|
}
|
2017-02-05 12:56:27 +00:00
|
|
|
|
2019-10-24 16:27:37 +00:00
|
|
|
for (auto &&spell : player->spellbookChanges.spells)
|
|
|
|
{
|
2018-07-02 18:50:21 +00:00
|
|
|
RW(spell.mId, send, true);
|
2016-11-21 04:07:29 +00:00
|
|
|
}
|
2016-11-21 00:28:05 +00:00
|
|
|
}
|