From 4e864ae2dc3f8513b74c8c16514f19bead4a2c14 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 27 Oct 2023 22:23:51 -0700 Subject: [PATCH 1/3] adjust price of vermin swarms --- docs/changelog.txt | 1 + library/modules/Items.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 1c0dbd9f21..de74e37b88 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -58,6 +58,7 @@ Template for new versions: ## Fixes - `stockpiles`: hide configure and help buttons when the overlay panel is minimized +- `caravan`: price of vermin swarms correctly adjusted down. a stack of 10000 is worth 1, not 10000 ## Misc Improvements - `buildingplan`: display how many items are available on the planner panel diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index 9443344806..1a9ca1fa6f 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -2042,8 +2042,12 @@ int Items::getValue(df::item *item, df::caravan_state *caravan) { int divisor = 1; auto creature = vector_get(world->raws.creatures.all, mat_type); - if (creature && size_t(mat_subtype) < creature->caste.size()) - divisor = creature->caste[mat_subtype]->misc.petvalue_divisor; + if (creature) { + if (creature->flags.is_set(df::creature_raw_flags::VERMIN_SOIL_COLONY)) + divisor = 10000; + else if (size_t(mat_subtype) < creature->caste.size()) + divisor = creature->caste[mat_subtype]->misc.petvalue_divisor; + } if (divisor > 1) value /= divisor; } From 5f6cfcdbe7491e453b4ab9e3e9b79e9789f6519e Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 28 Oct 2023 10:25:26 -0700 Subject: [PATCH 2/3] don't special case vermin; fallback on caste instead --- library/modules/Items.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index 1a9ca1fa6f..a91ea34704 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -2043,13 +2043,15 @@ int Items::getValue(df::item *item, df::caravan_state *caravan) int divisor = 1; auto creature = vector_get(world->raws.creatures.all, mat_type); if (creature) { - if (creature->flags.is_set(df::creature_raw_flags::VERMIN_SOIL_COLONY)) - divisor = 10000; - else if (size_t(mat_subtype) < creature->caste.size()) - divisor = creature->caste[mat_subtype]->misc.petvalue_divisor; + size_t caste = std::max(0, mat_subtype); + if (caste < creature->caste.size()) + divisor = creature->caste[caste]->misc.petvalue_divisor; } - if (divisor > 1) + if (divisor > 1) { value /= divisor; + if (!value) + value = 1; + } } // Add in value from units contained in cages From 31b568b2d1214f827ed4cad861b00f90c1774db2 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 28 Oct 2023 10:26:55 -0700 Subject: [PATCH 3/3] update changelog --- docs/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index de74e37b88..d8e4a6ad44 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -58,7 +58,7 @@ Template for new versions: ## Fixes - `stockpiles`: hide configure and help buttons when the overlay panel is minimized -- `caravan`: price of vermin swarms correctly adjusted down. a stack of 10000 is worth 1, not 10000 +- `caravan`: price of vermin swarms correctly adjusted down. a stack of 10000 bees is worth 10, not 10000 ## Misc Improvements - `buildingplan`: display how many items are available on the planner panel