From 383966511d695f2fabb1349036de61358a8c6b3c Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 21 Jul 2023 16:39:36 -0700 Subject: [PATCH 1/2] don't modify container while iterating --- plugins/logistics.cpp | 9 ++++++--- plugins/lua/logistics.lua | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/logistics.cpp b/plugins/logistics.cpp index 643fb4941..69b864c5c 100644 --- a/plugins/logistics.cpp +++ b/plugins/logistics.cpp @@ -122,6 +122,7 @@ static df::building_stockpilest* find_stockpile(int32_t stockpile_number) { static void validate_stockpile_configs(color_ostream& out, unordered_map &cache) { + vector to_remove; for (auto& entry : watched_stockpiles) { int stockpile_number = entry.first; PersistentDataItem &c = entry.second; @@ -129,13 +130,15 @@ static void validate_stockpile_configs(color_ostream& out, if (!bld || ( !get_config_bool(c, STOCKPILE_CONFIG_MELT) && !get_config_bool(c, STOCKPILE_CONFIG_TRADE) && - !get_config_bool(c, STOCKPILE_CONFIG_DUMP) && - !get_config_bool(c, STOCKPILE_CONFIG_TRAIN))) { - remove_stockpile_config(out, stockpile_number); + !get_config_bool(c, STOCKPILE_CONFIG_DUMP) && + !get_config_bool(c, STOCKPILE_CONFIG_TRAIN))) { + to_remove.push_back(stockpile_number); continue; } cache.emplace(bld, c); } + for (int stockpile_number : to_remove) + remove_stockpile_config(out, stockpile_number); } // remove this function once saves from 50.08 are no longer compatible diff --git a/plugins/lua/logistics.lua b/plugins/lua/logistics.lua index 891332236..0231ce593 100644 --- a/plugins/lua/logistics.lua +++ b/plugins/lua/logistics.lua @@ -75,7 +75,7 @@ local function print_status() print(('Total items marked for melting: %5d'):format(global_stats.total_melt)) print(('Total items marked for trading: %5d'):format(global_stats.total_trade)) print(('Total items marked for dumping: %5d'):format(global_stats.total_dump)) - print(('Total animals marked for training: %5d'):format(global_stats.total_train)) + print(('Total animals marked for training: %2d'):format(global_stats.total_train)) end local function for_stockpiles(opts, fn) From 87a391b2ce8a7fc6bfd8c6f280cef4e1043f49cb Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 21 Jul 2023 17:46:38 -0700 Subject: [PATCH 2/2] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index e8fc5725c..ff171fbb4 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -44,6 +44,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `logistics`: don't autotrain domestic animals brought by invaders (they'll get attacked by friendly creatures as soon as you let them out of their cage) - `logistics`: don't bring trade goods to depot if the only caravans present are tribute caravans - `gui/create-item`: when choosing a citizen to create the chosen items, avoid choosing a dead citizen +- `logistics`: fix potential crash when removing stockpiles or turning off stockpile features ## Misc Improvements - `stockpiles`: include exotic pets in the "tameable" filter