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

@ -1019,12 +1019,10 @@ namespace Server
public void GetProperties(ObjectPropertyList list)
{
SkillName skill;
for (int i = 0; i < 5; ++i)
{
SkillName skill;
double bonus;
if (!GetValues(i, out skill, out bonus))
if (!GetValues(i, out skill, out double bonus))
continue;
list.Add(1060451 + i, "#{0}\t{1}", GetLabel(skill), bonus);
@ -1123,10 +1121,7 @@ namespace Server
public SkillName GetSkill(int index)
{
SkillName skill;
double bonus;
GetValues(index, out skill, out bonus);
GetValues(index, out SkillName skill, out double _);
return skill;
}
@ -1138,10 +1133,7 @@ namespace Server
public double GetBonus(int index)
{
SkillName skill;
double bonus;
GetValues(index, out skill, out bonus);
GetValues(index, out SkillName _, out double bonus);
return bonus;
}
@ -1161,15 +1153,12 @@ namespace Server
if (m == null)
return;
double minSkill, maxSkill;
AnimalFormContext acontext = AnimalForm.GetContext(m);
TransformContext context = TransformationSpellHelper.GetContext(m);
if (context != null)
if (context?.Spell is Spell spell)
{
Spell spell = context.Spell as Spell;
spell.GetCastSkills(out minSkill, out maxSkill);
spell.GetCastSkills(out double minSkill, out _);
if (m.Skills[spell.CastSkill].Value < minSkill)
TransformationSpellHelper.RemoveContext(m, context, true);
}
@ -1180,28 +1169,28 @@ namespace Server
for (i = 0; i < AnimalForm.Entries.Length; ++i)
if (AnimalForm.Entries[i].Type == acontext.Type)
break;
if (m.Skills[SkillName.Ninjitsu].Value < AnimalForm.Entries[i].ReqSkill)
if (m.Skills.Ninjitsu.Value < AnimalForm.Entries[i].ReqSkill)
AnimalForm.RemoveContext(m, true);
}
if (!m.CanBeginAction(typeof(PolymorphSpell)) && m.Skills[SkillName.Magery].Value < 66.1)
if (!m.CanBeginAction<PolymorphSpell>() && m.Skills.Magery.Value < 66.1)
{
m.BodyMod = 0;
m.HueMod = -1;
m.NameMod = null;
m.EndAction(typeof(PolymorphSpell));
m.EndAction<PolymorphSpell>();
BaseArmor.ValidateMobile(m);
BaseClothing.ValidateMobile(m);
}
if (!m.CanBeginAction(typeof(IncognitoSpell)) && m.Skills[SkillName.Magery].Value < 38.1)
if (!m.CanBeginAction<IncognitoSpell>() && m.Skills.Magery.Value < 38.1)
{
if (m is PlayerMobile mobile)
mobile.SetHairMods(-1, -1);
m.BodyMod = 0;
m.HueMod = -1;
m.NameMod = null;
m.EndAction(typeof(IncognitoSpell));
m.EndAction<IncognitoSpell>();
BaseArmor.ValidateMobile(m);
BaseClothing.ValidateMobile(m);
BuffInfo.RemoveBuff(m, BuffIcon.Incognito);

View file

@ -86,9 +86,6 @@ namespace Server.Misc
{
private static Dictionary<Mobile, Timer> m_Dictionary = new Dictionary<Mobile, Timer>();
private static TimerStateCallback OnHandshakeTimeout_Callback = OnHandshakeTimeout;
private static TimerStateCallback OnForceDisconnect_Callback = OnForceDisconnect;
public static void Initialize()
{
if (Settings.Enabled)
@ -112,7 +109,7 @@ namespace Server.Misc
if (m_Dictionary.TryGetValue(m, out Timer t))
t?.Stop();
m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout_Callback, m);
m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout, m);
t.Start();
}
}
@ -133,9 +130,9 @@ namespace Server.Misc
}
}
private static void OnHandshakeTimeout(object state)
private static void OnHandshakeTimeout(Mobile m)
{
if (!(state is Mobile m))
if (m == null)
return;
m_Dictionary.Remove(m);
@ -145,30 +142,30 @@ namespace Server.Misc
// Console.WriteLine("Player '{0}' failed to negotiate features.", m);
// }
if (m.NetState != null && m.NetState.Running)
if (m.NetState?.Running == true)
{
m.SendGump(new WarningGump(1060635, 30720, Settings.WarningMessage, 0xFFC000, 420, 250, null, null));
m.SendGump(new WarningGump(1060635, 30720, Settings.WarningMessage, 0xFFC000, 420, 250));
if (m.AccessLevel <= AccessLevel.Player)
{
Timer t;
m_Dictionary[m] = t = Timer.DelayCall(Settings.DisconnectDelay, OnForceDisconnect_Callback, m);
m_Dictionary[m] = t = Timer.DelayCall(Settings.DisconnectDelay, OnForceDisconnect, m);
t.Start();
}
}
}
private static void OnForceDisconnect(object state)
private static void OnForceDisconnect(Mobile m)
{
if (state is Mobile m)
{
if (m.NetState != null && m.NetState.Running)
m.NetState.Dispose();
if (m == null)
return;
if (m.NetState != null && m.NetState.Running)
m.NetState.Dispose();
m_Dictionary.Remove(m);
m_Dictionary.Remove(m);
Console.WriteLine("Player {0} kicked (Failed assistant handshake)", m);
}
Console.WriteLine("Player {0} kicked (Failed assistant handshake)", m);
}
private sealed class BeginHandshake : ProtocolExtension

