1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-08-28 16:32:18 +00:00

Merge pull request #408 from madewokherd/parsecolor

util: Parse token as color, not overall string.
This commit is contained in:
Zeno Rogue 2025-07-09 18:26:30 +02:00 committed by GitHub
commit c87e5b600d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -615,17 +615,17 @@ color_t exp_parser::parsecolor(int prio) {
string token = next_token();
if(params.count(token)) return (color_t) real(params[token]->get_cld());
auto p = find_color_by_name(s);
auto p = find_color_by_name(token);
if(p) return (p->second << 8) | 0xFF;
color_t res;
if(s.size() == 6) {
int qty = sscanf(s.c_str(), "%x", &res);
if(token.size() == 6) {
int qty = sscanf(token.c_str(), "%x", &res);
if(qty == 0) throw hr_parse_exception("color parse error");
return res * 256 + 0xFF;
}
else if(s.size() == 8) {
int qty = sscanf(s.c_str(), "%x", &res);
else if(token.size() == 8) {
int qty = sscanf(token.c_str(), "%x", &res);
if(qty == 0) throw hr_parse_exception("color parse error");
return res;
}