mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 20:49:56 +00:00
35 lines
804 B
C++
35 lines
804 B
C++
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include "PacketPlayerSpellbook.hpp"
|
|
|
|
using namespace std;
|
|
using namespace mwmp;
|
|
|
|
PacketPlayerSpellbook::PacketPlayerSpellbook(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
|
{
|
|
packetID = ID_PLAYER_SPELLBOOK;
|
|
}
|
|
|
|
void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
PlayerPacket::Packet(bs, send);
|
|
|
|
RW(player->spellbookChanges.action, send);
|
|
|
|
uint32_t count;
|
|
|
|
if (send)
|
|
count = static_cast<uint32_t>(player->spellbookChanges.spells.size());
|
|
|
|
RW(count, send);
|
|
|
|
if (!send)
|
|
{
|
|
player->spellbookChanges.spells.clear();
|
|
player->spellbookChanges.spells.resize(count);
|
|
}
|
|
|
|
for (auto &&spell : player->spellbookChanges.spells)
|
|
{
|
|
RW(spell.mId, send, true);
|
|
}
|
|
}
|