Fix a few small issues

closes #58
This commit is contained in:
sfan5 2018-10-20 23:01:03 +02:00
parent 657499e981
commit b2406db169
3 changed files with 15 additions and 25 deletions

@ -269,7 +269,7 @@ void TileGenerator::parseColorsStream(std::istream &in)
if(strlen(line) == 0) if(strlen(line) == 0)
continue; continue;
char name[64]; char name[64 + 1];
unsigned int r, g, b, a, t; unsigned int r, g, b, a, t;
a = 255; a = 255;
t = 0; t = 0;
@ -536,7 +536,7 @@ void TileGenerator::renderScale()
if (m_scales & SCALE_TOP) { if (m_scales & SCALE_TOP) {
m_image->drawText(24, 0, "X", m_scaleColor); m_image->drawText(24, 0, "X", m_scaleColor);
for (int i = (m_xMin / 4) * 4; i <= m_xMax; i += 4) { for (int i = (m_xMin / 4) * 4; i <= m_xMax; i += 4) {
stringstream buf; std::ostringstream buf;
buf << i * 16; buf << i * 16;
int xPos = getImageX(i * 16, true); int xPos = getImageX(i * 16, true);
@ -550,7 +550,7 @@ void TileGenerator::renderScale()
if (m_scales & SCALE_LEFT) { if (m_scales & SCALE_LEFT) {
m_image->drawText(2, 24, "Z", m_scaleColor); m_image->drawText(2, 24, "Z", m_scaleColor);
for (int i = (m_zMax / 4) * 4; i >= m_zMin; i -= 4) { for (int i = (m_zMax / 4) * 4; i >= m_zMin; i -= 4) {
stringstream buf; std::ostringstream buf;
buf << i * 16; buf << i * 16;
int yPos = getImageY(i * 16 + 1, true); int yPos = getImageY(i * 16 + 1, true);
@ -566,7 +566,7 @@ void TileGenerator::renderScale()
yPos = m_yBorder + m_mapHeight*m_zoom + scale_d - 12; yPos = m_yBorder + m_mapHeight*m_zoom + scale_d - 12;
m_image->drawText(xPos, yPos, "X", m_scaleColor); m_image->drawText(xPos, yPos, "X", m_scaleColor);
for (int i = (m_xMin / 4) * 4; i <= m_xMax; i += 4) { for (int i = (m_xMin / 4) * 4; i <= m_xMax; i += 4) {
stringstream buf; std::ostringstream buf;
buf << i * 16; buf << i * 16;
xPos = getImageX(i * 16, true); xPos = getImageX(i * 16, true);
@ -583,7 +583,7 @@ void TileGenerator::renderScale()
yPos = m_yBorder + m_mapHeight*m_zoom - 24 - 12; yPos = m_yBorder + m_mapHeight*m_zoom - 24 - 12;
m_image->drawText(xPos, yPos, "Z", m_scaleColor); m_image->drawText(xPos, yPos, "Z", m_scaleColor);
for (int i = (m_zMax / 4) * 4; i >= m_zMin; i -= 4) { for (int i = (m_zMax / 4) * 4; i >= m_zMin; i -= 4) {
stringstream buf; std::ostringstream buf;
buf << i * 16; buf << i * 16;
xPos = m_xBorder + m_mapWidth*m_zoom; xPos = m_xBorder + m_mapWidth*m_zoom;

@ -20,24 +20,18 @@ public:
BlockPos(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {} BlockPos(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {}
bool operator < (const BlockPos &p) const bool operator < (const BlockPos &p) const
{ {
if (z > p.z) { if (z > p.z)
return true; return true;
} if (z < p.z)
if (z < p.z) {
return false; return false;
} if (y > p.y)
if (y > p.y) {
return true; return true;
} if (y < p.y)
if (y < p.y) {
return false; return false;
} if (x > p.x)
if (x > p.x) {
return true; return true;
} if (x < p.x)
if (x < p.x) {
return false; return false;
}
return false; return false;
} }
}; };

@ -147,24 +147,21 @@ int main(int argc, char *argv[])
generator.setBackend(optarg); generator.setBackend(optarg);
break; break;
case 'a': { case 'a': {
std::istringstream iss; std::istringstream iss(optarg);
iss.str(optarg);
int miny; int miny;
iss >> miny; iss >> miny;
generator.setMinY(miny); generator.setMinY(miny);
} }
break; break;
case 'c': { case 'c': {
std::istringstream iss; std::istringstream iss(optarg);
iss.str(optarg);
int maxy; int maxy;
iss >> maxy; iss >> maxy;
generator.setMaxY(maxy); generator.setMaxY(maxy);
} }
break; break;
case 'g': { case 'g': {
std::istringstream geometry; std::istringstream geometry(optarg);
geometry.str(optarg);
int x, y, w, h; int x, y, w, h;
char c; char c;
geometry >> x >> c >> y >> w >> h; geometry >> x >> c >> y >> w >> h;
@ -189,8 +186,7 @@ int main(int argc, char *argv[])
} }
break; break;
case 'z': { case 'z': {
std::istringstream iss; std::istringstream iss(optarg);
iss.str(optarg);
int zoom; int zoom;
iss >> zoom; iss >> zoom;
generator.setZoom(zoom); generator.setZoom(zoom);