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

@ -36,7 +36,7 @@ namespace Server.Engines.BulkOrders
AddHtmlLocalized(40, 96, 120, 20, 1045136, 0x7FFF); // Item requested:
AddItem(385, 96, deed.Graphic);
AddHtmlLocalized(40, 120, 210, 20, deed.Number, 0xFFFFFF);
AddHtmlLocalized(40, 120, 210, 20, deed.Number, 0x7FFF);
if (deed.RequireExceptional || deed.Material != BulkMaterialType.None)
{

View file

@ -291,7 +291,7 @@ namespace Server.Engines.ConPVP
{
if (part.Players[0] is PlayerMobile pm && pm.DuelPlayer != null)
{
name = name.Color(pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666);
name = name.Color(pm.DuelPlayer.Eliminated ? 0x663333 : 0x336666);
}
}
@ -327,7 +327,7 @@ namespace Server.Engines.ConPVP
{
if (mob is PlayerMobile pm && pm.DuelPlayer != null)
{
name = name.Color(pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666);
name = name.Color(pm.DuelPlayer.Eliminated ? 0x663333 : 0x336666);
}
}

View file

@ -37,7 +37,7 @@ namespace Server.Engines.Help
AddImageTiled(9, 11, 21, 53, 0xBBC);
AddButton(10, 12, 0x7D2, 0x7D2, 0);
AddHtmlLocalized(34, 28, 65, 24, 3001002, 0xFFFFFF); // Message
AddHtmlLocalized(34, 28, 65, 24, 3001002, 0x7FFF); // Message
}
public override void OnResponse(NetState state, in RelayInfo info)

View file

@ -65,7 +65,7 @@ namespace Server.Engines.MLQuests.Gumps
AddImage(379, 60, 0x15A9);
AddImage(425, 0, 0x28C9);
AddImage(90, 33, 0x232D);
AddHtmlLocalized(130, 45, 270, 16, label, 0xFFFFFF);
AddHtmlLocalized(130, 45, 270, 16, label, 0x7FFF);
AddImageTiled(130, 65, 175, 1, 0x238D);
}
@ -149,7 +149,7 @@ namespace Server.Engines.MLQuests.Gumps
0x2710
);
quest.Description.AddHtmlText(this, 98, 156, 312, 240, false, true, 0x15F90, 0xBDE784);
quest.Description.AddHtmlText(this, 98, 156, 312, 240, false, true, 0x5F90, 0xBDE784);
}
public void AddObjectives(MLQuest quest)
@ -250,7 +250,7 @@ namespace Server.Engines.MLQuests.Gumps
public void AddConversation(TextDefinition text)
{
text.AddHtmlText(this, 98, 140, 312, 180, false, true, 0x15F90, 0xBDE784);
text.AddHtmlText(this, 98, 140, 312, 180, false, true, 0x5F90, 0xBDE784);
}
/* OSI gump IDs:

View file

@ -11,7 +11,7 @@ namespace Server.Engines.MLQuests.Gumps
BuildPage();
title.AddHtmlText(this, 160, 108, 250, 16, false, false, 0x2710, 0x4AC684);
message.AddHtmlText(this, 98, 156, 312, 180, false, true, 0x15F90, 0xBDE784);
message.AddHtmlText(this, 98, 156, 312, 180, false, true, 0x5F90, 0xBDE784);
}
}
}

View file

@ -57,21 +57,21 @@ namespace Server.Engines.MLQuests.Gumps
* <BR>
* Are you certain you wish to cancel at this time?
*/
AddHtmlLocalized(25, 55, 300, 120, 1060836, 0xFFFFFF);
AddHtmlLocalized(25, 55, 300, 120, 1060836, 0x7FFF);
var quest = instance.Quest;
if (quest.IsChainTriggered || quest.NextQuest != null)
{
AddRadio(25, 145, 0x25F8, 0x25FB, false, 2);
AddHtmlLocalized(60, 150, 280, 20, 1075023, 0xFFFFFF); // Yes, I want to quit this entire chain!
AddHtmlLocalized(60, 150, 280, 20, 1075023, 0x7FFF); // Yes, I want to quit this entire chain!
}
AddRadio(25, 180, 0x25F8, 0x25FB, true, 1);
AddHtmlLocalized(60, 185, 280, 20, 1049005, 0xFFFFFF); // Yes, I really want to quit this quest!
AddHtmlLocalized(60, 185, 280, 20, 1049005, 0x7FFF); // Yes, I really want to quit this quest!
AddRadio(25, 215, 0x25F8, 0x25FB, false, 0);
AddHtmlLocalized(60, 220, 280, 20, 1049006, 0xFFFFFF); // No, I don't want to quit.
AddHtmlLocalized(60, 220, 280, 20, 1049006, 0x7FFF); // No, I don't want to quit.
AddButton(265, 220, 0xF7, 0xF8, 7);
}

