forked from teamnwah/openmw-tes3coop
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.5 KiB
C++
78 lines
1.5 KiB
C++
#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 *actorList)
|
|
{
|
|
this->actorList = actorList;
|
|
guid = actorList->guid;
|
|
}
|
|
|
|
void ActorPacket::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
if (!PacketHeader(bs, send))
|
|
return;
|
|
|
|
BaseActor actor;
|
|
|
|
for (unsigned int i = 0; i < actorList->count; i++)
|
|
{
|
|
if (send)
|
|
actor = actorList->baseActors.at(i);
|
|
|
|
RW(actor.refNum, send);
|
|
RW(actor.mpNum, send);
|
|
|
|
Actor(actor, send);
|
|
|
|
if (!send)
|
|
actorList->baseActors.push_back(actor);
|
|
}
|
|
}
|
|
|
|
bool ActorPacket::PacketHeader(RakNet::BitStream *bs, bool send)
|
|
{
|
|
BasePacket::Packet(bs, send);
|
|
|
|
RW(actorList->cell.mData, send, true);
|
|
RW(actorList->cell.mName, send, true);
|
|
|
|
if (send)
|
|
actorList->count = (unsigned int)(actorList->baseActors.size());
|
|
else
|
|
actorList->baseActors.clear();
|
|
|
|
RW(actorList->count, send);
|
|
|
|
if (actorList->count > maxActors)
|
|
{
|
|
actorList->isValid = false;
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
void ActorPacket::Actor(BaseActor &actor, bool send)
|
|
{
|
|
|
|
}
|