mirror of
https://github.com/minetest/minetestmapper.git
synced 2024-11-21 23:13:53 +01:00
Added storing of blocks.
This commit is contained in:
parent
6e653648b5
commit
0b9adc95b7
@ -12,6 +12,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include "TileGenerator.h"
|
||||
|
||||
using namespace std;
|
||||
@ -251,9 +252,9 @@ inline std::list<int> TileGenerator::getZValueList() const
|
||||
return zlist;
|
||||
}
|
||||
|
||||
void TileGenerator::getBlocksOnZ(int zPos, sqlite3_stmt *statement) const
|
||||
std::map<int, TileGenerator::BlockList> TileGenerator::getBlocksOnZ(int zPos, sqlite3_stmt *statement) const
|
||||
{
|
||||
map <int, list <pair <BlockPos, string> > > blocks;
|
||||
map<int, BlockList> blocks;
|
||||
|
||||
sqlite3_int64 psMin = encodeBlockPos(-2048, -2048, zPos);
|
||||
sqlite3_int64 psMax = encodeBlockPos( 2047, 2047, zPos);
|
||||
@ -270,27 +271,18 @@ void TileGenerator::getBlocksOnZ(int zPos, sqlite3_stmt *statement) const
|
||||
result = sqlite3_step(statement);
|
||||
if(result == SQLITE_ROW) {
|
||||
sqlite3_int64 blocknum = sqlite3_column_int64(statement, 0);
|
||||
const void *data = sqlite3_column_blob(statement, 1);
|
||||
|
||||
uint8_t version = static_cast<const uint8_t *>(data)[0];
|
||||
uint8_t flags = static_cast<const uint8_t *>(data)[1];
|
||||
if (version >= 22) {
|
||||
data += 4;
|
||||
}
|
||||
else {
|
||||
data += 2;
|
||||
}
|
||||
|
||||
|
||||
const char *data = reinterpret_cast<const char *>(sqlite3_column_blob(statement, 1));
|
||||
int size = sqlite3_column_bytes(statement, 1);
|
||||
BlockPos pos = decodeBlockPos(blocknum);
|
||||
blocks[pos.x].push_back(pair<BlockPos, string> (pos, ""));
|
||||
|
||||
blocks[pos.x].push_back(Block(pos, string(data, size)));
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
sqlite3_reset(statement);
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
void TileGenerator::writeImage(const std::string &output)
|
||||
|
@ -37,10 +37,15 @@ class DbError {
|
||||
class ColorError {
|
||||
};
|
||||
|
||||
class DecompressError {
|
||||
};
|
||||
|
||||
class TileGenerator
|
||||
{
|
||||
private:
|
||||
typedef std::map<std::string, Color> ColorMap;
|
||||
typedef std::pair<BlockPos, std::string> Block;
|
||||
typedef std::list<Block> BlockList;
|
||||
|
||||
public:
|
||||
TileGenerator();
|
||||
@ -48,8 +53,7 @@ public:
|
||||
void setBgColor(const std::string &bgColor);
|
||||
void setScaleColor(const std::string &scaleColor);
|
||||
void setOriginColor(const std::string &originColor);
|
||||
void setPlayerColor(const std::string &playerColor);
|
||||
Color parseColor(const std::string &color);
|
||||
void setPlayerColor(const std::string &playerColor); Color parseColor(const std::string &color);
|
||||
void setDrawOrigin(bool drawOrigin);
|
||||
void setDrawPlayers(bool drawPlayers);
|
||||
void setDrawScale(bool drawScale);
|
||||
@ -66,8 +70,9 @@ private:
|
||||
void createImage();
|
||||
void renderMap();
|
||||
std::list<int> getZValueList() const;
|
||||
void getBlocksOnZ(int zPos, sqlite3_stmt *statement) const;
|
||||
std::map<int, BlockList> getBlocksOnZ(int zPos, sqlite3_stmt *statement) const;
|
||||
void writeImage(const std::string &output);
|
||||
void *zlibDecompress(const void *data, std::size_t *processed) const;
|
||||
|
||||
private:
|
||||
Color m_bgColor;
|
||||
|
Loading…
Reference in New Issue
Block a user