aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/privileges.lua4
-rw-r--r--src/defaultsettings.cpp2
-rw-r--r--src/game.cpp17
-rw-r--r--src/guiKeyChangeMenu.cpp2
-rw-r--r--src/localplayer.cpp9
5 files changed, 31 insertions, 3 deletions
diff --git a/builtin/privileges.lua b/builtin/privileges.lua
index 9ec09d7f6..8dd06b24f 100644
--- a/builtin/privileges.lua
+++ b/builtin/privileges.lua
@@ -44,5 +44,9 @@ minetest.register_privilege("fast", {
description = "Can walk fast using the fast_move mode",
give_to_singleplayer = false,
})
+minetest.register_privilege("noclip", {
+ description = "Can fly through walls",
+ give_to_singleplayer = false,
+})
minetest.register_privilege("rollback", "Can use the rollback functionality")
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index c43e0e03c..d824d2923 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -43,6 +43,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
settings->setDefault("keymap_freemove", "KEY_KEY_K");
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
+ settings->setDefault("keymap_noclip", "KEY_KEY_H");
settings->setDefault("keymap_screenshot", "KEY_F12");
settings->setDefault("keymap_toggle_hud", "KEY_F1");
settings->setDefault("keymap_toggle_chat", "KEY_F2");
@@ -95,6 +96,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("shader_path", "");
settings->setDefault("video_driver", "opengl");
settings->setDefault("free_move", "false");
+ settings->setDefault("noclip", "false");
settings->setDefault("continuous_forward", "false");
settings->setDefault("fast_move", "false");
settings->setDefault("invert_mouse", "false");
diff --git a/src/game.cpp b/src/game.cpp
index 9cd460922..dbb71369f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1665,6 +1665,23 @@ void the_game(
statustext += L" (note: no 'fast' privilege)";
}
}
+ else if(input->wasKeyDown(getKeySetting("keymap_noclip")))
+ {
+ if(g_settings->getBool("noclip"))
+ {
+ g_settings->set("noclip","false");
+ statustext = L"noclip disabled";
+ statustext_time = 0;
+ }
+ else
+ {
+ g_settings->set("noclip","true");
+ statustext = L"noclip enabled";
+ statustext_time = 0;
+ if(!client.checkPrivilege("noclip"))
+ statustext += L" (note: no 'noclip' privilege)";
+ }
+ }
else if(input->wasKeyDown(getKeySetting("keymap_screenshot")))
{
irr::video::IImage* const image = driver->createScreenShot();
diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp
index 405a81e0b..8f7c7245c 100644
--- a/src/guiKeyChangeMenu.cpp
+++ b/src/guiKeyChangeMenu.cpp
@@ -46,6 +46,7 @@ enum
GUI_ID_KEY_FLY_BUTTON,
GUI_ID_KEY_FAST_BUTTON,
GUI_ID_KEY_JUMP_BUTTON,
+ GUI_ID_KEY_NOCLIP_BUTTON,
GUI_ID_KEY_CHAT_BUTTON,
GUI_ID_KEY_CMD_BUTTON,
GUI_ID_KEY_CONSOLE_BUTTON,
@@ -362,6 +363,7 @@ void GUIKeyChangeMenu::init_keys()
this->add_key(GUI_ID_KEY_CONSOLE_BUTTON, "Console", "keymap_console");
this->add_key(GUI_ID_KEY_FLY_BUTTON, "Toggle fly", "keymap_freemove");
this->add_key(GUI_ID_KEY_FAST_BUTTON, "Toggle fast", "keymap_fastmove");
+ this->add_key(GUI_ID_KEY_NOCLIP_BUTTON, "Toggle noclip", "keymap_noclip");
this->add_key(GUI_ID_KEY_RANGE_BUTTON, "Range select", "keymap_rangeselect");
this->add_key(GUI_ID_KEY_DUMP_BUTTON, "Print stacks", "keymap_print_debug_stacks");
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 14d1ac60e..96ddb4bb2 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -73,9 +73,11 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
return;
}
- // Skip collision detection if a special movement mode is used
+ // Skip collision detection if noclip mode is used
bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
- bool free_move = fly_allowed && g_settings->getBool("free_move");
+ bool noclip = m_gamedef->checkLocalPrivilege("noclip") &&
+ g_settings->getBool("noclip");
+ bool free_move = noclip && fly_allowed && g_settings->getBool("free_move");
if(free_move)
{
position += m_speed * dtime;
@@ -300,7 +302,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
Report collisions
*/
bool bouncy_jump = false;
- if(collision_info)
+ // Dont report if flying
+ if(collision_info && !g_settings->getBool("free_move"))
{
for(size_t i=0; i<result.collisions.size(); i++){
const CollisionInfo &info = result.collisions[i];