Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -62,8 +62,8 @@ namespace Server.Engines.Help
AddPage(0);
AddHtmlLocalized(150, 50, 360, 40, 1001002, false, false); // <CENTER><U>Ultima Online Help Menu</U></CENTER>
AddButton(425, 415, 2073, 2072, 0, GumpButtonType.Reply, 0); // Close
AddHtmlLocalized(150, 50, 360, 40, 1001002); // <CENTER><U>Ultima Online Help Menu</U></CENTER>
AddButton(425, 415, 2073, 2072, 0); // Close
AddPage(1);
@ -79,7 +79,7 @@ namespace Server.Engines.Help
@"<u>General question about Ultima Online.</u> Select this option if you have a general gameplay question, need help learning to use a skill, or if you would like to search the UO Knowledge Base.",
true, true);
AddButton(80, 205, 5540, 5541, 2, GumpButtonType.Reply, 0);
AddButton(80, 205, 5540, 5541, 2);
AddHtml(110, 205, 450, 58,
@"<u>My character is physically stuck in the game.</u> This choice only covers cases where your character is physically stuck in a location they cannot move out of. This option will only work two times in 24 hours.",
true, true);
@ -101,7 +101,7 @@ namespace Server.Engines.Help
@"<u>General question about Ultima Online.</u> Select this option if you have a general gameplay question, need help learning to use a skill, or if you would like to search the UO Knowledge Base.",
true, true);
AddButton(80, 170, 5540, 5541, 2, GumpButtonType.Reply, 0);
AddButton(80, 170, 5540, 5541, 2);
AddHtml(110, 170, 450, 74,
@"<u>My character is physically stuck in the game.</u> This choice only covers cases where your character is physically stuck in a location they cannot move out of. This option will only work two times in 24 hours.",
true, true);
@ -119,29 +119,29 @@ namespace Server.Engines.Help
AddPage(2);
AddButton(80, 90, 5540, 5541, 3, GumpButtonType.Reply, 0);
AddButton(80, 90, 5540, 5541, 3);
AddHtml(110, 90, 450, 74,
@"<u>Report a bug or contact Origin.</u> Use this option to launch your web browser and mail in a bug report. Your report will be read by our Quality Assurance Staff. We apologize for not being able to reply to individual reports. ",
true, true);
AddButton(80, 170, 5540, 5541, 4, GumpButtonType.Reply, 0);
AddButton(80, 170, 5540, 5541, 4);
AddHtml(110, 170, 450, 74,
@"<u>Suggestion for the Game.</u> If you'd like to make a suggestion for the game, it should be directed to the Development Team Members who participate in the discussion forums on the UO.Com web site. Choosing this option will take you to the Discussion Forums. ",
true, true);
AddButton(80, 250, 5540, 5541, 5, GumpButtonType.Reply, 0);
AddButton(80, 250, 5540, 5541, 5);
AddHtml(110, 250, 450, 74,
@"<u>Account Management</u> For questions regarding your account such as forgotten passwords, payment options, account activation, and account transfer, please choose this option.",
true, true);
AddButton(80, 330, 5540, 5541, 6, GumpButtonType.Reply, 0);
AddButton(80, 330, 5540, 5541, 6);
AddHtml(110, 330, 450, 74,
@"<u>Other.</u> If you are experiencing a problem in the game that does not fall into one of the other categories or is not addressed on the Support web page (located at http://support.uo.com), and requires in-game assistance, use this option. ",
true, true);
AddPage(3);
AddButton(80, 90, 5540, 5541, 7, GumpButtonType.Reply, 0);
AddButton(80, 90, 5540, 5541, 7);
AddHtmlLocalized(110, 90, 450, 145, 1062572, true,
true); /* <U><CENTER>Another player is harassing me (or Exploiting).</CENTER></U><BR>
* VERBAL HARASSMENT<BR>
@ -165,7 +165,7 @@ namespace Server.Engines.Help
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=41"><EFBFBD> What constitutes an exploit?</a>
*/
AddButton(80, 240, 5540, 5541, 8, GumpButtonType.Reply, 0);
AddButton(80, 240, 5540, 5541, 8);
AddHtmlLocalized(110, 240, 450, 145, 1062573, true,
true); /* <U><CENTER>Another player is harassing me using game mechanics.</CENTER></U><BR>
* <BR>
@ -188,7 +188,7 @@ namespace Server.Engines.Help
*/
AddButton(150, 390, 5540, 5541, 0, GumpButtonType.Page, 1);
AddHtmlLocalized(180, 390, 335, 40, 1001015, false, false); // NO - I meant to ask for help with another matter.
AddHtmlLocalized(180, 390, 335, 40, 1001015); // NO - I meant to ask for help with another matter.
}
public static void Initialize()
@ -252,7 +252,7 @@ namespace Server.Engines.Help
{
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house != null && house.IsAosRules && !from.Region.IsPartOf<SafeZone>()) // Dueling
if (house?.IsAosRules == true && !from.Region.IsPartOf<SafeZone>()) // Dueling
{
from.Location = house.BanLocation;
}
@ -331,4 +331,4 @@ namespace Server.Engines.Help
from.SendGump(new PagePromptGump(from, type));
}
}
}
}

