parseColorsStream: check RGB components presence

Report lines failing to match at least RGB components.
This commit is contained in:
Christophe Le Roy 2016-10-08 20:37:36 +02:00
parent 82a19b6cae
commit 51c99e2d56
1 changed files with 5 additions and 1 deletions

View File

@ -277,9 +277,13 @@ void TileGenerator::parseColorsStream(std::istream &in)
a = 255;
t = 0;
sscanf(line, "%64s %u %u %u %u %u", name, &r, &g, &b, &a, &t);
int read_items = sscanf(line, "%64s %u %u %u %u %u", name, &r, &g, &b, &a, &t);
if(strlen(name) == 0)
continue;
if(read_items < 4) {
std::cerr << "Unable to parse color '" << line << "'\n";
continue;
}
ColorEntry color = ColorEntry(r, g, b, a, t);
m_colorMap[name] = color;
}