Tidy up and modernize TileGenerator (Part 1)
This commit is contained in:
parent
72d29f21f0
commit
8062064193
@ -46,6 +46,7 @@ if(WIN32)
|
|||||||
set(sources ${sources} ResTempl1.rct)
|
set(sources ${sources} ResTempl1.rct)
|
||||||
add_definitions(-DVER_COMPANYNAME_STR="MyCompany")
|
add_definitions(-DVER_COMPANYNAME_STR="MyCompany")
|
||||||
add_definitions(-DVER_FILEVERSION_STR="1,1,0.0")
|
add_definitions(-DVER_FILEVERSION_STR="1,1,0.0")
|
||||||
|
add_definitions(-D_USE_MATH_DEFINES)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
find_library(ZLIB_LIBRARY NAMES zlib z)
|
find_library(ZLIB_LIBRARY NAMES zlib z)
|
||||||
|
@ -6,25 +6,26 @@
|
|||||||
* Company: LinuxOS.sk
|
* Company: LinuxOS.sk
|
||||||
* =====================================================================
|
* =====================================================================
|
||||||
*/
|
*/
|
||||||
|
#include <cerrno>
|
||||||
|
#include <climits>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <climits>
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cerrno>
|
#include <utility>
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "DataFileParser.h"
|
#include "DataFileParser.h"
|
||||||
#include "Settings.h"
|
#include "PaintEngine_libgd.h"
|
||||||
#include "PlayerAttributes.h"
|
#include "PlayerAttributes.h"
|
||||||
|
#include "Settings.h"
|
||||||
#include "TileGenerator.h"
|
#include "TileGenerator.h"
|
||||||
#include "ZlibDecompressor.h"
|
#include "ZlibDecompressor.h"
|
||||||
#include "PaintEngine_libgd.h"
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "db-sqlite3.h"
|
#include "db-sqlite3.h"
|
||||||
#endif
|
#endif
|
||||||
@ -115,75 +116,7 @@ const BlockPos TileGenerator::BlockPosLimitMin(MAPBLOCK_MIN, MAPBLOCK_MIN, MAPBL
|
|||||||
const BlockPos TileGenerator::BlockPosLimitMax(MAPBLOCK_MAX, MAPBLOCK_MAX, MAPBLOCK_MAX);
|
const BlockPos TileGenerator::BlockPosLimitMax(MAPBLOCK_MAX, MAPBLOCK_MAX, MAPBLOCK_MAX);
|
||||||
|
|
||||||
|
|
||||||
TileGenerator::TileGenerator():
|
TileGenerator::TileGenerator()
|
||||||
verboseCoordinates(0),
|
|
||||||
verboseReadColors(0),
|
|
||||||
verboseStatistics(0),
|
|
||||||
progressIndicator(false),
|
|
||||||
m_silenceSuggestions(0),
|
|
||||||
m_heightMap(false),
|
|
||||||
m_heightMapYScale(1),
|
|
||||||
m_seaLevel(0),
|
|
||||||
m_bgColor(255, 255, 255),
|
|
||||||
m_blockDefaultColor(0, 0, 0, 0),
|
|
||||||
m_scaleColor(0, 0, 0),
|
|
||||||
m_originColor(255, 0, 0),
|
|
||||||
m_playerColor(255, 0, 0),
|
|
||||||
m_tileBorderColor(0, 0, 0),
|
|
||||||
m_drawOrigin(false),
|
|
||||||
m_drawPlayers(false),
|
|
||||||
m_drawScale(DRAWSCALE_NONE),
|
|
||||||
m_drawAlpha(false),
|
|
||||||
m_drawAir(false),
|
|
||||||
m_drawIgnore(false),
|
|
||||||
m_shading(true),
|
|
||||||
m_backend(DEFAULT_BACKEND),
|
|
||||||
m_requestedBackend(DEFAULT_BACKEND),
|
|
||||||
m_scanEntireWorld(false),
|
|
||||||
m_shrinkGeometry(true),
|
|
||||||
m_blockGeometry(false),
|
|
||||||
m_scaleFactor(1),
|
|
||||||
m_chunkSize(0),
|
|
||||||
m_sideScaleMajor(0),
|
|
||||||
m_sideScaleMinor(0),
|
|
||||||
m_heightScaleMajor(0),
|
|
||||||
m_heightScaleMinor(0),
|
|
||||||
m_generateNoPrefetch(0),
|
|
||||||
m_databaseFormatSet(false),
|
|
||||||
m_databaseFormat(BlockPos::Unknown),
|
|
||||||
m_reportDatabaseFormat(false),
|
|
||||||
m_xMin(INT_MAX/16-1),
|
|
||||||
m_xMax(INT_MIN/16+1),
|
|
||||||
m_zMin(INT_MAX/16-1),
|
|
||||||
m_zMax(INT_MIN/16+1),
|
|
||||||
m_yMin(INT_MAX/16-1),
|
|
||||||
m_yMax(INT_MIN/16+1),
|
|
||||||
m_reqXMin(MAPBLOCK_MIN),
|
|
||||||
m_reqXMax(MAPBLOCK_MAX),
|
|
||||||
m_reqYMin(MAPBLOCK_MIN),
|
|
||||||
m_reqYMax(MAPBLOCK_MAX),
|
|
||||||
m_reqZMin(MAPBLOCK_MIN),
|
|
||||||
m_reqZMax(MAPBLOCK_MAX),
|
|
||||||
m_reqYMinNode(0),
|
|
||||||
m_reqYMaxNode(15),
|
|
||||||
m_YMinMapped(MAPBLOCK_MAX),
|
|
||||||
m_YMaxMapped(MAPBLOCK_MIN),
|
|
||||||
m_emptyMapArea(0),
|
|
||||||
m_mapXStartNodeOffset(0),
|
|
||||||
m_mapYStartNodeOffset(0),
|
|
||||||
m_mapXEndNodeOffset(0),
|
|
||||||
m_mapYEndNodeOffset(0),
|
|
||||||
m_tileXOrigin(TILECENTER_AT_WORLDCENTER),
|
|
||||||
m_tileZOrigin(TILECENTER_AT_WORLDCENTER),
|
|
||||||
m_tileWidth(0),
|
|
||||||
m_tileHeight(0),
|
|
||||||
m_tileBorderSize(1),
|
|
||||||
m_tileMapXOffset(0),
|
|
||||||
m_tileMapYOffset(0),
|
|
||||||
m_surfaceHeight(INT_MIN),
|
|
||||||
m_surfaceDepth(INT_MAX),
|
|
||||||
m_tileBorderXCount(0),
|
|
||||||
m_tileBorderYCount(0)
|
|
||||||
{
|
{
|
||||||
memset(&m_databaseFormatFound, 0, sizeof(m_databaseFormatFound));
|
memset(&m_databaseFormatFound, 0, sizeof(m_databaseFormatFound));
|
||||||
// Load default grey colors.
|
// Load default grey colors.
|
||||||
|
@ -7,26 +7,23 @@
|
|||||||
* =====================================================================
|
* =====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TILEGENERATOR_H_JJNUCARH
|
#pragma once
|
||||||
#define TILEGENERATOR_H_JJNUCARH
|
|
||||||
|
|
||||||
#include <gd.h>
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <iosfwd>
|
|
||||||
#include <list>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <set>
|
|
||||||
#include <list>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <iosfwd>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "PixelAttributes.h"
|
|
||||||
#include "BlockPos.h"
|
#include "BlockPos.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "db.h"
|
|
||||||
#include "PaintEngine.h"
|
#include "PaintEngine.h"
|
||||||
|
#include "PixelAttributes.h"
|
||||||
|
#include "db.h"
|
||||||
|
|
||||||
#define TILESIZE_CHUNK (INT_MIN)
|
#define TILESIZE_CHUNK (INT_MIN)
|
||||||
#define TILECENTER_AT_WORLDCENTER (INT_MAX)
|
#define TILECENTER_AT_WORLDCENTER (INT_MAX)
|
||||||
@ -106,7 +103,7 @@ public:
|
|||||||
void setHeightMapYScale(float scale);
|
void setHeightMapYScale(float scale);
|
||||||
void setSeaLevel(int level);
|
void setSeaLevel(int level);
|
||||||
void setBgColor(const Color &bgColor);
|
void setBgColor(const Color &bgColor);
|
||||||
void setBlockDefaultColor(const Color &olor);
|
void setBlockDefaultColor(const Color &color);
|
||||||
void setScaleColor(const Color &scaleColor);
|
void setScaleColor(const Color &scaleColor);
|
||||||
void setOriginColor(const Color &originColor);
|
void setOriginColor(const Color &originColor);
|
||||||
void setPlayerColor(const Color &playerColor);
|
void setPlayerColor(const Color &playerColor);
|
||||||
@ -195,94 +192,94 @@ public:
|
|||||||
static const BlockPos BlockPosLimitMin;
|
static const BlockPos BlockPosLimitMin;
|
||||||
static const BlockPos BlockPosLimitMax;
|
static const BlockPos BlockPosLimitMax;
|
||||||
|
|
||||||
int verboseCoordinates;
|
int verboseCoordinates{ 0 };
|
||||||
int verboseReadColors;
|
int verboseReadColors{ 0 };
|
||||||
int verboseStatistics;
|
int verboseStatistics{ 0 };
|
||||||
bool progressIndicator;
|
bool progressIndicator{ false };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned m_silenceSuggestions;
|
unsigned m_silenceSuggestions{ 0 };
|
||||||
bool m_heightMap;
|
bool m_heightMap{ false };
|
||||||
float m_heightMapYScale;
|
float m_heightMapYScale{ 1 };
|
||||||
int m_seaLevel;
|
int m_seaLevel{ 0 };
|
||||||
Color m_bgColor;
|
Color m_bgColor{ 255, 255, 255 };
|
||||||
Color m_blockDefaultColor;
|
Color m_blockDefaultColor{ 0, 0, 0, 0 };
|
||||||
Color m_scaleColor;
|
Color m_scaleColor{ 0, 0, 0 };
|
||||||
Color m_originColor;
|
Color m_originColor{ 255, 0, 0 };
|
||||||
Color m_playerColor;
|
Color m_playerColor{ 255, 0, 0 };
|
||||||
Color m_tileBorderColor;
|
Color m_tileBorderColor{ 0, 0, 0 };
|
||||||
bool m_drawOrigin;
|
bool m_drawOrigin{ false };
|
||||||
bool m_drawPlayers;
|
bool m_drawPlayers{ false };
|
||||||
int m_drawScale;
|
int m_drawScale{ DRAWSCALE_NONE };
|
||||||
bool m_drawAlpha;
|
bool m_drawAlpha{ false };
|
||||||
bool m_drawAir;
|
bool m_drawAir{ false };
|
||||||
bool m_drawIgnore;
|
bool m_drawIgnore{ false };
|
||||||
bool m_shading;
|
bool m_shading{ true };
|
||||||
std::string m_backend;
|
std::string m_backend{ DEFAULT_BACKEND };
|
||||||
std::string m_requestedBackend;
|
std::string m_requestedBackend{ DEFAULT_BACKEND };
|
||||||
bool m_scanEntireWorld;
|
bool m_scanEntireWorld{ false };
|
||||||
bool m_shrinkGeometry;
|
bool m_shrinkGeometry{ true };
|
||||||
bool m_blockGeometry;
|
bool m_blockGeometry{ false };
|
||||||
int m_scaleFactor;
|
int m_scaleFactor{ 1 };
|
||||||
int m_chunkSize;
|
int m_chunkSize{ 0 };
|
||||||
int m_sideScaleMajor;
|
int m_sideScaleMajor{ 0 };
|
||||||
int m_sideScaleMinor;
|
int m_sideScaleMinor{ 0 };
|
||||||
int m_heightScaleMajor;
|
int m_heightScaleMajor{ 0 };
|
||||||
int m_heightScaleMinor;
|
int m_heightScaleMinor{ 0 };
|
||||||
|
|
||||||
DB *m_db = nullptr;
|
DB *m_db = nullptr;
|
||||||
int m_generateNoPrefetch;
|
int m_generateNoPrefetch{ 0 };
|
||||||
bool m_databaseFormatSet;
|
bool m_databaseFormatSet{ false };
|
||||||
BlockPos::StrFormat m_databaseFormat;
|
BlockPos::StrFormat m_databaseFormat{ BlockPos::Unknown };
|
||||||
std::string m_recommendedDatabaseFormat;
|
std::string m_recommendedDatabaseFormat;
|
||||||
long long m_databaseFormatFound[BlockPos::STRFORMAT_MAX];
|
long long m_databaseFormatFound[BlockPos::STRFORMAT_MAX];
|
||||||
bool m_reportDatabaseFormat;
|
bool m_reportDatabaseFormat{ false };
|
||||||
PaintEngine *paintEngine = nullptr;
|
PaintEngine *paintEngine = nullptr;
|
||||||
PixelAttributes m_blockPixelAttributes;
|
PixelAttributes m_blockPixelAttributes;
|
||||||
PixelAttributes m_blockPixelAttributesScaled;
|
PixelAttributes m_blockPixelAttributesScaled;
|
||||||
int m_xMin;
|
int m_xMin{ INT_MAX / 16 - 1 };
|
||||||
int m_xMax;
|
int m_xMax{ INT_MIN / 16 + 1 };
|
||||||
int m_zMin;
|
int m_zMin{ INT_MAX / 16 - 1 };
|
||||||
int m_zMax;
|
int m_zMax{ INT_MIN / 16 + 1 };
|
||||||
int m_yMin;
|
int m_yMin{ INT_MAX / 16 - 1 };
|
||||||
int m_yMax;
|
int m_yMax{ INT_MIN / 16 + 1 };
|
||||||
int m_reqXMin;
|
int m_reqXMin{ MAPBLOCK_MIN };
|
||||||
int m_reqXMax;
|
int m_reqXMax{ MAPBLOCK_MAX };
|
||||||
int m_reqYMin;
|
int m_reqYMin{ MAPBLOCK_MIN };
|
||||||
int m_reqYMax;
|
int m_reqYMax{ MAPBLOCK_MAX };
|
||||||
int m_reqZMin;
|
int m_reqZMin{ MAPBLOCK_MIN };
|
||||||
int m_reqZMax;
|
int m_reqZMax{ MAPBLOCK_MAX };
|
||||||
int m_reqYMinNode; // Node offset within a map block
|
int m_reqYMinNode{ 0 }; // Node offset within a map block
|
||||||
int m_reqYMaxNode; // Node offset within a map block
|
int m_reqYMaxNode{ 15 }; // Node offset within a map block
|
||||||
int m_YMinMapped; // Lowest block number mapped (not empty or air)
|
int m_YMinMapped{ MAPBLOCK_MAX }; // Lowest block number mapped (not empty or air)
|
||||||
int m_YMaxMapped; // Higher block number mapped (not empty or air)
|
int m_YMaxMapped{ MAPBLOCK_MIN }; // Higher block number mapped (not empty or air)
|
||||||
long long m_emptyMapArea; // Number of blocks that are partly empty in the map
|
long long m_emptyMapArea{ 0 }; // Number of blocks that are partly empty in the map
|
||||||
long long m_worldBlocks; // Number of blocks in the world (if known)
|
long long m_worldBlocks; // Number of blocks in the world (if known)
|
||||||
int m_storedWidth;
|
int m_storedWidth;
|
||||||
int m_storedHeight;
|
int m_storedHeight;
|
||||||
int m_mapXStartNodeOffset;
|
int m_mapXStartNodeOffset{ 0 };
|
||||||
int m_mapYStartNodeOffset;
|
int m_mapYStartNodeOffset{ 0 };
|
||||||
int m_mapXEndNodeOffset;
|
int m_mapXEndNodeOffset{ 0 };
|
||||||
int m_mapYEndNodeOffset;
|
int m_mapYEndNodeOffset{ 0 };
|
||||||
int m_mapXStartNodeOffsetOrig;
|
int m_mapXStartNodeOffsetOrig;
|
||||||
int m_mapYStartNodeOffsetOrig;
|
int m_mapYStartNodeOffsetOrig;
|
||||||
int m_mapXEndNodeOffsetOrig;
|
int m_mapXEndNodeOffsetOrig;
|
||||||
int m_mapYEndNodeOffsetOrig;
|
int m_mapYEndNodeOffsetOrig;
|
||||||
int m_tileXOrigin;
|
int m_tileXOrigin{ TILECENTER_AT_WORLDCENTER };
|
||||||
int m_tileZOrigin;
|
int m_tileZOrigin{ TILECENTER_AT_WORLDCENTER };
|
||||||
int m_tileXCentered;
|
int m_tileXCentered;
|
||||||
int m_tileYCentered;
|
int m_tileYCentered;
|
||||||
int m_tileWidth;
|
int m_tileWidth{ 0 };
|
||||||
int m_tileHeight;
|
int m_tileHeight{ 0 };
|
||||||
int m_tileBorderSize;
|
int m_tileBorderSize{ 1 };
|
||||||
int m_tileMapXOffset;
|
int m_tileMapXOffset{ 0 };
|
||||||
int m_tileMapYOffset;
|
int m_tileMapYOffset{ 0 };
|
||||||
int m_tileBorderXCount;
|
int m_tileBorderXCount{ 0 };
|
||||||
int m_tileBorderYCount;
|
int m_tileBorderYCount{ 0 };
|
||||||
int m_pictWidth;
|
int m_pictWidth;
|
||||||
int m_pictHeight;
|
int m_pictHeight;
|
||||||
int m_surfaceHeight;
|
int m_surfaceHeight{ INT_MIN };
|
||||||
int m_surfaceDepth;
|
int m_surfaceDepth{ INT_MAX };
|
||||||
std::list<BlockPos> m_positions;
|
std::list<BlockPos> m_positions;
|
||||||
NodeID2NameMap m_nameMap;
|
NodeID2NameMap m_nameMap;
|
||||||
static const ColorEntry *NodeColorNotDrawn;
|
static const ColorEntry *NodeColorNotDrawn;
|
||||||
@ -294,5 +291,3 @@ private:
|
|||||||
std::vector<DrawObject> m_drawObjects;
|
std::vector<DrawObject> m_drawObjects;
|
||||||
}; /* ----- end of class TileGenerator ----- */
|
}; /* ----- end of class TileGenerator ----- */
|
||||||
|
|
||||||
#endif /* end of include guard: TILEGENERATOR_H_JJNUCARH */
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "mapper.h"
|
#include "mapper.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user