mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-11-04 13:26:54 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			62 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#include <components/openmw-mp/NetworkMessages.hpp>
 | 
						|
#include <components/openmw-mp/TimedLog.hpp>
 | 
						|
#include "PacketContainer.hpp"
 | 
						|
 | 
						|
using namespace mwmp;
 | 
						|
 | 
						|
PacketContainer::PacketContainer(RakNet::RakPeerInterface *peer) : ObjectPacket(peer)
 | 
						|
{
 | 
						|
    packetID = ID_CONTAINER;
 | 
						|
    hasCellData = true;
 | 
						|
}
 | 
						|
 | 
						|
void PacketContainer::Packet(RakNet::BitStream *newBitstream, bool send)
 | 
						|
{
 | 
						|
    if (!PacketHeader(newBitstream, send))
 | 
						|
        return;
 | 
						|
 | 
						|
    RW(objectList->action, send);
 | 
						|
    RW(objectList->containerSubAction, send);
 | 
						|
 | 
						|
    BaseObject baseObject;
 | 
						|
    for (unsigned int i = 0; i < objectList->baseObjectCount; i++)
 | 
						|
    {
 | 
						|
        if (send)
 | 
						|
        {
 | 
						|
            baseObject = objectList->baseObjects.at(i);
 | 
						|
            baseObject.containerItemCount = (unsigned int) (baseObject.containerItems.size());
 | 
						|
        }
 | 
						|
        else
 | 
						|
            baseObject.containerItems.clear();
 | 
						|
 | 
						|
        Object(baseObject, send);
 | 
						|
 | 
						|
        RW(baseObject.containerItemCount, send);
 | 
						|
 | 
						|
        if (baseObject.containerItemCount > maxObjects || baseObject.refId.empty() || (baseObject.refNum != 0 && baseObject.mpNum != 0))
 | 
						|
        {
 | 
						|
            objectList->isValid = false;
 | 
						|
            return;
 | 
						|
        }
 | 
						|
 | 
						|
        ContainerItem containerItem;
 | 
						|
 | 
						|
        for (unsigned int j = 0; j < baseObject.containerItemCount; j++)
 | 
						|
        {
 | 
						|
            if (send)
 | 
						|
                containerItem = baseObject.containerItems.at(j);
 | 
						|
 | 
						|
            RW(containerItem.refId, send, true);
 | 
						|
            RW(containerItem.count, send);
 | 
						|
            RW(containerItem.charge, send);
 | 
						|
            RW(containerItem.enchantmentCharge, send);
 | 
						|
            RW(containerItem.soul, send, true);
 | 
						|
            RW(containerItem.actionCount, send);
 | 
						|
 | 
						|
            if (!send)
 | 
						|
                baseObject.containerItems.push_back(containerItem);
 | 
						|
        }
 | 
						|
        if (!send)
 | 
						|
            objectList->baseObjects.push_back(baseObject);
 | 
						|
    }
 | 
						|
}
 |