aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPilzAdam <adam-k@outlook.com>2012-12-09 13:34:16 +0100
committerPilzAdam <adam-k@outlook.com>2012-12-11 16:44:13 +0100
commit52ba413185f96add259c480a68f5dffa389e80f4 (patch)
treea20aafa92b5ce3ad22eb2074afc4aea30d09260c /src
parent1d13d106dd58cd18a019046840c180da25001b02 (diff)
downloadminetest-52ba413185f96add259c480a68f5dffa389e80f4.tar.gz
minetest-52ba413185f96add259c480a68f5dffa389e80f4.tar.bz2
minetest-52ba413185f96add259c480a68f5dffa389e80f4.zip
Only fly through walls in noclip mode wich requires the noclip privilege
Diffstat (limited to 'src')
-rw-r--r--src/defaultsettings.cpp2
-rw-r--r--src/game.cpp17
-rw-r--r--src/guiKeyChangeMenu.cpp2
-rw-r--r--src/localplayer.cpp9
4 files changed, 27 insertions, 3 deletions
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];