Skip to content

Commit

Permalink
Boost deprecation logdomain severity when debug mode is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Mar 4, 2018
1 parent 322713d commit edb50cc
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 10 deletions.
21 changes: 20 additions & 1 deletion src/game_config.cpp
Expand Up @@ -113,7 +113,7 @@ std::vector<server_info> server_list;
// Gamestate flags
//
bool
debug = false,
debug_impl = false,
debug_lua = false,
editor = false,
ignore_replay_errors = false,
Expand All @@ -123,6 +123,25 @@ bool
disable_autosave = false,
no_addons = false;

const bool& debug = debug_impl;

void set_debug(bool new_debug) {
if(debug_impl && !new_debug) {
// Turning debug mode off; decrease deprecation severity
int severity;
if(lg::get_log_domain_severity("deprecation", severity)) {
lg::set_log_domain_severity("deprecation", severity - 2);
}
} else if(!debug_impl && new_debug) {
// Turning debug mode on; increase deprecation severity
int severity;
if(lg::get_log_domain_severity("deprecation", severity)) {
lg::set_log_domain_severity("deprecation", severity + 2);
}
}
debug_impl = new_debug;
}

//
// Orb display flahs
//
Expand Down
5 changes: 4 additions & 1 deletion src/game_config.hpp
Expand Up @@ -55,9 +55,12 @@ namespace game_config
/** Default percentage gold carried over to the next scenario. */
extern const int gold_carryover_percentage;

extern bool debug, debug_lua, editor, ignore_replay_errors, mp_debug,
extern bool debug_lua, editor, ignore_replay_errors, mp_debug,
exit_at_end, no_delay, disable_autosave, no_addons;

extern const bool& debug;
void set_debug(bool new_debug);

extern int cache_compression_level;

extern std::string path;
Expand Down
2 changes: 1 addition & 1 deletion src/game_launcher.cpp
Expand Up @@ -168,7 +168,7 @@ game_launcher::game_launcher(const commandline_options& cmdline_opts, const char
if (cmdline_opts_.clock)
gui2::dialogs::show_debug_clock_button = true;
if (cmdline_opts_.debug) {
game_config::debug = true;
game_config::set_debug(true);
game_config::mp_debug = true;
}
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
Expand Down
2 changes: 1 addition & 1 deletion src/help/help_impl.cpp
Expand Up @@ -70,7 +70,7 @@ help::section hidden_sections;

int last_num_encountered_units = -1;
int last_num_encountered_terrains = -1;
bool last_debug_state = game_config::debug;
boost::tribool last_debug_state = boost::indeterminate;

config dummy_cfg;
std::vector<std::string> empty_string_vector;
Expand Down
3 changes: 2 additions & 1 deletion src/help/help_impl.hpp
Expand Up @@ -42,6 +42,7 @@
#include <utility> // for pair, make_pair
#include <vector> // for vector, etc
#include <SDL.h> // for SDL_Surface
#include <boost/logic/tribool.hpp>

class config;
class unit_type;
Expand Down Expand Up @@ -320,7 +321,7 @@ extern help::section hidden_sections;

extern int last_num_encountered_units;
extern int last_num_encountered_terrains;
extern bool last_debug_state;
extern boost::tribool last_debug_state;

extern std::vector<std::string> empty_string_vector;
extern const int max_section_level;
Expand Down
4 changes: 2 additions & 2 deletions src/menu_events.cpp
Expand Up @@ -1713,7 +1713,7 @@ void console_handler::do_debug()
{
if(!menu_handler_.pc_.is_networked_mp() || game_config::mp_debug) {
print(get_cmd(), _("Debug mode activated!"));
game_config::debug = true;
game_config::set_debug(true);
} else {
command_failed(_("Debug mode not available in network games"));
}
Expand All @@ -1723,7 +1723,7 @@ void console_handler::do_nodebug()
{
if(game_config::debug) {
print(get_cmd(), _("Debug mode deactivated!"));
game_config::debug = false;
game_config::set_debug(false);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/wesnoth.cpp
Expand Up @@ -866,19 +866,19 @@ static int do_gameloop(const std::vector<std::string>& args)
LOG_GENERAL << "quitting game...\n";
return 0;
case gui2::dialogs::title_screen::MP_CONNECT:
game_config::debug = game_config::mp_debug;
game_config::set_debug(game_config::mp_debug);
if(!game->play_multiplayer(game_launcher::MP_CONNECT)) {
continue;
}
break;
case gui2::dialogs::title_screen::MP_HOST:
game_config::debug = game_config::mp_debug;
game_config::set_debug(game_config::mp_debug);
if(!game->play_multiplayer(game_launcher::MP_HOST)) {
continue;
}
break;
case gui2::dialogs::title_screen::MP_LOCAL:
game_config::debug = game_config::mp_debug;
game_config::set_debug(game_config::mp_debug);
if(!game->play_multiplayer(game_launcher::MP_LOCAL)) {
continue;
}
Expand Down

0 comments on commit edb50cc

Please sign in to comment.