From 7a7bfdca7c2dcbfe40467f64544112551abd7316 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 10 Mar 2020 20:32:04 +0100 Subject: [PATCH] minetest,get_connected_players: Return empty table at load time (#9493) --- src/script/lua_api/l_env.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 352c75fb2..3169fa4cf 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -643,7 +643,13 @@ int ModApiEnvMod::l_add_item(lua_State *L) // get_connected_players() int ModApiEnvMod::l_get_connected_players(lua_State *L) { - GET_ENV_PTR; + ServerEnvironment *env = (ServerEnvironment *) getEnv(L); + if (!env) { + log_deprecated(L, "Calling get_connected_players() at mod load time" + " is deprecated"); + lua_createtable(L, 0, 0); + return 1; + } lua_createtable(L, env->getPlayerCount(), 0); u32 i = 0;