File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ logcleaner
55 :tags: fort auto units
66
77This plugin prevents spam from cluttering your announcement history and filling
8- the 3000-item reports buffer. It runs every 100 ticks and clears selected report
9- types from both the global reports buffer and per-unit logs.
8+ the 3000-item reports buffer. It runs approximately every 100 ticks and clears
9+ selected report types from both the global reports buffer and per-unit logs.
1010
1111Usage
1212-----
Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ static bool clear_combat = false;
3131static bool clear_sparring = true ;
3232static bool clear_hunting = false ;
3333
34- static constexpr int32_t CLEANUP_TICK_INTERVAL = 97 ;
34+ static constexpr int32_t CYCLE_TICKS = 97 ;
35+ static int32_t cycle_timestamp = 0 ;
3536
3637static void cleanupLogs ();
3738static command_result do_command (color_ostream& out, std::vector<std::string>& params);
@@ -116,6 +117,7 @@ DFhackCExport command_result plugin_load_site_data(color_ostream& out) {
116117 clear_sparring = config.get_bool (CONFIG_CLEAR_SPARING);
117118 clear_hunting = config.get_bool (CONFIG_CLEAR_HUNTING);
118119
120+ cycle_timestamp = 0 ;
119121 return CR_OK;
120122}
121123
@@ -166,16 +168,13 @@ static void cleanupLogs() {
166168}
167169
168170DFhackCExport command_result plugin_onupdate (color_ostream& out, state_change_event event) {
169- static int32_t tick_counter = 0 ;
170-
171171 if (!is_enabled || !world)
172172 return CR_OK;
173+ else if (world->frame_counter - cycle_timestamp < CYCLE_TICKS)
174+ return CR_OK;
173175
174- tick_counter++;
175- if (tick_counter >= CLEANUP_TICK_INTERVAL) {
176- tick_counter = 0 ;
177- cleanupLogs ();
178- }
176+ cycle_timestamp = world->frame_counter ;
177+ cleanupLogs ();
179178
180179 return CR_OK;
181180}
You can’t perform that action at this time.
0 commit comments