Simplify color parsing code

This commit is contained in:
sfan5 2016-10-08 13:39:07 +02:00
parent 3e2b327167
commit 173dd75b31

@ -264,28 +264,19 @@ void TileGenerator::parseColorsStream(std::istream &in)
char line[128], *p; char line[128], *p;
while (in.good()) { while (in.good()) {
in.getline(line, 128); in.getline(line, 128);
p = line; while(*p++ != '\0') {
while(*p++ != '\0') if(*p != '#')
if(*p == '#') { continue;
*p = '\0'; // Cut off at the first # *p = '\0'; // Cut off at the first #
break; break;
} }
char name[75]; char name[64];
#ifdef __MINGW32__
// MinGW's sscanf doesn't support %hhu
unsigned int r, g, b, a, t; unsigned int r, g, b, a, t;
#else
uint8_t r, g, b, a, t;
#endif
a = 255; a = 255;
t = 0; t = 0;
#ifdef __MINGW32__ sscanf(line, "%64s %u %u %u %u %u", name, &r, &g, &b, &a, &t);
sscanf(line, "%75s %u %u %u %u %u", name, &r, &g, &b, &a, &t);
#else
sscanf(line, "%75s %hhu %hhu %hhu %hhu %hhu", name, &r, &g, &b, &a, &t);
#endif
if(strlen(name) == 0) if(strlen(name) == 0)
break; break;
ColorEntry color = ColorEntry(r, g, b, a, t); ColorEntry color = ColorEntry(r, g, b, a, t);