1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 00:49:54 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketSpellbook.cpp
David Cernat 33e85c54de Rename BasePlayer Inventory & Spellbook into PacketItems & PacketSpells
This avoids confusion when either of those is used to store and send a single item, and no longer requires coming up with confusing variable names like realSpellbook or realInventory for actual full spellbooks and inventories.
2017-01-19 18:06:59 +02:00

41 lines
985 B
C++

#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());
RW(player->packetSpells.count, send);
for (unsigned int i = 0; i < player->packetSpells.count; i++)
{
ESM::Spell spell;
if (send)
{
spell = player->packetSpells.spells[i];
RW(spell.mId, send);
}
else
{
RW(spell.mId, send);
player->packetSpells.spells.push_back(spell);
}
}
}