diff --git a/builtin/game/privileges.lua b/builtin/game/privileges.lua index 05c79440c..f89514134 100644 --- a/builtin/game/privileges.lua +++ b/builtin/game/privileges.lua @@ -58,4 +58,7 @@ core.register_privilege("zoom", { description = "Can zoom the camera", give_to_singleplayer = false, }) - +core.register_privilege("debug", { + description = "Allows enabling various debug options that may affect gameplay", + give_to_singleplayer = false, +}) diff --git a/src/clientmap.cpp b/src/clientmap.cpp index a0a780250..60170ab70 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -521,6 +521,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter); buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter); buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter); + buf->getMaterial().setFlag(video::EMF_WIREFRAME, m_control.show_wireframe); const video::SMaterial& material = buf->getMaterial(); video::IMaterialRenderer* rnd = diff --git a/src/clientmap.h b/src/clientmap.h index 396e68f64..8855eecf6 100644 --- a/src/clientmap.h +++ b/src/clientmap.h @@ -32,6 +32,7 @@ struct MapDrawControl range_all(false), wanted_range(0), wanted_max_blocks(0), + show_wireframe(false), blocks_drawn(0), blocks_would_have_drawn(0), farthest_drawn(0) @@ -43,6 +44,8 @@ struct MapDrawControl float wanted_range; // Maximum number of blocks to draw u32 wanted_max_blocks; + // show a wire frame for debugging + bool show_wireframe; // Number of blocks rendered is written here by the renderer u32 blocks_drawn; // Number of blocks that would have been drawn in wanted_range diff --git a/src/game.cpp b/src/game.cpp index 9a03071dd..af0476a0b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1573,7 +1573,7 @@ protected: bool shift_pressed); void toggleFog(float *statustext_time, bool *flag); void toggleDebug(float *statustext_time, bool *show_debug, - bool *show_profiler_graph); + bool *show_profiler_graph, bool *show_wireframe); void toggleUpdateCamera(float *statustext_time, bool *flag); void toggleProfiler(float *statustext_time, u32 *profiler_current_page, u32 profiler_max_page); @@ -2812,7 +2812,8 @@ void Game::processKeyInput(VolatileRunFlags *flags, } else if (wasKeyDown(KeyType::TOGGLE_UPDATE_CAMERA)) { toggleUpdateCamera(statustext_time, &flags->disable_camera_update); } else if (wasKeyDown(KeyType::TOGGLE_DEBUG)) { - toggleDebug(statustext_time, &flags->show_debug, &flags->show_profiler_graph); + toggleDebug(statustext_time, &flags->show_debug, &flags->show_profiler_graph, + &draw_control->show_wireframe); } else if (wasKeyDown(KeyType::TOGGLE_PROFILER)) { toggleProfiler(statustext_time, profiler_current_page, profiler_max_page); } else if (wasKeyDown(KeyType::INCREASE_VIEWING_RANGE)) { @@ -3119,22 +3120,33 @@ void Game::toggleFog(float *statustext_time, bool *flag) void Game::toggleDebug(float *statustext_time, bool *show_debug, - bool *show_profiler_graph) + bool *show_profiler_graph, bool *show_wireframe) { - // Initial / 3x toggle: Chat only + // Initial / 4x toggle: Chat only // 1x toggle: Debug text with chat // 2x toggle: Debug text with profiler graph + // 3x toggle: Debug text and wireframe if (!*show_debug) { *show_debug = true; *show_profiler_graph = false; + *show_wireframe = false; statustext = L"Debug info shown"; - } else if (*show_profiler_graph) { - *show_debug = false; - *show_profiler_graph = false; - statustext = L"Debug info and profiler graph hidden"; - } else { + } else if (!*show_profiler_graph) { *show_profiler_graph = true; statustext = L"Profiler graph shown"; + } else if (!*show_wireframe && client->checkPrivilege("debug")) { + *show_profiler_graph = false; + *show_wireframe = true; + statustext = L"Wireframe shown"; + } else { + *show_debug = false; + *show_profiler_graph = false; + *show_wireframe = false; + if (client->checkPrivilege("debug")) { + statustext = L"Debug info, profiler graph, and wireframe hidden"; + } else { + statustext = L"Debug info and profiler graph hidden"; + } } *statustext_time = 0; }