pull/112/merge
David Cernat 8 years ago
commit 4d053743a0

@ -845,4 +845,9 @@ unsigned short Networking::NumberOfConnections() const
unsigned int Networking::MaxConnections() const unsigned int Networking::MaxConnections() const
{ {
return peer->GetMaximumIncomingConnections(); return peer->GetMaximumIncomingConnections();
} }
int Networking::GetAvgPing(RakNet::AddressOrGUID addr) const
{
return peer->GetAveragePing(addr);
}

@ -27,6 +27,7 @@ namespace mwmp
unsigned short NumberOfConnections() const; unsigned short NumberOfConnections() const;
unsigned int MaxConnections() const; unsigned int MaxConnections() const;
int GetAvgPing(RakNet::AddressOrGUID) const;
int MainLoop(); int MainLoop();

@ -130,4 +130,11 @@ const char *ScriptFunctions::GetProtocolVersion() noexcept
{ {
static string version = to_string(TES3MP_PROTO_VERSION); static string version = to_string(TES3MP_PROTO_VERSION);
return version.c_str(); return version.c_str();
} }
int ScriptFunctions::GetAvgPing(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,-1);
return mwmp::Networking::Get().GetAvgPing(player->guid);
}

@ -60,6 +60,7 @@ public:
static void Kick(unsigned short pid) noexcept; static void Kick(unsigned short pid) noexcept;
static const char *GetServerVersion() noexcept; static const char *GetServerVersion() noexcept;
static const char *GetProtocolVersion() noexcept; static const char *GetProtocolVersion() noexcept;
static int GetAvgPing(unsigned short pid) noexcept;
static constexpr ScriptFunctionData functions[]{ static constexpr ScriptFunctionData functions[]{
{"CreateTimer", ScriptFunctions::CreateTimer}, {"CreateTimer", ScriptFunctions::CreateTimer},
@ -80,7 +81,8 @@ public:
{"SendMessage", ScriptFunctions::SendMessage}, {"SendMessage", ScriptFunctions::SendMessage},
{"Kick", ScriptFunctions::Kick}, {"Kick", ScriptFunctions::Kick},
{"GetServerVersion", ScriptFunctions::GetServerVersion}, {"GetServerVersion", ScriptFunctions::GetServerVersion},
{"GetProtocolVersion", ScriptFunctions::GetProtocolVersion}, {"GetProtocolVersion", ScriptFunctions::GetProtocolVersion},
{"GetAvgPing", ScriptFunctions::GetAvgPing},
TRANSLOCATIONFUNCTIONS, TRANSLOCATIONFUNCTIONS,
STATSFUNCTIONS, STATSFUNCTIONS,

Loading…
Cancel
Save