diff options
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_inventory.cpp | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_inventory.h | 9 | ||||
-rw-r--r-- | src/script/lua_api/l_object.cpp | 20 | ||||
-rw-r--r-- | src/script/lua_api/l_object.h | 1 | ||||
-rw-r--r-- | src/script/lua_api/l_server.cpp | 21 |
5 files changed, 23 insertions, 30 deletions
diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp index de9f9374a..110e68d23 100644 --- a/src/script/lua_api/l_inventory.cpp +++ b/src/script/lua_api/l_inventory.cpp @@ -420,7 +420,7 @@ void InvRef::create(lua_State *L, const InventoryLocation &loc) luaL_getmetatable(L, className); lua_setmetatable(L, -2); } -void InvRef::createPlayer(lua_State *L, Player *player) +void InvRef::createPlayer(lua_State *L, RemotePlayer *player) { NO_MAP_LOCK_REQUIRED; InventoryLocation loc; diff --git a/src/script/lua_api/l_inventory.h b/src/script/lua_api/l_inventory.h index 2d4b29d0c..cc5333965 100644 --- a/src/script/lua_api/l_inventory.h +++ b/src/script/lua_api/l_inventory.h @@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventory.h" #include "inventorymanager.h" -class Player; +class RemotePlayer; /* InvRef @@ -112,7 +112,7 @@ public: // Creates an InvRef and leaves it on top of stack // Not callable from Lua; all references are created on the C side. static void create(lua_State *L, const InventoryLocation &loc); - static void createPlayer(lua_State *L, Player *player); + static void createPlayer(lua_State *L, RemotePlayer *player); static void createNodeMeta(lua_State *L, v3s16 p); static void Register(lua_State *L); }; @@ -123,11 +123,6 @@ private: static int l_get_inventory(lua_State *L); - static void inventory_set_list_from_lua(Inventory *inv, const char *name, - lua_State *L, int tableindex, int forcesize); - static void inventory_get_list_to_lua(Inventory *inv, const char *name, - lua_State *L); - public: static void Initialize(lua_State *L, int top); }; diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 34e175ad0..b58d8e6cd 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -508,7 +508,7 @@ int ObjectRef::l_set_local_animation(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; // Do it @@ -554,7 +554,7 @@ int ObjectRef::l_set_eye_offset(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; // Do it @@ -1256,7 +1256,7 @@ int ObjectRef::l_hud_add(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; @@ -1319,7 +1319,7 @@ int ObjectRef::l_hud_remove(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; @@ -1339,7 +1339,7 @@ int ObjectRef::l_hud_change(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; @@ -1552,7 +1552,7 @@ int ObjectRef::l_hud_set_hotbar_image(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; @@ -1567,7 +1567,7 @@ int ObjectRef::l_hud_get_hotbar_image(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; @@ -1581,7 +1581,7 @@ int ObjectRef::l_hud_set_hotbar_selected_image(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; @@ -1596,7 +1596,7 @@ int ObjectRef::l_hud_get_hotbar_selected_image(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; @@ -1610,7 +1610,7 @@ int ObjectRef::l_set_sky(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - Player *player = getplayer(ref); + RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h index a7ac9dff9..dfc1b49d2 100644 --- a/src/script/lua_api/l_object.h +++ b/src/script/lua_api/l_object.h @@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc., class ServerActiveObject; class LuaEntitySAO; class PlayerSAO; -class Player; class RemotePlayer; /* 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; } |