mirror of
https://github.com/minetest/minetestmapper.git
synced 2024-11-22 15:33:49 +01:00
Improve color parsing, hopefully fixes #7
This commit is contained in:
parent
d8cfe79116
commit
dff4589152
@ -264,34 +264,27 @@ void TileGenerator::generate(const std::string &input, const std::string &output
|
|||||||
|
|
||||||
void TileGenerator::parseColorsStream(std::istream &in)
|
void TileGenerator::parseColorsStream(std::istream &in)
|
||||||
{
|
{
|
||||||
|
char line[128], *p;
|
||||||
while (in.good()) {
|
while (in.good()) {
|
||||||
string name;
|
in.getline(line, 128);
|
||||||
ColorEntry color;
|
p = line;
|
||||||
in >> name;
|
while(*p++ != '\0')
|
||||||
if (name[0] == '#') {
|
if(*p == '#') {
|
||||||
in.ignore(65536, '\n');
|
*p = '\0'; // Cut off at the first #
|
||||||
in >> name;
|
break;
|
||||||
}
|
}
|
||||||
while (name == "\n" && in.good()) {
|
|
||||||
in >> name;
|
char name[75];
|
||||||
}
|
uint8_t r, g, b, a, t;
|
||||||
int r, g, b, a, t;
|
a = 255;
|
||||||
in >> r;
|
|
||||||
in >> g;
|
|
||||||
in >> b;
|
|
||||||
if(in.peek() != '\n') {
|
|
||||||
in >> a;
|
|
||||||
if(in.peek() != '\n')
|
|
||||||
in >> t;
|
|
||||||
else
|
|
||||||
t = 0;
|
t = 0;
|
||||||
} else
|
|
||||||
a = 0xFF;
|
sscanf(line, "%75s %hhu %hhu %hhu %hhu %hhu", name, &r, &g, &b, &a, &t);
|
||||||
if (in.good()) {
|
if(strlen(name) == 0)
|
||||||
color = ColorEntry(r,g,b,a,t);
|
break;
|
||||||
|
ColorEntry color = ColorEntry(r, g, b, a, t);
|
||||||
m_colors[name] = color;
|
m_colors[name] = color;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileGenerator::openDb(const std::string &input)
|
void TileGenerator::openDb(const std::string &input)
|
||||||
@ -663,4 +656,3 @@ inline int TileGenerator::getImageY(int val) const
|
|||||||
{
|
{
|
||||||
return val + m_border;
|
return val + m_border;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user