1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-12 18:13:07 +00:00

Merge branch 'hexplusone' into 'master'

Correctly format single digit hex values

Closes #8541

See merge request OpenMW/openmw!4700
This commit is contained in:
psi29a 2025-06-03 06:41:04 +00:00
commit cf258821b4
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");
}