View file

@ -136,26 +136,27 @@ namespace Server.Misc
}
}
private static void KickMessage(Mobile from, bool okay)
{
from.SendMessage("You will be reminded of this again.");
if (m_OldClientResponse == OldClientResponse.LenientKick)
from.SendMessage(
"Old clients will be kicked after {0} days of character age and {1} hours of play time",
m_AgeLeniency, m_GameTimeLeniency);
Timer.DelayCall(TimeSpan.FromMinutes(Utility.Random(5, 15)), () => SendAnnoyGump(from));
}
private static void SendAnnoyGump(Mobile m)
{
if (m.NetState != null && m.NetState.Version < Required)
{
Gump g = new WarningGump(1060637, 30720,
$"Your client is out of date. Please update your client.<br>This server recommends that your client version be at least {Required}.<br> <br>You are currently using version {m.NetState.Version}.<br> <br>To patch, run UOPatch.exe inside your Ultima Online folder.",
0xFFC000, 480, 360,
delegate
{
m.SendMessage("You will be reminded of this again.");
0xFFC000, 480, 360, okay => KickMessage(m, okay), false);
if (m_OldClientResponse == OldClientResponse.LenientKick)
m.SendMessage(
"Old clients will be kicked after {0} days of character age and {1} hours of play time",
m_AgeLeniency, m_GameTimeLeniency);
Timer.DelayCall(TimeSpan.FromMinutes(Utility.Random(5, 15)), delegate { SendAnnoyGump(m); });
}, null, false);
g.Dragable = false;
g.Draggable = false;
g.Closable = false;
g.Resizable = false;

View file

@ -105,7 +105,7 @@ namespace Server.Items
{
if (from.InRange(GetWorldLocation(), 3))
{
from.CloseGump(typeof(MistletoeAddonGump));
from.CloseGump<MistletoeAddonGump>();
from.SendGump(new MistletoeAddonGump(from, this));
}
else
@ -216,7 +216,7 @@ namespace Server.Items
if (house != null && house.IsCoOwner(from))
{
from.SendLocalizedMessage(1062838); // Where would you like to place this decoration?
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget, null);
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget);
}
else
{
@ -229,7 +229,7 @@ namespace Server.Items
}
}
public void Placement_OnTarget(Mobile from, object targeted, object state)
public void Placement_OnTarget(Mobile from, object targeted)
{
if (!(targeted is IPoint3D p))
return;

View file

@ -65,7 +65,7 @@ namespace Server.Items
from.SendLocalizedMessage(1010097); // You cannot use this while mounted.
}
else if (from.CanBeginAction(typeof(SnowPile)))
else if (from.CanBeginAction<SnowPile>())
{
from.SendLocalizedMessage(1005575); // You carefully pack the snow into a ball...
from.Target = new SnowTarget(from, this);
@ -87,7 +87,7 @@ namespace Server.Items
protected override void OnTick()
{
m_From.EndAction(typeof(SnowPile));
m_From.EndAction<SnowPile>();
}
}
@ -112,13 +112,13 @@ namespace Server.Items
{
Container pack = targ.Backpack;
if (from.Region.IsPartOf(typeof(SafeZone)) || targ.Region.IsPartOf(typeof(SafeZone)))
if (from.Region.IsPartOf<SafeZone>() || targ.Region.IsPartOf<SafeZone>())
{
from.SendMessage("You may not throw snow here.");
}
else if (pack?.FindItemByType(new[] { typeof(SnowPile), typeof(PileOfGlacialSnow) }) != null)
{
if (from.BeginAction(typeof(SnowPile)))
if (from.BeginAction<SnowPile>())
{
new InternalTimer(from).Start();
@ -129,7 +129,7 @@ namespace Server.Items
targ.SendLocalizedMessage(1010572); // You have just been hit by a snowball!
from.SendLocalizedMessage(1010573); // You throw the snowball and hit the target!
Effects.SendMovingEffect(from, targ, 0x36E4, 7, 0, false, true, 0x47F, 0);
Effects.SendMovingEffect(from, targ, 0x36E4, 7, 0, false, true, 0x47F);
}
else
{

View file

@ -51,7 +51,7 @@ namespace Server.Items
from.SendLocalizedMessage(1010097); // You cannot use this while mounted.
}
else if (from.CanBeginAction(typeof(SnowPile)))
else if (from.CanBeginAction<SnowPile>())
{
from.SendLocalizedMessage(1005575); // You carefully pack the snow into a ball...
from.Target = new SnowTarget(from, this);
@ -73,7 +73,7 @@ namespace Server.Items
protected override void OnTick()
{
m_From.EndAction(typeof(SnowPile));
m_From.EndAction<SnowPile>();
}
}
@ -98,13 +98,13 @@ namespace Server.Items
{
Container pack = targ.Backpack;
if (from.Region.IsPartOf(typeof(SafeZone)) || targ.Region.IsPartOf(typeof(SafeZone)))
if (from.Region.IsPartOf<SafeZone>() || targ.Region.IsPartOf<SafeZone>())
{
from.SendMessage("You may not throw snow here.");
}
else if (pack?.FindItemByType(new[] { typeof(SnowPile), typeof(PileOfGlacialSnow) }) != null)
{
if (from.BeginAction(typeof(SnowPile)))
if (from.BeginAction<SnowPile>())
{
new InternalTimer(from).Start();
@ -115,7 +115,7 @@ namespace Server.Items
targ.SendLocalizedMessage(1010572); // You have just been hit by a snowball!
from.SendLocalizedMessage(1010573); // You throw the snowball and hit the target!
Effects.SendMovingEffect(from, targ, 0x36E4, 7, 0, false, true, 0x480, 0);
Effects.SendMovingEffect(from, targ, 0x36E4, 7, 0, false, true, 0x480);
}
else
{

View file

@ -314,28 +314,13 @@ namespace Server.Guilds
m_Members[i].GuildMessage(number);
}
public void AllianceMessage(int number, string args)
{
AllianceMessage(number, args, 0x3B2);
}
public void AllianceMessage(int number, string args, int hue)
public void AllianceMessage(int number, string args, int hue = 0x3B2)
{
for (int i = 0; i < m_Members.Count; ++i)
m_Members[i].GuildMessage(number, args, hue);
}
public void AllianceMessage(int number, bool append, string affix)
{
AllianceMessage(number, append, affix, "", 0x3B2);
}
public void AllianceMessage(int number, bool append, string affix, string args)
{
AllianceMessage(number, append, affix, args, 0x3B2);
}
public void AllianceMessage(int number, bool append, string affix, string args, int hue)
public void AllianceMessage(int number, bool append, string affix, string args = "", int hue = 0x3B2)
{
for (int i = 0; i < m_Members.Count; ++i)
m_Members[i].GuildMessage(number, append, affix, args, hue);
@ -483,9 +468,8 @@ namespace Server.Guilds
{
if (Kills > w.Kills)
return WarStatus.Win;
if (Kills < w.Kills)
return WarStatus.Lose;
return WarStatus.Draw;
return Kills < w.Kills ? WarStatus.Lose : WarStatus.Draw;
}
if (MaxKills > 0)
@ -534,8 +518,8 @@ namespace Server.Guilds
protected override void OnTick()
{
foreach (Guild g in BaseGuild.List.Values)
g.CheckExpiredWars();
foreach (BaseGuild g in BaseGuild.List.Values)
(g as Guild)?.CheckExpiredWars();
}
}
@ -583,7 +567,7 @@ namespace Server.Guilds
#endregion
}
public Guild(int id) : base(id) //serialization ctor
public Guild(uint id) : base(id) //serialization ctor
{
}
@ -674,7 +658,6 @@ namespace Server.Guilds
RemoveMember(mob);
}
public void Disband()
{
m_Leader = null;
@ -727,7 +710,7 @@ namespace Server.Guilds
}
else
{
Guild g = int.TryParse(arg, out int id)
Guild g = uint.TryParse(arg, out uint id)
? Find(id) as Guild
: FindByAbbrev(arg) as Guild ?? FindByName(arg) as Guild;
@ -751,7 +734,7 @@ namespace Server.Guilds
{
if (!BaseCommand.IsAccessible(from, o))
{
from.SendMessage("That is not accessible.");
from.SendLocalizedMessage(500447); // That is not accessible.
return;
}
@ -970,12 +953,7 @@ namespace Server.Guilds
}
}
public static void HandleDeath(Mobile victim)
{
HandleDeath(victim, null);
}
public static void HandleDeath(Mobile victim, Mobile killer)
public static void HandleDeath(Mobile victim, Mobile killer = null)
{
if (!NewGuildSystem)
return;
@ -1264,10 +1242,7 @@ namespace Server.Guilds
Members.Add(m);
m.Guild = this;
if (!NewGuildSystem)
m.GuildFealty = m_Leader;
else
m.GuildFealty = null;
m.GuildFealty = !NewGuildSystem ? m_Leader : null;
if (m is PlayerMobile mobile)
mobile.GuildRank = RankDefinition.Lowest;
@ -1276,12 +1251,7 @@ namespace Server.Guilds
}
}
public void RemoveMember(Mobile m)
{
RemoveMember(m, 1018028); // You have been dismissed from your guild.
}
public void RemoveMember(Mobile m, int message)
public void RemoveMember(Mobile m, int message = 1018028) // You have been dismissed from your guild.
{
if (Members.Contains(m))
{
@ -1599,4 +1569,4 @@ namespace Server.Guilds
#endregion
}
}
}

