From 4f963233f4f92cf8d1598fd3da61d657d96084a7 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Fri, 20 Mar 2015 19:23:04 -0600 Subject: [PATCH] Enticing the bookkeeper to work more often --- NEWS | 1 + plugins/stockflow.cpp | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 0eec7c3af..61ad7db2a 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,7 @@ DFHack Future stockflow: Fixed error message in Arena mode stockflow: No longer checks the DF version stockflow: Fixed ballistic arrow head orders + stockflow: Now convinces the bookkeeper to update records more often zone: Stopped crash when scrolling cage owner list New Plugins New Scripts diff --git a/plugins/stockflow.cpp b/plugins/stockflow.cpp index abbda87af..34dfc1bd7 100644 --- a/plugins/stockflow.cpp +++ b/plugins/stockflow.cpp @@ -81,12 +81,21 @@ public: } } - if (found && !bookkeeping) { - command_method("start_bookkeeping", out); - bookkeeping = true; - } else if (bookkeeping && !found) { - command_method("finish_bookkeeping", out); - bookkeeping = false; + if (found) { + // Entice the bookkeeper to spend less time update records. + ui->bookkeeper_precision += ui->bookkeeper_precision >> 3; + if (!bookkeeping) { + command_method("start_bookkeeping", out); + bookkeeping = true; + } + } else { + // Entice the bookkeeper to update records more often. + ui->bookkeeper_precision -= ui->bookkeeper_precision >> 5; + ui->bookkeeper_cooldown -= ui->bookkeeper_cooldown >> 2; + if (bookkeeping) { + command_method("finish_bookkeeping", out); + bookkeeping = false; + } } }