Skip to content

Commit 1ef9eee

Browse files
red-001nerzhul
authored andcommittedApr 27, 2017
Allow scripts to get the client protocol version in non-debug builds. (#5649)
1 parent d130e1f commit 1ef9eee

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed
 

‎doc/lua_api.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1991,11 +1991,11 @@ Helper functions
19911991
max_jitter = 0.5, -- maximum packet time jitter
19921992
avg_jitter = 0.03, -- average packet time jitter
19931993
connection_uptime = 200, -- seconds since client connected
1994+
prot_vers = 31, -- protocol version used by client
19941995

19951996
-- following information is available on debug build only!!!
19961997
-- DO NOT USE IN MODS
19971998
--ser_vers = 26, -- serialization version used by client
1998-
--prot_vers = 23, -- protocol version used by client
19991999
--major = 0, -- major version number
20002000
--minor = 4, -- minor version number
20012001
--patch = 10, -- patch version number

‎src/script/lua_api/l_server.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int ModApiServer::l_get_player_ip(lua_State *L)
137137
}
138138
}
139139

140-
// get_player_information()
140+
// get_player_information(name)
141141
int ModApiServer::l_get_player_information(lua_State *L)
142142
{
143143

@@ -231,15 +231,15 @@ int ModApiServer::l_get_player_information(lua_State *L)
231231
lua_pushnumber(L, uptime);
232232
lua_settable(L, table);
233233

234+
lua_pushstring(L,"protocol_version");
235+
lua_pushnumber(L, prot_vers);
236+
lua_settable(L, table);
237+
234238
#ifndef NDEBUG
235239
lua_pushstring(L,"serialization_version");
236240
lua_pushnumber(L, ser_vers);
237241
lua_settable(L, table);
238242

239-
lua_pushstring(L,"protocol_version");
240-
lua_pushnumber(L, prot_vers);
241-
lua_settable(L, table);
242-
243243
lua_pushstring(L,"major");
244244
lua_pushnumber(L, major);
245245
lua_settable(L, table);

‎src/script/lua_api/l_server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ModApiServer : public ModApiBase
7474
// get_player_ip()
7575
static int l_get_player_ip(lua_State *L);
7676

77-
// get_player_information()
77+
// get_player_information(name)
7878
static int l_get_player_information(lua_State *L);
7979

8080
// get_ban_list()

0 commit comments

Comments
 (0)