View file

@ -19,15 +19,14 @@ namespace Server.Engines.Help
AddPage(0);
AddHtmlLocalized(264, 80, 200, 24, 1062524, false, false); // Enter Description
AddHtmlLocalized(120, 108, 420, 48, 1062638, false,
false); // Please enter a brief description (up to 200 characters) of your problem:
AddHtmlLocalized(264, 80, 200, 24, 1062524); // Enter Description
AddHtmlLocalized(120, 108, 420, 48, 1062638); // Please enter a brief description (up to 200 characters) of your problem:
AddBackground(100, 148, 440, 200, 3500);
AddTextEntry(120, 168, 400, 200, 1153, 0, "");
AddButton(175, 355, 2074, 2075, 1, GumpButtonType.Reply, 0); // Okay
AddButton(405, 355, 2073, 2072, 0, GumpButtonType.Reply, 0); // Cancel
AddButton(175, 355, 2074, 2075, 1); // Okay
AddButton(405, 355, 2073, 2072, 0); // Cancel
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -58,4 +57,4 @@ namespace Server.Engines.Help
}
}
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net.Mail;
@ -258,10 +257,10 @@ namespace Server.Engines.Help
{
Mobile m = ns.Mobile;
if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && !IsHandling(m))
if (m?.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && !IsHandling(m))
m.SendMessage("A new page has been placed in the queue.");
if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify &&
if (m?.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify &&
Core.TickCount - m.LastMoveTime < 600000)
isStaffOnline = true;
}

View file

