Add new functions: GetServerVersion & GetProtocolVersion

This commit is contained in:
Koncord 2016-09-10 13:41:23 +08:00
parent a34d46f57e
commit babc3230b7
2 changed files with 15 additions and 0 deletions

View file

@ -9,6 +9,7 @@
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Version.hpp>
template<typename... Types>
constexpr char TypeString<Types...>::value[];
@ -119,3 +120,13 @@ void ScriptFunctions::Kick(unsigned short pid) noexcept
GET_PLAYER(pid, player,);
mwmp::Networking::GetPtr()->KickPlayer(player->guid);
}
const char *ScriptFunctions::GetServerVersion() noexcept
{
return TES3MP_VERSION;
}
const char *ScriptFunctions::GetProtocolVersion() noexcept
{
return to_string((int)TES3MP_PROTO_VERSION).c_str();
}

View file

@ -58,6 +58,8 @@ public:
static bool IsTimerElapsed(int timerId) noexcept;
static void Kick(unsigned short pid) noexcept;
static const char *GetServerVersion() noexcept;
static const char *GetProtocolVersion() noexcept;
static constexpr ScriptFunctionData functions[]{
{"CreateTimer", ScriptFunctions::CreateTimer},
@ -77,6 +79,8 @@ public:
// {"Cast", ScriptFunctions::Cast},
{"SendMessage", ScriptFunctions::SendMessage},
{"Kick", ScriptFunctions::Kick},
{"GetServerVersion", ScriptFunctions::GetServerVersion},
{"GetProtocolVersion", ScriptFunctions::GetProtocolVersion},
TRANSLOCATIONFUNCTIONS,
STATSFUNCTIONS,