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