From 21f8c58aeb9eee5498620fc6dfd6313f2f907bea Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Sat, 30 May 2015 06:38:58 -0300 Subject: [PATCH] Print info loglevel debug info when registering color ranges and palettes --- src/color_range.cpp | 16 ++++++++++++++++ src/color_range.hpp | 3 +++ src/game_config.cpp | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/src/color_range.cpp b/src/color_range.cpp index 62d7a83429c..89caa4f92b2 100644 --- a/src/color_range.cpp +++ b/src/color_range.cpp @@ -184,3 +184,19 @@ int color_range::index() const } return 0; } + +std::string color_range::debug() const +{ + std::ostringstream o; + + static const Uint32 mask = 0x00FFFFFF; + + o << std::hex << std::setfill('0') + << '{' << std::setw(6) << (mid_ & mask) + << ',' << std::setw(6) << (max_ & mask) + << ',' << std::setw(6) << (min_ & mask) + << ',' << std::setw(6) << (rep_ & mask) + << '}'; + + return o.str(); +} diff --git a/src/color_range.hpp b/src/color_range.hpp index 79a379f477c..12bc4bf094f 100644 --- a/src/color_range.hpp +++ b/src/color_range.hpp @@ -102,6 +102,9 @@ public: int index() const; // the default team index for this color, or 0 for none + /** Return a string describing the color range for debug output. */ + std::string debug() const; + private: Uint32 mid_ , max_ , min_ , rep_; }; diff --git a/src/game_config.cpp b/src/game_config.cpp index 1c38d4ab4fc..8771008c97e 100644 --- a/src/game_config.cpp +++ b/src/game_config.cpp @@ -31,6 +31,7 @@ static lg::log_domain log_engine("engine"); #define DBG_NG LOG_STREAM(debug, log_engine) +#define LOG_NG LOG_STREAM(info, log_engine) #define ERR_NG LOG_STREAM(err, log_engine) namespace game_config @@ -335,6 +336,9 @@ namespace game_config } team_rgb_range.insert(std::make_pair(id,color_range(temp))); team_rgb_name[id] = teamC["name"]; + + LOG_NG << "registered color range '" << id << "': " << team_rgb_range[id].debug() << '\n'; + //generate palette of same name; std::vector tp = palette(team_rgb_range[id]); if (tp.empty()) { @@ -352,6 +356,7 @@ namespace game_config ERR_NG << "Invalid color palette: " << rgb.second << std::endl; } team_rgb_colors.insert(std::make_pair(rgb.first, temp)); + LOG_NG << "registered color palette: " << rgb.first << '\n'; } } }