summaryrefslogtreecommitdiff
path: root/plugins/reveal.cpp
diff options
context:
space:
mode:
authorPetr Mrázek2011-06-27 02:13:01 +0200
committerPetr Mrázek2011-06-27 02:13:01 +0200
commit00ddb45dbdeaa1765b0433903f7e48078417dbe5 (patch)
treed642e8bde83f169ef84237dd77158b0d1dd11ef0 /plugins/reveal.cpp
parent722531f590a9f099b671c641d4c5afe3a2658b20 (diff)
downloaddfhack-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.cpp36
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())
{