summaryrefslogtreecommitdiff
path: root/plugins/mapexport
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-04-19 23:02:30 +0400
committerAlexander Gavrilov2012-04-19 23:02:30 +0400
commit0b32d374db8a58547d554d758e4e77ad850f54c5 (patch)
tree5cae6ab6e33a3b993d7fdddbd0af2452e3948fa4 /plugins/mapexport
parent4b87f1bcaca65b7fa7542dfa6e638413c5b6d48f (diff)
downloaddfhack-0b32d374db8a58547d554d758e4e77ad850f54c5.tar.gz
dfhack-0b32d374db8a58547d554d758e4e77ad850f54c5.tar.bz2
dfhack-0b32d374db8a58547d554d758e4e77ad850f54c5.tar.xz
Implement SOIL/STONE substitution logic, and add compat in mapexport.
Diffstat (limited to 'plugins/mapexport')
-rw-r--r--plugins/mapexport/mapexport.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/plugins/mapexport/mapexport.cpp b/plugins/mapexport/mapexport.cpp
index 592c526d..fa1736ed 100644
--- a/plugins/mapexport/mapexport.cpp
+++ b/plugins/mapexport/mapexport.cpp
@@ -2,7 +2,7 @@
#include "Console.h"
#include "Export.h"
#include "PluginManager.h"
-#include "modules/MapCache.h"
+#include "modules/MapCache.h"f
using namespace DFHack;
#include <fstream>
@@ -39,6 +39,46 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
return CR_OK;
}
+static dfproto::Tile::TileMaterialType toProto(df::tiletype_material mat)
+{
+ /*
+ * This is surely ugly, but casting enums without officially
+ * defined numerical values to protobuf enums is against the
+ * way protobufs are supposed to be used, because it defeats
+ * the backward compatible nature of the protocols.
+ */
+ switch (mat)
+ {
+#define CONVERT(name) case tiletype_material::name: return dfproto::Tile::name;
+ CONVERT(AIR)
+ case tiletype_material::PLANT:
+ CONVERT(SOIL)
+ CONVERT(STONE)
+ CONVERT(FEATURE)
+ CONVERT(LAVA_STONE)
+ CONVERT(MINERAL)
+ CONVERT(FROZEN_LIQUID)
+ CONVERT(CONSTRUCTION)
+ CONVERT(GRASS_LIGHT)
+ CONVERT(GRASS_DARK)
+ CONVERT(GRASS_DRY)
+ CONVERT(GRASS_DEAD)
+ CONVERT(HFS)
+ CONVERT(CAMPFIRE)
+ CONVERT(FIRE)
+ CONVERT(ASHES)
+ case tiletype_material::MAGMA:
+ return dfproto::Tile::MAGMA_TYPE;
+ CONVERT(DRIFTWOOD)
+ CONVERT(POOL)
+ CONVERT(BROOK)
+ CONVERT(RIVER)
+#undef CONVERT
+ default:
+ return dfproto::Tile::AIR;
+ }
+}
+
command_result mapexport (color_ostream &out, std::vector <std::string> & parameters)
{
bool showHidden = false;
@@ -195,7 +235,7 @@ command_result mapexport (color_ostream &out, std::vector <std::string> & parame
df::tiletype type = b->tiletypeAt(coord);
prototile->set_type((dfproto::Tile::TileType)tileShape(type));
- prototile->set_tile_material((dfproto::Tile::TileMaterialType)tileMaterial(type));
+ prototile->set_tile_material(toProto(tileMaterial(type)));
df::coord map_pos = df::coord(b_x*16+x,b_y*16+y,z);