[General] Add PreInit packet

0.6.1
Koncord 8 years ago
parent 0d53a6916d
commit 0c1905e842

@ -173,7 +173,7 @@ add_component_dir (openmw-mp
Packets/World/PacketVideoPlay
Packets/World/PacketScriptLocalShort Packets/World/PacketScriptLocalFloat Packets/World/PacketScriptMemberShort
Packets/World/PacketScriptGlobalShort)
Packets/World/PacketScriptGlobalShort Packets/PacketPreInit)
add_component_dir (fallback
fallback validate

@ -58,7 +58,8 @@ enum GameMessages
ID_SCRIPT_MEMBER_SHORT,
ID_SCRIPT_GLOBAL_SHORT,
ID_GAME_CONSOLE
ID_GAME_CONSOLE,
ID_GAME_PREINIT
};

@ -0,0 +1,38 @@
//
// Created by koncord on 05.03.17.
//
#include <components/openmw-mp/NetworkMessages.hpp>
#include <boost/foreach.hpp>
#include "PacketPreInit.hpp"
mwmp::PacketPreInit::PacketPreInit(RakNet::RakPeerInterface *peer) : BasePacket(peer)
{
packetID = ID_GAME_PREINIT;
}
void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, RakNet::RakNetGUID &guid, bool send, PluginContainer &checksums)
{
BasePacket::Packet(bs, guid, send);
unsigned int size = checksums.size();
RW(size, send);
if(send)
{
BOOST_FOREACH(PluginContainer::value_type & checksum, checksums)
{
RW(checksum.first, true);
RW(checksum.second, true);
}
}
else
{
for(unsigned int i = 0; i < size; i++)
{
PluginPair checksum;
RW(checksum.first, false);
RW(checksum.second, false);
checksums.push_back(checksum);
}
}
}

@ -0,0 +1,27 @@
//
// Created by koncord on 05.03.17.
//
#ifndef OPENMW_PACKETPREINIT_HPP
#define OPENMW_PACKETPREINIT_HPP
#include <vector>
#include "BasePacket.hpp"
namespace mwmp
{
class PacketPreInit : public BasePacket
{
public:
typedef std::pair<std::string, unsigned int> PluginPair;
typedef std::vector<PluginPair> PluginContainer;
PacketPreInit(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, RakNet::RakNetGUID &guid, bool send, PluginContainer &checksums);
};
}
#endif //OPENMW_PACKETPREINIT_HPP
Loading…
Cancel
Save