From 01a79dccb067dc8f11dd8a582b5746a2bba7226f Mon Sep 17 00:00:00 2001 From: ninjanomnom Date: Thu, 16 Aug 2018 14:50:09 -0400 Subject: [PATCH] Fixes timer buckets going into negatives and adds a regression test --- code/controllers/subsystem/timer.dm | 1 + code/modules/unit_tests/_unit_tests.dm | 6 ++++-- code/modules/unit_tests/timer_sanity.dm | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 code/modules/unit_tests/timer_sanity.dm diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index 7e48b07123e..4b347b2a39d 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -212,6 +212,7 @@ SUBSYSTEM_DEF(timer) if(!(qtimer.flags & TIMER_LOOP)) qdel(qtimer) else + bucket_count++ qtimer.spent = 0 qtimer.bucketEject() if(qtimer.flags & TIMER_CLIENT_TIME) diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 6d6de74faa4..8da5d7c1138 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -1,9 +1,11 @@ //include unit test files in this module in this ifdef +//Keep this sorted alphabetically #ifdef UNIT_TESTS -#include "unit_test.dm" -#include "reagent_recipe_collisions.dm" #include "reagent_id_typos.dm" +#include "reagent_recipe_collisions.dm" #include "spawn_humans.dm" #include "subsystem_init.dm" +#include "timer_sanity.dm" +#include "unit_test.dm" #endif diff --git a/code/modules/unit_tests/timer_sanity.dm b/code/modules/unit_tests/timer_sanity.dm new file mode 100644 index 00000000000..1e5b022b190 --- /dev/null +++ b/code/modules/unit_tests/timer_sanity.dm @@ -0,0 +1,3 @@ +/datum/unit_test/timer_sanity/Run() + if(SStimer.bucket_count < 0) + Fail("SStimer is going into negative bucket count from something") \ No newline at end of file