From ec037dd9240bc2a4163d789958f667594e5fc507 Mon Sep 17 00:00:00 2001 From: Sfan5 Date: Wed, 26 Mar 2014 16:28:24 +0100 Subject: [PATCH] Fix --min-y and --max-y handling --- TileGenerator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/TileGenerator.cpp b/TileGenerator.cpp index 5237ae4..9040dc0 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -311,10 +311,10 @@ void TileGenerator::loadBlocks() if (pos.x < m_geomX || pos.x >= m_geomX2 || pos.z < m_geomY || pos.z >= m_geomY2) { continue; } - if (pos.y < m_yMin) { + if (pos.y < m_yMin * 16) { continue; } - if (pos.y > m_yMax) { + if (pos.y > m_yMax * 16) { continue; } if (pos.x < m_xMin) { @@ -495,6 +495,8 @@ inline void TileGenerator::renderMapBlock(const unsigned_string &mapBlock, const int xBegin = (pos.x - m_xMin) * 16; int zBegin = (m_zMax - pos.z) * 16; const unsigned char *mapData = mapBlock.c_str(); + int minY = (pos.y * 16 > m_yMin) ? 0 : m_yMin - pos.y * 16; + int maxY = (pos.y * 16 < m_yMax) ? 15 : m_yMax - pos.y * 16; for (int z = 0; z < 16; ++z) { int imageY = getImageY(zBegin + 15 - z); for (int x = 0; x < 16; ++x) { @@ -502,8 +504,7 @@ inline void TileGenerator::renderMapBlock(const unsigned_string &mapBlock, const continue; } int imageX = getImageX(xBegin + x); - int minY = (pos.y * 16 > m_yMin) ? 0 : m_yMin - pos.y * 16; - int maxY = (pos.y * 16 < m_yMax) ? 15 : m_yMax - pos.y * 16; + for (int y = maxY; y >= minY; --y) { int position = x + (y << 4) + (z << 8); int content = readBlockContent(mapData, version, position);