View file

@ -43,7 +43,7 @@ namespace Server.Misc
}
case 0x0035: // i renounce my young player status*
{
if (from is PlayerMobile mobile && mobile.Young && !mobile.HasGump(typeof(RenounceYoungGump)))
if (from is PlayerMobile mobile && mobile.Young && !mobile.HasGump<RenounceYoungGump>())
mobile.SendGump(new RenounceYoungGump());
break;

View file

@ -67,9 +67,7 @@ namespace Server
if (m_LevelOverride > int.MinValue)
return m_LevelOverride;
int hours, minutes;
Clock.GetTime(from.Map, from.X, from.Y, out hours, out minutes);
Clock.GetTime(from.Map, from.X, from.Y, out int hours, out int minutes);
/* OSI times:
*
@ -130,7 +128,7 @@ namespace Server
protected override void OnTick()
{
m_Owner.EndAction(typeof(LightCycle));
m_Owner.EndAction<LightCycle>();
m_Owner.LightLevel = 0;
BuffInfo.RemoveBuff(m_Owner, BuffIcon.NightSight);
}

View file

@ -105,14 +105,9 @@ namespace Server.Misc
pmTarg?.DuelContext != null && pmTarg.DuelContext.Started)
return false;
if (from.Region.GetRegion(typeof(SafeZone)) is SafeZone sz /*&& sz.IsDisabled()*/)
if (from.Region.IsPartOf<SafeZone>() || target.Region.IsPartOf<SafeZone>())
return false;
sz = target.Region.GetRegion(typeof(SafeZone)) as SafeZone;
if (sz != null /*&& sz.IsDisabled()*/)
return false;
#endregion
Map map = from.Map;
@ -191,12 +186,7 @@ namespace Server.Misc
pmTarg?.DuelContext != null && pmTarg.DuelContext.Started)
return false;
if (from.Region.GetRegion(typeof(SafeZone)) is SafeZone sz /*&& sz.IsDisabled()*/)
return false;
sz = target.Region.GetRegion(typeof(SafeZone)) as SafeZone;
if (sz != null /*&& sz.IsDisabled()*/)
if (from.Region.IsPartOf<SafeZone>() || target.Region.IsPartOf<SafeZone>())
return false;
#endregion
@ -408,7 +398,7 @@ namespace Server.Misc
if (bcTarg?.InitialInnocent != true)
if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bcTarg) && pmTarg == null ||
!Core.ML && !target.CanBeginAction(typeof(PolymorphSpell)))
!Core.ML && !target.CanBeginAction<PolymorphSpell>())
return Notoriety.CanBeAttacked;
if (CheckAggressor(source.Aggressors, target))

