1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 21:19:57 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Worldstate/PacketWorldCollisionOverride.cpp
David Cernat 9102df7fde [General] Make WorldCollisionOverride also work with specific refIds
For now, this only makes it possible to enforce collision for specific refIds for placed objects.
2018-06-28 04:53:00 +03:00

38 lines
1.1 KiB
C++

#include "PacketWorldCollisionOverride.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace mwmp;
PacketWorldCollisionOverride::PacketWorldCollisionOverride(RakNet::RakPeerInterface *peer) : WorldstatePacket(peer)
{
packetID = ID_WORLD_COLLISION_OVERRIDE;
orderChannel = CHANNEL_WORLDSTATE;
}
void PacketWorldCollisionOverride::Packet(RakNet::BitStream *bs, bool send)
{
WorldstatePacket::Packet(bs, send);
RW(worldstate->hasPlayerCollision, send);
RW(worldstate->hasActorCollision, send);
RW(worldstate->hasPlacedObjectCollision, send);
RW(worldstate->useActorCollisionForPlacedObjects, send);
uint32_t enforcedCollisionCount;
if (send)
enforcedCollisionCount = static_cast<uint32_t>(worldstate->enforcedCollisionRefIds.size());
RW(enforcedCollisionCount, send);
if (!send)
{
worldstate->enforcedCollisionRefIds.clear();
worldstate->enforcedCollisionRefIds.resize(enforcedCollisionCount);
}
for (auto &&enforcedCollisionRefId : worldstate->enforcedCollisionRefIds)
{
RW(enforcedCollisionRefId, send);
}
}