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