fix index out of bounds error when reading gems

develop
Myk Taylor 2023-04-10 23:07:18 -07:00
parent 970f7df6c2
commit 51047367f4
No known key found for this signature in database
3 changed files with 15 additions and 9 deletions

@ -42,6 +42,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `blueprint`: interpret saplings, shrubs, and twigs as floors instead of walls
- `combine`: fix error processing stockpiles with boundaries that extend outside of the map
- `prospector`: display both "raw" Z levels and "cooked" elevations
- `stockpiles`: fix crash when importing settings for gems from other worlds
- `stockpiles`: allow numbers in saved stockpile filenames
## Misc Improvements
- `buildingplan`: items in the item selection dialog should now use the same item quality symbols as the base game

@ -62,7 +62,7 @@ local function assert_safe_name(name)
if not name or #name == 0 then
qerror('name missing or empty')
end
if name:find('[^%a._]') then
if name:find('[^%w._]') then
qerror('name can only contain numbers, letters, periods, and underscores')
end
end

@ -1871,15 +1871,19 @@ void StockpileSerializer::read_gems(DeserializeMode mode, const vector<string>&
return;
} else {
MaterialInfo mi;
for (size_t i = 0; i < builtin_size; ++i) {
for (int i = 0; i < (int)builtin_size; ++i) {
if (i < bgems.rough_other_mats_size()) {
string id = bgems.rough_other_mats(i);
if (mi.find(id) && mi.isValid() && size_t(mi.type) < builtin_size)
set_filter_elem("other/rough", filters, val, id, mi.type, pgems.rough_other_mats.at(mi.type));
id = bgems.cut_other_mats(i);
}
if (i < bgems.cut_other_mats_size()) {
string id = bgems.cut_other_mats(i);
if (mi.find(id) && mi.isValid() && size_t(mi.type) < builtin_size)
set_filter_elem("other/cut", filters, val, id, mi.type, pgems.cut_other_mats.at(mi.type));
}
}
}
});
}