fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771)

### Summary
- Fixes an issue that causes CUO to crash due to bad string caching in static gumps
- Fixes wrong/bad 16bit html gump hues.
- Moves `C16232` (16-bit to 32-bit) and `C32216` (32-bit to 16-bit) to Utility class for broader use.

TODO:
- Some gumps have different 32bit (for string content) vs 16bit (for localized content) strings. Does this matter?
This commit is contained in:
Kamron Batman 2024-05-10 22:44:16 -07:00 • committed by GitHub
parent a001eb03da
commit 622250b8f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 129 additions and 155 deletions

View file

@ -682,39 +682,15 @@ namespace Server.Engines.Quests
{
}
public static int C16232(int c16)
{
c16 &= 0x7FFF;
var r = ((c16 >> 10) & 0x1F) << 3;
var g = ((c16 >> 05) & 0x1F) << 3;
var b = (c16 & 0x1F) << 3;
return (r << 16) | (g << 8) | b;
}
public static int C16216(int c16) => c16 & 0x7FFF;
public static int C32216(int c32)
{
c32 &= 0xFFFFFF;
var r = ((c32 >> 16) & 0xFF) >> 3;
var g = ((c32 >> 08) & 0xFF) >> 3;
var b = (c32 & 0xFF) >> 3;
return (r << 10) | (g << 5) | b;
}
public void AddHtmlObject(int x, int y, int width, int height, object message, int color, bool back, bool scroll)
{
if (message is int html)
{
AddHtmlLocalized(x, y, width, height, html, C16216(color), back, scroll);
AddHtmlLocalized(x, y, width, height, html, color.C16216(), back, scroll);
}
else
{
AddHtml(x, y, width, height, message.ToString().Color(C16232(color)), back, scroll);
AddHtml(x, y, width, height, message.ToString().Color(color.C16216()), back, scroll);
}
}
}