Code cleanup (#188)

This commit is contained in:
Kamron Batman 2020-08-01 08:40:06 -07:00 • committed by GitHub
parent df53c16620
commit 010fd9402a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
185 changed files with 1052 additions and 1271 deletions

View file

@ -271,7 +271,7 @@ namespace Server.Engines.ConPVP
Timer.DelayCall(TimeSpan.FromSeconds(2.0), Evict);
if (m_Tournament != null)
Timer.DelayCall(TimeSpan.Zero, AttachToTournament_Sandbox);
Timer.DelayCall(AttachToTournament_Sandbox);
}
[CommandProperty(AccessLevel.GameMaster)]
@ -345,21 +345,7 @@ namespace Server.Engines.ConPVP
set => m_Bounds = value;
}
public int Spectators
{
get
{
if (m_Region == null)
return 0;
int specs = m_Region.GetPlayerCount() - Players.Count;
if (specs < 0)
specs = 0;
return specs;
}
}
public int Spectators => m_Region == null ? 0 : Math.Max(m_Region.GetPlayerCount() - Players.Count, 0);
[CommandProperty(AccessLevel.GameMaster)]
public Rectangle2D Zone
@ -476,22 +462,13 @@ namespace Server.Engines.ConPVP
public override string ToString() => "...";
public Point3D GetBaseStartPoint(int index)
{
if (index < 0)
index = 0;
return Points.Points[index % Points.Points.Length];
}
public Point3D GetBaseStartPoint(int index) => Points.Points[Math.Max(index, 0) % Points.Points.Length];
public void MoveInside(DuelPlayer[] players, int index)
{
if (index < 0)
index = 0;
else
index %= Points.Points.Length;
index = Math.Min(index, 0) % Points.Points.Length;
Point3D start = GetBaseStartPoint(index);
Point3D start = Points.Points[index];
int offset = 0;
@ -512,7 +489,7 @@ namespace Server.Engines.ConPVP
if (offset < offsets.Length)
p = offsets[offset++];
else
p = offsets[offsets.Length - 1];
p = offsets[^1];
p.X = p.X * matrix[0, 0] + p.Y * matrix[0, 1];
p.Y = p.X * matrix[1, 0] + p.Y * matrix[1, 1];

View file

@ -114,7 +114,7 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
}
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) => (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false;

View file

@ -68,7 +68,7 @@ namespace Server.Engines.ConPVP
}
}
Timer.DelayCall(TimeSpan.Zero, Delete).Start(); // delete this after the world loads
Timer.DelayCall(Delete); // delete this after the world loads
}
public override void Serialize(IGenericWriter writer)
@ -202,7 +202,7 @@ namespace Server.Engines.ConPVP
m_Path.Clear();
m_PathIdx = 0;
Timer.DelayCall(TimeSpan.FromSeconds(0.05), ContinueFlight).Start();
Timer.DelayCall(TimeSpan.FromSeconds(0.05), ContinueFlight);
}
private bool CheckCatch(Mobile m, Point3D myLoc)
@ -292,7 +292,7 @@ namespace Server.Engines.ConPVP
if (list.Count > 0)
{
Point3D p = list[list.Count - 1];
Point3D p = list[^1];
if (p.X != ix || p.Y != iy || p.Z != iz)
list.Add(new Point3D(ix, iy, iz));
@ -307,7 +307,7 @@ namespace Server.Engines.ConPVP
z += zslp;
}
if (list.Count > 0 && list[list.Count - 1] != dest)
if (list.Count > 0 && list[^1] != dest)
list.Add(dest);
/*if (dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ))
@ -540,7 +540,7 @@ namespace Server.Engines.ConPVP
if (m_PathIdx > 0 && m_PathIdx - 1 < m_Path.Count)
DoAnim(GetWorldLocation(), m_Path[m_PathIdx - 1], Map);
Timer.DelayCall(TimeSpan.FromSeconds(0.1), ContinueFlight).Start();
Timer.DelayCall(TimeSpan.FromSeconds(0.1), ContinueFlight);
}
else
{
@ -734,7 +734,7 @@ namespace Server.Engines.ConPVP
// has to be delayed in case some other target canceled us...
if (m_Resend)
Timer.DelayCall(TimeSpan.Zero, ResendBombTarget).Start();
Timer.DelayCall(ResendBombTarget);
}
private void ResendBombTarget()
@ -1499,7 +1499,7 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
}
private void DelayBounce_Callback(Mobile mob, Container corpse)

View file

@ -877,7 +877,7 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
}
private void DelayBounce_Callback(Mobile mob, Container corpse)

View file

@ -516,7 +516,7 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
}
private void DelayBounce_Callback(Mobile mob, Container corpse)
@ -846,7 +846,6 @@ namespace Server.Engines.ConPVP
{
m_CapStage = 0;
m_CaptureTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.0), CaptureTick);
m_CaptureTimer.Start();
}
}

View file

@ -883,7 +883,7 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
}
private void DelayBounce_Callback(Mobile mob, Container corpse)

View file

@ -657,7 +657,7 @@ namespace Server.Engines.ConPVP
m_PerPage = perPage;
index = Math.Max(m_Page * perPage, 0);
count = Math.Max(Math.Min(m_List.Count - index, perPage), 0);
count = Math.Clamp(m_List.Count - index, 0, perPage);
y = 53 + (12 - perPage) * 18;

View file

@ -173,7 +173,7 @@ namespace Server.Engines.ConPVP
}
Resize(Players.Length + 1);
Players[Players.Length - 1] = new DuelPlayer(player, this);
Players[^1] = new DuelPlayer(player, this);
}
public void Resize(int count)

View file

@ -433,7 +433,7 @@ namespace Server.Engines.ConPVP
if (Pyramid.Levels.Count < 1)
break;
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
PyramidLevel top = Pyramid.Levels[^1];
if (top.FreeAdvance != null || top.Matches.Count != 1)
break;
@ -451,7 +451,7 @@ namespace Server.Engines.ConPVP
if (Pyramid.Levels.Count < 2)
break;
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
PyramidLevel top = Pyramid.Levels[^1];
if (top.FreeAdvance != null || top.Matches.Count != 1)
break;
@ -471,7 +471,7 @@ namespace Server.Engines.ConPVP
GiveAwards(part.Players, TrophyRank.Silver, cash / 2);
}
PyramidLevel next = Pyramid.Levels[Pyramid.Levels.Count - 2];
PyramidLevel next = Pyramid.Levels[^2];
if (next.Matches.Count > 2)
break;
@ -739,7 +739,7 @@ namespace Server.Engines.ConPVP
}
else if (Pyramid.Levels.Count > 0)
{
PyramidLevel activeLevel = Pyramid.Levels[Pyramid.Levels.Count - 1];
PyramidLevel activeLevel = Pyramid.Levels[^1];
bool stillGoing = false;
for (int i = 0; i < activeLevel.Matches.Count; ++i)