forked from Mirrorlandia_minetest/minetest
Fix crash when calling remove/kick/ban_player on start (#11672)
This commit is contained in:
parent
5aa95fef10
commit
bc71622d21
@ -293,8 +293,10 @@ int ModApiServer::l_ban_player(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
Server *server = getServer(L);
|
||||
if (!getEnv(L))
|
||||
throw LuaError("Can't ban player before server has started up");
|
||||
|
||||
Server *server = getServer(L);
|
||||
const char *name = luaL_checkstring(L, 1);
|
||||
RemotePlayer *player = server->getEnv().getPlayer(name);
|
||||
if (!player) {
|
||||
@ -312,6 +314,10 @@ int ModApiServer::l_ban_player(lua_State *L)
|
||||
int ModApiServer::l_kick_player(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
if (!getEnv(L))
|
||||
throw LuaError("Can't kick player before server has started up");
|
||||
|
||||
const char *name = luaL_checkstring(L, 1);
|
||||
std::string message("Kicked");
|
||||
if (lua_isstring(L, 2))
|
||||
@ -334,7 +340,8 @@ int ModApiServer::l_remove_player(lua_State *L)
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
std::string name = luaL_checkstring(L, 1);
|
||||
ServerEnvironment *s_env = dynamic_cast<ServerEnvironment *>(getEnv(L));
|
||||
assert(s_env);
|
||||
if (!s_env)
|
||||
throw LuaError("Can't remove player before server has started up");
|
||||
|
||||
RemotePlayer *player = s_env->getPlayer(name.c_str());
|
||||
if (!player)
|
||||
|
Loading…
Reference in New Issue
Block a user