diff --git a/Minetestmapper/TileGenerator.cpp b/Minetestmapper/TileGenerator.cpp index b4d2d31..a7807dc 100644 --- a/Minetestmapper/TileGenerator.cpp +++ b/Minetestmapper/TileGenerator.cpp @@ -73,9 +73,9 @@ static inline void readString(string &str, const unsigned char *data, size_t off static inline void checkBlockNodeDataLimit(int version, size_t dataLength) { - int datapos = 16 * 16 * 16; + constexpr const int datapos = 16 * 16 * 16; if (version >= 24) { - size_t index = datapos << 1; + constexpr const size_t index = static_cast(datapos) << 1; checkDataLimit("node:24", index, 2, dataLength); } else if (version >= 20) { @@ -91,7 +91,7 @@ static inline void checkBlockNodeDataLimit(int version, size_t dataLength) static inline int readBlockContent(const unsigned char *mapData, int version, int datapos) { if (version >= 24) { - size_t index = datapos << 1; + size_t index = static_cast(datapos) << 1; return (mapData[index] << 8) | mapData[index + 1]; } else if (version >= 20) { @@ -118,7 +118,6 @@ const BlockPos TileGenerator::BlockPosLimitMax(MAPBLOCK_MAX, MAPBLOCK_MAX, MAPBL TileGenerator::TileGenerator() { - memset(&m_databaseFormatFound, 0, sizeof(m_databaseFormatFound)); // Load default grey colors. m_heightMapColors.push_back(HeightMapColor(INT_MIN, Color(0,0,0), -129, Color(0,0,0))); m_heightMapColors.push_back(HeightMapColor(-128, Color(0,0,0), 127, Color(255,255,255))); @@ -1540,9 +1539,8 @@ void TileGenerator::renderMap() << " (" << std::fixed << std::setprecision(0) << 100.0 * (m_zMax - pos.z()) / (m_zMax - m_zMin) << "%) \r" << std::flush; } - for (int i = 0; i < 16; ++i) { - m_readedPixels[i] = 0; - } + + m_readedPixels.fill(0); allReaded = false; currentPos = pos; } diff --git a/Minetestmapper/TileGenerator.h b/Minetestmapper/TileGenerator.h index 1744334..f6b22e5 100644 --- a/Minetestmapper/TileGenerator.h +++ b/Minetestmapper/TileGenerator.h @@ -9,6 +9,7 @@ #pragma once +#include #include #include #include @@ -232,7 +233,7 @@ private: bool m_databaseFormatSet{ false }; BlockPos::StrFormat m_databaseFormat{ BlockPos::Unknown }; std::string m_recommendedDatabaseFormat; - long long m_databaseFormatFound[BlockPos::STRFORMAT_MAX]; + std::array m_databaseFormatFound{ { 0 } }; bool m_reportDatabaseFormat{ false }; PaintEngine *paintEngine = nullptr; PixelAttributes m_blockPixelAttributes; @@ -286,7 +287,7 @@ private: const ColorEntry *m_nodeIDColor[MAPBLOCK_MAXCOLORS]; NodeColorMap m_nodeColors; HeightMapColorList m_heightMapColors; - uint16_t m_readedPixels[16]; + std::array m_readedPixels; std::set m_unknownNodes; std::vector m_drawObjects; }; /* ----- end of class TileGenerator ----- */