forked from teamnwah/openmw-tes3coop
[Server] Send server plugin list to client
This commit is contained in:
parent
931a5896ec
commit
bda9a76d29
2 changed files with 20 additions and 14 deletions
|
@ -209,13 +209,13 @@ void Networking::update(RakNet::Packet *packet)
|
|||
{
|
||||
for (int i = 0; plugin != plugins.end(); plugin++, i++)
|
||||
{
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "- %X\t%s", plugin->second, plugin->first.c_str());
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "- %X\t%s", plugin->second[0], plugin->first.c_str());
|
||||
if (samples[i].first == plugin->first) // if name is correct
|
||||
{
|
||||
auto &hashList = samples[i].second;
|
||||
if (hashList.empty()) // and server do not allow to have custom hash for plugin
|
||||
continue;
|
||||
auto it = find(hashList.begin(), hashList.end(), plugin->second);
|
||||
auto it = find(hashList.begin(), hashList.end(), plugin->second[0]);
|
||||
if(it == hashList.end()) // hash not found in sample
|
||||
break;
|
||||
|
||||
|
@ -224,12 +224,20 @@ void Networking::update(RakNet::Packet *packet)
|
|||
break;
|
||||
}
|
||||
}
|
||||
RakNet::BitStream bs;
|
||||
packetPreInit.SetSendStream(&bs);
|
||||
if(plugin != plugins.end()) // if condition is true, then client have wrong plugin list
|
||||
{
|
||||
//ToDo: Send our plugin list to player with allowed hashes
|
||||
//peer->CloseConnection(packet->systemAddress, true);
|
||||
packetPreInit.setChecksums(&samples);
|
||||
packetPreInit.Send(packet->systemAddress);
|
||||
peer->CloseConnection(packet->systemAddress, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketPreInit::PluginContainer tmp;
|
||||
packetPreInit.setChecksums(&tmp);
|
||||
packetPreInit.Send(packet->systemAddress);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -373,26 +381,25 @@ Networking *Networking::getPtr()
|
|||
return sThis;
|
||||
}
|
||||
|
||||
Networking::PluginListSample Networking::getPluginListSample()
|
||||
PacketPreInit::PluginContainer Networking::getPluginListSample()
|
||||
{
|
||||
PluginListSample pls;
|
||||
PacketPreInit::PluginContainer pls;
|
||||
unsigned id = 0;
|
||||
while(true)
|
||||
{
|
||||
unsigned field = 0;
|
||||
auto name = "";
|
||||
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(name, id, field);
|
||||
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(name, id, field++);
|
||||
if(strlen(name) == 0)
|
||||
break;
|
||||
HashList hashList;
|
||||
PacketPreInit::HashList hashList;
|
||||
while(true)
|
||||
{
|
||||
auto hash = "";
|
||||
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(hash, id, field);
|
||||
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(hash, id, field++);
|
||||
if(strlen(hash) == 0)
|
||||
break;
|
||||
hashList.push_back((unsigned)stoul(hash));
|
||||
field++;
|
||||
}
|
||||
pls.push_back({name, hashList});
|
||||
id++;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
||||
#include <components/openmw-mp/Controllers/ActorPacketController.hpp>
|
||||
#include <components/openmw-mp/Controllers/WorldPacketController.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketPreInit.hpp>
|
||||
#include "Player.hpp"
|
||||
|
||||
class MasterClient;
|
||||
|
@ -55,10 +56,8 @@ namespace mwmp
|
|||
static const Networking &get();
|
||||
static Networking *getPtr();
|
||||
|
||||
typedef std::vector<unsigned> HashList;
|
||||
typedef std::vector<std::pair<std::string, HashList>> PluginListSample;
|
||||
private:
|
||||
PluginListSample getPluginListSample();
|
||||
PacketPreInit::PluginContainer getPluginListSample();
|
||||
std::string serverPassword;
|
||||
static Networking *sThis;
|
||||
|
||||
|
|
Loading…
Reference in a new issue