From f8de51aba3bd8710c59203e16bce50cb1f6e95ec Mon Sep 17 00:00:00 2001 From: silverflyone Date: Tue, 4 Apr 2023 03:08:43 +1000 Subject: [PATCH 1/7] Update Buildings.cpp Fixes #3159. Valid map coordinates from (0, 0, 0) to (world->map.x_count - 1, world->map.y_count - 1, world->map.z_count - 1). Stockpile coords (x1, y1, z) to (x2, y2, z) may lie outside of this region. Use min of (0, 0) and max of (world->map.x_count - 1, world->map.y_count - 1) when iterating the block. --- library/modules/Buildings.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 2b6fc8ec8..8a71485b2 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -1637,17 +1637,17 @@ StockpileIterator& StockpileIterator::operator++() { ++current; } else { // Start with the top-left block covering the stockpile. - block = Maps::getTileBlock(stockpile->x1, stockpile->y1, stockpile->z); + block = Maps::getTileBlock(std::min(std::max(stockpile->x1, 0), world->map.x_count-1), std::min(std::max(stockpile->y1, 0), world->map.y_count-1), stockpile->z); current = 0; } while (current >= block->items.size()) { // Out of items in this block; find the next block to search. - if (block->map_pos.x + 16 <= stockpile->x2) { - block = Maps::getTileBlock(block->map_pos.x + 16, block->map_pos.y, stockpile->z); + if (std::max(block->map_pos.x + 16, 0) <= std::min(std::max(stockpile->x2, 0), world->map.x_count-1)) { + block = Maps::getTileBlock(std::min(std::max(block->map_pos.x + 16, 0), world->map.x_count-1), block->map_pos.y, stockpile->z); current = 0; - } else if (block->map_pos.y + 16 <= stockpile->y2) { - block = Maps::getTileBlock(stockpile->x1, block->map_pos.y + 16, stockpile->z); + } else if (std::max(block->map_pos.y + 16, 0) <= std::min(std::max(stockpile->y2, 0), world->map.y_count-1)) { + block = Maps::getTileBlock(std::min(std::max(stockpile->x1, 0), world->map.x_count-1), std::min(std::max(block->map_pos.y + 16, 0), world->map.y_count-1), stockpile->z); current = 0; } else { // All items in all blocks have been checked. From 181f0bdf720f85f29c3c159b7f77d70b00dc22cc Mon Sep 17 00:00:00 2001 From: silverflyone Date: Tue, 4 Apr 2023 03:27:32 +1000 Subject: [PATCH 2/7] Update Buildings.cpp Boundary checks added. --- library/modules/Buildings.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 8a71485b2..172975e21 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -1635,6 +1635,12 @@ StockpileIterator& StockpileIterator::operator++() { if (block) { // Check the next item in the current block. ++current; + } + else if (stockpile->x2 < 0 || stockpile->y2 < 0 || stockpile->z < 0 || stockpile->x1 > world->map.x_count - 1 || stockpile->y1 > world->map.y_count - 1 || stockpile->z > world->map.z_count - 1) { + // if the stockpile bounds exist outside of valid map plane then no items can be in the stockpile + block = NULL; + item = NULL; + return *this; } else { // Start with the top-left block covering the stockpile. block = Maps::getTileBlock(std::min(std::max(stockpile->x1, 0), world->map.x_count-1), std::min(std::max(stockpile->y1, 0), world->map.y_count-1), stockpile->z); From 0cf4497328807fe9d2b3531e15fe498040d013e2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 02:55:13 +0000 Subject: [PATCH 3/7] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/python-jsonschema/check-jsonschema: 0.21.0 → 0.22.0](https://github.com/python-jsonschema/check-jsonschema/compare/0.21.0...0.22.0) - [github.com/Lucas-C/pre-commit-hooks: v1.4.2 → v1.5.1](https://github.com/Lucas-C/pre-commit-hooks/compare/v1.4.2...v1.5.1) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 94bfad310..c305de56c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,11 +20,11 @@ repos: args: ['--fix=lf'] - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.21.0 + rev: 0.22.0 hooks: - id: check-github-workflows - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.4.2 + rev: v1.5.1 hooks: - id: forbid-tabs exclude_types: From d12938fb238f24e2dcfbe4e8703f7ea16eb7a71e Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Tue, 4 Apr 2023 07:13:18 +0000 Subject: [PATCH 4/7] Auto-update submodules library/xml: master scripts: master --- library/xml | 2 +- scripts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index 739d17867..d7f07e54b 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 739d1786723bbe912f448064c5705092a7936cc6 +Subproject commit d7f07e54b4ea7832b226f8d8678906c9c366918a diff --git a/scripts b/scripts index d2dad272e..53f0aedf9 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit d2dad272e4b24c043ca62f843511c763fb1f67b5 +Subproject commit 53f0aedf9f7df33a4f79246ba46de02794619d09 From 0cebad10785423cd5f6f3b854eb8594738eaed02 Mon Sep 17 00:00:00 2001 From: silverflyone Date: Wed, 5 Apr 2023 11:49:14 +1000 Subject: [PATCH 5/7] Update Buildings.cpp Removed extra min/max checks. --- library/modules/Buildings.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 172975e21..23b3263f3 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -1649,11 +1649,11 @@ StockpileIterator& StockpileIterator::operator++() { while (current >= block->items.size()) { // Out of items in this block; find the next block to search. - if (std::max(block->map_pos.x + 16, 0) <= std::min(std::max(stockpile->x2, 0), world->map.x_count-1)) { - block = Maps::getTileBlock(std::min(std::max(block->map_pos.x + 16, 0), world->map.x_count-1), block->map_pos.y, stockpile->z); + if (block->map_pos.x + 16 <= std::min(stockpile->x2, world->map.x_count-1)) { + block = Maps::getTileBlock(block->map_pos.x + 16, block->map_pos.y, stockpile->z); current = 0; - } else if (std::max(block->map_pos.y + 16, 0) <= std::min(std::max(stockpile->y2, 0), world->map.y_count-1)) { - block = Maps::getTileBlock(std::min(std::max(stockpile->x1, 0), world->map.x_count-1), std::min(std::max(block->map_pos.y + 16, 0), world->map.y_count-1), stockpile->z); + } else if (block->map_pos.y + 16 <= std::min(stockpile->y2, world->map.y_count-1)) { + block = Maps::getTileBlock(std::max(stockpile->x1, 0), block->map_pos.y + 16, stockpile->z); current = 0; } else { // All items in all blocks have been checked. From d42d9ec6268ef7654c386a67b1ef9da9cd91b699 Mon Sep 17 00:00:00 2001 From: silverflyone Date: Wed, 5 Apr 2023 12:53:39 +1000 Subject: [PATCH 6/7] Update changelog.txt Fix log entry --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index ff9d05b0f..7cc0ed0c0 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -39,6 +39,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `hotkeys`: hotkey hints on menu popup will no longer get their last character cut off by the scrollbar - ``launchdf``: launch Dwarf Fortress via the Steam client so Steam Workshop is functional - `blueprint`: interpret saplings, shrubs, and twigs as floors instead of walls +- ``Buildings::StockpileIterator:``: fix to use world map boundaries when stockpile coordinates exist outside of the world map. Fixes unhandled exception for `combine`. ## Misc Improvements - `buildingplan`: items in the item selection dialog should now use the same item quality symbols as the base game From 7294678e2757f671ff44ffd88ef3655ca90c7920 Mon Sep 17 00:00:00 2001 From: Myk Date: Tue, 4 Apr 2023 22:42:58 -0700 Subject: [PATCH 7/7] Update docs/changelog.txt --- docs/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 7cc0ed0c0..7f3262099 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -39,7 +39,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `hotkeys`: hotkey hints on menu popup will no longer get their last character cut off by the scrollbar - ``launchdf``: launch Dwarf Fortress via the Steam client so Steam Workshop is functional - `blueprint`: interpret saplings, shrubs, and twigs as floors instead of walls -- ``Buildings::StockpileIterator:``: fix to use world map boundaries when stockpile coordinates exist outside of the world map. Fixes unhandled exception for `combine`. +- `combine`: fix error processing stockpiles with boundaries that extend outside of the map ## Misc Improvements - `buildingplan`: items in the item selection dialog should now use the same item quality symbols as the base game