From 1ef9eee31133a3001ed0c642df5cbe54169850de Mon Sep 17 00:00:00 2001 From: red-001 Date: Thu, 27 Apr 2017 10:49:44 +0100 Subject: Allow scripts to get the client protocol version in non-debug builds. (#5649) --- doc/lua_api.txt | 2 +- src/script/lua_api/l_server.cpp | 10 +++++----- src/script/lua_api/l_server.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index d4141b5d4..b47046cb1 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1991,11 +1991,11 @@ Helper functions max_jitter = 0.5, -- maximum packet time jitter avg_jitter = 0.03, -- average packet time jitter connection_uptime = 200, -- seconds since client connected + prot_vers = 31, -- protocol version used by client -- following information is available on debug build only!!! -- DO NOT USE IN MODS --ser_vers = 26, -- serialization version used by client - --prot_vers = 23, -- protocol version used by client --major = 0, -- major version number --minor = 4, -- minor version number --patch = 10, -- patch version number diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index 813d5a945..7b723d14c 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -137,7 +137,7 @@ int ModApiServer::l_get_player_ip(lua_State *L) } } -// get_player_information() +// get_player_information(name) int ModApiServer::l_get_player_information(lua_State *L) { @@ -231,15 +231,15 @@ int ModApiServer::l_get_player_information(lua_State *L) lua_pushnumber(L, uptime); lua_settable(L, table); + lua_pushstring(L,"protocol_version"); + lua_pushnumber(L, prot_vers); + lua_settable(L, table); + #ifndef NDEBUG lua_pushstring(L,"serialization_version"); lua_pushnumber(L, ser_vers); lua_settable(L, table); - lua_pushstring(L,"protocol_version"); - lua_pushnumber(L, prot_vers); - lua_settable(L, table); - lua_pushstring(L,"major"); lua_pushnumber(L, major); lua_settable(L, table); diff --git a/src/script/lua_api/l_server.h b/src/script/lua_api/l_server.h index e6c0df978..3a4a917c0 100644 --- a/src/script/lua_api/l_server.h +++ b/src/script/lua_api/l_server.h @@ -74,7 +74,7 @@ private: // get_player_ip() static int l_get_player_ip(lua_State *L); - // get_player_information() + // get_player_information(name) static int l_get_player_information(lua_State *L); // get_ban_list() -- cgit v1.2.3