aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/cpp_api/s_cheats.cpp31
-rw-r--r--src/script/lua_api/l_client.h11
-rw-r--r--src/script/lua_api/l_server.cpp19
-rw-r--r--src/script/lua_api/l_server.h3
4 files changed, 21 insertions, 43 deletions
diff --git a/src/script/cpp_api/s_cheats.cpp b/src/script/cpp_api/s_cheats.cpp
index 8f3e4ef14..4ad62f2fe 100644
--- a/src/script/cpp_api/s_cheats.cpp
+++ b/src/script/cpp_api/s_cheats.cpp
@@ -15,44 +15,42 @@ GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
+*/
#include "cpp_api/s_cheats.h"
#include "cpp_api/s_base.h"
#include "cpp_api/s_internal.h"
#include "settings.h"
-ScriptApiCheatsCheat::ScriptApiCheatsCheat(const std::string &name, const std::string &setting) :
- m_name(name),
- m_setting(setting),
- m_function_ref(0)
+ScriptApiCheatsCheat::ScriptApiCheatsCheat(
+ const std::string &name, const std::string &setting) :
+ m_name(name),
+ m_setting(setting), m_function_ref(0)
{
}
ScriptApiCheatsCheat::ScriptApiCheatsCheat(const std::string &name, const int &function) :
- m_name(name),
- m_setting(""),
- m_function_ref(function)
+ m_name(name), m_setting(""), m_function_ref(function)
{
}
bool ScriptApiCheatsCheat::is_enabled()
{
try {
- return ! m_function_ref && g_settings->getBool(m_setting);
+ return !m_function_ref && g_settings->getBool(m_setting);
} catch (SettingNotFoundException &) {
return false;
}
}
void ScriptApiCheatsCheat::toggle(lua_State *L, int error_handler)
-{
+{
if (m_function_ref) {
lua_rawgeti(L, LUA_REGISTRYINDEX, m_function_ref);
lua_pcall(L, 0, 0, error_handler);
} else
- g_settings->setBool(m_setting, ! is_enabled());
+ g_settings->setBool(m_setting, !is_enabled());
}
ScriptApiCheatsCategory::ScriptApiCheatsCategory(const std::string &name) :
@@ -75,7 +73,8 @@ void ScriptApiCheatsCategory::read_cheats(lua_State *L)
if (lua_isstring(L, -1))
cheat = new ScriptApiCheatsCheat(name, lua_tostring(L, -1));
else if (lua_isfunction(L, -1)) {
- cheat = new ScriptApiCheatsCheat(name, luaL_ref(L, LUA_REGISTRYINDEX));
+ cheat = new ScriptApiCheatsCheat(
+ name, luaL_ref(L, LUA_REGISTRYINDEX));
lua_pushnil(L);
}
if (cheat)
@@ -93,10 +92,10 @@ ScriptApiCheats::~ScriptApiCheats()
void ScriptApiCheats::init_cheats()
{
SCRIPTAPI_PRECHECKHEADER
-
+
lua_getglobal(L, "core");
lua_getfield(L, -1, "cheats");
- if (! lua_istable(L, -1)) {
+ if (!lua_istable(L, -1)) {
lua_pop(L, 2);
return;
}
@@ -116,10 +115,10 @@ void ScriptApiCheats::init_cheats()
void ScriptApiCheats::toggle_cheat(ScriptApiCheatsCheat *cheat)
{
SCRIPTAPI_PRECHECKHEADER
-
+
PUSH_ERROR_HANDLER(L);
int error_handler = lua_gettop(L) - 1;
lua_insert(L, error_handler);
-
+
cheat->toggle(L, error_handler);
}
diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h
index ebce7c02a..4e49ad60e 100644
--- a/src/script/lua_api/l_client.h
+++ b/src/script/lua_api/l_client.h
@@ -104,24 +104,25 @@ private:
// get_csm_restrictions()
static int l_get_csm_restrictions(lua_State *L);
-
+
// send_damage(damage)
static int l_send_damage(lua_State *L);
-
+
// place_node(pos)
static int l_place_node(lua_State *L);
-
+
// dig_node(pos)
static int l_dig_node(lua_State *L);
-
+
// get_inventory(location)
static int l_get_inventory(lua_State *L);
-
+
// set_keypress(key_setting, pressed)
static int l_set_keypress(lua_State *L);
// drop_selected_item()
static int l_drop_selected_item(lua_State *L);
+
public:
static void Initialize(lua_State *L, int top);
};
diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp
index befbfb936..64ae924d2 100644
--- a/src/script/lua_api/l_server.cpp
+++ b/src/script/lua_api/l_server.cpp
@@ -338,23 +338,6 @@ int ModApiServer::l_kick_player(lua_State *L)
return 1;
}
-// redirect_player(name, address, port)
-int ModApiServer::l_redirect_player(lua_State *L)
-{
- NO_MAP_LOCK_REQUIRED;
- const char *name = luaL_checkstring(L, 1);
- const char *address = luaL_checkstring(L, 2);
- u16 port = luaL_checknumber(L, 3);
- RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name);
- if (player == NULL) {
- lua_pushboolean(L, false); // No such player
- return 1;
- }
- getServer(L)->RedirectPeer(player->getPeerId(), address, port);
- lua_pushboolean(L, true);
- return 1;
-}
-
// remove_player(name)
int ModApiServer::l_remove_player(lua_State *L)
{
@@ -580,8 +563,6 @@ void ModApiServer::Initialize(lua_State *L, int top)
API_FCT(get_ban_description);
API_FCT(ban_player);
API_FCT(kick_player);
- API_FCT(redirect_player);
- API_FCT(remove_player);
API_FCT(unban_player_or_ip);
API_FCT(notify_authentication_modified);
diff --git a/src/script/lua_api/l_server.h b/src/script/lua_api/l_server.h
index 3b590af9d..938bfa8ef 100644
--- a/src/script/lua_api/l_server.h
+++ b/src/script/lua_api/l_server.h
@@ -96,9 +96,6 @@ private:
// kick_player(name, [message]) -> success
static int l_kick_player(lua_State *L);
-
- // redirect_player(name, address, port) -> success
- static int l_redirect_player(lua_State *L);
// remove_player(name)
static int l_remove_player(lua_State *L);