2017-04-05 01:06:45 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include "PacketActorList.hpp"
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-04-09 05:51:28 +00:00
|
|
|
PacketActorList::PacketActorList(RakNet::RakPeerInterface *peer) : ActorPacket(peer)
|
2017-04-05 01:06:45 +00:00
|
|
|
{
|
|
|
|
packetID = ID_ACTOR_LIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketActorList::Packet(RakNet::BitStream *bs, bool send)
|
|
|
|
{
|
2017-06-08 20:34:56 +00:00
|
|
|
if (!ActorPacket::PacketHeader(bs, send))
|
2017-06-02 19:42:10 +00:00
|
|
|
return;
|
2017-04-05 01:06:45 +00:00
|
|
|
|
2017-04-09 13:32:44 +00:00
|
|
|
RW(actorList->action, send);
|
2017-04-05 01:45:51 +00:00
|
|
|
|
2017-08-27 16:15:56 +00:00
|
|
|
BaseActor *actor;
|
2017-04-05 01:06:45 +00:00
|
|
|
|
2017-04-09 13:32:44 +00:00
|
|
|
for (unsigned int i = 0; i < actorList->count; i++)
|
2017-04-05 01:06:45 +00:00
|
|
|
{
|
|
|
|
if (send)
|
2017-08-27 16:15:56 +00:00
|
|
|
actor = actorList->baseActors.at(i).get();
|
|
|
|
else
|
|
|
|
actor = new BaseActor();
|
2017-04-05 01:06:45 +00:00
|
|
|
|
2017-08-27 16:15:56 +00:00
|
|
|
RW(actor->refId, send);
|
|
|
|
RW(actor->refNumIndex, send);
|
|
|
|
RW(actor->mpNum, send);
|
2017-04-05 01:06:45 +00:00
|
|
|
|
2017-08-27 16:15:56 +00:00
|
|
|
if (actor->refId.empty() || (actor->refNumIndex != 0 && actor->mpNum != 0))
|
2017-05-16 11:20:40 +00:00
|
|
|
{
|
|
|
|
actorList->isValid = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-05 01:06:45 +00:00
|
|
|
if (!send)
|
2017-08-27 16:15:56 +00:00
|
|
|
actorList->baseActors.push_back(std::shared_ptr<BaseActor>(actor));
|
2017-04-05 01:06:45 +00:00
|
|
|
}
|
|
|
|
}
|