@ -28,8 +28,8 @@ namespace Server.Engines.Help
AddImageTiled(9, 11, 21, 53, 0xBBC);
AddButton(10, 12, 0x7D2, 0x7D2, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(34, 28, 65, 24, 3001002, 0xFFFFFF, false, false); // Message
AddButton(10, 12, 0x7D2, 0x7D2, 0);
AddHtmlLocalized(34, 28, 65, 24, 3001002, 0xFFFFFF); // Message
}
public override void OnResponse(NetState state, RelayInfo info)
@ -55,7 +55,7 @@ namespace Server.Engines.Help
Add(new GumpLabel(180, 12, 2100, "Page Queue"));
List<PageEntry> list = PageQueue.List;
for (int i = 0;i < list.Count;)
{
PageEntry e = list[i];
@ -98,7 +98,7 @@ namespace Server.Engines.Help
$"[{typeString}] {e.Message} <basefont color=#{(e.Handler == null ? 0xFF0000 : 0xFF):X6}>[<u>{(e.Handler == null ? "Unhandled" : "Handling")}</u>]</basefont>";
Add(new GumpHtml(12, 44 + i % 5 * 80, 350, 70, html, true, true));
Add(new GumpButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0));
Add(new GumpButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, i + 1));
}
}
@ -176,9 +176,9 @@ namespace Server.Engines.Help
if (!File.Exists(path))
return new List<PredefinedResponse>();
List<PredefinedResponse> list = new List<PredefinedResponse>();
try
{
using (StreamReader ip = new StreamReader(path))
@ -229,7 +229,7 @@ namespace Server.Engines.Help
AddImageTiled(0, 0, 410, 448, 0xA40);
AddAlphaRegion(1, 1, 408, 446);
AddHtml(10, 10, 390, 20, Color(Center("Predefined Responses"), LabelColor32), false, false);
AddHtml(10, 10, 390, 20, Color(Center("Predefined Responses"), LabelColor32));
List<PredefinedResponse> list = PredefinedResponse.List;
@ -256,16 +256,15 @@ namespace Server.Engines.Help
if (canEdit)
{
AddButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, 2 + i * 3, GumpButtonType.Reply, 0);
AddButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, 2 + i * 3);
if (i > 0)
AddButton(377, 44 + i % 5 * 80 + 2, 0x15E0, 0x15E4, 3 + i * 3, GumpButtonType.Reply, 0);
AddButton(377, 44 + i % 5 * 80 + 2, 0x15E0, 0x15E4, 3 + i * 3);
else
AddImage(377, 44 + i % 5 * 80 + 2, 0x25E4);
if (i < list.Count - 1)
AddButton(377, 44 + i % 5 * 80 + 70 - 2 - 16, 0x15E2, 0x15E6, 4 + i * 3, GumpButtonType.Reply,
0);
AddButton(377, 44 + i % 5 * 80 + 70 - 2 - 16, 0x15E2, 0x15E6, 4 + i * 3);
else
AddImage(377, 44 + i % 5 * 80 + 70 - 2 - 16, 0x25E8);
}
@ -282,8 +281,8 @@ namespace Server.Engines.Help
AddLabel(48, 10, 2100, "Previous Page");
}
AddButton(12, 44 + i % 5 * 80, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0);
AddHtml(45, 44 + i % 5 * 80, 200, 20, Color("New Response", LabelColor32), false, false);
AddButton(12, 44 + i % 5 * 80, 0xFAB, 0xFAD, 1);
AddHtml(45, 44 + i % 5 * 80, 200, 20, Color("New Response", LabelColor32));
}
}
else if (canEdit)
@ -291,17 +290,17 @@ namespace Server.Engines.Help
AddImageTiled(0, 0, 410, 250, 0xA40);
AddAlphaRegion(1, 1, 408, 248);
AddHtml(10, 10, 390, 20, Color(Center("Predefined Response Editor"), LabelColor32), false, false);
AddHtml(10, 10, 390, 20, Color(Center("Predefined Response Editor"), LabelColor32));
AddButton(10, 40, 0xFB1, 0xFB3, 1, GumpButtonType.Reply, 0);
AddHtml(45, 40, 200, 20, Color("Remove", LabelColor32), false, false);
AddButton(10, 40, 0xFB1, 0xFB3, 1);
AddHtml(45, 40, 200, 20, Color("Remove", LabelColor32));
AddButton(10, 70, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
AddHtml(45, 70, 200, 20, Color("Title:", LabelColor32), false, false);
AddButton(10, 70, 0xFA5, 0xFA7, 2);
AddHtml(45, 70, 200, 20, Color("Title:", LabelColor32));
AddTextInput(10, 90, 300, 20, 0, response.Title);
AddButton(10, 120, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0);
AddHtml(45, 120, 200, 20, Color("Message:", LabelColor32), false, false);
AddButton(10, 120, 0xFA5, 0xFA7, 3);
AddHtml(45, 120, 200, 20, Color("Message:", LabelColor32));
AddTextInput(10, 140, 390, 100, 1, response.Message);
}
}
@ -473,7 +472,7 @@ namespace Server.Engines.Help
AddLabelCropped(128, 38, 264, 20, 2100,
$"{entry.Sender.RawName} {entry.Sender.Location} [{entry.Sender.Map}]");
AddButton(18, bottom - buttons * 22, 0xFAB, 0xFAD, 8, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFAB, 0xFAD, 8);
AddImageTiled(52, bottom - buttons * 22 + 1, 340, 80, 0xA40 /*0xBBC*/ /*0x2458*/);
AddImageTiled(53, bottom - buttons * 22 + 2, 338, 78, 0xBBC /*0x2426*/);
AddTextEntry(55, bottom - buttons++ * 22 + 2, 336, 78, 0x480, 0, "");
@ -483,7 +482,7 @@ namespace Server.Engines.Help
if (entry.Sender != m)
{
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 1);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Sender");
}
@ -493,10 +492,10 @@ namespace Server.Engines.Help
{
AddLabelCropped(128, 58, 264, 20, 2100, "Unhandled");
AddButton(18, bottom - buttons * 22, 0xFB1, 0xFB3, 5, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFB1, 0xFB3, 5);
AddLabel(52, bottom - buttons++ * 22, 2100, "Delete Page");
AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 4, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 4);
AddLabel(52, bottom - buttons++ * 22, 2100, "Handle Page");
}
else
@ -505,15 +504,15 @@ namespace Server.Engines.Help
if (entry.Handler != m)
{
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 2);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Handler");
}
else
{
AddButton(18, bottom - buttons * 22, 0xFA2, 0xFA4, 6, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFA2, 0xFA4, 6);
AddLabel(52, bottom - buttons++ * 22, 2100, "Abandon Page");
AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 7, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 7);
AddLabel(52, bottom - buttons++ * 22, 2100, "Page Handled");
}
}
@ -521,12 +520,12 @@ namespace Server.Engines.Help
AddLabel(18, 78, 2100, "Page Location:");
AddLabelCropped(128, 78, 264, 20, 2100, $"{entry.PageLocation} [{entry.PageMap}]");
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 3);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Page Location");
if (entry.SpeechLog != null)
{
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0);
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 10);
AddLabel(52, bottom - buttons * 22, 2100, "View Speech Log");
}
@ -541,7 +540,7 @@ namespace Server.Engines.Help
List<PredefinedResponse> preresp = PredefinedResponse.List;
AddButton(18, 18, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
AddButton(410 - 18 - 32, 18, 0xFAB, 0xFAC, 9, GumpButtonType.Reply, 0);
AddButton(410 - 18 - 32, 18, 0xFAB, 0xFAC, 9);
if (preresp.Count == 0)
{
@ -553,7 +552,7 @@ namespace Server.Engines.Help
for (int i = 0; i < preresp.Count; ++i)
{
AddButton(18, 40 + i * 22, 0xFA5, 0xFA7, 100 + i, GumpButtonType.Reply, 0);
AddButton(18, 40 + i * 22, 0xFA5, 0xFA7, 100 + i);
AddLabel(52, 40 + i * 22, 2100, preresp[i].Title);
}
}
@ -799,4 +798,4 @@ namespace Server.Engines.Help
}
}
}
}
}

