diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aec7a20252..cd7debba64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: args: ['--fix=lf'] - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.28.6 + rev: 0.29.1 hooks: - id: check-github-workflows - repo: https://github.com/Lucas-C/pre-commit-hooks diff --git a/docs/changelog.txt b/docs/changelog.txt index 04a1e31a05..cb53923b80 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -56,6 +56,7 @@ Template for new versions: ## New Features ## Fixes +- `buildingplan`: improved performance in forts with large numbers of items ## Misc Improvements diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index d774745dd3..b44dc00858 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -263,7 +263,6 @@ static void add_zone_to_all_buildings(df::building* zone_as_building) static void remove_building_from_zone(df::building* bld, df::building_civzonest* zone) { erase_from_vector(zone->contained_buildings, &df::building::id, bld->id); vector_erase_at(bld->relations, binsearch_index(bld->relations, &df::building::id, zone->id)); - } static void remove_zone_from_all_buildings(df::building* zone_as_building) diff --git a/library/xml b/library/xml index 0f72fd964d..bce0053c6b 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 0f72fd964d1cc230226a598c99be129f82c1dba0 +Subproject commit bce0053c6b3146e1e9465cf88d3ef2fb754efff0 diff --git a/plugins/autobutcher.cpp b/plugins/autobutcher.cpp index db6e23d76d..42cddf42a7 100644 --- a/plugins/autobutcher.cpp +++ b/plugins/autobutcher.cpp @@ -146,7 +146,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) autobutcher_cycle(out); return CR_OK; } diff --git a/plugins/autochop.cpp b/plugins/autochop.cpp index bce3e2fe08..054cc7bd0a 100644 --- a/plugins/autochop.cpp +++ b/plugins/autochop.cpp @@ -190,7 +190,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) { + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) { int32_t designated = do_cycle(out); if (0 < designated) out.print("autochop: designated %d tree(s) for chopping\n", designated); diff --git a/plugins/autoclothing.cpp b/plugins/autoclothing.cpp index b7f75f379f..22c31c610d 100644 --- a/plugins/autoclothing.cpp +++ b/plugins/autoclothing.cpp @@ -293,7 +293,7 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { // Whatever you put here will be done in each game step. Don't abuse it. // It's optional, so you can just comment it out like this if you don't need it. DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) do_autoclothing(); return CR_OK; } diff --git a/plugins/autofarm.cpp b/plugins/autofarm.cpp index 7e80aee47b..e5e161a80e 100644 --- a/plugins/autofarm.cpp +++ b/plugins/autofarm.cpp @@ -444,7 +444,7 @@ DFhackCExport command_result plugin_shutdown(color_ostream& out) DFhackCExport command_result plugin_onupdate(color_ostream& out) { - if (enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) autofarmInstance->process(out); return CR_OK; diff --git a/plugins/autonestbox.cpp b/plugins/autonestbox.cpp index 2ac881e0b4..36455511f1 100644 --- a/plugins/autonestbox.cpp +++ b/plugins/autonestbox.cpp @@ -111,7 +111,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) autonestbox_cycle(out); return CR_OK; } diff --git a/plugins/autoslab.cpp b/plugins/autoslab.cpp index 94981858c6..3de30be7e9 100644 --- a/plugins/autoslab.cpp +++ b/plugins/autoslab.cpp @@ -126,8 +126,7 @@ static const int32_t CYCLE_TICKS = 1289; DFhackCExport command_result plugin_onupdate(color_ostream &out) { - CoreSuspender suspend; - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) do_cycle(out); return CR_OK; } diff --git a/plugins/buildingplan/buildingplan.cpp b/plugins/buildingplan/buildingplan.cpp index 4943d19b9f..f8db78bbc2 100644 --- a/plugins/buildingplan/buildingplan.cpp +++ b/plugins/buildingplan/buildingplan.cpp @@ -343,8 +343,7 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out) { if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) return CR_OK; - if (is_enabled && - (cycle_requested || world->frame_counter - cycle_timestamp >= CYCLE_TICKS)) + if (cycle_requested || world->frame_counter - cycle_timestamp >= CYCLE_TICKS) do_cycle(out); return CR_OK; } @@ -667,22 +666,23 @@ static int scanAvailableItems(color_ostream &out, df::building_type type, int16_ auto &jitem = job_items[index]; auto vector_ids = getVectorIds(out, jitem, ignore_filters); + ItemFilter filter = filters[index]; + set special = specials; + if (ignore_filters || counts) { + // don't filter by material; we want counts for all materials + filter.setMaterialMask(0); + filter.setMaterials(set()); + special.clear(); + } + if (ignore_quality) { + filter.setMinQuality(df::item_quality::Ordinary); + filter.setMaxQuality(df::item_quality::Artifact); + } + int count = 0; for (auto vector_id : vector_ids) { auto other_id = ENUM_ATTR(job_item_vector_id, other, vector_id); for (auto &item : df::global::world->items.other[other_id]) { - ItemFilter filter = filters[index]; - set special = specials; - if (ignore_filters || counts) { - // don't filter by material; we want counts for all materials - filter.setMaterialMask(0); - filter.setMaterials(set()); - special.clear(); - } - if (ignore_quality) { - filter.setMinQuality(df::item_quality::Ordinary); - filter.setMaxQuality(df::item_quality::Artifact); - } if (itemPassesScreen(out, item) && matchesFilters(item, jitem, heat, filter, special)) { if (item_ids) item_ids->emplace_back(item->id); diff --git a/plugins/dig.cpp b/plugins/dig.cpp index 6008f9fa13..964681a8e4 100644 --- a/plugins/dig.cpp +++ b/plugins/dig.cpp @@ -222,7 +222,7 @@ static void do_cycle(color_ostream &out) { } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) do_cycle(out); return CR_OK; } diff --git a/plugins/dwarfvet.cpp b/plugins/dwarfvet.cpp index c8fbf69599..49b973b64e 100644 --- a/plugins/dwarfvet.cpp +++ b/plugins/dwarfvet.cpp @@ -113,7 +113,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) dwarfvet_cycle(out); return CR_OK; } diff --git a/plugins/examples/persistent_per_save_example.cpp b/plugins/examples/persistent_per_save_example.cpp index cc0d6c4c10..465332b8f6 100644 --- a/plugins/examples/persistent_per_save_example.cpp +++ b/plugins/examples/persistent_per_save_example.cpp @@ -164,7 +164,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) do_cycle(out); return CR_OK; } diff --git a/plugins/infiniteSky.cpp b/plugins/infiniteSky.cpp index 4ef8fd30d2..55fd4be229 100644 --- a/plugins/infiniteSky.cpp +++ b/plugins/infiniteSky.cpp @@ -65,8 +65,6 @@ void doInfiniteSky(color_ostream& out, int32_t howMany); DFhackCExport command_result plugin_onupdate ( color_ostream &out ) { - if ( !enabled ) - return CR_OK; if ( !Core::getInstance().isMapLoaded() ) return CR_OK; { diff --git a/plugins/logistics.cpp b/plugins/logistics.cpp index cec76d5d47..724f0d00e3 100644 --- a/plugins/logistics.cpp +++ b/plugins/logistics.cpp @@ -187,7 +187,7 @@ DFhackCExport command_result plugin_load_site_data(color_ostream &out) { } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (!is_enabled || !Core::getInstance().isMapLoaded() || !World::isFortressMode()) + if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) return CR_OK; if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) { logistics_cycle(out, true); diff --git a/plugins/misery.cpp b/plugins/misery.cpp index 3c7ce0598c..bcd0c7a8ac 100644 --- a/plugins/misery.cpp +++ b/plugins/misery.cpp @@ -116,7 +116,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) do_cycle(out); return CR_OK; } diff --git a/plugins/nestboxes.cpp b/plugins/nestboxes.cpp index eda2d9e959..6f21628170 100644 --- a/plugins/nestboxes.cpp +++ b/plugins/nestboxes.cpp @@ -102,7 +102,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) do_cycle(out); return CR_OK; } diff --git a/plugins/preserve-tombs.cpp b/plugins/preserve-tombs.cpp index e384de736c..5beb2cb4db 100644 --- a/plugins/preserve-tombs.cpp +++ b/plugins/preserve-tombs.cpp @@ -153,7 +153,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= cycle_freq) + if (world->frame_counter - cycle_timestamp >= cycle_freq) update_tomb_assignments(out); return CR_OK; } diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index af5d95d1fd..aa68c9e8d9 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -299,8 +299,6 @@ DFhackCExport command_result plugin_shutdown(color_ostream &out) DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (!enableUpdates) - return CR_OK; KeyUpdate(); return CR_OK; } diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 355abf02b7..ea55565c79 100644 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -219,7 +219,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) { + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) { int32_t num_enabled_seeds, num_disabled_seeds; do_cycle(out, &num_enabled_seeds, &num_disabled_seeds); if (0 < num_enabled_seeds) diff --git a/plugins/stockflow.cpp b/plugins/stockflow.cpp index 49d56816bc..a32f37e7b0 100644 --- a/plugins/stockflow.cpp +++ b/plugins/stockflow.cpp @@ -217,9 +217,6 @@ static LuaHelper helper; #define DELTA_TICKS 600 DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (!enabled) - return CR_OK; - if (!Maps::IsValid()) return CR_OK; diff --git a/plugins/suspendmanager.cpp b/plugins/suspendmanager.cpp index 6fab7287c2..14a9115f0e 100644 --- a/plugins/suspendmanager.cpp +++ b/plugins/suspendmanager.cpp @@ -851,8 +851,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && - (cycle_needed || world->frame_counter - cycle_timestamp >= CYCLE_TICKS)) + if (cycle_needed || world->frame_counter - cycle_timestamp >= CYCLE_TICKS) do_cycle(out); return CR_OK; } diff --git a/plugins/tailor.cpp b/plugins/tailor.cpp index 456444fe5c..5b746333ce 100644 --- a/plugins/tailor.cpp +++ b/plugins/tailor.cpp @@ -701,7 +701,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS) { + if (world->frame_counter - cycle_timestamp >= CYCLE_TICKS) { int ordered = do_cycle(out); if (0 < ordered) out.print("tailor: ordered %d items of clothing\n", ordered); diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index 7e94922737..a81e956ba3 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -608,9 +608,6 @@ static void process_constraints(color_ostream &out); DFhackCExport command_result plugin_onupdate(color_ostream &out) { - if (!enabled) - return CR_OK; - // Every 5 frames check the jobs for disappearance static unsigned cnt = 0; if ((++cnt % 5) != 0) diff --git a/scripts b/scripts index ba5c4c7316..f198cc6a11 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit ba5c4c7316334a907c87ea9adbe71b2cf5c16981 +Subproject commit f198cc6a114f12236a03cee834134fa995ca645e