Add a command-line option to report which colors file is being used.

This commit is contained in:
Rogier 2014-06-09 08:30:50 +02:00
parent b7fe1404fa
commit 224c6b1df7
4 changed files with 22 additions and 0 deletions

View File

@ -339,3 +339,8 @@ verbose:
* database access statistics. * database access statistics.
verbose-search-colors:
report the location of the colors file that was used.
With `--verbose-search-colors=2`, report all locations that are being
searched as well.

View File

@ -118,6 +118,7 @@ static inline int readBlockContent(const unsigned char *mapData, int version, in
TileGenerator::TileGenerator(): TileGenerator::TileGenerator():
verboseCoordinates(0), verboseCoordinates(0),
verboseReadColors(0),
verboseStatistics(false), verboseStatistics(false),
progressIndicator(false), progressIndicator(false),
m_bgColor(255, 255, 255), m_bgColor(255, 255, 255),
@ -326,12 +327,16 @@ void TileGenerator::setMaxY(int y)
void TileGenerator::parseColorsFile(const std::string &fileName) void TileGenerator::parseColorsFile(const std::string &fileName)
{ {
if (verboseReadColors >= 2)
cout << "Checking for colors file: " << fileName << std::endl;
ifstream in; ifstream in;
in.open(fileName.c_str(), ifstream::in); in.open(fileName.c_str(), ifstream::in);
if (!in.is_open()) { if (!in.is_open()) {
throw std::runtime_error(std::string("Failed to open colors file '") + fileName + "'"); throw std::runtime_error(std::string("Failed to open colors file '") + fileName + "'");
return; return;
} }
if (verboseReadColors >= 1)
cout << "Reading colors file: " << fileName << std::endl;
parseColorsStream(in, fileName.c_str()); parseColorsStream(in, fileName.c_str());
in.close(); in.close();
} }

View File

@ -153,6 +153,7 @@ private:
public: public:
int verboseCoordinates; int verboseCoordinates;
int verboseReadColors;
bool verboseStatistics; bool verboseStatistics;
bool progressIndicator; bool progressIndicator;

View File

@ -25,6 +25,7 @@ using namespace std;
#define OPT_SQLITE_CACHEWORLDROW 0x81 #define OPT_SQLITE_CACHEWORLDROW 0x81
#define OPT_PROGRESS_INDICATOR 0x82 #define OPT_PROGRESS_INDICATOR 0x82
#define OPT_DRAW_OBJECT 0x83 #define OPT_DRAW_OBJECT 0x83
#define OPT_VERBOSE_SEARCH_COLORS 0x86
// Will be replaced with the actual name and location of the executable (if found) // Will be replaced with the actual name and location of the executable (if found)
string executableName = "minetestmapper"; string executableName = "minetestmapper";
@ -94,6 +95,7 @@ void usage()
" --tileorigin <x>,<y>|world|map\n" " --tileorigin <x>,<y>|world|map\n"
" --tilecenter <x>,<y>|world|map\n" " --tilecenter <x>,<y>|world|map\n"
" --verbose[=n]\n" " --verbose[=n]\n"
" --verbose-search-colors[=n]\n"
" --progress\n" " --progress\n"
"Color formats:\n" "Color formats:\n"
"\t'#000' or '#000000' (RGB)\n" "\t'#000' or '#000000' (RGB)\n"
@ -548,6 +550,7 @@ int main(int argc, char *argv[])
{"tilecenter", required_argument, 0, 'T'}, {"tilecenter", required_argument, 0, 'T'},
{"tilebordercolor", required_argument, 0, 'B'}, {"tilebordercolor", required_argument, 0, 'B'},
{"verbose", optional_argument, 0, 'v'}, {"verbose", optional_argument, 0, 'v'},
{"verbose-search-colors", optional_argument, 0, OPT_VERBOSE_SEARCH_COLORS},
{"progress", no_argument, 0, OPT_PROGRESS_INDICATOR}, {"progress", no_argument, 0, OPT_PROGRESS_INDICATOR},
{NULL, 0, 0, 0} {NULL, 0, 0, 0}
}; };
@ -627,6 +630,14 @@ int main(int argc, char *argv[])
generator.verboseCoordinates = 1; generator.verboseCoordinates = 1;
} }
break; break;
case OPT_VERBOSE_SEARCH_COLORS:
if (optarg && isdigit(optarg[0]) && optarg[1] == '\0') {
generator.verboseReadColors = optarg[0] - '0';
}
else {
generator.verboseReadColors++;
}
break;
case 'e': case 'e':
generator.setDrawAlpha(true); generator.setDrawAlpha(true);
break; break;