diff --git a/Projects/Server/ContextMenus/ContextMenu.cs b/Projects/Server/ContextMenus/ContextMenu.cs
index d3cb9207c..65f771282 100644
--- a/Projects/Server/ContextMenus/ContextMenu.cs
+++ b/Projects/Server/ContextMenus/ContextMenu.cs
@@ -31,11 +31,11 @@ namespace Server.ContextMenus
if (target is Mobile mobile)
{
- mobile.GetContextMenuEntries(@from, list);
+ mobile.GetContextMenuEntries(from, list);
}
else if (target is Item item)
{
- item.GetContextMenuEntries(@from, list);
+ item.GetContextMenuEntries(from, list);
}
Entries = list.ToArray();
diff --git a/Projects/Server/Items/Container.cs b/Projects/Server/Items/Container.cs
index a079e36b3..164d03bb6 100644
--- a/Projects/Server/Items/Container.cs
+++ b/Projects/Server/Items/Container.cs
@@ -570,7 +570,7 @@ namespace Server.Items
for (var i = 0; i < stackItems.Count; i++)
{
- stackItems[i].m_StackItem.StackWith(@from, stackItems[i].m_DropItem, false);
+ stackItems[i].m_StackItem.StackWith(from, stackItems[i].m_DropItem, false);
}
return true;
@@ -674,7 +674,7 @@ namespace Server.Items
if (CheckContentDisplay(from))
{
- LabelTo(@from, "({0} item{2}, {1} stones)", TotalItems, TotalWeight, TotalItems != 1 ? "s" : string.Empty);
+ LabelTo(from, "({0} item{2}, {1} stones)", TotalItems, TotalWeight, TotalItems != 1 ? "s" : string.Empty);
}
// LabelTo( from, 1050044, String.Format( "{0}\t{1}", TotalItems.ToString(), TotalWeight.ToString() ) );
@@ -824,11 +824,11 @@ namespace Server.Items
{
if (from.AccessLevel > AccessLevel.Player || from.InRange(GetWorldLocation(), 2))
{
- DisplayTo(@from);
+ DisplayTo(from);
}
else
{
- @from.SendLocalizedMessage(500446); // That is too far away.
+ from.SendLocalizedMessage(500446); // That is too far away.
}
}
diff --git a/Projects/Server/Items/Item.cs b/Projects/Server/Items/Item.cs
index 9cf08fc5e..c04ef3817 100644
--- a/Projects/Server/Items/Item.cs
+++ b/Projects/Server/Items/Item.cs
@@ -2254,11 +2254,11 @@ namespace Server
{
if (m_Parent is Item parentItem)
{
- parentItem.GetChildContextMenuEntries(@from, list, item);
+ parentItem.GetChildContextMenuEntries(from, list, item);
}
else if (m_Parent is Mobile parentMobile)
{
- parentMobile.GetChildContextMenuEntries(@from, list, item);
+ parentMobile.GetChildContextMenuEntries(from, list, item);
}
}
@@ -2266,11 +2266,11 @@ namespace Server
{
if (m_Parent is Item item)
{
- item.GetChildContextMenuEntries(@from, list, this);
+ item.GetChildContextMenuEntries(from, list, this);
}
else if (m_Parent is Mobile mobile)
{
- mobile.GetChildContextMenuEntries(@from, list, this);
+ mobile.GetChildContextMenuEntries(from, list, this);
}
}
@@ -3241,7 +3241,7 @@ namespace Server
// OSI sends 1074769, bug!
if (QuestItem)
{
- @from.SendLocalizedMessage(
+ from.SendLocalizedMessage(
1049343
); // You can only drop quest items into the top-most level of your backpack while you still need them for your quest.
}
@@ -3667,7 +3667,7 @@ namespace Server
if (target is Container container && p.m_X != -1 && p.m_Y != -1)
{
- return OnDroppedInto(@from, container, p);
+ return OnDroppedInto(from, container, p);
}
return OnDroppedOnto(from, target);
@@ -4212,11 +4212,11 @@ namespace Server
{
if (m_Parent is Item parentItem)
{
- parentItem.OnItemUsed(@from, item);
+ parentItem.OnItemUsed(from, item);
}
else if (m_Parent is Mobile parentMobile)
{
- parentMobile.OnItemUsed(@from, item);
+ parentMobile.OnItemUsed(from, item);
}
}
@@ -4234,11 +4234,11 @@ namespace Server
{
if (m_Parent is Item parentItem)
{
- parentItem.OnItemLifted(@from, item);
+ parentItem.OnItemLifted(from, item);
}
else if (m_Parent is Mobile parentMobile)
{
- parentMobile.OnItemLifted(@from, item);
+ parentMobile.OnItemLifted(from, item);
}
}
@@ -4261,7 +4261,7 @@ namespace Server
{
if (m_Parent is Item parentItem)
{
- parentItem.OnSingleClickContained(@from, item);
+ parentItem.OnSingleClickContained(from, item);
}
}
@@ -4271,7 +4271,7 @@ namespace Server
if (opl.Header > 0)
{
- @from.Send(
+ from.Send(
new MessageLocalized(
Serial,
m_ItemID,
@@ -4295,7 +4295,7 @@ namespace Server
if (DisplayLootType)
{
- LabelLootTypeTo(@from);
+ LabelLootTypeTo(from);
}
var ns = from.NetState;
diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs
index 5b1e30d17..a4cbef921 100644
--- a/Projects/Server/Mobiles/Mobile.cs
+++ b/Projects/Server/Mobiles/Mobile.cs
@@ -3758,7 +3758,7 @@ namespace Server
}
else
{
- hue = Notoriety.GetHue(Notoriety.Compute(@from, this));
+ hue = Notoriety.GetHue(Notoriety.Compute(from, this));
}
from.Send(new MessageLocalized(Serial, Body, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs));
@@ -5571,7 +5571,7 @@ namespace Server
{
if (item.QuestItem)
{
- @from.SendLocalizedMessage(1074868); // Stacks of quest items cannot be unstacked.
+ from.SendLocalizedMessage(1074868); // Stacks of quest items cannot be unstacked.
}
reject = LRReason.CannotLift;
@@ -5634,7 +5634,7 @@ namespace Server
foreach (var ns in eable)
{
- if (ns.Mobile != @from && ns.Mobile.CanSee(@from) && ns.Mobile.InLOS(@from) &&
+ if (ns.Mobile != from && ns.Mobile.CanSee(from) && ns.Mobile.InLOS(from) &&
ns.Mobile.CanSee(root))
{
if (p == null)
@@ -5645,7 +5645,7 @@ namespace Server
map
);
- p = Packet.Acquire(new DragEffect(src, @from, item.ItemID, item.Hue, amount));
+ p = Packet.Acquire(new DragEffect(src, from, item.ItemID, item.Hue, amount));
}
ns.Send(p);
@@ -5671,7 +5671,7 @@ namespace Server
if (liftSound != -1)
{
- @from.Send(new PlaySound(liftSound, @from));
+ from.Send(new PlaySound(liftSound, from));
}
from.NextActionTime = Core.TickCount + ActionDelay;
@@ -5845,7 +5845,7 @@ namespace Server
if (to == null || !item.DropToItem(from, to, loc))
{
- item.Bounce(@from);
+ item.Bounce(from);
}
else
{
@@ -5882,7 +5882,7 @@ namespace Server
if (!item.DropToWorld(from, loc))
{
- item.Bounce(@from);
+ item.Bounce(from);
}
else
{
@@ -5919,7 +5919,7 @@ namespace Server
if (to == null || !item.DropToMobile(from, to, loc))
{
- item.Bounce(@from);
+ item.Bounce(from);
}
else
{
@@ -6443,7 +6443,7 @@ namespace Server
if (from != null)
{
- RegisterDamage(amount, @from);
+ RegisterDamage(amount, from);
}
DisruptiveAction();
@@ -6473,7 +6473,7 @@ namespace Server
if (informMount)
{
- Mount?.OnRiderDamaged(amount, @from, newHits < 0);
+ Mount?.OnRiderDamaged(amount, from, newHits < 0);
}
if (newHits < 0)
@@ -8624,7 +8624,7 @@ namespace Server
{
if (from.Map == Map && Utility.InUpdateRange(this, from) && from.CanSee(this))
{
- @from.Send(new MobileStatus(@from, this, m_NetState));
+ from.Send(new MobileStatus(from, this, m_NetState));
}
if (from == this)
@@ -8634,7 +8634,7 @@ namespace Server
if (Party is IParty ip)
{
- ip.OnStatsQuery(@from, this);
+ ip.OnStatsQuery(from, this);
}
}
@@ -8708,7 +8708,7 @@ namespace Server
}
else
{
- hue = Notoriety.GetHue(Notoriety.Compute(@from, this));
+ hue = Notoriety.GetHue(Notoriety.Compute(from, this));
}
var name = Name ?? string.Empty;
@@ -10143,7 +10143,7 @@ namespace Server
if (CanPaperdollBeOpenedBy(from))
{
- DisplayPaperdollTo(@from);
+ DisplayPaperdollTo(from);
}
}
@@ -10175,7 +10175,7 @@ namespace Server
{
if (CanPaperdollBeOpenedBy(from))
{
- DisplayPaperdollTo(@from);
+ DisplayPaperdollTo(from);
}
}
@@ -10590,11 +10590,11 @@ namespace Server
{
if (m_CallbackHandlesCancel && m_Callback != null)
{
- m_Callback(@from, "");
+ m_Callback(from, "");
}
else
{
- m_CancelCallback?.Invoke(@from, "");
+ m_CancelCallback?.Invoke(from, "");
}
}
}
diff --git a/Projects/Server/Network/PacketHandlers.cs b/Projects/Server/Network/PacketHandlers.cs
index de5cb0336..8f41acf22 100644
--- a/Projects/Server/Network/PacketHandlers.cs
+++ b/Projects/Server/Network/PacketHandlers.cs
@@ -433,7 +433,7 @@ namespace Server.Network
if (targ != null)
{
- EventSink.InvokeRenameRequest(@from, targ, pvSrc.ReadStringSafe());
+ EventSink.InvokeRenameRequest(from, targ, pvSrc.ReadStringSafe());
}
}
@@ -631,7 +631,7 @@ namespace Server.Network
if (item != null && from.Map == item.Map && Utility.InUpdateRange(item.GetWorldLocation(), from.Location) &&
from.CanSee(item))
{
- item.OnHelpRequest(@from);
+ item.OnHelpRequest(from);
}
}
else if (serial.IsMobile)
@@ -668,7 +668,7 @@ namespace Server.Network
if (m != null)
{
- @from.Attack(m);
+ from.Attack(m);
}
}
@@ -827,11 +827,11 @@ namespace Server.Network
if (type == 0)
{
- p.OnCancel(@from);
+ p.OnCancel(from);
}
else
{
- p.OnResponse(@from, text);
+ p.OnResponse(from, text);
}
}
}
@@ -858,11 +858,11 @@ namespace Server.Network
if (type == 0)
{
- p.OnCancel(@from);
+ p.OnCancel(from);
}
else
{
- p.OnResponse(@from, text);
+ p.OnResponse(from, text);
}
}
}
@@ -970,7 +970,7 @@ namespace Server.Network
if (!to.AllowEquipFrom(from) || !to.EquipItem(item))
{
- item.Bounce(@from);
+ item.Bounce(from);
}
item.ClearBounce();
@@ -1458,7 +1458,7 @@ namespace Server.Network
if (m?.Deleted == false)
{
- @from.Use(m);
+ from.Use(m);
}
}
else if (s.IsItem)
@@ -1467,7 +1467,7 @@ namespace Server.Network
if (item?.Deleted == false)
{
- @from.Use(item);
+ from.Use(item);
}
}
}
@@ -1500,7 +1500,7 @@ namespace Server.Network
{
if (from.Region.OnSingleClick(from, m))
{
- m.OnSingleClick(@from);
+ m.OnSingleClick(from);
}
}
}
@@ -1520,7 +1520,7 @@ namespace Server.Network
{
if (item.Parent is Item parentItem)
{
- parentItem.OnSingleClickContained(@from, item);
+ parentItem.OnSingleClickContained(from, item);
}
item.OnSingleClick(from);
@@ -1581,7 +1581,7 @@ namespace Server.Network
if (from != null && ok && from.Alive && from.Body.IsHuman && !from.Mounted)
{
- @from.Animate(action, 7, 1, true, false, 0);
+ from.Animate(action, 7, 1, true, false, 0);
}
}
@@ -1711,7 +1711,7 @@ namespace Server.Network
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
{
- m.SendPropertiesTo(@from);
+ m.SendPropertiesTo(from);
}
}
else if (s.IsItem)
@@ -1721,7 +1721,7 @@ namespace Server.Network
if (item?.Deleted == false && from.CanSee(item) &&
Utility.InUpdateRange(from.Location, item.GetWorldLocation()))
{
- item.SendPropertiesTo(@from);
+ item.SendPropertiesTo(from);
}
}
}
@@ -1744,7 +1744,7 @@ namespace Server.Network
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
{
- m.SendPropertiesTo(@from);
+ m.SendPropertiesTo(from);
}
}
else if (s.IsItem)
@@ -1754,7 +1754,7 @@ namespace Server.Network
if (item?.Deleted == false && from.CanSee(item) &&
Utility.InUpdateRange(from.Location, item.GetWorldLocation()))
{
- item.SendPropertiesTo(@from);
+ item.SendPropertiesTo(from);
}
}
}
@@ -2031,12 +2031,12 @@ namespace Server.Network
{
case 0x04: // Stats
{
- m.OnStatsQuery(@from);
+ m.OnStatsQuery(from);
break;
}
case 0x05:
{
- m.OnSkillsQuery(@from);
+ m.OnSkillsQuery(from);
break;
}
default:
diff --git a/Projects/Server/SecureTrade.cs b/Projects/Server/SecureTrade.cs
index c82101e92..382c73277 100644
--- a/Projects/Server/SecureTrade.cs
+++ b/Projects/Server/SecureTrade.cs
@@ -25,22 +25,22 @@ namespace Server
if (from6017)
{
- @from.Send(new SecureTradeEquip6017(To.Container, to));
+ from.Send(new SecureTradeEquip6017(To.Container, to));
}
else
{
- @from.Send(new SecureTradeEquip(To.Container, to));
+ from.Send(new SecureTradeEquip(To.Container, to));
}
from.Send(new UpdateSecureTrade(From.Container, false, false));
if (from6017)
{
- @from.Send(new SecureTradeEquip6017(From.Container, @from));
+ from.Send(new SecureTradeEquip6017(From.Container, from));
}
else
{
- @from.Send(new SecureTradeEquip(From.Container, @from));
+ from.Send(new SecureTradeEquip(From.Container, from));
}
from.Send(new DisplaySecureTrade(to, From.Container, To.Container, to.Name));
@@ -48,12 +48,12 @@ namespace Server
if (from.Account != null && from704565)
{
- @from.Send(
+ from.Send(
new UpdateSecureTrade(
From.Container,
TradeFlag.UpdateLedger,
- @from.Account.TotalGold,
- @from.Account.TotalPlat
+ from.Account.TotalGold,
+ from.Account.TotalPlat
)
);
}
@@ -63,11 +63,11 @@ namespace Server
if (to6017)
{
- to.Send(new SecureTradeEquip6017(From.Container, @from));
+ to.Send(new SecureTradeEquip6017(From.Container, from));
}
else
{
- to.Send(new SecureTradeEquip(From.Container, @from));
+ to.Send(new SecureTradeEquip(From.Container, from));
}
to.Send(new UpdateSecureTrade(To.Container, false, false));
diff --git a/Projects/Server/Targeting/Target.cs b/Projects/Server/Targeting/Target.cs
index 4b3480cba..afc912c05 100644
--- a/Projects/Server/Targeting/Target.cs
+++ b/Projects/Server/Targeting/Target.cs
@@ -168,31 +168,31 @@ namespace Server.Targeting
{
if (!from.CanSee(targeted))
{
- OnCantSeeTarget(@from, targeted);
+ OnCantSeeTarget(from, targeted);
}
else if (CheckLOS && !from.InLOS(targeted))
{
- OnTargetOutOfLOS(@from, targeted);
+ OnTargetOutOfLOS(from, targeted);
}
else if (item?.InSecureTrade == true)
{
- OnTargetInSecureTrade(@from, targeted);
+ OnTargetInSecureTrade(from, targeted);
}
else if (item?.IsAccessibleTo(from) == false)
{
- OnTargetNotAccessible(@from, targeted);
+ OnTargetNotAccessible(from, targeted);
}
else if (item?.CheckTarget(from, this, targeted) == false)
{
- OnTargetUntargetable(@from, targeted);
+ OnTargetUntargetable(from, targeted);
}
else if (mobile?.CheckTarget(from, this, mobile) == false)
{
- OnTargetUntargetable(@from, mobile);
+ OnTargetUntargetable(from, mobile);
}
else if (from.Region.OnTarget(from, this, targeted))
{
- OnTarget(@from, targeted);
+ OnTarget(from, targeted);
}
}
diff --git a/Projects/UOContent/Accounting/Account.cs b/Projects/UOContent/Accounting/Account.cs
index ded506daa..a4ef8e9de 100644
--- a/Projects/UOContent/Accounting/Account.cs
+++ b/Projects/UOContent/Accounting/Account.cs
@@ -63,7 +63,9 @@ namespace Server.Accounting
// Automatically upgrade plain passwords to current algorithm.
if (!upgraded)
+ {
SetPassword(Utility.GetText(node["password"], null));
+ }
}
else
{
@@ -85,19 +87,31 @@ namespace Server.Accounting
IPRestrictions = LoadAccessCheck(node);
for (var i = 0; i < m_Mobiles.Length; ++i)
+ {
if (m_Mobiles[i] != null)
+ {
m_Mobiles[i].Account = this;
+ }
+ }
var totalGameTime = Utility.GetXMLTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero);
if (totalGameTime == TimeSpan.Zero)
+ {
for (var i = 0; i < m_Mobiles.Length; i++)
+ {
if (m_Mobiles[i] is PlayerMobile m)
+ {
totalGameTime += m.GameTime;
+ }
+ }
+ }
m_TotalGameTime = totalGameTime;
if (Young)
+ {
CheckYoung();
+ }
Accounts.Add(this);
}
@@ -148,15 +162,19 @@ namespace Server.Accounting
var isBanned = GetFlag(0);
if (!isBanned)
+ {
return false;
+ }
if (GetBanTags(out var banTime, out var banDuration))
+ {
if (banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= banTime + banDuration)
{
SetUnspecifiedBan(null); // clear
Banned = false;
return false;
}
+ }
return true;
}
@@ -197,7 +215,9 @@ namespace Server.Accounting
get
{
if (AccessLevel != AccessLevel.Player)
+ {
return false;
+ }
var inactiveLength = DateTime.UtcNow - LastLogin;
@@ -214,8 +234,12 @@ namespace Server.Accounting
get
{
for (var i = 0; i < m_Mobiles.Length; i++)
+ {
if (m_Mobiles[i] is PlayerMobile m && m.NetState != null)
+ {
return m_TotalGameTime + (DateTime.UtcNow - m.SessionStart);
+ }
+ }
return m_TotalGameTime;
}
@@ -231,12 +255,16 @@ namespace Server.Accounting
var m = this[i];
if (m == null)
+ {
continue;
+ }
var list = BaseHouse.GetHouses(m);
for (var j = 0; j < list.Count; ++j)
+ {
list[j].Delete();
+ }
m.Delete();
@@ -245,7 +273,9 @@ namespace Server.Accounting
}
if (LoginIPs.Length != 0 && AccountHandler.IPTable.ContainsKey(LoginIPs[0]))
+ {
--AccountHandler.IPTable[LoginIPs[0]];
+ }
Accounts.Remove(Username);
}
@@ -283,11 +313,15 @@ namespace Server.Accounting
var ok = AccountSecurity.GetPasswordProtection(m_PasswordAlgorithm).ValidatePassword(Password, phrase);
if (!ok)
+ {
return false;
+ }
// Upgrade the password protection in case we change the algorithm
if (m_PasswordAlgorithm != AccountSecurity.CurrentAlgorithm)
+ {
SetPassword(plainPassword);
+ }
return true;
}
@@ -302,8 +336,12 @@ namespace Server.Accounting
var count = 0;
for (var i = 0; i < Length; i++)
+ {
if (this[i] != null)
+ {
count++;
+ }
+ }
return count;
}
@@ -334,7 +372,9 @@ namespace Server.Accounting
var m = m_Mobiles[index];
if (m?.Deleted != true)
+ {
return m;
+ }
// This is the only place that clears a mobile for garbage collection
// outside of an entire account deletion.
@@ -349,12 +389,16 @@ namespace Server.Accounting
if (index >= 0 && index < m_Mobiles.Length)
{
if (m_Mobiles[index] != null)
+ {
m_Mobiles[index].Account = null;
+ }
m_Mobiles[index] = value;
if (m_Mobiles[index] != null)
+ {
m_Mobiles[index].Account = this;
+ }
}
}
}
@@ -387,7 +431,10 @@ namespace Server.Accounting
/// True if successful, false if amount given is less than or equal to zero.
public bool DepositGold(int amount)
{
- if (amount <= 0) return false;
+ if (amount <= 0)
+ {
+ return false;
+ }
var plat = Math.DivRem(amount, AccountGold.CurrencyThreshold, out var gold);
TotalPlat += plat;
@@ -403,7 +450,10 @@ namespace Server.Accounting
/// True if successful, false if amount given is less than or equal to zero.
public bool DepositPlat(int amount)
{
- if (amount <= 0) return false;
+ if (amount <= 0)
+ {
+ return false;
+ }
TotalPlat += amount;
return true;
@@ -418,8 +468,15 @@ namespace Server.Accounting
/// True if successful, false if balance was too low.
public bool WithdrawGold(int amount)
{
- if (amount <= 0) return true;
- if (amount > TotalGold) return false;
+ if (amount <= 0)
+ {
+ return true;
+ }
+
+ if (amount > TotalGold)
+ {
+ return false;
+ }
TotalGold -= amount;
@@ -433,8 +490,15 @@ namespace Server.Accounting
/// True if successful, false if balance was too low.
public bool WithdrawPlat(int amount)
{
- if (amount <= 0) return true;
- if (amount > TotalPlat) return false;
+ if (amount <= 0)
+ {
+ return true;
+ }
+
+ if (amount > TotalPlat)
+ {
+ return false;
+ }
TotalPlat -= amount;
@@ -464,9 +528,13 @@ namespace Server.Accounting
public void SetFlag(int index, bool value)
{
if (value)
+ {
Flags |= 1 << index;
+ }
else
+ {
Flags &= ~(1 << index);
+ }
}
///
@@ -488,12 +556,16 @@ namespace Server.Accounting
for (var i = Tags.Count - 1; i >= 0; --i)
{
if (i >= Tags.Count)
+ {
continue;
+ }
var tag = Tags[i];
if (tag.Name == name)
+ {
Tags.RemoveAt(i);
+ }
}
}
@@ -529,7 +601,9 @@ namespace Server.Accounting
var tag = Tags[i];
if (tag.Name == name)
+ {
return tag.Value;
+ }
}
return null;
@@ -543,19 +617,31 @@ namespace Server.Accounting
public void SetBanTags(Mobile from, DateTime banTime, TimeSpan banDuration)
{
if (from == null)
+ {
RemoveTag("BanDealer");
+ }
else
+ {
SetTag("BanDealer", from.ToString());
+ }
if (banTime == DateTime.MinValue)
+ {
RemoveTag("BanTime");
+ }
else
+ {
SetTag("BanTime", XmlConvert.ToString(banTime, XmlDateTimeSerializationMode.Utc));
+ }
if (banDuration == TimeSpan.Zero)
+ {
RemoveTag("BanDuration");
+ }
else
+ {
SetTag("BanDuration", banDuration.ToString());
+ }
}
public bool GetBanTags(out DateTime banTime, out TimeSpan banDuration)
@@ -565,11 +651,17 @@ namespace Server.Accounting
banTime = Utility.GetXMLDateTime(GetTag("BanTime"), DateTime.MinValue);
if (tagDuration == "Infinite")
+ {
banDuration = TimeSpan.MaxValue;
+ }
else if (tagDuration != null)
+ {
banDuration = Utility.ToTimeSpan(tagDuration);
+ }
else
+ {
banDuration = TimeSpan.Zero;
+ }
return banTime != DateTime.MinValue && banDuration != TimeSpan.Zero;
}
@@ -584,7 +676,9 @@ namespace Server.Accounting
private static void EventSink_Connected(Mobile m)
{
if (!(m.Account is Account acc))
+ {
return;
+ }
if (acc.Young && acc.m_YoungTimer == null)
{
@@ -596,7 +690,9 @@ namespace Server.Accounting
private static void EventSink_Disconnected(Mobile m)
{
if (!(m.Account is Account acc))
+ {
return;
+ }
if (acc.m_YoungTimer != null)
{
@@ -605,7 +701,9 @@ namespace Server.Accounting
}
if (!(m is PlayerMobile pm))
+ {
return;
+ }
acc.m_TotalGameTime += DateTime.UtcNow - pm.SessionStart;
}
@@ -613,10 +711,14 @@ namespace Server.Accounting
private static void EventSink_Login(Mobile m)
{
if (!(m is PlayerMobile pm))
+ {
return;
+ }
if (!(m.Account is Account acc))
+ {
return;
+ }
if (pm.Young && acc.Young)
{
@@ -636,6 +738,7 @@ namespace Server.Accounting
Young = false;
for (var i = 0; i < m_Mobiles.Length; i++)
+ {
if (m_Mobiles[i] is PlayerMobile m && m.Young)
{
m.Young = false;
@@ -643,26 +746,34 @@ namespace Server.Accounting
if (m.NetState != null)
{
if (message > 0)
+ {
m.SendLocalizedMessage(message);
+ }
m.SendLocalizedMessage(
1019039
); // You are no longer considered a young player of Ultima Online, and are no longer subject to the limitations and benefits of being in that caste.
}
}
+ }
}
public void CheckYoung()
{
if (TotalGameTime >= YoungDuration)
+ {
RemoveYoungStatus(
1019038
); // You are old enough to be considered an adult, and have outgrown your status as a young player!
+ }
}
private bool UpgradePassword(string password, PasswordProtectionAlgorithm algorithm)
{
- if (password == null || algorithm < m_PasswordAlgorithm) return false;
+ if (password == null || algorithm < m_PasswordAlgorithm)
+ {
+ return false;
+ }
m_PasswordAlgorithm = algorithm;
Password = password?.Replace("-", string.Empty);
@@ -688,7 +799,9 @@ namespace Server.Accounting
var text = Utility.GetText(ip, null);
if (text != null)
+ {
list.Add(text);
+ }
}
stringList = list.ToArray();
@@ -720,12 +833,16 @@ namespace Server.Accounting
count = 0;
foreach (XmlElement ip in addressList.GetElementsByTagName("ip"))
+ {
if (count < list.Length)
+ {
if (IPAddress.TryParse(Utility.GetText(ip, null), out var address))
{
list[count] = Utility.Intern(address);
count++;
}
+ }
+ }
if (count != list.Length)
{
@@ -733,7 +850,9 @@ namespace Server.Accounting
list = new IPAddress[count];
for (var i = 0; i < count && i < old.Length; ++i)
+ {
list[i] = old[i];
+ }
}
}
else
@@ -759,19 +878,25 @@ namespace Server.Accounting
// Above is legacy, no longer used
if (chars != null)
+ {
foreach (XmlElement ele in chars.GetElementsByTagName("char"))
+ {
try
{
var index = Utility.GetXMLInt32(Utility.GetAttribute(ele, "index", "0"), 0);
var serial = Utility.GetXMLUInt32(Utility.GetText(ele, "0"), 0);
if (index >= 0 && index < list.Length)
+ {
list[index] = World.FindMobile(serial);
+ }
}
catch
{
// ignored
}
+ }
+ }
return list;
}
@@ -791,6 +916,7 @@ namespace Server.Accounting
list = new List();
foreach (XmlElement comment in comments.GetElementsByTagName("comment"))
+ {
try
{
list.Add(new AccountComment(comment));
@@ -799,6 +925,7 @@ namespace Server.Accounting
{
// ignored
}
+ }
}
return list;
@@ -819,6 +946,7 @@ namespace Server.Accounting
list = new List();
foreach (XmlElement tag in tags.GetElementsByTagName("tag"))
+ {
try
{
list.Add(new AccountTag(tag));
@@ -827,6 +955,7 @@ namespace Server.Accounting
{
// ignored
}
+ }
}
return list;
@@ -848,26 +977,36 @@ namespace Server.Accounting
var hasAccess = false;
if (m_AccessLevel >= level)
+ {
hasAccess = true;
+ }
else
+ {
for (var i = 0; !hasAccess && i < Length; ++i)
{
var m = this[i];
if (m?.AccessLevel >= level)
+ {
hasAccess = true;
+ }
}
+ }
Console.WriteLine("{0} {1}", hasAccess ? "yes" : "no", m_AccessLevel);
if (!hasAccess)
+ {
return false;
+ }
}
var accessAllowed = IPRestrictions.Length == 0 || IPLimiter.IsExempt(ipAddress);
for (var i = 0; !accessAllowed && i < IPRestrictions.Length; ++i)
+ {
accessAllowed = Utility.IPMatch(IPRestrictions[i], ipAddress);
+ }
return accessAllowed;
}
@@ -878,35 +1017,44 @@ namespace Server.Accounting
/// NetState instance to record.
public void LogAccess(NetState ns)
{
- if (ns != null) LogAccess(ns.Address);
+ if (ns != null)
+ {
+ LogAccess(ns.Address);
+ }
}
public void LogAccess(IPAddress ipAddress)
{
if (IPLimiter.IsExempt(ipAddress))
+ {
return;
+ }
if (LoginIPs.Length == 0)
{
- if (AccountHandler.IPTable.ContainsKey(ipAddress))
- AccountHandler.IPTable[ipAddress]++;
- else
- AccountHandler.IPTable[ipAddress] = 1;
+ AccountHandler.IPTable.TryGetValue(ipAddress, out var result);
+ AccountHandler.IPTable[ipAddress] = result + 1;
}
var contains = false;
for (var i = 0; !contains && i < LoginIPs.Length; ++i)
+ {
contains = LoginIPs[i].Equals(ipAddress);
+ }
if (contains)
+ {
return;
+ }
var old = LoginIPs;
LoginIPs = new IPAddress[old.Length + 1];
for (var i = 0; i < old.Length; ++i)
+ {
LoginIPs[i] = old[i];
+ }
LoginIPs[old.Length] = ipAddress;
}
@@ -924,7 +1072,9 @@ namespace Server.Accounting
var hasAccess = HasAccess(ipAddress);
if (hasAccess)
+ {
LogAccess(ipAddress);
+ }
return hasAccess;
}
@@ -997,7 +1147,9 @@ namespace Server.Accounting
xml.WriteStartElement("comments");
for (var i = 0; i < m_Comments.Count; ++i)
+ {
m_Comments[i].Save(xml);
+ }
xml.WriteEndElement();
}
@@ -1007,7 +1159,9 @@ namespace Server.Accounting
xml.WriteStartElement("tags");
for (var i = 0; i < m_Tags.Count; ++i)
+ {
m_Tags[i].Save(xml);
+ }
xml.WriteEndElement();
}
diff --git a/Projects/UOContent/Accounting/AccountHandler.cs b/Projects/UOContent/Accounting/AccountHandler.cs
index 2b7926e25..5ac1e407a 100644
--- a/Projects/UOContent/Accounting/AccountHandler.cs
+++ b/Projects/UOContent/Accounting/AccountHandler.cs
@@ -38,7 +38,7 @@ namespace Server.Misc
// Jhelom
// ..
new CityInfo( "Haven", "Buckler's Hideaway", 3667, 2625, 0 )
-
+
if (Core.AOS)
{
//CityInfo haven = new CityInfo( "Haven", "Uzeraan's Mansion", 3618, 2591, 0 );
@@ -65,11 +65,13 @@ namespace Server.Misc
m_IPTable = new Dictionary();
foreach (Account a in Accounts.GetAccounts())
+ {
if (a.LoginIPs.Length > 0)
{
var ip = a.LoginIPs[0];
m_IPTable[ip] = (m_IPTable.TryGetValue(ip, out var value) ? value : 0) + 1;
}
+ }
}
return m_IPTable;
@@ -93,7 +95,9 @@ namespace Server.Misc
EventSink.GameLogin += EventSink_GameLogin;
if (PasswordCommandEnabled)
+ {
CommandSystem.Register("Password", AccessLevel.Player, Password_OnCommand);
+ }
}
[Usage("Password ")]
@@ -105,17 +109,23 @@ namespace Server.Misc
var from = e.Mobile;
if (!(from.Account is Account acct))
+ {
return;
+ }
var accessList = acct.LoginIPs;
if (accessList.Length == 0)
+ {
return;
+ }
var ns = from.NetState;
if (ns == null)
+ {
return;
+ }
if (e.Length == 0)
{
@@ -142,7 +152,9 @@ namespace Server.Misc
var isSafe = true;
for (var i = 0; isSafe && i < pass.Length; ++i)
+ {
isSafe = pass[i] >= 0x20 && pass[i] < 0x7F;
+ }
if (!isSafe)
{
@@ -166,9 +178,13 @@ namespace Server.Misc
if (entry != null)
{
if (entry.Message.StartsWith("[Automated: Change Password]"))
+ {
from.SendMessage("You already have a password change request in the help system queue.");
+ }
else
+ {
from.SendMessage("Your IP address does not match that which created this account.");
+ }
}
else if (PageQueue.CheckAllowedToPage(from))
{
@@ -246,19 +262,18 @@ namespace Server.Misc
}
}
- public static bool CanCreate(IPAddress ip)
- {
- if (!IPTable.ContainsKey(ip))
- return true;
-
- return IPTable[ip] < MaxAccountsPerIP;
- }
+ public static bool CanCreate(IPAddress ip) =>
+ !IPTable.TryGetValue(ip, out var result) || result < MaxAccountsPerIP;
private static bool IsForbiddenChar(char c)
{
for (var i = 0; i < m_ForbiddenChars.Length; ++i)
+ {
if (c == m_ForbiddenChars[i])
+ {
return true;
+ }
+ }
return false;
}
@@ -266,18 +281,26 @@ namespace Server.Misc
private static Account CreateAccount(NetState state, string un, string pw)
{
if (un.Length == 0 || pw.Length == 0)
+ {
return null;
+ }
var isSafe = !(un.StartsWith(" ") || un.EndsWith(" ") || un.EndsWith("."));
for (var i = 0; isSafe && i < un.Length; ++i)
+ {
isSafe = un[i] >= 0x20 && un[i] < 0x7F && !IsForbiddenChar(un[i]);
+ }
for (var i = 0; isSafe && i < pw.Length; ++i)
+ {
isSafe = pw[i] >= 0x20 && pw[i] < 0x7F;
+ }
if (!isSafe)
+ {
return null;
+ }
if (!CanCreate(state.Address))
{
@@ -307,10 +330,8 @@ namespace Server.Misc
Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);
- using (var op = new StreamWriter("ipLimits.log", true))
- {
- op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.UtcNow);
- }
+ using var op = new StreamWriter("ipLimits.log", true);
+ op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.UtcNow);
return;
}
@@ -329,7 +350,9 @@ namespace Server.Misc
e.Accepted = acct?.CheckAccess(e.State) ?? false;
if (!e.Accepted)
+ {
e.RejectReason = ALRReason.BadComm;
+ }
}
else
{
@@ -362,7 +385,9 @@ namespace Server.Misc
}
if (!e.Accepted)
+ {
AccountAttackLimiter.RegisterInvalidAccess(e.State);
+ }
}
public static void EventSink_GameLogin(GameLoginEventArgs e)
@@ -414,15 +439,23 @@ namespace Server.Misc
}
if (!e.Accepted)
+ {
AccountAttackLimiter.RegisterInvalidAccess(e.State);
+ }
}
public static bool CheckAccount(Mobile mobCheck, Mobile accCheck)
{
if (accCheck?.Account is Account a)
+ {
for (var i = 0; i < a.Length; ++i)
+ {
if (a[i] == mobCheck)
+ {
return true;
+ }
+ }
+ }
return false;
}
diff --git a/Projects/UOContent/Commands/HelpInfo.cs b/Projects/UOContent/Commands/HelpInfo.cs
index 78729ceda..7a0239e3b 100644
--- a/Projects/UOContent/Commands/HelpInfo.cs
+++ b/Projects/UOContent/Commands/HelpInfo.cs
@@ -36,9 +36,13 @@ namespace Server.Commands
var m = e.Mobile;
if (m.AccessLevel >= c.AccessLevel)
+ {
m.SendGump(new CommandInfoGump(c));
+ }
else
+ {
m.SendMessage("You don't have access to that command.");
+ }
return;
}
@@ -67,17 +71,23 @@ namespace Server.Commands
var attrs = mi.GetCustomAttributes(typeof(UsageAttribute), false);
if (attrs.Length == 0)
+ {
continue;
+ }
var usage = attrs[0] as UsageAttribute;
attrs = mi.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attrs.Length == 0)
+ {
continue;
+ }
if (usage == null || !(attrs[0] is DescriptionAttribute desc))
+ {
continue;
+ }
attrs = mi.GetCustomAttributes(typeof(AliasesAttribute), false);
@@ -114,14 +124,18 @@ namespace Server.Commands
var desc = command.Description;
if (usage == null || desc == null)
+ {
continue;
+ }
var cmds = command.Commands;
var cmd = cmds[0];
var aliases = new string[cmds.Length - 1];
for (var j = 0; j < aliases.Length; ++j)
+ {
aliases[j] = cmds[j + 1];
+ }
desc = desc.Replace("<", "(").Replace(">", ")");
@@ -132,25 +146,39 @@ namespace Server.Commands
sb.Append("Modifiers: ");
if ((command.Supports & CommandSupport.Global) != 0)
+ {
sb.Append("Global, ");
+ }
if ((command.Supports & CommandSupport.Online) != 0)
+ {
sb.Append("Online, ");
+ }
if ((command.Supports & CommandSupport.Region) != 0)
+ {
sb.Append("Region, ");
+ }
if ((command.Supports & CommandSupport.Contained) != 0)
+ {
sb.Append("Contained, ");
+ }
if ((command.Supports & CommandSupport.Multi) != 0)
+ {
sb.Append("Multi, ");
+ }
if ((command.Supports & CommandSupport.Area) != 0)
+ {
sb.Append("Area, ");
+ }
if ((command.Supports & CommandSupport.Self) != 0)
+ {
sb.Append("Self, ");
+ }
sb.Remove(sb.Length - 2, 2);
sb.Append("
");
@@ -183,14 +211,18 @@ namespace Server.Commands
var desc = command.Description;
if (usage == null || desc == null)
+ {
continue;
+ }
var cmds = command.Accessors;
var cmd = cmds[0];
var aliases = new string[cmds.Length - 1];
for (var j = 0; j < aliases.Length; ++j)
+ {
aliases[j] = cmds[j + 1];
+ }
desc = desc.Replace("<", ")").Replace(">", ")");
@@ -213,8 +245,9 @@ namespace Server.Commands
SortedHelpInfo = list;
foreach (var c in SortedHelpInfo)
- if (!HelpInfos.ContainsKey(c.Name.ToLower()))
- HelpInfos.Add(c.Name.ToLower(), c);
+ {
+ HelpInfos.TryAdd(c.Name.ToLower(), c);
+ }
}
public class CommandListGump : BaseGridGump
@@ -234,8 +267,12 @@ namespace Server.Commands
m_List = new List();
foreach (var c in SortedHelpInfo)
+ {
if (from.AccessLevel >= c.AccessLevel)
+ {
m_List.Add(c);
+ }
+ }
}
else
{
@@ -245,9 +282,13 @@ namespace Server.Commands
AddNewPage();
if (m_Page > 0)
+ {
AddEntryButton(20, ArrowLeftID1, ArrowLeftID2, 1, ArrowLeftWidth, ArrowLeftHeight);
+ }
else
+ {
AddEntryHeader(20);
+ }
AddEntryHtml(
160,
@@ -257,9 +298,13 @@ namespace Server.Commands
);
if ((m_Page + 1) * EntriesPerPage < m_List.Count)
+ {
AddEntryButton(20, ArrowRightID1, ArrowRightID2, 2, ArrowRightWidth, ArrowRightHeight);
+ }
else
+ {
AddEntryHeader(20);
+ }
var last = (int)AccessLevel.Player - 1;
@@ -300,14 +345,18 @@ namespace Server.Commands
case 1:
{
if (m_Page > 0)
+ {
m.SendGump(new CommandListGump(m_Page - 1, m, m_List));
+ }
break;
}
case 2:
{
if ((m_Page + 1) * EntriesPerPage < SortedHelpInfo.Count)
+ {
m.SendGump(new CommandListGump(m_Page + 1, m, m_List));
+ }
break;
}
@@ -369,7 +418,9 @@ namespace Server.Commands
for (var i = 0; i < aliases.Length; ++i)
{
if (i != 0)
+ {
sb.Append(", ");
+ }
sb.Append(aliases[i]);
}
diff --git a/Projects/UOContent/Engines/Craft/Core/Recipes.cs b/Projects/UOContent/Engines/Craft/Core/Recipes.cs
index 93d9c9854..77c5874d5 100644
--- a/Projects/UOContent/Engines/Craft/Core/Recipes.cs
+++ b/Projects/UOContent/Engines/Craft/Core/Recipes.cs
@@ -16,7 +16,9 @@ namespace Server.Engines.Craft
CraftItem = item;
if (Recipes.ContainsKey(id))
+ {
throw new Exception("Attempting to create recipe with preexisting ID.");
+ }
Recipes.Add(id, this);
LargestRecipeID = Math.Max(id, LargestRecipeID);
diff --git a/Projects/UOContent/Engines/Spawners/SpawnerEntry.cs b/Projects/UOContent/Engines/Spawners/SpawnerEntry.cs
index 683ae7686..5f8ca8338 100644
--- a/Projects/UOContent/Engines/Spawners/SpawnerEntry.cs
+++ b/Projects/UOContent/Engines/Spawners/SpawnerEntry.cs
@@ -33,18 +33,20 @@ namespace Server.Engines.Spawners
for (var i = 0; i < count; ++i)
// IEntity e = World.FindEntity( reader.ReadInt() );
+ {
if (reader.ReadEntity() is ISpawnable e)
{
e.Spawner = parent;
if (e is BaseCreature creature)
+ {
creature.RemoveIfUntamed = true;
+ }
Spawned.Add(e);
-
- if (!parent.Spawned.ContainsKey(e))
- parent.Spawned.Add(e, this);
+ parent.Spawned.TryAdd(e, this);
}
+ }
}
[JsonPropertyName("probability")] public int SpawnedProbability { get; set; }
@@ -81,11 +83,17 @@ namespace Server.Engines.Spawners
object o = Spawned[i];
if (o is Item item)
+ {
writer.Write(item);
+ }
else if (o is Mobile mobile)
+ {
writer.Write(mobile);
+ }
else
+ {
writer.Write(Serial.MinusOne);
+ }
}
}
diff --git a/Projects/UOContent/Gumps/AdminGump.cs b/Projects/UOContent/Gumps/AdminGump.cs
index 621190c25..94fd09144 100644
--- a/Projects/UOContent/Gumps/AdminGump.cs
+++ b/Projects/UOContent/Gumps/AdminGump.cs
@@ -137,7 +137,9 @@ namespace Server.Gumps
AddPageButton(10, 90, GetButtonID(0, 4), "FIREWALL", AdminGumpPage.Firewall, AdminGumpPage.FirewallInfo);
if (notice != null)
+ {
AddHtml(12, 392, 396, 36, Color(notice, LabelColor32));
+ }
switch (pageType)
{
@@ -147,10 +149,16 @@ namespace Server.Gumps
var active = 0;
foreach (Account acct in Accounts.GetAccounts())
+ {
if (acct.Banned)
+ {
++banned;
+ }
else
+ {
++active;
+ }
+ }
AddLabel(20, 130, LabelHue, "Active Accounts:");
AddLabel(150, 130, LabelHue, active.ToString());
@@ -194,16 +202,16 @@ namespace Server.Gumps
AddLabel(150, 350, LabelHue, os);
/*string str;
-
+
try{ str = FormatTimeSpan( Core.Process.TotalProcessorTime ); }
catch{ str = "(unable to retrieve)"; }
-
+
AddLabel( 20, 330, LabelHue, "Process Time:" );
AddLabel( 250, 330, LabelHue, str );*/
/*try{ str = Core.Process.PriorityClass.ToString(); }
catch{ str = "(unable to retrieve)"; }
-
+
AddLabel( 20, 350, LabelHue, "Process Priority:" );
AddLabel( 250, 350, LabelHue, str );*/
@@ -374,7 +382,9 @@ namespace Server.Gumps
AddButtonLabeled(220, 290, GetButtonID(3, 315), "Make Developer");
if (from.AccessLevel >= AccessLevel.Owner)
+ {
AddButtonLabeled(220, 310, GetButtonID(3, 316), "Make Owner");
+ }
}
}
@@ -450,31 +460,48 @@ namespace Server.Gumps
AddLabelCropped(273, 120, 109, 20, LabelHue, "IP Address");
if (listPage > 0)
+ {
AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0));
+ }
else
+ {
AddImage(375, 122, 0x25EA);
+ }
if ((listPage + 1) * 12 < m_List.Count)
+ {
AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1));
+ }
else
+ {
AddImage(392, 122, 0x25E6);
+ }
if (m_List.Count == 0)
+ {
AddLabel(12, 140, LabelHue, "There are no clients to display.");
+ }
for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < m_List.Count; ++i, ++index)
{
if (!(m_List[index] is NetState ns))
+ {
continue;
+ }
var m = ns.Mobile;
var a = ns.Account as Account;
var offset = 140 + i * 20;
if (m == null)
+ {
AddLabelCropped(12, offset, 81, 20, LabelHue, "(logging in)");
+ }
else
+ {
AddLabelCropped(12, offset, 81, 20, GetHueFor(m), m.Name);
+ }
+
AddLabelCropped(95, offset, 81, 20, LabelHue, a == null ? "(no account)" : a.Username);
AddLabelCropped(
178,
@@ -489,7 +516,9 @@ namespace Server.Gumps
AddLabelCropped(273, offset, 109, 20, LabelHue, ns.ToString());
if (a != null || m != null)
+ {
AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(4, index + 2));
+ }
}
break;
@@ -497,7 +526,9 @@ namespace Server.Gumps
case AdminGumpPage.ClientInfo:
{
if (!(state is Mobile m))
+ {
break;
+ }
AddClientHeader();
@@ -596,17 +627,27 @@ namespace Server.Gumps
AddLabelCropped(192, 120, 180, 20, LabelHue, "Accounts");
if (listPage > 0)
+ {
AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0));
+ }
else
+ {
AddImage(375, 122, 0x25EA);
+ }
if ((listPage + 1) * 12 < sharedAccounts.Count)
+ {
AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1));
+ }
else
+ {
AddImage(392, 122, 0x25E6);
+ }
if (sharedAccounts.Count == 0)
+ {
AddLabel(12, 140, LabelHue, "There are no accounts to display.");
+ }
var sb = new StringBuilder();
@@ -625,12 +666,16 @@ namespace Server.Gumps
AddLabelCropped(72, offset, 120, 20, LabelHue, ipAddr.ToString());
if (sb.Length > 0)
+ {
sb.Length = 0;
+ }
for (var j = 0; j < accts.Count; ++j)
{
if (j > 0)
+ {
sb.Append(", ");
+ }
if (j < 4)
{
@@ -661,25 +706,39 @@ namespace Server.Gumps
AddAccountHeader();
if (rads == null)
+ {
AddLabelCropped(12, 120, 120, 20, LabelHue, "Name");
+ }
else
+ {
AddLabelCropped(32, 120, 100, 20, LabelHue, "Name");
+ }
AddLabelCropped(132, 120, 120, 20, LabelHue, "Access Level");
AddLabelCropped(252, 120, 120, 20, LabelHue, "Status");
if (listPage > 0)
+ {
AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0));
+ }
else
+ {
AddImage(375, 122, 0x25EA);
+ }
if ((listPage + 1) * 12 < m_List.Count)
+ {
AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1));
+ }
else
+ {
AddImage(392, 122, 0x25E6);
+ }
if (m_List.Count == 0)
+ {
AddLabel(12, 140, LabelHue, "There are no accounts to display.");
+ }
if (rads != null && notice == null)
{
@@ -693,7 +752,9 @@ namespace Server.Gumps
for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < m_List.Count; ++i, ++index)
{
if (!(m_List[index] is Account a))
+ {
continue;
+ }
var offset = 140 + i * 20;
@@ -712,11 +773,17 @@ namespace Server.Gumps
AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(accessLevel));
if (online)
+ {
AddLabelCropped(252, offset, 120, 20, GreenHue, "Online");
+ }
else if (a.Banned)
+ {
AddLabelCropped(252, offset, 120, 20, RedHue, "Banned");
+ }
else
+ {
AddLabelCropped(252, offset, 120, 20, RedHue, "Offline");
+ }
AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56));
}
@@ -751,7 +818,9 @@ namespace Server.Gumps
case AdminGumpPage.AccountDetails_ChangePassword:
{
if (!(state is Account a))
+ {
break;
+ }
AddHtml(10, 125, 400, 20, Color(Center("Change Password"), LabelColor32));
@@ -771,7 +840,9 @@ namespace Server.Gumps
case AdminGumpPage.AccountDetails_ChangeAccess:
{
if (!(state is Account a))
+ {
break;
+ }
AddHtml(10, 125, 400, 20, Color(Center("Change Access Level"), LabelColor32));
@@ -795,7 +866,9 @@ namespace Server.Gumps
AddButtonLabeled(20, 300, GetButtonID(5, 33), "Developer");
if (from.AccessLevel >= AccessLevel.Owner)
+ {
AddButtonLabeled(20, 320, GetButtonID(5, 34), "Owner");
+ }
}
}
@@ -804,13 +877,19 @@ namespace Server.Gumps
case AdminGumpPage.AccountDetails_Information:
{
if (!(state is Account a))
+ {
break;
+ }
var charCount = 0;
for (var i = 0; i < a.Length; ++i)
+ {
if (a[i] != null)
+ {
++charCount;
+ }
+ }
AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32));
@@ -838,9 +917,13 @@ namespace Server.Gumps
var remaining = DateTime.UtcNow - banTime;
if (remaining < TimeSpan.Zero)
+ {
remaining = TimeSpan.Zero;
+ }
else if (remaining > banDuration)
+ {
remaining = banDuration;
+ }
var remMinutes = remaining.TotalMinutes;
var totMinutes = banDuration.TotalMinutes;
@@ -874,9 +957,13 @@ namespace Server.Gumps
AddButtonLabeled(200, 320, GetButtonID(5, 9), "Change Access Level");
if (!a.Banned)
+ {
AddButtonLabeled(20, 350, GetButtonID(5, 10), "Ban Account");
+ }
else
+ {
AddButtonLabeled(20, 350, GetButtonID(5, 11), "Unban Account");
+ }
AddButtonLabeled(200, 350, GetButtonID(5, 25), "Delete Account");
@@ -885,7 +972,9 @@ namespace Server.Gumps
case AdminGumpPage.AccountDetails_Access:
{
if (!(state is Account a))
+ {
break;
+ }
AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32));
@@ -909,7 +998,9 @@ namespace Server.Gumps
case AdminGumpPage.AccountDetails_Access_ClientIPs:
{
if (!(state is Account a))
+ {
break;
+ }
List ipAddresses;
@@ -944,17 +1035,27 @@ namespace Server.Gumps
AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32));
if (listPage > 0)
+ {
AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0));
+ }
else
+ {
AddImage(184, 223, 0x25EA);
+ }
if ((listPage + 1) * 6 < ipAddresses.Count)
+ {
AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1));
+ }
else
+ {
AddImage(201, 223, 0x25E6);
+ }
if (ipAddresses.Count == 0)
+ {
AddHtml(18, 243, 200, 60, Color("This account has not yet been accessed.", LabelColor32));
+ }
for (int i = 0, index = listPage * 6; i < 6 && index >= 0 && index < ipAddresses.Count; ++i, ++index)
{
@@ -969,7 +1070,9 @@ namespace Server.Gumps
case AdminGumpPage.AccountDetails_Access_Restrictions:
{
if (!(state is Account a))
+ {
break;
+ }
List ipRestrictions;
@@ -1006,17 +1109,27 @@ namespace Server.Gumps
AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32));
if (listPage > 0)
+ {
AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0));
+ }
else
+ {
AddImage(184, 223, 0x25EA);
+ }
if ((listPage + 1) * 6 < ipRestrictions.Count)
+ {
AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1));
+ }
else
+ {
AddImage(201, 223, 0x25E6);
+ }
if (ipRestrictions.Count == 0)
+ {
AddHtml(18, 243, 200, 60, Color("There are no addresses in this list.", LabelColor32));
+ }
for (int i = 0, index = listPage * 6;
i < 6 && index >= 0 && index < ipRestrictions.Count;
@@ -1031,7 +1144,9 @@ namespace Server.Gumps
case AdminGumpPage.AccountDetails_Characters:
{
if (!(state is Account a))
+ {
break;
+ }
AddHtml(10, 125, 400, 20, Color(Center("Characters"), LabelColor32));
@@ -1046,7 +1161,9 @@ namespace Server.Gumps
var m = a[i];
if (m == null)
+ {
continue;
+ }
var offset = 170 + index * 20;
@@ -1054,9 +1171,13 @@ namespace Server.Gumps
AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(m.AccessLevel));
if (m.NetState != null)
+ {
AddLabelCropped(252, offset, 120, 20, GreenHue, "Online");
+ }
else
+ {
AddLabelCropped(252, offset, 120, 20, RedHue, "Offline");
+ }
AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, i + 50));
@@ -1064,14 +1185,18 @@ namespace Server.Gumps
}
if (index == 0)
+ {
AddLabel(12, 170, LabelHue, "The character list is empty.");
+ }
goto case AdminGumpPage.AccountDetails;
}
case AdminGumpPage.AccountDetails_Comments:
{
if (!(state is Account a))
+ {
break;
+ }
AddHtml(10, 125, 400, 20, Color(Center("Comments"), LabelColor32));
@@ -1080,12 +1205,16 @@ namespace Server.Gumps
var sb = new StringBuilder();
if (a.Comments.Count == 0)
+ {
sb.Append("There are no comments for this account.");
+ }
for (var i = 0; i < a.Comments.Count; ++i)
{
if (i > 0)
+ {
sb.Append("
");
+ }
var c = a.Comments[i];
@@ -1099,7 +1228,9 @@ namespace Server.Gumps
case AdminGumpPage.AccountDetails_Tags:
{
if (!(state is Account a))
+ {
break;
+ }
AddHtml(10, 125, 400, 20, Color(Center("Tags"), LabelColor32));
@@ -1108,12 +1239,16 @@ namespace Server.Gumps
var sb = new StringBuilder();
if (a.Tags.Count == 0)
+ {
sb.Append("There are no tags for this account.");
+ }
for (var i = 0; i < a.Tags.Count; ++i)
{
if (i > 0)
+ {
sb.Append("
");
+ }
var tag = a.Tags[i];
@@ -1143,17 +1278,27 @@ namespace Server.Gumps
AddLabelCropped(12, 120, 358, 20, LabelHue, "IP Address");
if (listPage > 0)
+ {
AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0));
+ }
else
+ {
AddImage(375, 122, 0x25EA);
+ }
if ((listPage + 1) * 12 < firewallEntries.Count)
+ {
AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1));
+ }
else
+ {
AddImage(392, 122, 0x25E6);
+ }
if (firewallEntries.Count == 0)
+ {
AddLabel(12, 140, LabelHue, "The firewall list is empty.");
+ }
for (int i = 0, index = listPage * 12;
i < 12 && index >= 0 && index < firewallEntries.Count;
@@ -1174,7 +1319,9 @@ namespace Server.Gumps
AddFirewallHeader();
if (!(state is Firewall.IFirewallEntry firewallEntry))
+ {
break;
+ }
AddHtml(10, 125, 400, 20, Color(Center(firewallEntry.ToString()), LabelColor32));
@@ -1197,11 +1344,13 @@ namespace Server.Gumps
var contains = false;
for (var i = 0; !contains && i < loginList.Length; ++i)
+ {
if (firewallEntry.IsBlocked(loginList[i]))
{
blockedAccts.Add(acct);
break;
}
+ }
}
blockedAccts.Sort(AccountComparer.Instance);
@@ -1213,17 +1362,27 @@ namespace Server.Gumps
}
if (listPage > 0)
+ {
AddButton(375, 177, 0x15E3, 0x15E7, GetButtonID(1, 0));
+ }
else
+ {
AddImage(375, 177, 0x25EA);
+ }
if ((listPage + 1) * 12 < blockedAccts.Count)
+ {
AddButton(392, 177, 0x15E1, 0x15E5, GetButtonID(1, 1));
+ }
else
+ {
AddImage(392, 177, 0x25E6);
+ }
if (blockedAccts.Count == 0)
+ {
AddLabelCropped(12, 200, 398, 20, LabelHue, "No accounts found.");
+ }
for (int i = 0, index = listPage * 9;
i < 9 && index >= 0 && index < blockedAccts.Count;
@@ -1239,11 +1398,17 @@ namespace Server.Gumps
AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(accessLevel));
if (online)
+ {
AddLabelCropped(252, offset, 120, 20, GreenHue, "Online");
+ }
else if (a.Banned)
+ {
AddLabelCropped(252, offset, 120, 20, RedHue, "Banned");
+ }
else
+ {
AddLabelCropped(252, offset, 120, 20, RedHue, "Offline");
+ }
AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56));
}
@@ -1261,7 +1426,9 @@ namespace Server.Gumps
var isSelection = m_PageType == page;
for (var i = 0; !isSelection && i < subPages.Length; ++i)
+ {
isSelection = m_PageType == subPages[i];
+ }
AddSelectedButton(x, y, buttonID, text, isSelection);
}
@@ -1296,13 +1463,19 @@ namespace Server.Gumps
public static string FormatByteAmount(long totalBytes)
{
if (totalBytes > 1000000000)
+ {
return $"{(double)totalBytes / 1073741824:F1} GB";
+ }
if (totalBytes > 1000000)
+ {
return $"{(double)totalBytes / 1048576:F1} MB";
+ }
if (totalBytes > 1000)
+ {
return $"{(double)totalBytes / 1024:F1} KB";
+ }
return $"{totalBytes} Bytes";
}
@@ -1324,7 +1497,9 @@ namespace Server.Gumps
public static int GetHueFor(Mobile m)
{
if (m == null)
+ {
return LabelHue;
+ }
switch (m.AccessLevel)
{
@@ -1337,7 +1512,9 @@ namespace Server.Gumps
default:
{
if (m.Kills >= 5)
+ {
return 0x21;
+ }
return m.Criminal ? 0x3B1 : 0x58;
}
@@ -1349,7 +1526,9 @@ namespace Server.Gumps
var v = (int)level;
if (v >= 0 && v < m_AccessLevelStrings.Length)
+ {
return m_AccessLevelStrings[v];
+ }
return "Unknown";
}
@@ -1411,8 +1590,9 @@ namespace Server.Gumps
var theirAddresses = acct.LoginIPs;
for (var i = 0; i < theirAddresses.Length; ++i)
- if (!table.ContainsKey(theirAddresses[i]))
- table[theirAddresses[i]] = new List { acct };
+ {
+ table.TryAdd(theirAddresses[i], new List { acct });
+ }
}
var tableEntries = table.ToList();
@@ -1423,9 +1603,13 @@ namespace Server.Gumps
var list = kvp.Value;
if (kvp.Value.Count == 1)
+ {
list.RemoveAt(i--);
+ }
else
+ {
list.Sort(AccountComparer.Instance);
+ }
}
tableEntries.Sort(SharedAccountComparer.Instance);
@@ -1445,10 +1629,14 @@ namespace Server.Gumps
var contains = false;
for (var i = 0; !contains && i < theirAddresses.Length; ++i)
+ {
contains = ipAddress.Equals(theirAddresses[i]);
+ }
if (contains)
+ {
list.Add(acct);
+ }
}
list.Sort(AccountComparer.Instance);
@@ -1469,11 +1657,15 @@ namespace Server.Gumps
var check = theirAddresses[i];
for (var j = 0; !contains && j < ipAddresses.Length; ++j)
+ {
contains = check.Equals(ipAddresses[j]);
+ }
}
if (contains)
+ {
list.Add(acct);
+ }
}
list.Sort(AccountComparer.Instance);
@@ -1483,7 +1675,9 @@ namespace Server.Gumps
public static void BanShared_Callback(Mobile from, bool okay, Account a)
{
if (from.AccessLevel < AccessLevel.Administrator)
+ {
return;
+ }
string notice;
List list = null;
@@ -1508,13 +1702,17 @@ namespace Server.Gumps
from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, notice, a));
if (okay)
+ {
from.SendGump(new BanDurationGump(list));
+ }
}
public static void AccountDelete_Callback(Mobile from, bool okay, Account a)
{
if (from.AccessLevel < AccessLevel.Administrator)
+ {
return;
+ }
if (okay)
{
@@ -1555,7 +1753,9 @@ namespace Server.Gumps
public static void ResendGump_Callback(Mobile from, List