diff options
Diffstat (limited to 'src/script/lua_api/l_server.cpp')
-rw-r--r-- | src/script/lua_api/l_server.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index 59d3f5c70..95e5da07f 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -106,7 +106,7 @@ int ModApiServer::l_get_player_ip(lua_State *L) { NO_MAP_LOCK_REQUIRED; const char * name = luaL_checkstring(L, 1); - Player *player = getEnv(L)->getPlayer(name); + RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name); if(player == NULL) { lua_pushnil(L); // no such player @@ -133,9 +133,8 @@ int ModApiServer::l_get_player_information(lua_State *L) NO_MAP_LOCK_REQUIRED; const char * name = luaL_checkstring(L, 1); - Player *player = getEnv(L)->getPlayer(name); - if(player == NULL) - { + RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name); + if (player == NULL) { lua_pushnil(L); // no such player return 1; } @@ -278,15 +277,15 @@ int ModApiServer::l_ban_player(lua_State *L) { NO_MAP_LOCK_REQUIRED; const char * name = luaL_checkstring(L, 1); - Player *player = getEnv(L)->getPlayer(name); - if(player == NULL) - { + RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name); + if (player == NULL) { lua_pushboolean(L, false); // no such player return 1; } try { - Address addr = getServer(L)->getPeerAddress(getEnv(L)->getPlayer(name)->peer_id); + Address addr = getServer(L)->getPeerAddress( + dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name)->peer_id); std::string ip_str = addr.serializeString(); getServer(L)->setIpBanned(ip_str, name); } @@ -314,9 +313,9 @@ int ModApiServer::l_kick_player(lua_State *L) { message = "Kicked."; } - Player *player = getEnv(L)->getPlayer(name); - if (player == NULL) - { + + RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name); + if (player == NULL) { lua_pushboolean(L, false); // No such player return 1; } |