summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mrázek2011-10-30 02:50:29 +0100
committerPetr Mrázek2011-10-30 02:50:29 +0100
commit13ca2e608fb478ad1226281a1397091e90e55e20 (patch)
tree42c8c0a9469564bd8e07a5cec9234b1a4813ea72
parent6e3dbbdd720b947f2fff692398f796baed9cbc58 (diff)
downloaddfhack-13ca2e608fb478ad1226281a1397091e90e55e20.tar.gz
dfhack-13ca2e608fb478ad1226281a1397091e90e55e20.tar.bz2
dfhack-13ca2e608fb478ad1226281a1397091e90e55e20.tar.xz
Added df2mc (TroZ) and drybuckets (Quietust) plugins
-rw-r--r--.gitmodules3
-rw-r--r--CMakeLists.txt5
-rw-r--r--plugins/CMakeLists.txt7
m---------plugins/df2mc0
-rw-r--r--plugins/drybuckets.cpp76
5 files changed, 90 insertions, 1 deletions
diff --git a/.gitmodules b/.gitmodules
index 071f19cf..5fcc3ec0 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "plugins/stonesense"]
path = plugins/stonesense
url = git://github.com/peterix/stonesense.git
+[submodule "plugins/df2mc"]
+ path = plugins/df2mc
+ url = git://github.com/peterix/DF2MC.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b13acece..bb520ff5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ set(DF_VERSION_MINOR "31")
set(DF_VERSION_PATCH "25")
set(DF_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}")
-set(DFHACK_RELEASE "6")
+set(DFHACK_RELEASE "7")
## where to install things (after the build is done, classic 'make install' or package structure)
# the dfhack libraries will be installed here:
@@ -56,6 +56,9 @@ SET(DFHACK_DEVDOC_DESTINATION hack)
OPTION(BUILD_LIBRARY "Build the library that goes into DF." ON)
OPTION(BUILD_PLUGINS "Build the plugins." ON)
+#add depends to include path
+INCLUDE_DIRECTORIES ( library/depends )
+
# build the static lua for dfusion
INCLUDE_DIRECTORIES ( lua/include )
add_subdirectory (lua)
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 5c9869ff..045943c1 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -20,6 +20,12 @@ if(BUILD_STONESENSE)
add_subdirectory (stonesense)
endif()
+OPTION(BUILD_DF2MC "Build DF2MC (needs a checkout first)." ON)
+if(BUILD_DF2MC)
+ add_subdirectory (df2mc)
+endif()
+
+
OPTION(BUILD_DEV_PLUGINS "Build developer plugins." OFF)
if(BUILD_DEV_PLUGINS)
add_subdirectory (devel)
@@ -28,6 +34,7 @@ endif()
DFHACK_PLUGIN(reveal reveal.cpp)
DFHACK_PLUGIN(probe probe.cpp)
+DFHACK_PLUGIN(drybuckets drybuckets.cpp)
DFHACK_PLUGIN(getplants getplants.cpp)
DFHACK_PLUGIN(plants plants.cpp)
DFHACK_PLUGIN(fastdwarf fastdwarf.cpp)
diff --git a/plugins/df2mc b/plugins/df2mc
new file mode 160000
+Subproject 18e75ea6a04aa070a43c9d1d055d1ebf4530ccf
diff --git a/plugins/drybuckets.cpp b/plugins/drybuckets.cpp
new file mode 100644
index 00000000..1041cb7a
--- /dev/null
+++ b/plugins/drybuckets.cpp
@@ -0,0 +1,76 @@
+// Dry Buckets : Remove all "water" objects from buckets scattered around the fortress
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <climits>
+#include <vector>
+#include <set>
+using namespace std;
+
+#include <dfhack/Core.h>
+#include <dfhack/Console.h>
+#include <dfhack/Export.h>
+#include <dfhack/PluginManager.h>
+#include <vector>
+#include <string>
+#include <algorithm>
+#include <dfhack/modules/Items.h>
+
+using namespace DFHack;
+
+DFhackCExport command_result df_drybuckets (Core * c, vector <string> & parameters);
+
+DFhackCExport const char * plugin_name ( void )
+{
+ return "drybuckets";
+}
+
+DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
+{
+ commands.clear();
+ commands.push_back(PluginCommand("drybuckets", "Removes water from buckets.", df_drybuckets));
+ return CR_OK;
+}
+
+DFhackCExport command_result plugin_shutdown ( Core * c )
+{
+ return CR_OK;
+}
+
+DFhackCExport command_result df_drybuckets (Core * c, vector <string> & parameters)
+{
+ if(parameters.size() > 0)
+ {
+ string & p = parameters[0];
+ if(p == "?" || p == "help")
+ {
+ c->con.print("This utility removes all objects of type LIQUID_MISC:NONE and material WATER:NONE - that is, water stored in buckets.\n");
+ return CR_OK;
+ }
+ }
+ c->Suspend();
+ DFHack::Items * Items = c->getItems();
+
+ vector <df_item *> p_items;
+ if(!Items->readItemVector(p_items))
+ {
+ c->con.printerr("Can't access the item vector.\n");
+ c->Resume();
+ return CR_FAILURE;
+ }
+ std::size_t numItems = p_items.size();
+
+ int dried_total = 0;
+ for (std::size_t i = 0; i < numItems; i++)
+ {
+ df_item *item = p_items[i];
+ if ((item->getType() == 72) && (item->getMaterial() == 6))
+ {
+ item->flags.garbage_colect = 1;
+ dried_total++;
+ }
+ }
+ c->Resume();
+ c->con.print("Done. %d buckets of water emptied.\n", dried_total);
+ return CR_OK;
+} \ No newline at end of file