1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-22 19:53:52 +00:00
openmw-tes3mp/components/openmw-mp/Packets/World/PacketContainer.cpp
David Cernat 3d5860d6f4 Merge pull request #396 from TES3MP/0.6.3 while resolving conflicts
Conflicts:
	apps/openmw-mp/Player.cpp
	apps/openmw-mp/Script/Functions/Settings.cpp
	apps/openmw-mp/Script/Functions/Settings.hpp
	apps/openmw-mp/Script/Functions/World.cpp
	apps/openmw-mp/Script/Functions/World.hpp
	apps/openmw/mwgui/container.cpp
	apps/openmw/mwmp/LocalActor.cpp
	apps/openmw/mwmp/LocalPlayer.cpp
	apps/openmw/mwmp/WorldEvent.cpp
	apps/openmw/mwmp/processors/world/ProcessorContainer.hpp
	components/openmw-mp/Base/BaseEvent.hpp
	components/openmw-mp/Log.cpp
	components/openmw-mp/Log.hpp
2018-03-30 09:32:43 +03:00

54 lines
1.4 KiB
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include "PacketContainer.hpp"
using namespace mwmp;
PacketContainer::PacketContainer(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
{
packetID = ID_CONTAINER;
hasCellData = true;
}
void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
{
if (!PacketHeader(bs, send))
return;
RW(event->action, send);
RW(event->containerSubAction, send);
for (auto &&worldObject : event->worldObjects)
{
Object(worldObject, send);
if (send)
{
worldObject.containerItemCount = (unsigned int) (worldObject.containerItems.size());
}
RW(worldObject.containerItemCount, send);
if (!send)
{
worldObject.containerItems.clear();
worldObject.containerItems.resize(worldObject.containerItemCount);
}
if (worldObject.containerItemCount > maxObjects || worldObject.refId.empty()
|| (worldObject.refNumIndex != 0 && worldObject.mpNum != 0))
{
event->isValid = false;
return;
}
for (auto &&containerItem: worldObject.containerItems)
{
RW(containerItem.refId, send);
RW(containerItem.count, send);
RW(containerItem.charge, send);
RW(containerItem.enchantmentCharge, send);
RW(containerItem.actionCount, send);
}
}
}