From 833bf518d973473d8abf8533e58b069610ddeb9c Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 7 May 2012 18:31:28 -0600 Subject: [PATCH] Fix some issues --- plugins/Brushes.h | 20 ++++++++++---------- plugins/tiletypes.cpp | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/plugins/Brushes.h b/plugins/Brushes.h index 7cbc73daa..a408f47b9 100644 --- a/plugins/Brushes.h +++ b/plugins/Brushes.h @@ -201,17 +201,17 @@ command_result parseRectangle(color_ostream & out, int & width, int & height, int & zLevels, bool hasConsole = true) { - int newWidth = 0, newHeight = 0, newZLevels = 1; - // z is different so 'range w h' won't ask for it. + int newWidth = 0, newHeight = 0, newZLevels = 0; if (end > start + 1) { newWidth = atoi(input[start++].c_str()); newHeight = atoi(input[start++].c_str()); - } - - if (end > start) { - newZLevels = atoi(input[start++].c_str()); + if (end > start) { + newZLevels = atoi(input[start++].c_str()); + } else { + newZLevels = 1; // So 'range w h' won't ask for it. + } } string command = ""; @@ -226,7 +226,7 @@ command_result parseRectangle(color_ostream & out, str << "Set range width <" << width << "> "; con.lineedit(str.str(), command, hist); hist.add(command); - newWidth = command == "" ? width : atoi(command.c_str()); + newWidth = command.empty() ? width : atoi(command.c_str()); } else { return CR_WRONG_USAGE; } @@ -240,7 +240,7 @@ command_result parseRectangle(color_ostream & out, str << "Set range height <" << height << "> "; con.lineedit(str.str(), command, hist); hist.add(command); - newHeight = command == "" ? height : atoi(command.c_str()); + newHeight = command.empty() ? height : atoi(command.c_str()); } else { return CR_WRONG_USAGE; } @@ -254,7 +254,7 @@ command_result parseRectangle(color_ostream & out, str << "Set range z-levels <" << zLevels << "> "; con.lineedit(str.str(), command, hist); hist.add(command); - newZLevels = command == "" ? zLevels : atoi(command.c_str()); + newZLevels = command.empty() ? zLevels : atoi(command.c_str()); } else { return CR_WRONG_USAGE; } @@ -262,7 +262,7 @@ command_result parseRectangle(color_ostream & out, width = newWidth < 1? 1 : newWidth; height = newHeight < 1? 1 : newHeight; - zLevels = newZLevels < 1? 1 : zLevels; + zLevels = newZLevels < 1? 1 : newZLevels; return CR_OK; } diff --git a/plugins/tiletypes.cpp b/plugins/tiletypes.cpp index b7914f259..59bdc7b3d 100644 --- a/plugins/tiletypes.cpp +++ b/plugins/tiletypes.cpp @@ -461,14 +461,10 @@ bool tryVariant(std::string value, TileType &paint) bool processTileType(color_ostream & out, TileType &paint, std::vector ¶ms, int start, int end) { - if (params.size() < start + 2) - { - return false; - } - int loc = start; std::string option = params[loc++]; - std::string value = params[loc++]; + std::string value = end <= loc ? "" : params[loc++]; + tolower(option); toupper(value); int valInt; if (value == "ANY") @@ -605,6 +601,18 @@ bool processTileType(color_ostream & out, TileType &paint, std::vector= -1 && valInt < 2) + { + paint.aquifer = valInt; + found = true; + } + else + { + out << "Unknown aquifer flag: " << value << std::endl; + } + } else if (option == "all" || option == "a") { loc--;