View file

@ -56,7 +56,7 @@ namespace Server.Engines.MLQuests.Objectives
public static void WriteTimeRemaining(Gump g, ref int y, TimeSpan timeRemaining)
{
g.AddHtmlLocalized(103, y, 120, 16, 1062379, 0x15F90); // Est. time remaining:
g.AddHtmlLocalized(103, y, 120, 16, 1062379, 0x5F90); // Est. time remaining:
g.AddLabel(223, y, 0x481, timeRemaining.TotalSeconds.ToString("F0"));
y += 16;
}

View file

@ -50,7 +50,7 @@ namespace Server.Engines.MLQuests.Objectives
{
var amount = DesiredAmount.ToString();
g.AddHtmlLocalized(98, y, 350, 16, 1072205, 0x15F90); // Obtain
g.AddHtmlLocalized(98, y, 350, 16, 1072205, 0x5F90); // Obtain
g.AddLabel(143, y, 0x481, amount);
if (Name.Number > 0)
@ -67,7 +67,7 @@ namespace Server.Engines.MLQuests.Objectives
{
if (Name.Number > 0)
{
g.AddHtmlLocalized(98, y, 312, 32, Name.Number, 0x15F90);
g.AddHtmlLocalized(98, y, 312, 32, Name.Number, 0x5F90);
}
else if (Name.String != null)
{
@ -207,11 +207,11 @@ namespace Server.Engines.MLQuests.Objectives
{
base.WriteToGump(g, ref y);
g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x15F90); // Total
g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x5F90); // Total
g.AddLabel(223, y, 0x481, GetCurrentTotal().ToString());
y += 16;
g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x15F90); // Return to
g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x5F90); // Return to
g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Instance.QuesterType));
y += 16;
}

View file

@ -74,7 +74,7 @@ namespace Server.Engines.MLQuests.Objectives
{
var amount = Amount.ToString();
g.AddHtmlLocalized(98, y, 312, 16, 1072207, 0x15F90); // Deliver
g.AddHtmlLocalized(98, y, 312, 16, 1072207, 0x5F90); // Deliver
g.AddLabel(143, y, 0x481, amount);
if (Name.Number > 0)
@ -89,7 +89,7 @@ namespace Server.Engines.MLQuests.Objectives
y += 32;
g.AddHtmlLocalized(103, y, 120, 16, 1072379, 0x15F90); // Deliver to
g.AddHtmlLocalized(103, y, 120, 16, 1072379, 0x5F90); // Deliver to
g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Destination));
y += 16;

View file

@ -65,11 +65,11 @@ namespace Server.Engines.MLQuests.Objectives
public override void WriteToGump(Gump g, ref int y)
{
g.AddHtmlLocalized(98, y, 312, 16, 1072206, 0x15F90); // Escort to
g.AddHtmlLocalized(98, y, 312, 16, 1072206, 0x5F90); // Escort to
if (Destination.Name.Number > 0)
{
g.AddHtmlLocalized(173, y, 312, 20, Destination.Name.Number, 0xFFFFFF);
g.AddHtmlLocalized(173, y, 312, 20, Destination.Name.Number, 0x7FFF);
}
else if (Destination.Name.String != null)
{

View file

@ -73,7 +73,7 @@ namespace Server.Engines.MLQuests.Objectives
var skillLabel = AosSkillBonuses.GetLabel(Skill);
var args = $"#{skillLabel}\t{ThresholdFixed / 10.0:0.#}";
g.AddHtmlLocalized(98, y, 312, 16, 1077485, args, 0x15F90); // Increase ~1_SKILL~ to ~2_VALUE~
g.AddHtmlLocalized(98, y, 312, 16, 1077485, args, 0x5F90); // Increase ~1_SKILL~ to ~2_VALUE~
y += 16;
}
@ -158,7 +158,7 @@ namespace Server.Engines.MLQuests.Objectives
if (IsCompleted())
{
g.AddHtmlLocalized(113, y, 312, 20, 1055121, 0xFFFFFF); // Complete
g.AddHtmlLocalized(113, y, 312, 20, 1055121, 0x7FFF); // Complete
y += 16;
}
}

