From 52dec0114f890d03e6ba7e92822208bdebac75ce Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 16 Mar 2023 23:45:22 -0700 Subject: [PATCH] properly count required bars/cloth and don't output confusing total quantities --- docs/changelog.txt | 2 ++ plugins/showmood.cpp | 24 ++++++------------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 5a668f344..b0ebc87f1 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,6 +38,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes -@ `buildingplan`: items are now attached correctly to screw pumps and other multi-item buildings -@ `buildingplan`: buildings with different material filters will no longer get "stuck" if one of the filters currently matches no items +- `showmood` properly count required number of bars and cloth when they aren't the main item for the strange mood ## Misc Improvements -@ `buildingplan`: can now filter by clay materials @@ -49,6 +50,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `blueprint`: now writes blueprints to the ``dfhack-config/blueprints`` directory - `blueprint-library-guide`: library blueprints have moved from ``blueprints`` to ``hack/data/blueprints`` - player-created blueprints should now go in the ``dfhack-config/blueprints`` folder. please move your existing blueprints from ``blueprints`` to ``dfhack-config/blueprints``. you don't need to move the library blueprints -- those can be safely deleted from the old ``blueprints`` directory. +-@ `showmood`: clarify how many bars and/or cloth items are actually needed for the mood ## Documentation diff --git a/plugins/showmood.cpp b/plugins/showmood.cpp index 79a733b7b..3ef6a6fb2 100644 --- a/plugins/showmood.cpp +++ b/plugins/showmood.cpp @@ -275,29 +275,17 @@ command_result df_showmood (color_ostream &out, vector & parameters) // count how many items of this type the crafter already collected { int count_got = 0; - int dimension_got = 0; int divisor = 1; - bool has_dims = false; - if (item->item_type == item_type::BAR) { + if (item->item_type == item_type::BAR) divisor = 150; - has_dims = true; - } else if (item->item_type == item_type::CLOTH) { + else if (item->item_type == item_type::CLOTH) divisor = 10000; - has_dims = true; - } - for (size_t j = 0; j < job->items.size(); j++) - { - if(job->items[j]->job_item_idx == int32_t(i)) - { - if (has_dims) - dimension_got += job->items[j]->item->getTotalDimension(); + for (size_t j = 0; j < job->items.size(); j++) { + if (job->items[j]->job_item_idx == int32_t(i)) count_got += 1; - } } - out.print(", got %i of %i", count_got, item->quantity/divisor); - if (has_dims) - out.print(" (%i of %i sub-units)", dimension_got, item->quantity); - out.print("\n"); + out.print(", got %i of %i\n", count_got, + item->quantity < divisor ? item->quantity : item->quantity/divisor); } } }