2017-05-16 16:25:31 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <components/openmw-mp/Log.hpp>
|
|
|
|
#include "PacketActorEquipment.hpp"
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
|
|
|
PacketActorEquipment::PacketActorEquipment(RakNet::RakPeerInterface *peer) : ActorPacket(peer)
|
|
|
|
{
|
|
|
|
packetID = ID_ACTOR_EQUIPMENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketActorEquipment::Packet(RakNet::BitStream *bs, bool send)
|
|
|
|
{
|
|
|
|
ActorPacket::Packet(bs, send);
|
|
|
|
|
2017-05-24 19:09:35 +00:00
|
|
|
if (send)
|
2017-05-16 16:25:31 +00:00
|
|
|
actorList->count = (unsigned int)(actorList->baseActors.size());
|
2017-05-24 19:09:35 +00:00
|
|
|
else
|
|
|
|
actorList->baseActors.clear();
|
2017-05-16 16:25:31 +00:00
|
|
|
|
|
|
|
RW(actorList->count, send);
|
|
|
|
|
2017-06-01 22:35:32 +00:00
|
|
|
if (actorList->count > maxActors)
|
|
|
|
{
|
|
|
|
actorList->isValid = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-16 16:25:31 +00:00
|
|
|
BaseActor actor;
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < actorList->count; i++)
|
|
|
|
{
|
|
|
|
if (send)
|
|
|
|
{
|
|
|
|
actor = actorList->baseActors.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
RW(actor.refNumIndex, send);
|
|
|
|
RW(actor.mpNum, send);
|
|
|
|
|
2017-05-26 19:53:28 +00:00
|
|
|
for (int j = 0; j < 19; j++)
|
2017-05-26 01:37:49 +00:00
|
|
|
{
|
2017-05-26 19:53:28 +00:00
|
|
|
RW(actor.equipedItems[j].refId, send);
|
|
|
|
RW(actor.equipedItems[j].count, send);
|
|
|
|
RW(actor.equipedItems[j].charge, send);
|
2017-05-26 01:37:49 +00:00
|
|
|
}
|
|
|
|
|
2017-05-16 16:25:31 +00:00
|
|
|
if (!send)
|
|
|
|
{
|
|
|
|
actorList->baseActors.push_back(actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|