mirror of
https://github.com/minetest/minetest.git
synced 2024-09-12 00:26:50 +02:00
Only fly through walls in noclip mode wich requires the noclip privilege
This commit is contained in:
parent
1d13d106dd
commit
52ba413185
@ -44,5 +44,9 @@ minetest.register_privilege("fast", {
|
|||||||
description = "Can walk fast using the fast_move mode",
|
description = "Can walk fast using the fast_move mode",
|
||||||
give_to_singleplayer = false,
|
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")
|
minetest.register_privilege("rollback", "Can use the rollback functionality")
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ void set_default_settings(Settings *settings)
|
|||||||
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
|
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
|
||||||
settings->setDefault("keymap_freemove", "KEY_KEY_K");
|
settings->setDefault("keymap_freemove", "KEY_KEY_K");
|
||||||
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
|
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
|
||||||
|
settings->setDefault("keymap_noclip", "KEY_KEY_H");
|
||||||
settings->setDefault("keymap_screenshot", "KEY_F12");
|
settings->setDefault("keymap_screenshot", "KEY_F12");
|
||||||
settings->setDefault("keymap_toggle_hud", "KEY_F1");
|
settings->setDefault("keymap_toggle_hud", "KEY_F1");
|
||||||
settings->setDefault("keymap_toggle_chat", "KEY_F2");
|
settings->setDefault("keymap_toggle_chat", "KEY_F2");
|
||||||
@ -95,6 +96,7 @@ void set_default_settings(Settings *settings)
|
|||||||
settings->setDefault("shader_path", "");
|
settings->setDefault("shader_path", "");
|
||||||
settings->setDefault("video_driver", "opengl");
|
settings->setDefault("video_driver", "opengl");
|
||||||
settings->setDefault("free_move", "false");
|
settings->setDefault("free_move", "false");
|
||||||
|
settings->setDefault("noclip", "false");
|
||||||
settings->setDefault("continuous_forward", "false");
|
settings->setDefault("continuous_forward", "false");
|
||||||
settings->setDefault("fast_move", "false");
|
settings->setDefault("fast_move", "false");
|
||||||
settings->setDefault("invert_mouse", "false");
|
settings->setDefault("invert_mouse", "false");
|
||||||
|
17
src/game.cpp
17
src/game.cpp
@ -1665,6 +1665,23 @@ void the_game(
|
|||||||
statustext += L" (note: no 'fast' privilege)";
|
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")))
|
else if(input->wasKeyDown(getKeySetting("keymap_screenshot")))
|
||||||
{
|
{
|
||||||
irr::video::IImage* const image = driver->createScreenShot();
|
irr::video::IImage* const image = driver->createScreenShot();
|
||||||
|
@ -46,6 +46,7 @@ enum
|
|||||||
GUI_ID_KEY_FLY_BUTTON,
|
GUI_ID_KEY_FLY_BUTTON,
|
||||||
GUI_ID_KEY_FAST_BUTTON,
|
GUI_ID_KEY_FAST_BUTTON,
|
||||||
GUI_ID_KEY_JUMP_BUTTON,
|
GUI_ID_KEY_JUMP_BUTTON,
|
||||||
|
GUI_ID_KEY_NOCLIP_BUTTON,
|
||||||
GUI_ID_KEY_CHAT_BUTTON,
|
GUI_ID_KEY_CHAT_BUTTON,
|
||||||
GUI_ID_KEY_CMD_BUTTON,
|
GUI_ID_KEY_CMD_BUTTON,
|
||||||
GUI_ID_KEY_CONSOLE_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_CONSOLE_BUTTON, "Console", "keymap_console");
|
||||||
this->add_key(GUI_ID_KEY_FLY_BUTTON, "Toggle fly", "keymap_freemove");
|
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_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_RANGE_BUTTON, "Range select", "keymap_rangeselect");
|
||||||
this->add_key(GUI_ID_KEY_DUMP_BUTTON, "Print stacks", "keymap_print_debug_stacks");
|
this->add_key(GUI_ID_KEY_DUMP_BUTTON, "Print stacks", "keymap_print_debug_stacks");
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,11 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
|||||||
return;
|
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 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)
|
if(free_move)
|
||||||
{
|
{
|
||||||
position += m_speed * dtime;
|
position += m_speed * dtime;
|
||||||
@ -300,7 +302,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
|||||||
Report collisions
|
Report collisions
|
||||||
*/
|
*/
|
||||||
bool bouncy_jump = false;
|
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++){
|
for(size_t i=0; i<result.collisions.size(); i++){
|
||||||
const CollisionInfo &info = result.collisions[i];
|
const CollisionInfo &info = result.collisions[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user