1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-28 12:11:33 +00:00

Correctly format single digit hex values

This commit is contained in:
Evil Eye 2025-05-31 15:43:50 +02:00
parent 0c6c71f6cb
commit 9929c35021
2 changed files with 5 additions and 1 deletions

View file

@ -235,6 +235,7 @@
Bug #8462: Crashes when resizing the window on macOS
Bug #8465: Blue screen w/ antialiasing and post-processing on macOS
Bug #8503: Camera does not handle NaN gracefully
Bug #8541: Lua: util.color:asHex produces wrong output for some colors
Feature #1415: Infinite fall failsafe
Feature #2566: Handle NAM9 records for manual cell references
Feature #3501: OpenMW-CS: Instance Editing - Shortcuts for axial locking

View file

@ -47,7 +47,10 @@ namespace Misc
for (size_t i = 0; i < rgb.size(); i++)
{
int b = static_cast<int>(rgb[i] * 255.0f);
auto [_, ec] = std::to_chars(result.data() + i * 2, result.data() + (i + 1) * 2, b, 16);
char* start = result.data() + i * 2;
if (b < 16)
start++;
auto [_, ec] = std::to_chars(start, result.data() + (i + 1) * 2, b, 16);
if (ec != std::errc())
throw std::logic_error("Error when converting number to base 16");
}