Cleanup & Fixes for .NET 5 (#309)
- [X] Fixes several bugs - [X] Updates more ordinal issues - [X] Cleans up the code a bit - [X] Turns classes static that should have been - [X] Changes TcpServer.Instances to a HashSet Bumps release version
This commit is contained in:
parent
4ad8811df2
commit
525cda5413
266 changed files with 1348 additions and 1800 deletions
|
|
@ -102,8 +102,7 @@ namespace Server.Gumps
|
|||
CommandSystem.Register("AddDoor", AccessLevel.GameMaster, AddDoor_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("AddDoor")]
|
||||
[Description("Displays a menu from which you can interactively add doors.")]
|
||||
[Usage("AddDoor"), Description("Displays a menu from which you can interactively add doors.")]
|
||||
public static void AddDoor_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
e.Mobile.SendGump(new AddDoorGump());
|
||||
|
|
|
|||
|
|
@ -196,8 +196,8 @@ namespace Server.Gumps
|
|||
AddLabel(20, 350, LabelHue, "Operating System: ");
|
||||
var os = Environment.OSVersion.ToString();
|
||||
|
||||
os = os.Replace("Microsoft", "MSFT");
|
||||
os = os.Replace("Service Pack", "SP");
|
||||
os = os.Replace("Microsoft", "MSFT", StringComparison.Ordinal);
|
||||
os = os.Replace("Service Pack", "SP", StringComparison.Ordinal);
|
||||
|
||||
AddLabel(150, 350, LabelHue, os);
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ namespace Server.Gumps
|
|||
sb.Append(curIOCP);
|
||||
sb.Append("<br>Usage: ");
|
||||
sb.Append((maxIOCP - curIOCP) * 100 / maxIOCP);
|
||||
sb.Append("%");
|
||||
sb.Append('%');
|
||||
|
||||
AddLabel(20, 200, LabelHue, "Pooling:");
|
||||
AddHtml(20, 220, 380, 150, sb.ToString(), true, true);
|
||||
|
|
@ -446,7 +446,7 @@ namespace Server.Gumps
|
|||
{
|
||||
if (m_List == null)
|
||||
{
|
||||
var states = TcpServer.Instances;
|
||||
var states = TcpServer.Instances.ToList();
|
||||
states.Sort(NetStateComparer.Instance);
|
||||
|
||||
m_List = states.ToList<object>();
|
||||
|
|
@ -612,14 +612,11 @@ namespace Server.Gumps
|
|||
if (m_List == null)
|
||||
{
|
||||
sharedAccounts = GetAllSharedAccounts();
|
||||
m_List = Utility.CastListContravariant<KeyValuePair<IPAddress, List<Account>>, object>(
|
||||
sharedAccounts
|
||||
);
|
||||
m_List = sharedAccounts.CastListContravariant<KeyValuePair<IPAddress, List<Account>>, object>();
|
||||
}
|
||||
else
|
||||
{
|
||||
sharedAccounts =
|
||||
Utility.CastListCovariant<object, KeyValuePair<IPAddress, List<Account>>>(m_List);
|
||||
sharedAccounts = m_List.CastListCovariant<object, KeyValuePair<IPAddress, List<Account>>>();
|
||||
}
|
||||
|
||||
AddLabelCropped(12, 120, 60, 20, LabelHue, "Count");
|
||||
|
|
@ -1007,11 +1004,11 @@ namespace Server.Gumps
|
|||
if (m_List == null)
|
||||
{
|
||||
ipAddresses = a.LoginIPs.ToList();
|
||||
m_List = Utility.CastListContravariant<IPAddress, object>(ipAddresses);
|
||||
m_List = ipAddresses.CastListContravariant<IPAddress, object>();
|
||||
}
|
||||
else
|
||||
{
|
||||
ipAddresses = Utility.CastListCovariant<object, IPAddress>(m_List);
|
||||
ipAddresses = m_List.CastListCovariant<object, IPAddress>();
|
||||
}
|
||||
|
||||
AddHtml(10, 195, 400, 20, Color(Center("Client Addresses"), LabelColor32));
|
||||
|
|
@ -1079,11 +1076,11 @@ namespace Server.Gumps
|
|||
if (m_List == null)
|
||||
{
|
||||
ipRestrictions = a.IPRestrictions.ToList();
|
||||
m_List = Utility.CastListContravariant<string, object>(ipRestrictions);
|
||||
m_List = ipRestrictions.CastListContravariant<string, object>();
|
||||
}
|
||||
else
|
||||
{
|
||||
ipRestrictions = Utility.CastListCovariant<object, string>(m_List);
|
||||
ipRestrictions = m_List.CastListCovariant<object, string>();
|
||||
}
|
||||
|
||||
AddHtml(10, 195, 400, 20, Color(Center("Address Restrictions"), LabelColor32));
|
||||
|
|
@ -1268,11 +1265,11 @@ namespace Server.Gumps
|
|||
if (m_List == null)
|
||||
{
|
||||
firewallEntries = Firewall.List;
|
||||
m_List = Utility.CastListContravariant<Firewall.IFirewallEntry, object>(firewallEntries);
|
||||
m_List = firewallEntries.CastListContravariant<Firewall.IFirewallEntry, object>();
|
||||
}
|
||||
else
|
||||
{
|
||||
firewallEntries = Utility.CastListCovariant<object, Firewall.IFirewallEntry>(m_List);
|
||||
firewallEntries = m_List.CastListCovariant<object, Firewall.IFirewallEntry>();
|
||||
}
|
||||
|
||||
AddLabelCropped(12, 120, 358, 20, LabelHue, "IP Address");
|
||||
|
|
@ -1354,11 +1351,11 @@ namespace Server.Gumps
|
|||
}
|
||||
|
||||
blockedAccts.Sort(AccountComparer.Instance);
|
||||
m_List = Utility.CastListContravariant<Account, object>(blockedAccts);
|
||||
m_List = blockedAccts.CastListContravariant<Account, object>();
|
||||
}
|
||||
else
|
||||
{
|
||||
blockedAccts = Utility.CastListCovariant<object, Account>(m_List);
|
||||
blockedAccts = m_List.CastListCovariant<object, Account>();
|
||||
}
|
||||
|
||||
if (listPage > 0)
|
||||
|
|
@ -1485,10 +1482,9 @@ namespace Server.Gumps
|
|||
CommandSystem.Register("Admin", AccessLevel.Administrator, Admin_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("Admin")]
|
||||
[Description(
|
||||
"Opens an interface providing server information and administration features including client, account, and firewall management."
|
||||
)]
|
||||
[Usage("Admin"), Description(
|
||||
"Opens an interface providing server information and administration features including client, account, and firewall management."
|
||||
)]
|
||||
public static void Admin_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
e.Mobile.SendGump(new AdminGump(e.Mobile, AdminGumpPage.Clients));
|
||||
|
|
@ -1972,7 +1968,7 @@ namespace Server.Gumps
|
|||
|
||||
if (m_PageType == AdminGumpPage.Accounts)
|
||||
{
|
||||
var list = Utility.CastListCovariant<object, Account>(m_List);
|
||||
var list = m_List.CastListCovariant<object, Account>();
|
||||
|
||||
if (list != null && m_State is List<Account> rads)
|
||||
{
|
||||
|
|
@ -2350,12 +2346,10 @@ namespace Server.Gumps
|
|||
|
||||
if (level > AccessLevel.Player)
|
||||
{
|
||||
var clients = TcpServer.Instances;
|
||||
var count = 0;
|
||||
|
||||
for (var i = 0; i < clients.Count; ++i)
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
var ns = clients[i];
|
||||
var a = ns.Account;
|
||||
|
||||
if (a == null)
|
||||
|
|
@ -2450,12 +2444,8 @@ namespace Server.Gumps
|
|||
}
|
||||
else
|
||||
{
|
||||
var instances = TcpServer.Instances;
|
||||
|
||||
for (var i = 0; i < instances.Count; ++i)
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
var ns = instances[i];
|
||||
|
||||
bool isMatch;
|
||||
|
||||
if (forName)
|
||||
|
|
@ -2463,12 +2453,12 @@ namespace Server.Gumps
|
|||
var m = ns.Mobile;
|
||||
var a = ns.Account;
|
||||
|
||||
isMatch = m?.Name.ToLower().IndexOf(match, StringComparison.Ordinal) >= 0
|
||||
|| a?.Username.ToLower().IndexOf(match, StringComparison.Ordinal) >= 0;
|
||||
isMatch = m?.Name.ToLower().Contains(match, StringComparison.Ordinal) == true
|
||||
|| a?.Username.ToLower().Contains(match, StringComparison.Ordinal) == true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isMatch = ns.ToString().IndexOf(match, StringComparison.Ordinal) >= 0;
|
||||
isMatch = ns.ToString().Contains(match, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
if (isMatch)
|
||||
|
|
@ -2518,7 +2508,7 @@ namespace Server.Gumps
|
|||
from,
|
||||
AdminGumpPage.Clients,
|
||||
0,
|
||||
Utility.CastListContravariant<NetState, object>(results),
|
||||
results.CastListContravariant<NetState, object>(),
|
||||
"One match found."
|
||||
)
|
||||
);
|
||||
|
|
@ -2531,7 +2521,7 @@ namespace Server.Gumps
|
|||
from,
|
||||
AdminGumpPage.Clients,
|
||||
0,
|
||||
Utility.CastListContravariant<NetState, object>(results),
|
||||
results.CastListContravariant<NetState, object>(),
|
||||
notice ?? (results.Count == 0 ? "Nothing matched your search terms." : null)
|
||||
)
|
||||
);
|
||||
|
|
@ -2726,7 +2716,7 @@ namespace Server.Gumps
|
|||
{
|
||||
results = Accounts.GetAccounts()
|
||||
.Where(acct =>
|
||||
acct.Username.ToLower().IndexOf(match, StringComparison.Ordinal) >= 0)
|
||||
acct.Username.ToLower().Contains(match, StringComparison.Ordinal))
|
||||
.ToList();
|
||||
results.Sort(AccountComparer.Instance);
|
||||
}
|
||||
|
|
@ -2751,7 +2741,7 @@ namespace Server.Gumps
|
|||
from,
|
||||
AdminGumpPage.Accounts,
|
||||
0,
|
||||
Utility.CastListContravariant<IAccount, object>(results),
|
||||
results.CastListContravariant<IAccount, object>(),
|
||||
results.Count == 0 ? "Nothing matched your search terms." : null,
|
||||
new List<object>()
|
||||
)
|
||||
|
|
@ -2879,7 +2869,7 @@ namespace Server.Gumps
|
|||
from,
|
||||
AdminGumpPage.Accounts,
|
||||
0,
|
||||
Utility.CastListContravariant<Account, object>(list),
|
||||
list.CastListContravariant<Account, object>(),
|
||||
null,
|
||||
new List<object>()
|
||||
)
|
||||
|
|
@ -3502,7 +3492,7 @@ namespace Server.Gumps
|
|||
from,
|
||||
AdminGumpPage.Accounts,
|
||||
0,
|
||||
Utility.CastListContravariant<Account, object>(kvp.Value),
|
||||
kvp.Value.CastListContravariant<Account, object>(),
|
||||
null,
|
||||
new List<object>()
|
||||
)
|
||||
|
|
@ -3539,7 +3529,7 @@ namespace Server.Gumps
|
|||
{
|
||||
var check = Firewall.List[i].ToString();
|
||||
|
||||
if (check?.IndexOf(match) >= 0)
|
||||
if (check?.Contains(match, StringComparison.Ordinal) == true)
|
||||
{
|
||||
results.Add(Firewall.List[i]);
|
||||
}
|
||||
|
|
@ -3691,7 +3681,7 @@ namespace Server.Gumps
|
|||
{
|
||||
index -= 4;
|
||||
|
||||
if (m_List != null && index >= 0 && index < m_List.Count)
|
||||
if (m_List != null && index < m_List.Count)
|
||||
{
|
||||
from.SendGump(
|
||||
new AdminGump(from, AdminGumpPage.FirewallInfo, 0, null, null, m_List[index])
|
||||
|
|
@ -3899,7 +3889,7 @@ namespace Server.Gumps
|
|||
}
|
||||
case 8:
|
||||
{
|
||||
if (m_List != null && index >= 0 && index < m_List.Count)
|
||||
if (m_List != null && index < m_List.Count)
|
||||
{
|
||||
if (!(m_State is Account a))
|
||||
{
|
||||
|
|
@ -3943,7 +3933,7 @@ namespace Server.Gumps
|
|||
}
|
||||
case 9:
|
||||
{
|
||||
if (m_List != null && index >= 0 && index < m_List.Count)
|
||||
if (m_List != null && index < m_List.Count)
|
||||
{
|
||||
if (m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs)
|
||||
{
|
||||
|
|
@ -3968,7 +3958,7 @@ namespace Server.Gumps
|
|||
from,
|
||||
AdminGumpPage.Accounts,
|
||||
0,
|
||||
Utility.CastListContravariant<Account, object>(list),
|
||||
list.CastListContravariant<Account, object>(),
|
||||
null,
|
||||
new List<object>()
|
||||
)
|
||||
|
|
@ -3994,7 +3984,7 @@ namespace Server.Gumps
|
|||
}
|
||||
case 10:
|
||||
{
|
||||
if (m_List != null && index >= 0 && index < m_List.Count)
|
||||
if (m_List != null && index < m_List.Count)
|
||||
{
|
||||
if (m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@ namespace Server.Gumps
|
|||
CommandSystem.Register("Comments", AccessLevel.Counselor, Comments_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("Comments")]
|
||||
[Description("View/Modify/Add account comments.")]
|
||||
[Usage("Comments"), Description("View/Modify/Add account comments.")]
|
||||
private static void Comments_OnCommand(CommandEventArgs args)
|
||||
{
|
||||
args.Mobile.SendMessage("Select the player to view account comments.");
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Server.Gumps
|
|||
|
||||
if (text.Length >= 3)
|
||||
{
|
||||
var guilds = Utility.CastListCovariant<BaseGuild, Guild>(BaseGuild.Search(text));
|
||||
var guilds = BaseGuild.Search(text).CastListCovariant<BaseGuild, Guild>();
|
||||
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Server.Guilds
|
|||
"",
|
||||
0,
|
||||
GuildDisplayType.All,
|
||||
Utility.CastListCovariant<BaseGuild, Guild>(new List<BaseGuild>(World.Guilds.Values)),
|
||||
World.Guilds.Values.CastListCovariant<BaseGuild, Guild>(),
|
||||
1063136 + (int)GuildDisplayType.All
|
||||
)
|
||||
{
|
||||
|
|
@ -44,7 +44,7 @@ namespace Server.Guilds
|
|||
filter,
|
||||
startNumber,
|
||||
display,
|
||||
Utility.CastListCovariant<BaseGuild, Guild>(new List<BaseGuild>(World.Guilds.Values)),
|
||||
World.Guilds.Values.CastListCovariant<BaseGuild, Guild>(),
|
||||
1063136 + (int)display
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Server.Guilds
|
|||
: base(
|
||||
pm,
|
||||
g,
|
||||
Utility.SafeConvertList<Mobile, PlayerMobile>(g.Members),
|
||||
g.Members.SafeConvertList<Mobile, PlayerMobile>(),
|
||||
currentComparer,
|
||||
ascending,
|
||||
filter,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
namespace Server.Gumps
|
||||
{
|
||||
public class PropsConfig
|
||||
public static class PropsConfig
|
||||
{
|
||||
public static readonly bool OldStyle = false;
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ namespace Server.Gumps
|
|||
public static readonly int OffsetGumpID = 0x0A40; // Pure black
|
||||
|
||||
public static readonly int
|
||||
HeaderGumpID = OldStyle ? 0x0BBC : 0x0E14; // Light offwhite, textured : Dark navy blue, textured
|
||||
HeaderGumpID = OldStyle ? 0x0BBC : 0x0E14; // Light off-white, textured : Dark navy blue, textured
|
||||
|
||||
public static readonly int EntryGumpID = 0x0BBC; // Light offwhite, textured
|
||||
public static readonly int BackGumpID = 0x13BE; // Gray slate/stoney
|
||||
|
|
|
|||
|
|
@ -757,7 +757,7 @@ namespace Server.Gumps
|
|||
if (t == typeof(byte) || t == typeof(sbyte) || t == typeof(short) || t == typeof(ushort) || t == typeof(int) ||
|
||||
t == typeof(uint) || t == typeof(long) || t == typeof(ulong))
|
||||
{
|
||||
if (s.StartsWith("0x"))
|
||||
if (s.StartsWith("0x", StringComparison.Ordinal))
|
||||
{
|
||||
if (t == typeof(ulong) || t == typeof(uint) || t == typeof(ushort) || t == typeof(byte))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ namespace Server.Gumps
|
|||
|
||||
for (var i = 0; i < m_GroupNames.Length; ++i)
|
||||
{
|
||||
if (DisplayName.StartsWith(m_GroupNames[i]))
|
||||
if (DisplayName.StartsWith(m_GroupNames[i], StringComparison.Ordinal))
|
||||
{
|
||||
DisplayName = DisplayName.Substring(m_GroupNames[i].Length);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -120,8 +120,7 @@ namespace Server.Gumps
|
|||
CommandSystem.Register("ToTAdmin", AccessLevel.Administrator, ToTAdmin_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("ToTAdmin")]
|
||||
[Description("Displays a menu to configure Treasures of Tokuno.")]
|
||||
[Usage("ToTAdmin"), Description("Displays a menu to configure Treasures of Tokuno.")]
|
||||
public static void ToTAdmin_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
ToTAdminGump tg;
|
||||
|
|
|
|||
|
|
@ -160,10 +160,9 @@ namespace Server.Gumps
|
|||
CommandSystem.Register("ViewHouses", AccessLevel.GameMaster, ViewHouses_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("ViewHouses")]
|
||||
[Description(
|
||||
"Displays a menu listing all houses of a targeted player. The menu also contains specific house details, and options to: go to house, open house menu, and demolish house."
|
||||
)]
|
||||
[Usage("ViewHouses"), Description(
|
||||
"Displays a menu listing all houses of a targeted player. The menu also contains specific house details, and options to: go to house, open house menu, and demolish house."
|
||||
)]
|
||||
public static void ViewHouses_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
e.Mobile.BeginTarget(-1, false, TargetFlags.None, ViewHouses_OnTarget);
|
||||
|
|
|
|||
|
|
@ -83,9 +83,8 @@ namespace Server.Gumps
|
|||
CommandSystem.Register("WhoList", AccessLevel.Counselor, WhoList_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("WhoList [filter]")]
|
||||
[Aliases("Who")]
|
||||
[Description("Lists all connected clients. Optionally filters results by name.")]
|
||||
[Usage("WhoList [filter]"), Aliases("Who"),
|
||||
Description("Lists all connected clients. Optionally filters results by name.")]
|
||||
private static void WhoList_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
e.Mobile.SendGump(new WhoGump(e.Mobile, e.ArgString));
|
||||
|
|
@ -96,16 +95,15 @@ namespace Server.Gumps
|
|||
var filter = rawFilter.Trim().ToLower().DefaultIfNullOrEmpty(null);
|
||||
|
||||
var list = new List<Mobile>();
|
||||
var states = TcpServer.Instances;
|
||||
|
||||
for (var i = 0; i < states.Count; ++i)
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
var m = states[i].Mobile;
|
||||
var m = ns.Mobile;
|
||||
|
||||
if (m != null && (m == owner || !m.Hidden || owner.AccessLevel >= m.AccessLevel ||
|
||||
m is PlayerMobile mobile && mobile.VisibilityList.Contains(owner)))
|
||||
{
|
||||
if (filter != null && !(m.Name?.ToLower().IndexOf(filter, StringComparison.Ordinal) >= 0))
|
||||
if (filter != null && m.Name?.ToLower().Contains(filter, StringComparison.Ordinal) != true)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
@ -317,9 +315,14 @@ namespace Server.Gumps
|
|||
|
||||
public int Compare(Mobile x, Mobile y)
|
||||
{
|
||||
if (x == null || y == null)
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
|
||||
if (x.AccessLevel > y.AccessLevel)
|
||||
|
|
@ -327,12 +330,7 @@ namespace Server.Gumps
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (x.AccessLevel < y.AccessLevel)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Insensitive.Compare(x.Name, y.Name);
|
||||
return x.AccessLevel < y.AccessLevel ? 1 : Insensitive.Compare(x.Name, y.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue