From 0a5e24b7d75c68ffd516c3a957c2a801b8fba474 Mon Sep 17 00:00:00 2001 From: Rogier Date: Tue, 10 Mar 2015 13:23:44 +0100 Subject: [PATCH] Add option --silence-suggestions, to disable certain messages Specific message types will be in a later commit --- TileGenerator.cpp | 6 ++++++ TileGenerator.h | 4 ++++ doc/manual.rst | 11 +++++++++++ mapper.cpp | 28 ++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/TileGenerator.cpp b/TileGenerator.cpp index eeefa53..c1594b2 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -137,6 +137,7 @@ TileGenerator::TileGenerator(): verboseReadColors(0), verboseStatistics(0), progressIndicator(false), + m_silenceSuggestions(0), m_heightMap(false), m_heightMapYScale(1), m_seaLevel(0), @@ -208,6 +209,11 @@ TileGenerator::~TileGenerator() { } +void TileGenerator::setSilenceSuggestion(unsigned flags) +{ + m_silenceSuggestions |= flags; +} + void TileGenerator::setGenerateNoPrefetch(int enable) { m_generateNoPrefetch = enable; diff --git a/TileGenerator.h b/TileGenerator.h index 3c19000..d9ede27 100644 --- a/TileGenerator.h +++ b/TileGenerator.h @@ -54,6 +54,8 @@ #define SCALESIZE_VERT 50 #define HEIGHTSCALESIZE 60 +#define SUGGESTION_ALL 0xffffffff + class TileGenerator { private: @@ -109,6 +111,7 @@ public: TileGenerator(); ~TileGenerator(); + void setSilenceSuggestion(unsigned flags); void setGenerateNoPrefetch(int enable); void setDBFormat(BlockPos::StrFormat format, bool query); void setHeightMap(bool enable); @@ -217,6 +220,7 @@ public: bool progressIndicator; private: + unsigned m_silenceSuggestions; bool m_heightMap; float m_heightMapYScale; int m_seaLevel; diff --git a/doc/manual.rst b/doc/manual.rst index 958f095..284343e 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -282,6 +282,7 @@ Feedback / information options: * ``--version`` : Print version ID of minetestmapper * ``--verbose[=]`` : Report world and map statistics (size, dimensions, number of blocks) * ``--verbose-search-colors[=n]`` : Report which colors files are used and/or which locations are searched + * ``--silence-suggestions all`` : Do not bother doing suggestions * ``--progress`` : Show a progress indicator while generating the map Miscellaneous options @@ -1055,6 +1056,15 @@ Detailed Description of Options .. image:: images/drawscale-both.png .. image:: images/sidescale-interval.png +``--silence-suggestions all`` +...................................... + Do not print usage suggestions of the specified types. + + If applicable, minetestmapper may suggest using or adjusting certain options + if that may be advantageous. This option disables such messages. + + :all: Silence all existing (and future) suggestions there may be. + ``--sqlite-cacheworldrow`` .......................... This option is no longer supported, as minetestmapper performed @@ -1765,6 +1775,7 @@ More information is available: .. _--origincolor: `--origincolor `_ .. _--output: `--output `_ .. _--playercolor: `--playercolor `_ +.. _--silence-suggestions: `--silence-suggestions all`_ .. _--scalecolor: `--scalecolor `_ .. _--scalefactor: `--scalefactor 1:`_ .. _--height-level-0: `--height-level-0 `_ diff --git a/mapper.cpp b/mapper.cpp index 7cff181..7007116 100644 --- a/mapper.cpp +++ b/mapper.cpp @@ -41,6 +41,7 @@ using namespace std; #define OPT_SCALEINTERVAL 0x8f #define OPT_NO_BLOCKLIST_PREFETCH 0x90 #define OPT_DATABASE_FORMAT 0x91 +#define OPT_SILENCE_SUGGESTIONS 0x92 // Will be replaced with the actual name and location of the executable (if found) string executableName = "minetestmapper"; @@ -124,6 +125,7 @@ void usage() " --tilecenter ,|world|map\n" " --scalefactor 1:\n" " --chunksize \n" + " --silence-suggestions all\n" " --verbose[=n]\n" " --verbose-search-colors[=n]\n" " --progress\n" @@ -631,6 +633,7 @@ int main(int argc, char *argv[]) {"tilebordercolor", required_argument, 0, 'B'}, {"scalefactor", required_argument, 0, OPT_SCALEFACTOR}, {"chunksize", required_argument, 0, OPT_CHUNKSIZE}, + {"silence-suggestions", required_argument, 0, OPT_SILENCE_SUGGESTIONS}, {"verbose", optional_argument, 0, 'v'}, {"verbose-search-colors", optional_argument, 0, OPT_VERBOSE_SEARCH_COLORS}, {"progress", no_argument, 0, OPT_PROGRESS_INDICATOR}, @@ -863,6 +866,31 @@ int main(int argc, char *argv[]) } } break; + case OPT_SILENCE_SUGGESTIONS: { + for (size_t i = 0; i < strlen(optarg); i++) { + optarg[i] = tolower(optarg[i]); + if (optarg[i] == ',') + optarg[i] = ' '; + } + std::istringstream iss(optarg); + std::string flag; + do { + iss >> flag >> std::ws; + if (iss.fail()) { + std::cerr << "Invalid flag(s) to '" << long_options[option_index].name << "': '" << optarg << "'" << std::endl; + usage(); + exit(1); + } + else if (flag == "all") + generator.setSilenceSuggestion(SUGGESTION_ALL); + else { + std::cerr << "Invalid flag to '" << long_options[option_index].name << "': '" << flag << "'" << std::endl; + usage(); + exit(1); + } + } while (!iss.eof()); + } + break; case 'v': if (optarg && isdigit(optarg[0]) && optarg[1] == '\0') { generator.verboseStatistics = optarg[0] - '0';