Modernization Fixes & Updates to Default Values (#3)

This commit is contained in:
Kamron Batman 2018-10-28 00:33:16 -07:00 • committed by GitHub
parent 445eddff68
commit dcf64091b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
768 changed files with 10507 additions and 14196 deletions

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Accounting;
using Server.Commands;
@ -677,11 +676,11 @@ namespace Server.Factions
public static void FactionItemReset_OnCommand(CommandEventArgs e)
{
ArrayList pots = new ArrayList();
List<Item> items = new List<Item>();
foreach (Item item in World.Items.Values)
if (item is IFactionItem && !(item is HoodedShroudOfShadows))
pots.Add(item);
items.Add(item);
int[] hues = new int[Factions.Count * 2];
@ -693,9 +692,9 @@ namespace Server.Factions
int count = 0;
for (int i = 0; i < pots.Count; ++i)
for (int i = 0; i < items.Count; ++i)
{
Item item = (Item)pots[i];
Item item = items[i];
IFactionItem fci = (IFactionItem)item;
if (fci.FactionItemState != null || item.LootType != LootType.Blessed)
@ -918,7 +917,7 @@ namespace Server.Factions
if (smallest == null)
return true; // sanity
if (StabilityFactor > 0 && (Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count)
if ((Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count)
return false;
return true;
@ -939,7 +938,7 @@ namespace Server.Factions
return;
}
if (killer.GetDistanceToSqrt(victim) > 64)
if (killer?.GetDistanceToSqrt(victim) > 64)
{
sigil.ReturnHome();
killer.SendLocalizedMessage(1042230); // The sigil has gone back to its home location.
@ -947,13 +946,13 @@ namespace Server.Factions
else if (Sigil.ExistsOn(killer))
{
sigil.ReturnHome();
killer.SendLocalizedMessage(
killer?.SendLocalizedMessage(
1010258); // The sigil has gone back to its home location because you already have a sigil.
}
else if (!killerPack.TryDropItem(killer, sigil, false))
{
sigil.ReturnHome();
killer.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full.
killer?.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full.
}
});
@ -998,7 +997,7 @@ namespace Server.Factions
#region Dueling
if (victim.Region.IsPartOf(typeof(SafeZone)))
if (victim.Region.IsPartOf<SafeZone>())
return;
#endregion
@ -1231,12 +1230,7 @@ namespace Server.Factions
}
}
context.m_Timer = Timer.DelayCall(SkillLossPeriod, new TimerStateCallback(ClearSkillLoss_Callback), mob);
}
private static void ClearSkillLoss_Callback(object state)
{
ClearSkillLoss((Mobile)state);
context.m_Timer = Timer.DelayCall(SkillLossPeriod, () => ClearSkillLoss(mob));
}
public static bool ClearSkillLoss(Mobile mob)

View file

@ -11,10 +11,8 @@ namespace Server.Factions
EventSink.Speech += EventSink_Speech;
}
private static void ShowScore_Sandbox(object state)
private static void ShowScore_Sandbox(PlayerState pl)
{
PlayerState pl = (PlayerState)state;
pl?.Mobile.PublicOverheadMessage(MessageType.Regular, pl.Mobile.SpeechHue, true,
pl.KillPoints.ToString("N0")); // NOTE: Added 'N0'
}
@ -141,16 +139,13 @@ namespace Server.Factions
PlayerState pl = PlayerState.Find(from);
if (pl != null)
Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl);
Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl);
break;
}
case 0x0178: // i honor your leadership
{
Faction faction = Faction.Find(from);
faction?.BeginHonorLeadership(from);
Faction.Find(from)?.BeginHonorLeadership(from);
break;
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
using Server.Targeting;
@ -7,7 +6,7 @@ using Server.Targeting;
namespace Server.Factions
{
[CustomEnum(new[] { "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" })]
public abstract class Town : IComparable
public abstract class Town : IComparable, IComparable<Town>
{
public const int SilverCaptureBonus = 10000;
@ -133,6 +132,11 @@ namespace Server.Factions
public static List<Town> Towns => Reflector.Towns;
public int CompareTo(Town other)
{
return Definition.Sort - other.Definition.Sort;
}
public int CompareTo(object obj)
{
return Definition.Sort - ((Town)obj).Definition.Sort;
@ -225,12 +229,12 @@ namespace Server.Factions
if (Silver + flow < 0)
{
ArrayList toDelete = BuildFinanceList();
List<Mobile> toDelete = BuildFinanceList();
while (Silver + flow < 0 && toDelete.Count > 0)
{
int index = Utility.Random(toDelete.Count);
Mobile mob = (Mobile)toDelete[index];
Mobile mob = toDelete[index];
mob.Delete();
@ -242,19 +246,15 @@ namespace Server.Factions
Silver += flow;
}
public ArrayList BuildFinanceList()
public List<Mobile> BuildFinanceList()
{
ArrayList list = new ArrayList();
List<Mobile> list = new List<Mobile>();
List<VendorList> vendorLists = VendorLists;
for (int i = 0; i < VendorLists.Count; ++i)
list.AddRange(VendorLists[i].Vendors);
for (int i = 0; i < vendorLists.Count; ++i)
list.AddRange(vendorLists[i].Vendors);
List<GuardList> guardLists = GuardLists;
for (int i = 0; i < guardLists.Count; ++i)
list.AddRange(guardLists[i].Guards);
for (int i = 0; i < GuardLists.Count; ++i)
list.AddRange(GuardLists[i].Guards);
return list;
}