fix: Adds more null checks for text definition to prevent NPEs (#936)

This commit is contained in:
Kamron Batman 2022-02-18 11:13:38 -08:00 • committed by GitHub
parent 04909828c8
commit 2009ac6892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 82 additions and 61 deletions

View file

@ -28,21 +28,24 @@ namespace Server.Gumps
AddImageTiled(10, 40, width - 20, height - 80, 2624);
AddAlphaRegion(10, 40, width - 20, height - 80);
if (content.Number > 0)
if (content != null)
{
AddHtmlLocalized(10, 40, width - 20, height - 80, content.Number, contentColor, false, true);
}
else
{
AddHtml(
10,
40,
width - 20,
height - 80,
$"<BASEFONT COLOR=#{contentColor:X6}>{content.String}</BASEFONT>",
false,
true
);
if (content.Number > 0)
{
AddHtmlLocalized(10, 40, width - 20, height - 80, content.Number, contentColor, false, true);
}
else
{
AddHtml(
10,
40,
width - 20,
height - 80,
$"<BASEFONT COLOR=#{contentColor:X6}>{content.String}</BASEFONT>",
false,
true
);
}
}
AddImageTiled(10, height - 30, width - 20, 20, 2624);

View file

@ -28,21 +28,24 @@ namespace Server.Gumps
AddImageTiled(10, 40, width - 20, height - 80, 2624);
AddAlphaRegion(10, 40, width - 20, height - 80);
if (content.Number > 0)
if (content != null)
{
AddHtmlLocalized(10, 40, width - 20, height - 80, content.Number, contentColor, false, true);
}
else
{
AddHtml(
10,
40,
width - 20,
height - 80,
$"<BASEFONT COLOR=#{contentColor:X6}>{content.String}</BASEFONT>",
false,
true
);
if (content.Number > 0)
{
AddHtmlLocalized(10, 40, width - 20, height - 80, content.Number, contentColor, false, true);
}
else
{
AddHtml(
10,
40,
width - 20,
height - 80,
$"<BASEFONT COLOR=#{contentColor:X6}>{content.String}</BASEFONT>",
false,
true
);
}
}
AddImageTiled(10, height - 30, width - 20, 20, 2624);