summaryrefslogtreecommitdiff
path: root/plugins/lair.cpp
diff options
context:
space:
mode:
authorPetr Mrázek2012-03-11 22:25:30 +0100
committerPetr Mrázek2012-03-11 22:25:30 +0100
commit3b87f7bd3ad0d948211865cb2608ba75c35514bb (patch)
tree7c14d85f10632495147fc05f987dfdae9fd8d594 /plugins/lair.cpp
parent32cc4c892889110644ebfeb5e4a2e5859bd057cf (diff)
downloaddfhack-3b87f7bd3ad0d948211865cb2608ba75c35514bb.tar.gz
dfhack-3b87f7bd3ad0d948211865cb2608ba75c35514bb.tar.bz2
dfhack-3b87f7bd3ad0d948211865cb2608ba75c35514bb.tar.xz
Add revforget command, lair plugin
revforget throws away data reveal keeps in order to be able to hide the revealed parts of the map lair allows marking the map as monster lair (or the opposite while using the 'reset' option)
Diffstat (limited to 'plugins/lair.cpp')
-rw-r--r--plugins/lair.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/lair.cpp b/plugins/lair.cpp
new file mode 100644
index 00000000..0c291276
--- /dev/null
+++ b/plugins/lair.cpp
@@ -0,0 +1,63 @@
+#include <stdint.h>
+#include <iostream>
+#include <map>
+#include <vector>
+#include "Core.h"
+#include "Console.h"
+#include "Export.h"
+#include "PluginManager.h"
+#include "modules/Maps.h"
+#include "modules/World.h"
+#include "modules/MapCache.h"
+#include "modules/Gui.h"
+using namespace DFHack;
+using namespace df::enums;
+using df::global::world;
+
+DFHACK_PLUGIN("lair");
+
+enum state
+{
+ LAIR_RESET,
+ LAIR_SET,
+};
+
+command_result lair(color_ostream &out, std::vector<std::string> & params)
+{
+ state do_what = LAIR_SET;
+ for(auto iter = params.begin(); iter != params.end(); iter++)
+ {
+ if(*iter == "reset")
+ do_what = LAIR_RESET;
+ }
+ CoreSuspender lock;
+ if (!Maps::IsValid())
+ {
+ out.printerr("Map is not available!\n");
+ return CR_FAILURE;
+ }
+ uint32_t x_max,y_max,z_max;
+ Maps::getSize(x_max,y_max,z_max);
+ for (size_t i = 0; i < world->map.map_blocks.size(); i++)
+ {
+ df::map_block *block = world->map.map_blocks[i];
+ DFHack::occupancies40d & occupancies = block->occupancy;
+ // for each tile in block
+ for (uint32_t x = 0; x < 16; x++) for (uint32_t y = 0; y < 16; y++)
+ {
+ // set to revealed
+ occupancies[x][y].bits.monster_lair = (do_what == LAIR_SET);
+ }
+ }
+ if(do_what == LAIR_SET)
+ out.print("Map marked as lair.\n");
+ else
+ out.print("Map no longer marked as lair.\n");
+ return CR_OK;
+}
+
+DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
+{
+ commands.push_back(PluginCommand("lair","Mark the map as a monster lair, preventing item scatter ('lair reset' reverts that).",lair));
+ return CR_OK;
+}