View file

@ -36,7 +36,7 @@ namespace Server.Misc
return true;
if (female && itemID == 0x2048 || !female && itemID == 0x2046)
return false; //Buns & Receeding Hair
return false; //Buns & Receding Hair
if (itemID >= 0x203B && itemID <= 0x203D)
return true;
@ -59,7 +59,7 @@ namespace Server.Misc
case 5: return 0x2047; //Afro
case 6: return 0x2049; //Pig tails
case 7: return 0x204A; //Krisna
default: return female ? 0x2046 : 0x2048; //Buns or Receeding Hair
default: return female ? 0x2046 : 0x2048; //Buns or Receding Hair
}
}
@ -284,16 +284,12 @@ namespace Server.Misc
public override bool ValidateFacialHair(bool female, int itemID)
{
if (female)
return false;
return itemID >= 0x42AD && itemID <= 0x42B0;
return !female && itemID >= 0x42AD && itemID <= 0x42B0;
}
public override int RandomFacialHair(bool female)
{
if (female)
return 0;
return Utility.RandomList(0, 0x42AD, 0x42AE, 0x42AF, 0x42B0);
return female ? 0 : Utility.RandomList(0, 0x42AD, 0x42AE, 0x42AF, 0x42B0);
}
public override int ClipSkinHue(int hue)