View file

@ -18,15 +18,14 @@ namespace Server.Engines.Help
AddPage(0);
AddHtmlLocalized(150, 40, 360, 40, 1062610, false, false); // <CENTER><U>Ultima Online Help Response</U></CENTER>
AddHtmlLocalized(150, 40, 360, 40, 1062610); // <CENTER><U>Ultima Online Help Response</U></CENTER>
AddHtml(80, 90, 480, 290, $"{name} tells {from.Name}: {text}", true, true);
AddHtmlLocalized(80, 390, 480, 40, 1062611, false,
false); // Clicking the OKAY button will remove the reponse you have received.
AddButton(400, 417, 2074, 2075, 1, GumpButtonType.Reply, 0); // OKAY
AddHtmlLocalized(80, 390, 480, 40, 1062611); // Clicking the OKAY button will remove the reponse you have received.
AddButton(400, 417, 2074, 2075, 1); // OKAY
AddButton(475, 417, 2073, 2072, 0, GumpButtonType.Reply, 0); // CANCEL
AddButton(475, 417, 2073, 2072, 0); // CANCEL
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -35,4 +34,4 @@ namespace Server.Engines.Help
m_From.SendGump(new MessageSentGump(m_From, m_Name, m_Text));
}
}
}
}

View file

@ -39,8 +39,7 @@ namespace Server.Engines.Help
string playerAccount = player.Account is Account ? player.Account.Username : "???";
AddHtml(10, 10, 280, 20,
$"<basefont color=#A0A0FF><center>SPEECH LOG - {playerName} (<i>{Utility.FixHtml(playerAccount)}</i>)</center></basefont>",
false, false);
$"<basefont color=#A0A0FF><center>SPEECH LOG - {playerName} (<i>{Utility.FixHtml(playerAccount)}</i>)</center></basefont>");
int lastPage = (log.Count - 1) / MaxEntriesPerPage;
@ -80,12 +79,12 @@ namespace Server.Engines.Help
AddHtml(10, 40, 280, 350, sLog, false, true);
if (page > 0)
AddButton(10, 395, 0xFAE, 0xFB0, 1, GumpButtonType.Reply, 0); // Previous page
AddButton(10, 395, 0xFAE, 0xFB0, 1); // Previous page
AddLabel(45, 395, 0x481, $"Current page: {page + 1}/{lastPage + 1}");
if (page < lastPage)
AddButton(261, 395, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0); // Next page
AddButton(261, 395, 0xFA5, 0xFA7, 2); // Next page
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -111,4 +110,4 @@ namespace Server.Engines.Help
}
}
}
}
}

