Use a common ustring type definition instead of different custom versions
parent
0117556550
commit
902f3b45d7
|
@ -881,8 +881,8 @@ void TileGenerator::renderMap()
|
|||
|
||||
ZlibDecompressor decompressor(data, length);
|
||||
decompressor.setSeekPos(dataOffset);
|
||||
ZlibDecompressor::string mapData = decompressor.decompress();
|
||||
ZlibDecompressor::string mapMetadata = decompressor.decompress();
|
||||
ustring mapData = decompressor.decompress();
|
||||
ustring mapMetadata = decompressor.decompress();
|
||||
dataOffset = decompressor.seekPos();
|
||||
|
||||
// Skip unused data
|
||||
|
@ -973,7 +973,7 @@ void TileGenerator::renderMap()
|
|||
cout << std::setw(40) << "" << "\r";
|
||||
}
|
||||
|
||||
inline void TileGenerator::renderMapBlock(const unsigned_string &mapBlock, const BlockPos &pos, int version)
|
||||
inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPos &pos, int version)
|
||||
{
|
||||
int xBegin = worldBlockX2StoredX(pos.x);
|
||||
int zBegin = worldBlockZ2StoredY(pos.z);
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <string>
|
||||
#include "types.h"
|
||||
#include "PixelAttributes.h"
|
||||
#include "Color.h"
|
||||
#include "db.h"
|
||||
|
@ -78,9 +80,8 @@ struct BlockPos {
|
|||
class TileGenerator
|
||||
{
|
||||
private:
|
||||
typedef std::basic_string<unsigned char> unsigned_string;
|
||||
typedef std::map<std::string, ColorEntry> ColorMap;
|
||||
typedef std::pair<BlockPos, unsigned_string> Block;
|
||||
typedef std::pair<BlockPos, ustring> Block;
|
||||
typedef std::list<Block> BlockList;
|
||||
|
||||
public:
|
||||
|
@ -138,7 +139,7 @@ private:
|
|||
std::list<int> getZValueList() const;
|
||||
Block getBlockOnPos(BlockPos pos);
|
||||
void pushPixelRows(int zPosLimit);
|
||||
void renderMapBlock(const unsigned_string &mapBlock, const BlockPos &pos, int version);
|
||||
void renderMapBlock(const ustring &mapBlock, const BlockPos &pos, int version);
|
||||
void renderScale();
|
||||
void renderOrigin();
|
||||
void renderPlayers(const std::string &inputPath);
|
||||
|
|
|
@ -32,12 +32,12 @@ std::size_t ZlibDecompressor::seekPos() const
|
|||
return m_seekPos;
|
||||
}
|
||||
|
||||
ZlibDecompressor::string ZlibDecompressor::decompress()
|
||||
ustring ZlibDecompressor::decompress()
|
||||
{
|
||||
const unsigned char *data = m_data + m_seekPos;
|
||||
const std::size_t size = m_size - m_seekPos;
|
||||
|
||||
string buffer;
|
||||
ustring buffer;
|
||||
const size_t BUFSIZE = 128 * 1024;
|
||||
uint8_t temp_buffer[BUFSIZE];
|
||||
|
||||
|
@ -58,7 +58,7 @@ ZlibDecompressor::string ZlibDecompressor::decompress()
|
|||
strm.avail_out = BUFSIZE;
|
||||
strm.next_out = temp_buffer;
|
||||
ret = inflate(&strm, Z_NO_FLUSH);
|
||||
buffer += string(reinterpret_cast<unsigned char *>(temp_buffer), BUFSIZE - strm.avail_out);
|
||||
buffer += ustring(reinterpret_cast<unsigned char *>(temp_buffer), BUFSIZE - strm.avail_out);
|
||||
} while (ret == Z_OK);
|
||||
if (ret != Z_STREAM_END) {
|
||||
throw DecompressError();
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include "types.h"
|
||||
|
||||
|
||||
class ZlibDecompressor
|
||||
{
|
||||
public:
|
||||
typedef std::basic_string<unsigned char> string;
|
||||
class DecompressError {
|
||||
};
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
|||
~ZlibDecompressor();
|
||||
void setSeekPos(std::size_t seekPos);
|
||||
std::size_t seekPos() const;
|
||||
string decompress();
|
||||
ustring decompress();
|
||||
|
||||
private:
|
||||
const unsigned char *m_data;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "db-leveldb.h"
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include "types.h"
|
||||
|
||||
inline int64_t stoi64(const std::string &s) {
|
||||
std::stringstream tmp(s);
|
||||
|
@ -69,7 +70,7 @@ DBBlock DBLevelDB::getBlockOnPos(int x, int y, int z)
|
|||
|
||||
status = m_db->Get(leveldb::ReadOptions(), i64tos(iPos), &datastr);
|
||||
if(status.ok()) {
|
||||
block = DBBlock( iPos, std::basic_string<unsigned char>( (const unsigned char*) datastr.c_str(), datastr.size() ) );
|
||||
block = DBBlock( iPos, ustring( (const unsigned char*) datastr.c_str(), datastr.size() ) );
|
||||
m_blocksReadCount++;
|
||||
m_blocksUnCachedCount++;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "db-sqlite3.h"
|
||||
#include <stdexcept>
|
||||
#include <unistd.h> // for usleep
|
||||
#include "types.h"
|
||||
|
||||
|
||||
DBSQLite3::DBSQLite3(const std::string &mapdir) :
|
||||
|
@ -138,7 +139,7 @@ DBBlock DBSQLite3::getBlockOnPosRaw(sqlite3_int64 psPos)
|
|||
sqlite3_int64 blocknum = sqlite3_column_int64(m_blockOnPosStatement, 0);
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(sqlite3_column_blob(m_blockOnPosStatement, 1));
|
||||
int size = sqlite3_column_bytes(m_blockOnPosStatement, 1);
|
||||
block = DBBlock(blocknum, std::basic_string<unsigned char>(data, size));
|
||||
block = DBBlock(blocknum, ustring(data, size));
|
||||
m_blocksUnCachedCount++;
|
||||
//std::cerr << "Read block " << blocknum << " from database" << std::endl;
|
||||
break;
|
||||
|
@ -182,7 +183,7 @@ void DBSQLite3::cacheBlocks(sqlite3_stmt *SQLstatement)
|
|||
sqlite3_int64 blocknum = sqlite3_column_int64(SQLstatement, 0);
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(sqlite3_column_blob(SQLstatement, 1));
|
||||
int size = sqlite3_column_bytes(SQLstatement, 1);
|
||||
m_blockCache[blocknum] = DBBlock(blocknum, std::basic_string<unsigned char>(data, size));
|
||||
m_blockCache[blocknum] = DBBlock(blocknum, ustring(data, size));
|
||||
m_blocksCachedCount++;
|
||||
//std::cerr << "Cache block " << blocknum << " from database" << std::endl;
|
||||
} else if (result == SQLITE_BUSY) { // Wait some time and try again
|
||||
|
|
Loading…
Reference in New Issue