Fix some issues

develop
Jared Adams 2012-05-07 18:31:28 -06:00
parent 567b3e2a52
commit 833bf518d9
2 changed files with 24 additions and 16 deletions

@ -201,17 +201,17 @@ command_result parseRectangle(color_ostream & out,
int & width, int & height, int & zLevels, int & width, int & height, int & zLevels,
bool hasConsole = true) bool hasConsole = true)
{ {
int newWidth = 0, newHeight = 0, newZLevels = 1; int newWidth = 0, newHeight = 0, newZLevels = 0;
// z is different so 'range w h' won't ask for it.
if (end > start + 1) if (end > start + 1)
{ {
newWidth = atoi(input[start++].c_str()); newWidth = atoi(input[start++].c_str());
newHeight = atoi(input[start++].c_str()); newHeight = atoi(input[start++].c_str());
} if (end > start) {
newZLevels = atoi(input[start++].c_str());
if (end > start) { } else {
newZLevels = atoi(input[start++].c_str()); newZLevels = 1; // So 'range w h' won't ask for it.
}
} }
string command = ""; string command = "";
@ -226,7 +226,7 @@ command_result parseRectangle(color_ostream & out,
str << "Set range width <" << width << "> "; str << "Set range width <" << width << "> ";
con.lineedit(str.str(), command, hist); con.lineedit(str.str(), command, hist);
hist.add(command); hist.add(command);
newWidth = command == "" ? width : atoi(command.c_str()); newWidth = command.empty() ? width : atoi(command.c_str());
} else { } else {
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
} }
@ -240,7 +240,7 @@ command_result parseRectangle(color_ostream & out,
str << "Set range height <" << height << "> "; str << "Set range height <" << height << "> ";
con.lineedit(str.str(), command, hist); con.lineedit(str.str(), command, hist);
hist.add(command); hist.add(command);
newHeight = command == "" ? height : atoi(command.c_str()); newHeight = command.empty() ? height : atoi(command.c_str());
} else { } else {
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
} }
@ -254,7 +254,7 @@ command_result parseRectangle(color_ostream & out,
str << "Set range z-levels <" << zLevels << "> "; str << "Set range z-levels <" << zLevels << "> ";
con.lineedit(str.str(), command, hist); con.lineedit(str.str(), command, hist);
hist.add(command); hist.add(command);
newZLevels = command == "" ? zLevels : atoi(command.c_str()); newZLevels = command.empty() ? zLevels : atoi(command.c_str());
} else { } else {
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
} }
@ -262,7 +262,7 @@ command_result parseRectangle(color_ostream & out,
width = newWidth < 1? 1 : newWidth; width = newWidth < 1? 1 : newWidth;
height = newHeight < 1? 1 : newHeight; height = newHeight < 1? 1 : newHeight;
zLevels = newZLevels < 1? 1 : zLevels; zLevels = newZLevels < 1? 1 : newZLevels;
return CR_OK; return CR_OK;
} }

@ -461,14 +461,10 @@ bool tryVariant(std::string value, TileType &paint)
bool processTileType(color_ostream & out, TileType &paint, std::vector<std::string> &params, int start, int end) bool processTileType(color_ostream & out, TileType &paint, std::vector<std::string> &params, int start, int end)
{ {
if (params.size() < start + 2)
{
return false;
}
int loc = start; int loc = start;
std::string option = params[loc++]; std::string option = params[loc++];
std::string value = params[loc++]; std::string value = end <= loc ? "" : params[loc++];
tolower(option);
toupper(value); toupper(value);
int valInt; int valInt;
if (value == "ANY") if (value == "ANY")
@ -605,6 +601,18 @@ bool processTileType(color_ostream & out, TileType &paint, std::vector<std::stri
out << "Unknown skyview flag: " << value << std::endl; out << "Unknown skyview flag: " << value << std::endl;
} }
} }
else if (option == "aquifer" || option == "aqua")
{
if (valInt >= -1 && valInt < 2)
{
paint.aquifer = valInt;
found = true;
}
else
{
out << "Unknown aquifer flag: " << value << std::endl;
}
}
else if (option == "all" || option == "a") else if (option == "all" || option == "a")
{ {
loc--; loc--;