diff options
| author | Alexander Gavrilov | 2011-12-30 18:12:15 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2011-12-30 18:12:15 +0400 |
| commit | 53346328e8cc12dc2bb800534aefcb4eabb15502 (patch) | |
| tree | 0d4486e577dfda7cda01d26b1643a7cbee4bed1d /plugins/seedwatch.cpp | |
| parent | 298e2fe92d7b709be4528f2eb15380bdd92a54da (diff) | |
| download | dfhack-53346328e8cc12dc2bb800534aefcb4eabb15502.tar.gz dfhack-53346328e8cc12dc2bb800534aefcb4eabb15502.tar.bz2 dfhack-53346328e8cc12dc2bb800534aefcb4eabb15502.tar.xz | |
Notify plugins about game being loaded or unloaded.
As a test, make seadwatch deactivate on these events.
Diffstat (limited to 'plugins/seedwatch.cpp')
| -rwxr-xr-x | plugins/seedwatch.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 418398e3..90175470 100755 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -288,10 +288,32 @@ DFhackCExport DFHack::command_result plugin_init(DFHack::Core* pCore, std::vecto return DFHack::CR_OK; } +DFhackCExport DFHack::command_result plugin_onstatechange(DFHack::Core* pCore, DFHack::state_change_event event) +{ + switch (event) { + case DFHack::SC_GAME_LOADED: + case DFHack::SC_GAME_UNLOADED: + if (running) + pCore->con.printerr("seedwatch deactivated due to game load/unload\n"); + running = false; + break; + default: + break; + } + + return DFHack::CR_OK; +} + DFhackCExport DFHack::command_result plugin_onupdate(DFHack::Core* pCore) { - if(running) + if (running) { + // reduce processing rate + static int counter = 0; + if (++counter < 500) + return DFHack::CR_OK; + counter = 0; + DFHack::Core& core = *pCore; DFHack::World *w = core.getWorld(); DFHack::t_gamemodes gm; |
