Skip to content

Commit 32e02b4

Browse files
authored
Fix tint color RGB mode conversion (#2200)
The game's code looks weird because the switch case forgot to add break. Has very little impact on the vanilla game: | TintColor | RGB565 Before | RGB565 After | RGB24 Before | RGB24 After | | - | - | - | - | - | | IronCurtain | 0x0000 | 0x0000 | `#000000` | `#000000` | | ForceShield | 0x0018 | 0x0018 | `#0000C6` | `#0000C6` | | Berserk | 0xE000 | 0xC000 | `#E70000` | `#C60000` | Vanilla Berserk tint in game: Before | After ---|--- <img width="320" alt="before" src="https://github.com/user-attachments/assets/05755945-2018-4fdc-8c92-ea70101189ca" /> | <img width="320" alt="after" src="https://github.com/user-attachments/assets/f70d114b-f544-4f9c-b1c6-004b07faf63b" /> --- Update: Custom tint color for better comparison, R=21, G=21, B=0 | RGB565 Before | RGB565 After | RGB24 Before | RGB24 After | | - | - | - | - | | 0xFFE0 | 0xAAA0 | `#FFFF00` | `#AD5500` | Custom tint in game: Before | After ---|--- <img width="320" alt="before" src="https://github.com/user-attachments/assets/08349c6e-83b7-4d82-81ed-e265c943512b" /> | <img width="320" alt="after" src="https://github.com/user-attachments/assets/06fcc4f5-777c-4367-9a94-a2a2d11ea392" />
1 parent c937f30 commit 32e02b4

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ Vanilla fixes:
656656
- Fixed the issue that the time for units in the area guard mission to reacquire targets after eliminating the target is significantly longer than that in other missions (by TaranDahl)
657657
- Purely visual animations and particles excluded from sync checks (by Starkku)
658658
- Fixed AI team recruitment inconsistency causing underfilled teams (by handama)
659+
- Fixed the issue where tint color RGB mode conversion was incorrect (by Shatyuka)
659660
660661
Phobos fixes:
661662
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)

src/Utilities/GeneralUtils.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,18 @@ int GeneralUtils::GetColorFromColorAdd(int colorIndex)
282282
const int green = color.G;
283283
const int blue = color.B;
284284

285-
if (Drawing::ColorMode == RGBMode::RGB565)
286-
colorValue |= blue | (32 * (green | (red << 6)));
287-
288-
if (Drawing::ColorMode != RGBMode::RGB655)
289-
colorValue |= blue | (((32 * red) | (green >> 1)) << 6);
290-
291-
colorValue |= blue | (32 * ((32 * red) | (green >> 1)));
285+
switch (Drawing::ColorMode)
286+
{
287+
case RGBMode::RGB565:
288+
colorValue |= (red << 6 | green) << 5 | blue;
289+
break;
290+
case RGBMode::RGB556:
291+
colorValue |= (red << 5 | green >> 1) << 6 | blue;
292+
break;
293+
default:
294+
colorValue |= (red << 5 | green >> 1) << 5 | blue;
295+
break;
296+
}
292297

293298
return colorValue;
294299
}

0 commit comments

Comments
 (0)