1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-22 21:53:50 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Actor/PacketActorFrame.cpp

78 lines
2.1 KiB
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include "PacketActorFrame.hpp"
using namespace mwmp;
PacketActorFrame::PacketActorFrame(RakNet::RakPeerInterface *peer) : ActorPacket(peer)
{
packetID = ID_ACTOR_FRAME;
}
void PacketActorFrame::Packet(RakNet::BitStream *bs, bool send)
{
ActorPacket::Packet(bs, send);
if (!send)
event->objectChanges.objects.clear();
else
event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size());
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)
{
worldObject = event->objectChanges.objects.at(i);
}
RW(worldObject.refId, send);
RW(worldObject.refNumIndex, send);
RW(worldObject.mpNum, send);
RW(worldObject.pos, send);
RW(worldObject.drawState, send);
RW(worldObject.headPitch, send);
RW(worldObject.headYaw, send);
RW(worldObject.hasAnimation, send);
RW(worldObject.hasAnimStates, send);
RW(worldObject.hasMovement, send);
if (worldObject.hasAnimation)
{
RW(worldObject.animation.groupname, send);
RW(worldObject.animation.mode, send);
RW(worldObject.animation.count, send);
RW(worldObject.animation.persist, send);
}
if (worldObject.hasAnimStates)
{
RW(worldObject.animStates.idlestate, send);
RW(worldObject.animStates.movestate, send);
RW(worldObject.animStates.jumpstate, send);
RW(worldObject.animStates.forcestateupdate, send);
}
if (worldObject.hasMovement)
{
RW(worldObject.movement.x, send);
RW(worldObject.movement.y, send);
RW(worldObject.movement.y, send);
}
if (!send)
{
event->objectChanges.objects.push_back(worldObject);
}
}
}