diff --git a/library/include/modules/EventManager.h b/library/include/modules/EventManager.h index 1a6f15245..c1c09da7d 100644 --- a/library/include/modules/EventManager.h +++ b/library/include/modules/EventManager.h @@ -36,7 +36,7 @@ namespace DFHack { }; DFHACK_EXPORT void registerListener(EventType::EventType e, EventHandler handler, Plugin* plugin); - DFHACK_EXPORT void registerTick(EventHandler handler, int32_t when, Plugin* plugin); + DFHACK_EXPORT void registerTick(EventHandler handler, int32_t when, Plugin* plugin, bool absolute=false); DFHACK_EXPORT void unregister(EventType::EventType e, EventHandler handler, Plugin* plugin); DFHACK_EXPORT void unregisterAll(Plugin* plugin); void manageEvents(color_ostream& out); diff --git a/library/modules/EventManager.cpp b/library/modules/EventManager.cpp index 63455b664..553a69668 100644 --- a/library/modules/EventManager.cpp +++ b/library/modules/EventManager.cpp @@ -1,4 +1,5 @@ #include "Core.h" +#include "Console.h" #include "modules/EventManager.h" #include "modules/Job.h" #include "modules/World.h" @@ -33,11 +34,17 @@ void DFHack::EventManager::registerListener(EventType::EventType e, EventHandler handlers[e].insert(pair(plugin, handler)); } -void DFHack::EventManager::registerTick(EventHandler handler, int32_t when, Plugin* plugin) { +void DFHack::EventManager::registerTick(EventHandler handler, int32_t when, Plugin* plugin, bool absolute) { uint32_t tick = DFHack::World::ReadCurrentYear()*ticksPerYear + DFHack::World::ReadCurrentTick(); if ( !Core::getInstance().isWorldLoaded() ) { tick = 0; + if ( absolute ) { + Core::getInstance().getConsole().print("Warning: absolute flag will not be honored.\n"); + } + } + if ( absolute ) { + tick = 0; } tickQueue.insert(pair(tick+(uint32_t)when, handler));