View file

@ -74,7 +74,7 @@ namespace Server.Misc
points += 20;
if (CheckAnimal(from, typeof(Dog)) || CheckAnimal(from, typeof(Cat)))
points += from.Skills[SkillName.Ninjitsu].Fixed / 30;
points += from.Skills.Ninjitsu.Fixed / 30;
return TimeSpan.FromSeconds(1.0 / (0.1 * (1 + points)));
}
@ -86,7 +86,7 @@ namespace Server.Misc
CheckBonusSkill(from, from.Stam, from.StamMax, SkillName.Focus);
int points = (int)(from.Skills[SkillName.Focus].Value * 0.1);
int points = (int)(from.Skills.Focus.Value * 0.1);
if (from is BaseCreature creature && creature.IsParagon || from is Leviathan)
points += 40;
@ -123,13 +123,13 @@ namespace Server.Misc
if (Core.AOS)
{
double medPoints = from.Int + from.Skills[SkillName.Meditation].Value * 3;
double medPoints = from.Int + from.Skills.Meditation.Value * 3;
medPoints *= from.Skills[SkillName.Meditation].Value < 100.0 ? 0.025 : 0.0275;
medPoints *= from.Skills.Meditation.Value < 100.0 ? 0.025 : 0.0275;
CheckBonusSkill(from, from.Mana, from.ManaMax, SkillName.Focus);
double focusPoints = from.Skills[SkillName.Focus].Value * 0.05;
double focusPoints = from.Skills.Focus.Value * 0.05;
if (armorPenalty > 0)
medPoints = 0; // In AOS, wearing any meditation-blocking armor completely removes meditation bonus
@ -161,7 +161,7 @@ namespace Server.Misc
}
else
{
double medPoints = (from.Int + from.Skills[SkillName.Meditation].Value) * 0.5;
double medPoints = (from.Int + from.Skills.Meditation.Value) * 0.5;
if (medPoints <= 0)
rate = 7.0;

View file

@ -147,14 +147,13 @@ namespace Server.Misc
if (m_ActivePollers.Count == 0)
return;
Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(EventSink_Login_Callback), e.Mobile);
Timer.DelayCall(TimeSpan.FromSeconds(1.0), EventSink_Login_Callback, e.Mobile);
}
private static void EventSink_Login_Callback(object state)
private static void EventSink_Login_Callback(Mobile from)
{
Mobile from = (Mobile)state;
NetState ns = from.NetState;
if (ns == null)
return;
@ -189,15 +188,6 @@ namespace Server.Misc
}
}
public void SendQueuedPoll_Callback(object state)
{
object[] states = (object[])state;
Mobile from = (Mobile)states[0];
Queue<ShardPoller> queue = (Queue<ShardPoller>)states[1];
from.SendGump(new ShardPollGump(from, this, false, queue));
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.Administrator)
@ -493,13 +483,13 @@ namespace Server.Misc
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Polls != null && m_Polls.Count > 0)
if (m_Polls?.Count > 0)
{
ShardPoller poller = m_Polls.Dequeue();
if (poller != null)
Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(poller.SendQueuedPoll_Callback),
new object[] { m_From, m_Polls });
Timer.DelayCall(TimeSpan.FromSeconds(1.0),
() => m_From.SendGump(new ShardPollGump(m_From, poller, false, m_Polls)));
}
if (info.ButtonID == 1)

