Fix issue with loading 0-dice monster attacks

This commit is contained in:
2017-01-21 16:18:49 -05:00
parent 324922b15d
commit e30c509ff1

View File

@@ -1143,19 +1143,20 @@ void readItemsFromXml(ticpp::Document&& data, cScenario& scenario) {
static std::pair<int,int> parseDice(std::string str, std::string elem, std::string attr, std::string fname, int row, int col) {
int count = 0, sides = 0;
bool found_d = false;
bool found_d = false, found_count = false;
for(char c : str) {
if(isdigit(c)) {
if(found_d) {
sides *= 10;
sides += c - '0';
} else {
found_count = true;
count *= 10;
count += c - '0';
}
} else if(!found_d && c == 'd') {
found_d = true;
if(count == 0) count = 1;
if(!found_count) count = 1;
}
else throw xBadVal(elem, attr, str, row, col, fname);
}