View file

@ -125,7 +125,7 @@ namespace Server.Menus.Questions
AddBackground(0, 0, 270, 320, 2600);
AddHtmlLocalized(50, 20, 250, 35, 1011027, false, false); // Chose a town:
AddHtmlLocalized(50, 20, 250, 35, 1011027); // Chose a town:
StuckMenuEntry[] entries = IsInSecondAgeArea(beheld) ? m_T2AEntries : m_Entries;
@ -133,26 +133,18 @@ namespace Server.Menus.Questions
{
StuckMenuEntry entry = entries[i];
AddButton(50, 55 + 35 * i, 208, 209, i + 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(75, 55 + 35 * i, 335, 40, entry.Name, false, false);
AddButton(50, 55 + 35 * i, 208, 209, i + 1);
AddHtmlLocalized(75, 55 + 35 * i, 335, 40, entry.Name);
}
AddButton(55, 263, 4005, 4007, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(90, 265, 200, 35, 1011012, false, false); // CANCEL
AddButton(55, 263, 4005, 4007, 0);
AddHtmlLocalized(90, 265, 200, 35, 1011012); // CANCEL
}
private static bool IsInSecondAgeArea(Mobile m)
{
if (m.Map != Map.Trammel && m.Map != Map.Felucca)
return false;
if (m.X >= 5120 && m.Y >= 2304)
return true;
if (m.Region.IsPartOf("Terathan Keep"))
return true;
return false;
return (m.Map == Map.Trammel || m.Map == Map.Felucca) &&
(m.X >= 5120 && m.Y >= 2304 || m.Region.IsPartOf("Terathan Keep"));
}
public void BeginClose()
@ -289,4 +281,4 @@ namespace Server.Menus.Questions
}
}
}
}
}