From b5ede66224f2fe9d112bbcf3b748dfa5a0569ca7 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Wed, 19 Sep 2012 19:46:54 +0400 Subject: [PATCH] Switch some plugins to using world load/unload instead of map. Otherwise they apply and remove hooks every time fast travel is used. --- plugins/add-spatter.cpp | 8 ++++---- plugins/power-meter.cpp | 8 ++++---- plugins/steam-engine.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/add-spatter.cpp b/plugins/add-spatter.cpp index 35ea11ef5..425ffe9d0 100644 --- a/plugins/add-spatter.cpp +++ b/plugins/add-spatter.cpp @@ -397,7 +397,7 @@ static void enable_hooks(bool enable) DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { switch (event) { - case SC_MAP_LOADED: + case SC_WORLD_LOADED: if (find_reactions(out)) { out.print("Detected spatter add reactions - enabling plugin.\n"); @@ -406,7 +406,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan else enable_hooks(false); break; - case SC_MAP_UNLOADED: + case SC_WORLD_UNLOADED: enable_hooks(false); reactions.clear(); products.clear(); @@ -420,8 +420,8 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { - if (Core::getInstance().isMapLoaded()) - plugin_onstatechange(out, SC_MAP_LOADED); + if (Core::getInstance().isWorldLoaded()) + plugin_onstatechange(out, SC_WORLD_LOADED); return CR_OK; } diff --git a/plugins/power-meter.cpp b/plugins/power-meter.cpp index 0466b68e4..17261adb2 100644 --- a/plugins/power-meter.cpp +++ b/plugins/power-meter.cpp @@ -200,7 +200,7 @@ DFHACK_PLUGIN_LUA_FUNCTIONS { DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { switch (event) { - case SC_MAP_LOADED: + case SC_WORLD_LOADED: { auto pworld = Core::getInstance().getWorld(); bool enable = pworld->GetPersistentData("power-meter/enabled").isValid(); @@ -212,7 +212,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan } } break; - case SC_MAP_UNLOADED: + case SC_WORLD_UNLOADED: enable_hooks(false); break; default: @@ -224,8 +224,8 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { - if (Core::getInstance().isMapLoaded()) - plugin_onstatechange(out, SC_MAP_LOADED); + if (Core::getInstance().isWorldLoaded()) + plugin_onstatechange(out, SC_WORLD_LOADED); return CR_OK; } diff --git a/plugins/steam-engine.cpp b/plugins/steam-engine.cpp index cacfc6e16..d884191e5 100644 --- a/plugins/steam-engine.cpp +++ b/plugins/steam-engine.cpp @@ -972,7 +972,7 @@ static void enable_hooks(bool enable) DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { switch (event) { - case SC_MAP_LOADED: + case SC_WORLD_LOADED: if (find_engines()) { out.print("Detected steam engine workshops - enabling plugin.\n"); @@ -981,7 +981,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan else enable_hooks(false); break; - case SC_MAP_UNLOADED: + case SC_WORLD_UNLOADED: enable_hooks(false); engines.clear(); break; @@ -994,8 +994,8 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { - if (Core::getInstance().isMapLoaded()) - plugin_onstatechange(out, SC_MAP_LOADED); + if (Core::getInstance().isWorldLoaded()) + plugin_onstatechange(out, SC_WORLD_LOADED); return CR_OK; }