1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 00:49:54 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Actor/ActorPacket.cpp

78 lines
1.5 KiB
C++
Raw Normal View History

#include <components/openmw-mp/NetworkMessages.hpp>
#include <PacketPriority.h>
#include <RakPeer.h>
#include "ActorPacket.hpp"
using namespace mwmp;
ActorPacket::ActorPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
{
packetID = 0;
priority = HIGH_PRIORITY;
reliability = RELIABLE_ORDERED;
orderChannel = CHANNEL_ACTOR;
this->peer = peer;
}
ActorPacket::~ActorPacket()
{
}
void ActorPacket::setActorList(BaseActorList *newActorList)
{
actorList = newActorList;
guid = actorList->guid;
}
2017-05-28 07:23:16 +00:00
void ActorPacket::Packet(RakNet::BitStream *newBitstream, bool send)
2017-06-02 19:42:10 +00:00
{
if (!PacketHeader(newBitstream, send))
2017-06-02 19:42:10 +00:00
return;
BaseActor actor;
for (unsigned int i = 0; i < actorList->count; i++)
{
if (send)
actor = actorList->baseActors.at(i);
2017-06-02 19:42:10 +00:00
RW(actor.refNum, send);
2017-06-02 19:42:10 +00:00
RW(actor.mpNum, send);
Actor(actor, send);
if (!send)
actorList->baseActors.push_back(actor);
}
}
bool ActorPacket::PacketHeader(RakNet::BitStream *newBitstream, bool send)
2017-05-28 07:23:16 +00:00
{
BasePacket::Packet(newBitstream, send);
2017-05-28 07:23:16 +00:00
RW(actorList->cell.mData, send, true);
RW(actorList->cell.mName, send, true);
2017-06-02 19:42:10 +00:00
if (send)
actorList->count = (unsigned int)(actorList->baseActors.size());
else
actorList->baseActors.clear();
RW(actorList->count, send);
if (actorList->count > maxActors)
{
2017-06-02 19:42:10 +00:00
actorList->isValid = false;
return false;
}
2017-06-02 19:42:10 +00:00
return true;
2017-06-02 19:42:10 +00:00
}
void ActorPacket::Actor(BaseActor &actor, bool send)
{
2017-05-28 07:23:16 +00:00
}