summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_server.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2016-12-22 23:16:00 +0100
committerest31 <MTest31@outlook.com>2016-12-22 23:16:00 +0100
commit81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (patch)
tree1e9ef1be1b3295a8673d6e4f0bdeb4c2d3a6015f /src/script/lua_api/l_server.cpp
parent8077612dcb48221281e726a60eb97bf73fde462b (diff)
parent231ac33d34dfaaddf292c5f31b1eae43eeefba2d (diff)
downloadminetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.tar.gz
minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.tar.bz2
minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.zip
Merge 0.4.15 changes into stable-0.4
0.4.15 release!
Diffstat (limited to 'src/script/lua_api/l_server.cpp')
-rw-r--r--src/script/lua_api/l_server.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp
index 59d3f5c70..b6d44e0ff 100644
--- a/src/script/lua_api/l_server.cpp
+++ b/src/script/lua_api/l_server.cpp
@@ -45,6 +45,15 @@ int ModApiServer::l_get_server_status(lua_State *L)
return 1;
}
+// get_server_uptime()
+int ModApiServer::l_get_server_uptime(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ lua_pushnumber(L, getServer(L)->getUptime());
+ return 1;
+}
+
+
// print(text)
int ModApiServer::l_print(lua_State *L)
{
@@ -106,7 +115,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 +142,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 +286,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 +322,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;
}
@@ -508,6 +516,7 @@ void ModApiServer::Initialize(lua_State *L, int top)
{
API_FCT(request_shutdown);
API_FCT(get_server_status);
+ API_FCT(get_server_uptime);
API_FCT(get_worldpath);
API_FCT(is_singleplayer);