Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/plugins/logcleaner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ logcleaner
:tags: fort auto units

This plugin prevents spam from cluttering your announcement history and filling
the 3000-item reports buffer. It runs every 100 ticks and clears selected report
types from both the global reports buffer and per-unit logs.
the 3000-item reports buffer. It runs approximately every 100 ticks and clears
selected report types from both the global reports buffer and per-unit logs.

Usage
-----
Expand Down
2 changes: 1 addition & 1 deletion plugins/autolabor/autolabor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
return CR_OK;
}

if (world->frame_counter - cycle_timestamp <= CYCLE_TICKS)
if (world->frame_counter - cycle_timestamp < CYCLE_TICKS)
Copy link
Copy Markdown
Member

@ab9rf ab9rf Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while there might be merit to this change, it's unnecessary to dealing with a defect in a pending release. feel free to repropose in a separate PR

even when not in a pre-release feature freeze it's best to keep PRs to a single issue, and a PR that is intended to fix a defect in a imminently pending release should absolutely only address the specific defect and nothing else

return CR_OK;

cycle_timestamp = world->frame_counter;
Expand Down
15 changes: 7 additions & 8 deletions plugins/logcleaner/logcleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ static bool clear_combat = false;
static bool clear_sparring = true;
static bool clear_hunting = false;

static constexpr int32_t CLEANUP_TICK_INTERVAL = 97;
static constexpr int32_t CYCLE_TICKS = 97;
static int32_t cycle_timestamp = 0;

static void cleanupLogs();
static command_result do_command(color_ostream& out, std::vector<std::string>& params);
Expand Down Expand Up @@ -116,6 +117,7 @@ DFhackCExport command_result plugin_load_site_data(color_ostream& out) {
clear_sparring = config.get_bool(CONFIG_CLEAR_SPARING);
clear_hunting = config.get_bool(CONFIG_CLEAR_HUNTING);

cycle_timestamp = 0;
return CR_OK;
}

Expand Down Expand Up @@ -166,16 +168,13 @@ static void cleanupLogs() {
}

DFhackCExport command_result plugin_onupdate(color_ostream& out, state_change_event event) {
static int32_t tick_counter = 0;

if (!is_enabled || !world)
return CR_OK;
else if (world->frame_counter - cycle_timestamp < CYCLE_TICKS)
return CR_OK;

tick_counter++;
if (tick_counter >= CLEANUP_TICK_INTERVAL) {
tick_counter = 0;
cleanupLogs();
}
cycle_timestamp = world->frame_counter;
cleanupLogs();

return CR_OK;
}
Expand Down