diff --git a/src/karts/xml_characteristic.cpp b/src/karts/xml_characteristic.cpp index 82c0b5d0d..99be54e41 100644 --- a/src/karts/xml_characteristic.cpp +++ b/src/karts/xml_characteristic.cpp @@ -212,8 +212,9 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value, std::size_t pos2; while ((pos2 = processor.find_first_of(operators, pos)) != std::string::npos) { - parts.push_back(processor.substr(pos, pos2)); - operations.push_back(processor.substr(pos2, pos2 + 1)); + std::string s = processor.substr(pos, pos2); + parts.push_back(processor.substr(pos, pos2-pos)); + operations.push_back(processor.substr(pos2, 1)); pos = pos2 + 1; } parts.push_back(processor.substr(pos)); @@ -224,15 +225,15 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value, // If nothing preceeds the first operator, insert x if (parts[index].empty()) { - if (!*is_set) + // - is a special case: We don't take e.g. "-5" as relative, it + // describes a negative number. So + if (!*is_set && operations[index] == "-") + *value = 0; + else if (!*is_set) { Log::error("XmlCharacteristic::processFloat", "x is unknown"); return; } - // - is a special case: We don't take e.g. "-5" as relative, it - // describes a negative number - else if (operations[index] == "-") - *value = 0; else *value = x; }