More work on getting the map exporter up to speed.

develop
Mike Stewart 2012-01-27 17:32:52 -08:00
parent e68cdee95b
commit b89cd43b85
5 changed files with 53 additions and 54 deletions

@ -1 +1 @@
Subproject commit 867e7de022af7a5cc623b360ae2b864df395316f
Subproject commit 3da91078d44282fa096f71f3f1e44809f9699e3d

@ -6,6 +6,9 @@
using namespace DFHack;
#include <fstream>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
using namespace google::protobuf::io;
#include "DataDefs.h"
#include "df/world.h"
@ -63,21 +66,30 @@ DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & pa
c->Resume();
return CR_FAILURE;
}
Maps::getSize(x_max, y_max, z_max);
MapExtras::MapCache map;
DFHack::Materials *mats = c->getMaterials();
DFHack::Vegetation *veg = c->getVegetation();
if (veg->Start())
std::ofstream output_file(filename, std::ios::out | std::ios::trunc | std::ios::binary);
if (!output_file.is_open())
{
c->con.printerr("Unable to read vegetation; plants won't be listed!\n" );
c->con.printerr("Couldn't open the output file.\n");
c->Resume();
return CR_FAILURE;
}
ZeroCopyOutputStream *raw_output = new OstreamOutputStream(&output_file);
CodedOutputStream *coded_output = new CodedOutputStream(raw_output);
coded_output->WriteLittleEndian32(0x50414DDF);
Maps::getSize(x_max, y_max, z_max);
MapExtras::MapCache map;
DFHack::Materials *mats = c->getMaterials();
dfproto::Map protomap;
protomap.set_x_size(x_max);
protomap.set_y_size(y_max);
protomap.set_z_size(z_max);
//coded_output->WriteVarint32(protomap.ByteSize());
//protomap.SerializeToCodedStream(coded_output);
DFHack::t_feature blockFeatureGlobal;
DFHack::t_feature blockFeatureLocal;
@ -95,7 +107,7 @@ DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & pa
continue;
}
dfproto::Block *protoblock = protomap.add_block();
dfproto::Block *protoblock = new dfproto::Block;
protoblock->set_x(b_x);
protoblock->set_y(b_y);
protoblock->set_z(z);
@ -159,19 +171,9 @@ DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & pa
} // block y
} // z
std::ofstream output(filename, std::ios::out | std::ios::trunc | std::ios::binary);
if (!output.is_open())
{
c->con.printerr("Couldn't open the output file.\n");
c->Resume();
return CR_FAILURE;
}
if (!protomap.SerializeToOstream(&output))
{
c->con.printerr("Failed to save map file.\n");
c->Resume();
return CR_FAILURE;
}
delete coded_output;
delete raw_output;
c->con.print("Map succesfully exported.\n");
c->Resume();
return CR_OK;

@ -1,5 +1,5 @@
package dfproto;
//option optimize_for = LITE_RUNTIME;
option optimize_for = LITE_RUNTIME;
import "Tile.proto";

@ -1,5 +1,5 @@
package dfproto;
//option optimize_for = LITE_RUNTIME;
option optimize_for = LITE_RUNTIME;
import "Block.proto";
@ -8,5 +8,4 @@ message Map
required uint32 x_size = 1;
required uint32 y_size = 2;
required uint32 z_size = 3;
repeated Block block = 4;
}

@ -1,38 +1,36 @@
package dfproto;
//option optimize_for = LITE_RUNTIME;
option optimize_for = LITE_RUNTIME;
message Tile
{
enum TileType
{
EMPTY = 0;
WALL = 1;
PILLAR = 2;
BROOK_BED = 3;
FORTIFICATION = 4;
STAIR_UP = 5;
STAIR_DOWN = 6;
STAIR_UPDOWN = 7;
RAMP = 8;
RAMP_TOP = 9;
FLOOR = 10;
BROOK_TOP = 11;
RIVER_BED = 12;
POOL = 13;
TREE_DEAD = 14;
TREE_OK = 15;
SAPLING_DEAD = 16;
SAPLING_OK = 17;
SHRUB_DEAD = 18;
SHRUB_OK = 19;
BOULDER = 20;
PEBLLES = 21;
ENDLESS_PIT = 22;
}
required uint32 x = 1;
required uint32 y = 2;
enum TileType
{
EMPTY = 0;
WALL = 1;
PILLAR = 2;
BROOK_BED = 3;
FORTIFICATION = 4;
STAIR_UP = 5;
STAIR_DOWN = 6;
STAIR_UPDOWN = 7;
RAMP = 8;
RAMP_TOP = 9;
FLOOR = 10;
BROOK_TOP = 11;
RIVER_BED = 12;
POOL = 13;
TREE_DEAD = 14;
TREE_OK = 15;
SAPLING_DEAD = 16;
SAPLING_OK = 17;
SHRUB_DEAD = 18;
SHRUB_OK = 19;
BOULDER = 20;
PEBLLES = 21;
ENDLESS_PIT = 22;
}
required TileType type = 3;
required TileType type = 3;
optional uint32 material = 4;
}