2017-05-24 16:01:28 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include "PacketObjectTrap.hpp"
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
|
|
|
PacketObjectTrap::PacketObjectTrap(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
|
|
|
{
|
|
|
|
packetID = ID_OBJECT_TRAP;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketObjectTrap::Packet(RakNet::BitStream *bs, bool send)
|
|
|
|
{
|
|
|
|
WorldPacket::Packet(bs, send);
|
|
|
|
|
2017-05-24 19:09:35 +00:00
|
|
|
if (send)
|
2017-05-24 16:01:28 +00:00
|
|
|
event->worldObjectCount = (unsigned int)(event->worldObjects.size());
|
2017-05-24 19:09:35 +00:00
|
|
|
else
|
|
|
|
event->worldObjects.clear();
|
2017-05-24 16:01:28 +00:00
|
|
|
|
|
|
|
RW(event->worldObjectCount, 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->worldObjectCount; i++)
|
|
|
|
{
|
|
|
|
if (send)
|
|
|
|
{
|
|
|
|
worldObject = event->worldObjects.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
RW(worldObject.refId, send);
|
|
|
|
RW(worldObject.refNumIndex, send);
|
|
|
|
RW(worldObject.mpNum, send);
|
2017-05-25 22:28:43 +00:00
|
|
|
RW(worldObject.isDisarmed, send);
|
|
|
|
|
|
|
|
if (!worldObject.isDisarmed)
|
|
|
|
RW(worldObject.position, send);
|
2017-05-24 16:01:28 +00:00
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
|
|
|
event->worldObjects.push_back(worldObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|