summaryrefslogtreecommitdiff
path: root/plugins/mapexport
diff options
context:
space:
mode:
authorMike Stewart2012-01-19 22:15:51 -0800
committerMike Stewart2012-01-19 22:15:51 -0800
commitfb41e457c4af7f8e649fb8487f13ac58da41f70d (patch)
treed37641b9cc8e9e5fc380573f401a055689be998d /plugins/mapexport
parent1e59811e65844985f0d1e2cc4ebaad3a30ea28ae (diff)
downloaddfhack-fb41e457c4af7f8e649fb8487f13ac58da41f70d.tar.gz
dfhack-fb41e457c4af7f8e649fb8487f13ac58da41f70d.tar.bz2
dfhack-fb41e457c4af7f8e649fb8487f13ac58da41f70d.tar.xz
Added a plugin that starts up and shuts down protobufs. Will add actual map export functionality to it tomorrow.
Diffstat (limited to 'plugins/mapexport')
-rw-r--r--plugins/mapexport/CMakeLists.txt35
-rw-r--r--plugins/mapexport/mapexport.cpp45
-rw-r--r--plugins/mapexport/proto/Tile.proto10
3 files changed, 90 insertions, 0 deletions
diff --git a/plugins/mapexport/CMakeLists.txt b/plugins/mapexport/CMakeLists.txt
new file mode 100644
index 00000000..722ac663
--- /dev/null
+++ b/plugins/mapexport/CMakeLists.txt
@@ -0,0 +1,35 @@
+PROJECT(mapexport)
+SET(MAPEXPORT_SOURCE_DIR ${dfhack_SOURCE_DIR}/plugins/mapexport)
+
+include_directories (
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${dfhack_SOURCE_DIR}/library/depends/protobuf/
+)
+
+#Generated protobuf files and the headers they will require
+SET(PROJECT_HDRS
+${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/stubs/once.h
+${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/stubs/common.h
+${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/io/coded_stream.h
+${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/wire_format_lite_inl.h
+${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/generated_message_util.h
+${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/repeated_field.h
+${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/extension_set.h
+proto/Tile.pb.h
+)
+
+SET(PROJECT_SRCS
+mapexport.cpp
+proto/Tile.pb.cc
+)
+
+SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
+LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
+
+ADD_CUSTOM_COMMAND(
+OUTPUT proto/Tile.pb.cc proto/Tile.pb.h
+COMMAND protoc -I=${CMAKE_CURRENT_SOURCE_DIR}/proto --cpp_out=proto ${CMAKE_CURRENT_SOURCE_DIR}/proto/Tile.proto
+DEPENDS protoc ${CMAKE_CURRENT_SOURCE_DIR}/proto/Tile.proto
+)
+
+DFHACK_PLUGIN(mapexport ${PROJECT_SRCS} ${PROJECT_HDRS} LINK_LIBRARIES libprotobuf-lite)
diff --git a/plugins/mapexport/mapexport.cpp b/plugins/mapexport/mapexport.cpp
new file mode 100644
index 00000000..d1a02225
--- /dev/null
+++ b/plugins/mapexport/mapexport.cpp
@@ -0,0 +1,45 @@
+#include "Core.h"
+#include <Console.h>
+#include <Export.h>
+#include <PluginManager.h>
+#include "proto/Tile.pb.h"
+using namespace DFHack;
+
+DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters);
+
+DFhackCExport const char * plugin_name ( void )
+{
+ return "mapexport";
+}
+
+DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
+{
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+ commands.clear();
+ commands.push_back(PluginCommand("mapexport", "Starts up and shuts down protobufs.", mapexport, true));
+ return CR_OK;
+}
+
+DFhackCExport command_result plugin_shutdown ( Core * c )
+{
+ google::protobuf::ShutdownProtobufLibrary();
+ return CR_OK;
+}
+
+DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters)
+{
+ for(int i = 0; i < parameters.size();i++)
+ {
+ if(parameters[i] == "help" || parameters[i] == "?")
+ {
+ c->con.print("This doesn't do anything at all yet.\n");
+ return CR_OK;
+ }
+ }
+
+ c->Suspend();
+ dfproto::Tile tile;
+ c->con.print("Hold on, I'm working on it!\n");
+ c->Resume();
+ return CR_OK;
+}
diff --git a/plugins/mapexport/proto/Tile.proto b/plugins/mapexport/proto/Tile.proto
new file mode 100644
index 00000000..aa708be2
--- /dev/null
+++ b/plugins/mapexport/proto/Tile.proto
@@ -0,0 +1,10 @@
+package dfproto;
+option optimize_for = LITE_RUNTIME;
+
+message Tile
+{
+ required uint32 x = 1;
+ required uint32 y = 2;
+ required uint32 tiletype = 3;
+ optional uint32 material = 4;
+} \ No newline at end of file