diff options
| author | Petr Mrázek | 2011-06-27 02:13:01 +0200 |
|---|---|---|
| committer | Petr Mrázek | 2011-06-27 02:13:01 +0200 |
| commit | 00ddb45dbdeaa1765b0433903f7e48078417dbe5 (patch) | |
| tree | d642e8bde83f169ef84237dd77158b0d1dd11ef0 /plugins/reveal.cpp | |
| parent | 722531f590a9f099b671c641d4c5afe3a2658b20 (diff) | |
| download | dfhack-00ddb45dbdeaa1765b0433903f7e48078417dbe5.tar.gz dfhack-00ddb45dbdeaa1765b0433903f7e48078417dbe5.tar.bz2 dfhack-00ddb45dbdeaa1765b0433903f7e48078417dbe5.tar.xz | |
Added optional plugin_onupdate function, called each Core update.
Diffstat (limited to 'plugins/reveal.cpp')
| -rw-r--r-- | plugins/reveal.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/plugins/reveal.cpp b/plugins/reveal.cpp index e6ff7064..20e58d14 100644 --- a/plugins/reveal.cpp +++ b/plugins/reveal.cpp @@ -42,6 +42,22 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> return CR_OK; } +DFhackCExport command_result plugin_onupdate ( Core * c ) +{ + // if the map is revealed and we're in fortress mode, force the game to pause. + if(revealed) + { + DFHack::World *World =c->getWorld(); + t_gamemodes gm; + World->ReadGameMode(gm); + if(gm.game_mode == GM_Fort) + { + World->SetPauseState(true); + } + } + return CR_OK; +} + DFhackCExport command_result plugin_shutdown ( Core * c ) { return CR_OK; @@ -58,6 +74,14 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> & c->Suspend(); DFHack::Maps *Maps =c->getMaps(); DFHack::World *World =c->getWorld(); + t_gamemodes gm; + World->ReadGameMode(gm); + if(gm.game_mode != GM_Fort) + { + dfout << "Only in fortress mode." << std::endl; + c->Resume(); + return CR_FAILURE; + } // init the map if(!Maps->Start()) { @@ -98,8 +122,8 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> & World->SetPauseState(true); revealed = true; c->Resume(); - dfout << "Map revealed. The game has been paused for you." << std::endl; - dfout << "Unpausing can unleash the forces of hell!" << std::endl; + dfout << "Map revealed." << std::endl; + dfout << "Unpausing can unleash the forces of hell, so it has beed temporarily disabled!" << std::endl; dfout << "Run 'unreveal' to revert to previous state." << std::endl; return CR_OK; } @@ -115,6 +139,14 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string> c->Suspend(); DFHack::Maps *Maps =c->getMaps(); DFHack::World *World =c->getWorld(); + t_gamemodes gm; + World->ReadGameMode(gm); + if(gm.game_mode != GM_Fort) + { + dfout << "Only in fortress mode." << std::endl; + c->Resume(); + return CR_FAILURE; + } Maps = c->getMaps(); if(!Maps->Start()) { |
