From babc3230b76aa4cd4b39c15554cc463ccaab61a8 Mon Sep 17 00:00:00 2001 From: Koncord Date: Sat, 10 Sep 2016 13:41:23 +0800 Subject: [PATCH] Add new functions: GetServerVersion & GetProtocolVersion --- apps/openmw-mp/Script/ScriptFunctions.cpp | 11 +++++++++++ apps/openmw-mp/Script/ScriptFunctions.hpp | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/apps/openmw-mp/Script/ScriptFunctions.cpp b/apps/openmw-mp/Script/ScriptFunctions.cpp index fc29c6d5b..c08475855 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.cpp +++ b/apps/openmw-mp/Script/ScriptFunctions.cpp @@ -9,6 +9,7 @@ #include #include #include +#include template constexpr char TypeString::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(); +} \ No newline at end of file diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 8d59b7d57..643bc1f63 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -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,