Skip to content

Commit cf25882

Browse files
committed
Merge branch 'hexplusone' into 'master'
Correctly format single digit hex values Closes #8541 See merge request OpenMW/openmw!4700
2 parents a74b669 + 9929c35 commit cf25882

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@
235235
Bug #8462: Crashes when resizing the window on macOS
236236
Bug #8465: Blue screen w/ antialiasing and post-processing on macOS
237237
Bug #8503: Camera does not handle NaN gracefully
238+
Bug #8541: Lua: util.color:asHex produces wrong output for some colors
238239
Feature #1415: Infinite fall failsafe
239240
Feature #2566: Handle NAM9 records for manual cell references
240241
Feature #3501: OpenMW-CS: Instance Editing - Shortcuts for axial locking

components/misc/color.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ namespace Misc
4747
for (size_t i = 0; i < rgb.size(); i++)
4848
{
4949
int b = static_cast<int>(rgb[i] * 255.0f);
50-
auto [_, ec] = std::to_chars(result.data() + i * 2, result.data() + (i + 1) * 2, b, 16);
50+
char* start = result.data() + i * 2;
51+
if (b < 16)
52+
start++;
53+
auto [_, ec] = std::to_chars(start, result.data() + (i + 1) * 2, b, 16);
5154
if (ec != std::errc())
5255
throw std::logic_error("Error when converting number to base 16");
5356
}

0 commit comments

Comments
 (0)