allow whitespace in create item masks

This commit is contained in:
Martin Michelsen
2025-11-28 12:41:25 -08:00
parent e02a006b60
commit 3ef91b0159
2 changed files with 17 additions and 14 deletions
+16 -8
View File
@@ -264,22 +264,30 @@ phosg::JSON QuestMetadata::json() const {
QuestMetadata::CreateItemMask::CreateItemMask(const std::string& s) {
phosg::StringReader r(s);
// Ignore all whitespace
auto get_ch = [&]() -> char {
char ch = r.get_s8();
while ((ch == ' ') || (ch == '\t')) {
ch = r.get_s8();
}
return ch;
};
for (size_t z = 0; z < 12 && !r.eof(); z++) {
auto& range = this->data1_ranges[z];
char c = r.get_s8();
char c = get_ch();
if (c == '[') {
c = r.get_s8();
range.min = (phosg::value_for_hex_char(c) << 4) | phosg::value_for_hex_char(r.get_s8());
if (r.get_s8() != '-') {
c = get_ch();
range.min = (phosg::value_for_hex_char(c) << 4) | phosg::value_for_hex_char(get_ch());
if (get_ch() != '-') {
throw std::runtime_error("invalid range spec");
}
c = r.get_s8();
range.max = (phosg::value_for_hex_char(c) << 4) | phosg::value_for_hex_char(r.get_s8());
if (r.get_s8() != ']') {
c = get_ch();
range.max = (phosg::value_for_hex_char(c) << 4) | phosg::value_for_hex_char(get_ch());
if (get_ch() != ']') {
throw std::runtime_error("invalid range spec");
}
} else {
range.min = (phosg::value_for_hex_char(c) << 4) | phosg::value_for_hex_char(r.get_s8());
range.min = (phosg::value_for_hex_char(c) << 4) | phosg::value_for_hex_char(get_ch());
range.max = range.min;
}
}