|
10 | 10 | #include <pl/patterns/pattern_bitfield.hpp> |
11 | 11 |
|
12 | 12 | #include <bit> |
| 13 | +#include <wolv/utils/charconv.hpp> |
13 | 14 |
|
14 | 15 | namespace pl::core::ast { |
15 | 16 |
|
@@ -348,7 +349,7 @@ namespace pl::core::ast { |
348 | 349 | if (!pattern->hasOverriddenColor()) { |
349 | 350 | if (const auto &arguments = attributable->getAttributeArguments("color"); arguments.size() == 1) { |
350 | 351 | auto colorString = getAttributeValueAsString(arguments.front(), evaluator); |
351 | | - u32 color = strtoul(colorString.c_str(), nullptr, 16); |
| 352 | + u32 color = wolv::util::from_chars<u32>(colorString, 16).value_or(0); |
352 | 353 | pattern->setColor(hlp::changeEndianess(color, std::endian::big) >> 8); |
353 | 354 | } else if (auto singleColor = attributable->hasAttribute("single_color", false); singleColor) { |
354 | 355 | pattern->setColor(pattern->getColor()); |
@@ -406,7 +407,7 @@ namespace pl::core::ast { |
406 | 407 |
|
407 | 408 | if (const auto &arguments = attributable->getAttributeArguments("color"); arguments.size() == 1) { |
408 | 409 | auto colorString = getAttributeValueAsString(arguments.front(), evaluator); |
409 | | - u32 color = strtoul(colorString.c_str(), nullptr, 16); |
| 410 | + u32 color = wolv::util::from_chars<u32>(colorString, 16).value_or(0); |
410 | 411 | pattern->setColor(hlp::changeEndianess(color, std::endian::big) >> 8); |
411 | 412 | } else if (auto singleColor = attributable->hasAttribute("single_color", false); singleColor) { |
412 | 413 | pattern->setColor(pattern->getColor()); |
|
0 commit comments