mirror of
https://github.com/minetest/minetestmapper.git
synced 2025-07-04 17:40:22 +02:00
parseColorsStream: fix empty/white lines detection
When input line is empty, sscanf does not write a '\0' to the %s target. Initialize its first byte to '\0' to properly detect empty lines after. Next, we do not want to stop reading the file upon reading an empty line: use continue instead of break. The latter was not noticed because of the former.
This commit is contained in:
@ -272,13 +272,14 @@ void TileGenerator::parseColorsStream(std::istream &in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char name[64];
|
char name[64];
|
||||||
|
name[0] = '\0';
|
||||||
unsigned int r, g, b, a, t;
|
unsigned int r, g, b, a, t;
|
||||||
a = 255;
|
a = 255;
|
||||||
t = 0;
|
t = 0;
|
||||||
|
|
||||||
sscanf(line, "%64s %u %u %u %u %u", name, &r, &g, &b, &a, &t);
|
sscanf(line, "%64s %u %u %u %u %u", name, &r, &g, &b, &a, &t);
|
||||||
if(strlen(name) == 0)
|
if(strlen(name) == 0)
|
||||||
break;
|
continue;
|
||||||
ColorEntry color = ColorEntry(r, g, b, a, t);
|
ColorEntry color = ColorEntry(r, g, b, a, t);
|
||||||
m_colorMap[name] = color;
|
m_colorMap[name] = color;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user