View file

@ -27,7 +27,7 @@ namespace Server.Engines.MLQuests.Objectives
{
var amount = DesiredAmount.ToString();
g.AddHtmlLocalized(98, y, 312, 16, 1072204, 0x15F90); // Slay
g.AddHtmlLocalized(98, y, 312, 16, 1072204, 0x5F90); // Slay
g.AddLabel(133, y, 0x481, amount);
if (Name.Number > 0)
@ -43,11 +43,11 @@ namespace Server.Engines.MLQuests.Objectives
if (Area != null)
{
g.AddHtmlLocalized(103, y, 312, 20, 1018327, 0x15F90); // Location
g.AddHtmlLocalized(103, y, 312, 20, 1018327, 0x5F90); // Location
if (Area.Name.Number > 0)
{
g.AddHtmlLocalized(223, y, 312, 20, Area.Name.Number, 0xFFFFFF);
g.AddHtmlLocalized(223, y, 312, 20, Area.Name.Number, 0x7FFF);
}
else if (Area.Name.String != null)
{
@ -127,11 +127,11 @@ namespace Server.Engines.MLQuests.Objectives
base.WriteToGump(g, ref y);
g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x15F90); // Total
g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x5F90); // Total
g.AddLabel(223, y, 0x481, Slain.ToString());
y += 16;
g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x15F90); // Return to
g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x5F90); // Return to
g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Instance.QuesterType));
y += 16;
}

View file

@ -14,7 +14,7 @@ namespace Server.Engines.MLQuests.Rewards
public void WriteToGump(Gump g, int x, ref int y)
{
Name.AddHtmlText(g, x, y, 280, LabelHeight, false, false, 0x15F90, 0xBDE784);
Name.AddHtmlText(g, x, y, 280, LabelHeight, false, false, 0x5F90, 0xBDE784);
}
public abstract void AddRewardItems(PlayerMobile pm, List<Item> rewards);

View file

@ -155,7 +155,7 @@ namespace Server.Engines.Plants
AddItem(92, 167, 0x1B9D);
AddItem(161, 167, 0x1B9D);
AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00);
AddHtmlLocalized(136, 167, 42, 20, message, 0xFC00);
break;
}
@ -164,7 +164,7 @@ namespace Server.Engines.Plants
AddItem(91, 164, 0x18E6);
AddItem(161, 164, 0x18E6);
AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207);
AddHtmlLocalized(132, 167, 42, 20, message, 0xC207);
break;
}
@ -173,7 +173,7 @@ namespace Server.Engines.Plants
AddItem(96, 168, 0xC61);
AddItem(162, 168, 0xC61);
AddHtmlLocalized(129, 167, 42, 20, message, 0x008200);
AddHtmlLocalized(129, 167, 42, 20, message, 0x8200);
break;
}
@ -182,7 +182,7 @@ namespace Server.Engines.Plants
AddItem(93, 162, 0x1A99);
AddItem(162, 162, 0x1A99);
AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0);
AddHtmlLocalized(129, 167, 42, 20, message, 0x83E0);
break;
}

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);
}
}
}

View file

@ -12,7 +12,7 @@ namespace Server.Engines.Quests.Zento
if (!Completed)
{
// Deathwatch Beetle Hatchlings killed:
gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF);
gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0xC6BF);
gump.AddLabel(70, 280, 0x64, "0");
gump.AddLabel(100, 280, 0x64, "/");
@ -47,7 +47,7 @@ namespace Server.Engines.Quests.Zento
if (!Completed)
{
// Deathwatch Beetle Hatchlings killed:
gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF);
gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0xC6BF);
gump.AddLabel(70, 280, 0x64, "1");
gump.AddLabel(100, 280, 0x64, "/");
@ -95,7 +95,7 @@ namespace Server.Engines.Quests.Zento
if (!Completed)
{
// Deathwatch Beetle Hatchlings killed:
gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF);
gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0xC6BF);
gump.AddLabel(70, 280, 0x64, CurProgress.ToString());
gump.AddLabel(100, 280, 0x64, "/");