Skip to content

Commit 33a04e6

Browse files
committed
fix incorrect use of std::extent in stockpiles
unintended consequence of #5847
1 parent 3bde796 commit 33a04e6

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎docs/changelog.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Template for new versions:
5959
## New Features
6060

6161
## Fixes
62+
- `stockpiles` will no longer incorrectly size the "rough gem" and "cut gem" vectors, which avoids a crash when viewing stockpile settings. This potentially affects anything that uses blueprints to create a stockpile, including `gui/quantum`
6263

6364
## Misc Improvements
6465

‎plugins/stockpiles/StockpileSerializer.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,24 +1984,24 @@ void StockpileSettingsSerializer::read_gems(color_ostream& out, DeserializeMode
19841984
std::bind(&StockpileSettings::gems, mBuffer),
19851985
mSettings->flags.whole,
19861986
mSettings->flags.mask_gems,
1987-
[&]() {
1987+
[&] () {
19881988
pgems.cut_other_mats.clear();
19891989
pgems.cut_mats.clear();
19901990
pgems.rough_other_mats.clear();
19911991
pgems.rough_mats.clear();
19921992
},
1993-
[&](bool all, char val) {
1994-
auto & bgems = mBuffer.gems();
1993+
[&] (bool all, char val) {
1994+
auto& bgems = mBuffer.gems();
19951995

19961996
unserialize_list_material(out, "mats/rough", all, val, filters, gem_mat_is_allowed,
1997-
[&](const size_t& idx) -> const string& { return bgems.rough_mats(idx); },
1997+
[&] (const size_t& idx) -> const string& { return bgems.rough_mats(idx); },
19981998
bgems.rough_mats_size(), pgems.rough_mats);
19991999

20002000
unserialize_list_material(out, "mats/cut", all, val, filters, gem_cut_mat_is_allowed,
2001-
[&](const size_t& idx) -> const string& { return bgems.cut_mats(idx); },
2001+
[&] (const size_t& idx) -> const string& { return bgems.cut_mats(idx); },
20022002
bgems.cut_mats_size(), pgems.cut_mats);
20032003

2004-
const size_t builtin_size = std::extent<decltype(world->raws.mat_table.builtin)>::value;
2004+
const size_t builtin_size = world->raws.mat_table.builtin.size();
20052005
pgems.rough_other_mats.resize(builtin_size, '\0');
20062006
pgems.cut_other_mats.resize(builtin_size, '\0');
20072007
if (all) {

0 commit comments

Comments
 (0)