From acd2256900baba0e214982ba5db96364b21102c2 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 17 Jan 2023 21:26:33 -0800 Subject: [PATCH] restore orders library functionality --- docs/changelog.txt | 1 + docs/plugins/orders.rst | 2 +- plugins/orders.cpp | 21 ++++++++------------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index a5d4ab434..542c2b54f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## New Plugins ## Fixes +- `orders`: allow the orders library to be listed and imported properly (if you previously copied the orders library into your ``dfhack-config/orders`` directory to work around this bug, you can remove those files now) ## Misc Improvements diff --git a/docs/plugins/orders.rst b/docs/plugins/orders.rst index bc15fd175..8beb246e4 100644 --- a/docs/plugins/orders.rst +++ b/docs/plugins/orders.rst @@ -23,7 +23,7 @@ Usage one-time orders first, then yearly, seasonally, monthly, and finally, daily. You can keep your orders automatically sorted by adding the following command to -your ``onMapLoad.init`` file:: +your ``dfhack-config/init/onMapLoad.init`` file:: repeat -name orders-sort -time 1 -timeUnits days -command [ orders sort ] diff --git a/plugins/orders.cpp b/plugins/orders.cpp index 6118b3997..e3c57d0f1 100644 --- a/plugins/orders.cpp +++ b/plugins/orders.cpp @@ -41,7 +41,7 @@ DFHACK_PLUGIN("orders"); REQUIRE_GLOBAL(world); static const std::string ORDERS_DIR = "dfhack-config/orders"; -static const std::string ORDERS_LIBRARY_DIR = "dfhack-config/orders/library"; +static const std::string ORDERS_LIBRARY_DIR = "hack/data/orders"; static command_result orders_command(color_ostream & out, std::vector & parameters); @@ -86,6 +86,11 @@ static command_result orders_command(color_ostream & out, std::vector files; - if (0 < Filesystem::listdir_recursive(ORDERS_DIR, files, 0, false)) - { - out << COLOR_LIGHTRED << "Unable to list files in directory: " << ORDERS_DIR << std::endl; - return CR_FAILURE; - } + Filesystem::listdir_recursive(ORDERS_DIR, files, 0, false); - if (files.empty()) - { - out << COLOR_YELLOW << "No exported orders yet. Create manager orders and export them with 'orders export ', or copy pre-made orders .json files into " << ORDERS_DIR << "." << std::endl << std::endl; - } - - for (auto it : files) - { + for (auto it : files) { if (it.second) continue; // skip directories std::string name = it.first;