diff --git a/dfhack.init-example b/dfhack.init-example index 9ee5ecc46..39c0e61df 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -64,3 +64,6 @@ tweak patrol-duty # display creature weight in build plate menu as ??K, instead of (???df: Max tweak readable-build-plate + +# improve FPS by squashing endless item temperature update loops +tweak stable-temp diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index 9853f7f95..fbea30231 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -32,6 +32,8 @@ #include "df/squad_order_trainst.h" #include "df/ui_build_selector.h" #include "df/building_trapst.h" +#include "df/item_actual.h" +#include "df/contaminant.h" #include @@ -85,6 +87,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector size(); i++) + { + auto obj = (*contaminants)[i]; + + if (abs(obj->temperature - temperature) == 1) + { + obj->temperature = temperature; + obj->temperature_fraction = temperature_fraction; + } + } + } + + return INTERPOSE_NEXT(updateContaminants)(); + } +}; + +IMPLEMENT_VMETHOD_INTERPOSE(stable_temp_hook, adjustTemperature); +IMPLEMENT_VMETHOD_INTERPOSE(stable_temp_hook, updateContaminants); + static void enable_hook(color_ostream &out, VMethodInterposeLinkBase &hook, vector ¶meters) { if (vector_get(parameters, 1) == "disable") @@ -375,6 +425,11 @@ static command_result tweak(color_ostream &out, vector ¶meters) enable_hook(out, INTERPOSE_HOOK(readable_build_plate_hook, render), parameters); } + else if (cmd == "stable-temp") + { + enable_hook(out, INTERPOSE_HOOK(stable_temp_hook, adjustTemperature), parameters); + enable_hook(out, INTERPOSE_HOOK(stable_temp_hook, updateContaminants), parameters); + } else return CR_WRONG_USAGE;