Skip to content
Permalink
Browse files

Add debug priv, and allow player to display the scene as wire-frame. (#…

  • Loading branch information
lhofhansl authored and est31 committed Nov 4, 2016
1 parent bf315c0 commit f8fd432dca9f84a489cb7033afc4e4eef7cff49d
Showing with 29 additions and 10 deletions.
  1. +4 −1 builtin/game/privileges.lua
  2. +1 −0 src/clientmap.cpp
  3. +3 −0 src/clientmap.h
  4. +21 −9 src/game.cpp
@@ -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,
})
@@ -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 =
@@ -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
@@ -1573,7 +1573,7 @@ class Game {
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;
}

0 comments on commit f8fd432

Please sign in to comment.
You can’t perform that action at this time.