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

@ -287,7 +287,7 @@ namespace Server.Mobiles
{
Say(500381); // Thou canst not withdraw so much at one time!
}
else if (pack == null || pack.Deleted || !(pack.TotalWeight < pack.MaxWeight) ||
else if (pack?.Deleted != false || !(pack.TotalWeight < pack.MaxWeight) ||
!(pack.TotalItems < pack.MaxItems))
{
Say(1048147); // Your backpack can't hold anything else.
@ -426,4 +426,4 @@ namespace Server.Mobiles
int version = reader.ReadInt();
}
}
}
}

View file

@ -302,15 +302,13 @@ namespace Server.Mobiles
{
base.OnSpeech(e);
EDI dest = GetDestination();
if (GetDestination() == null || e.Handled || !e.Mobile.InRange(Location, 3))
return;
if (dest != null && !e.Handled && e.Mobile.InRange(Location, 3))
{
if (e.HasKeyword(0x1D)) // *destination*
e.Handled = SayDestinationTo(e.Mobile);
else if (e.HasKeyword(0x1E)) // *i will take thee*
e.Handled = AcceptEscorter(e.Mobile);
}
if (e.HasKeyword(0x1D)) // *destination*
e.Handled = SayDestinationTo(e.Mobile);
else if (e.HasKeyword(0x1E)) // *i will take thee*
e.Handled = AcceptEscorter(e.Mobile);
}
public override void OnAfterDelete()
@ -600,7 +598,7 @@ namespace Server.Mobiles
picked = possible[Utility.Random(possible.Length)];
EDI test = EDI.Find(picked);
if (test != null && test.Contains(Location))
if (test.Contains(Location))
picked = null;
}
@ -673,10 +671,7 @@ namespace Server.Mobiles
foreach (Region r in list)
{
if (r.Name == null)
continue;
if (r is DungeonRegion || r is TownRegion)
if (r.Name != null && (r is DungeonRegion || r is TownRegion))
m_Table[r.Name] = new EscortDestinationInfo(r.Name, r);
}
}

View file

@ -21,16 +21,7 @@ namespace Server.Mobiles
{
private static GlobalTownCrierEntryList m_Instance;
public static GlobalTownCrierEntryList Instance
{
get
{
if (m_Instance == null)
m_Instance = new GlobalTownCrierEntryList();
return m_Instance;
}
}
public static GlobalTownCrierEntryList Instance => m_Instance ?? (m_Instance = new GlobalTownCrierEntryList());
public bool IsEmpty => Entries == null || Entries.Count == 0;
@ -225,13 +216,12 @@ namespace Server.Mobiles
AddImageTiled(0, 0, 300, 38 + (count == 0 ? 20 : count * 85), 0xA40);
AddAlphaRegion(1, 1, 298, 36 + (count == 0 ? 20 : count * 85));
AddHtml(8, 8, 300 - 8 - 30, 20, "<basefont color=#FFFFFF><center>TOWN CRIER MESSAGES</center></basefont>", false,
false);
AddHtml(8, 8, 300 - 8 - 30, 20, "<basefont color=#FFFFFF><center>TOWN CRIER MESSAGES</center></basefont>");
AddButton(300 - 8 - 30, 8, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0);
AddButton(300 - 8 - 30, 8, 0xFAB, 0xFAD, 1);
if (count == 0)
AddHtml(8, 30, 284, 20, "<basefont color=#FFFFFF>The crier has no news.</basefont>", false, false);
AddHtml(8, 30, 284, 20, "<basefont color=#FFFFFF>The crier has no news.</basefont>");
else
for (int i = 0; i < entries.Count; ++i)
{
@ -272,7 +262,7 @@ namespace Server.Mobiles
AddHtml(8, 35 + i * 85, 254, 80, sb.ToString(), true, true);
AddButton(300 - 8 - 26, 35 + i * 85, 0x15E1, 0x15E5, 2 + i, GumpButtonType.Reply, 0);
AddButton(300 - 8 - 26, 35 + i * 85, 0x15E1, 0x15E5, 2 + i);
}
}
@ -544,4 +534,4 @@ namespace Server.Mobiles
NameHue = -1;
}
}
}
}