mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-22 07:53:51 +00:00
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include <components/openmw-mp/Log.hpp>
|
|
#include "PacketContainer.hpp"
|
|
|
|
using namespace mwmp;
|
|
|
|
PacketContainer::PacketContainer(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
|
{
|
|
packetID = ID_CONTAINER;
|
|
hasCellData = true;
|
|
}
|
|
|
|
void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
if (!PacketHeader(bs, send))
|
|
return;
|
|
|
|
RW(event->action, send);
|
|
|
|
for (auto &&worldObject : event->worldObjects)
|
|
{
|
|
Object(worldObject, send);
|
|
|
|
if (send)
|
|
{
|
|
worldObject.containerItemCount = (unsigned int) (worldObject.containerItems.size());
|
|
}
|
|
|
|
RW(worldObject.containerItemCount, send);
|
|
|
|
if (!send)
|
|
{
|
|
worldObject.containerItems.clear();
|
|
worldObject.containerItems.resize(worldObject.containerItemCount);
|
|
}
|
|
|
|
if (worldObject.containerItemCount > maxObjects || worldObject.refId.empty()
|
|
|| (worldObject.refNumIndex != 0 && worldObject.mpNum != 0))
|
|
{
|
|
event->isValid = false;
|
|
return;
|
|
}
|
|
|
|
for (auto &&containerItem: worldObject.containerItems)
|
|
{
|
|
RW(containerItem.refId, send);
|
|
RW(containerItem.count, send);
|
|
RW(containerItem.charge, send);
|
|
RW(containerItem.actionCount, send);
|
|
}
|
|
}
|
|
}
|