2017-02-04 11:14:37 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include "PacketContainer.hpp"
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
|
|
|
PacketContainer::PacketContainer(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
|
|
|
{
|
|
|
|
packetID = ID_CONTAINER;
|
|
|
|
}
|
|
|
|
|
2017-03-06 09:44:08 +00:00
|
|
|
void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
|
2017-02-04 11:14:37 +00:00
|
|
|
{
|
2017-03-06 09:44:08 +00:00
|
|
|
WorldPacket::Packet(bs, send);
|
2017-02-04 18:14:39 +00:00
|
|
|
|
2017-02-15 18:14:25 +00:00
|
|
|
RW(event->action, send);
|
2017-02-04 19:32:06 +00:00
|
|
|
|
2017-02-15 18:14:25 +00:00
|
|
|
if (send)
|
2017-02-04 19:32:06 +00:00
|
|
|
{
|
2017-02-15 18:14:25 +00:00
|
|
|
event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size());
|
2017-02-04 19:32:06 +00:00
|
|
|
}
|
2017-02-04 18:14:39 +00:00
|
|
|
else
|
|
|
|
{
|
2017-02-15 18:14:25 +00:00
|
|
|
event->objectChanges.objects.clear();
|
2017-02-04 18:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RW(event->objectChanges.count, send);
|
|
|
|
|
|
|
|
RW(event->cell.mData.mFlags, send);
|
|
|
|
RW(event->cell.mData.mX, send);
|
|
|
|
RW(event->cell.mData.mY, send);
|
|
|
|
RW(event->cell.mName, send);
|
|
|
|
|
|
|
|
WorldObject worldObject;
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < event->objectChanges.count; i++)
|
|
|
|
{
|
|
|
|
if (send)
|
|
|
|
{
|
2017-02-05 17:01:06 +00:00
|
|
|
worldObject = event->objectChanges.objects.at(i);
|
2017-02-15 18:14:25 +00:00
|
|
|
worldObject.containerChanges.count = (unsigned int)(worldObject.containerChanges.items.size());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
worldObject.containerChanges.items.clear();
|
2017-02-04 18:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RW(worldObject.refId, send);
|
|
|
|
RW(worldObject.refNumIndex, send);
|
2017-04-04 07:16:09 +00:00
|
|
|
RW(worldObject.mpNum, send);
|
2017-02-15 18:14:25 +00:00
|
|
|
RW(worldObject.containerChanges.count, send);
|
2017-02-04 18:14:39 +00:00
|
|
|
|
2017-02-15 18:14:25 +00:00
|
|
|
ContainerItem containerItem;
|
2017-02-04 18:14:39 +00:00
|
|
|
|
2017-02-15 18:14:25 +00:00
|
|
|
for (unsigned int i = 0; i < worldObject.containerChanges.count; i++)
|
2017-02-04 18:14:39 +00:00
|
|
|
{
|
2017-02-15 18:14:25 +00:00
|
|
|
if (send)
|
|
|
|
{
|
|
|
|
containerItem = worldObject.containerChanges.items.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
RW(containerItem.refId, send);
|
|
|
|
RW(containerItem.count, send);
|
|
|
|
RW(containerItem.charge, send);
|
|
|
|
RW(containerItem.actionCount, send);
|
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
|
|
|
worldObject.containerChanges.items.push_back(containerItem);
|
|
|
|
}
|
2017-02-04 18:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
2017-02-15 18:14:25 +00:00
|
|
|
event->objectChanges.objects.push_back(worldObject);
|
2017-02-04 18:14:39 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-04 11:14:37 +00:00
|
|
|
}
|