View file

@ -206,7 +206,7 @@ namespace Server.Misc
public static void Gain(Mobile from, Skill skill)
{
if (from.Region.IsPartOf(typeof(Jail)))
if (from.Region.IsPartOf<Jail>())
return;
if (from is BaseCreature creature && creature.IsDeadPet)

View file

@ -34,8 +34,8 @@ namespace Server
new Rectangle2D(new Point2D(0, 0), new Point2D(288 * 8, 200 * 8))
};
private static Hashtable m_ShopTable;
private static ArrayList m_ShopList;
private static Dictionary<Point2D, ShopInfo> m_ShopTable;
private static List<ShopInfo> m_ShopList;
public static void Initialize()
{
@ -122,19 +122,19 @@ namespace Server
private static void Process(Map map, Rectangle2D[] regions)
{
m_ShopTable = new Hashtable();
m_ShopList = new ArrayList();
m_ShopTable = new Dictionary<Point2D, ShopInfo>();
m_ShopList = new List<ShopInfo>();
World.Broadcast(0x35, true, "Generating vendor spawns for {0}, please wait.", map);
for (int i = 0; i < regions.Length; ++i)
for (int x = 0; x < map.Width; ++x)
for (int y = 0; y < map.Height; ++y)
CheckPoint(map, regions[i].X + x, regions[i].Y + y);
for (int x = 0; x < map.Width; ++x)
for (int y = 0; y < map.Height; ++y)
CheckPoint(map, regions[i].X + x, regions[i].Y + y);
for (int i = 0; i < m_ShopList.Count; ++i)
{
ShopInfo si = (ShopInfo)m_ShopList[i];
ShopInfo si = m_ShopList[i];
int xTotal = 0;
int yTotal = 0;
@ -143,7 +143,7 @@ namespace Server
for (int j = 0; j < si.m_Floor.Count; ++j)
{
Point2D fp = (Point2D)si.m_Floor[j];
Point2D fp = si.m_Floor[j];
xTotal += fp.X;
yTotal += fp.Y;
@ -162,7 +162,7 @@ namespace Server
int xAvg = xTotal / si.m_Floor.Count;
int yAvg = yTotal / si.m_Floor.Count;
ArrayList names = new ArrayList();
List<string> names = new List<string>();
ShopFlags flags = si.m_Flags;
if ((flags & ShopFlags.Armor) != 0)
@ -209,11 +209,10 @@ namespace Server
{
Point2D cp = Point2D.Zero;
int dist = 100000;
int tz;
for (int k = 0; k < si.m_Floor.Count; ++k)
{
Point2D fp = (Point2D)si.m_Floor[k];
Point2D fp = si.m_Floor[k];
int rx = fp.X - xAvg;
int ry = fp.Y - yAvg;
@ -222,7 +221,7 @@ namespace Server
if (fd > 0 && fd < 5)
fd -= Utility.Random(10);
if (fd < dist && GetFloorZ(map, fp.X, fp.Y, out tz))
if (fd < dist && GetFloorZ(map, fp.X, fp.Y, out _))
{
dist = fd;
cp = fp;
@ -235,7 +234,7 @@ namespace Server
if (!GetFloorZ(map, cp.X, cp.Y, out int z))
continue;
new Spawner(1, 1, 1, 0, 4, (string)names[j]).MoveToWorld(new Point3D(cp.X, cp.Y, z), map);
new Spawner(1, 1, 1, 0, 4, names[j]).MoveToWorld(new Point3D(cp.X, cp.Y, z), map);
}
}
@ -393,24 +392,22 @@ namespace Server
if (flags != ShopFlags.None)
{
Point2D p = new Point2D(x, y);
ShopInfo si = (ShopInfo)m_ShopTable[p];
ShopInfo si = m_ShopTable[p];
if (si == null)
{
ArrayList floor = new ArrayList();
List<Point2D> floor = new List<Point2D>();
RecurseFindFloor(map, x, y, floor);
if (floor.Count == 0)
return;
si = new ShopInfo();
si.m_Flags = flags;
si.m_Floor = floor;
si = new ShopInfo { m_Flags = flags, m_Floor = floor };
m_ShopList.Add(si);
for (int i = 0; i < floor.Count; ++i)
m_ShopTable[(Point2D)floor[i]] = si;
m_ShopTable[floor[i]] = si;
}
else
{
@ -477,7 +474,7 @@ namespace Server
return hasSurface;
}
private static void RecurseFindFloor(Map map, int x, int y, ArrayList floor)
private static void RecurseFindFloor(Map map, int x, int y, List<Point2D> floor)
{
Point2D p = new Point2D(x, y);
@ -511,7 +508,7 @@ namespace Server
private class ShopInfo
{
public ShopFlags m_Flags;
public ArrayList m_Floor;
public List<Point2D> m_Floor;
}
}
}
}

View file

@ -280,15 +280,15 @@ namespace Server
{
int z = map.GetAverageZ(x, y);
if (map.CanFit(x, y, z, 16, false, false, true))
if (map.CanFit(x, y, z, 16, false, false))
return z;
for (int i = 1; i <= 20; ++i)
{
if (map.CanFit(x, y, z + i, 16, false, false, true))
if (map.CanFit(x, y, z + i, 16, false, false))
return z + i;
if (map.CanFit(x, y, z - i, 16, false, false, true))
if (map.CanFit(x, y, z - i, 16, false, false))
return z - i;
}