Removes old comparable/comparers. (#31)

This commit is contained in:
Kamron Batman 2019-03-11 15:35:04 -07:00 • committed by GitHub
parent 513e54f70e
commit a45094f2dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 95 additions and 249 deletions

View file

@ -3,7 +3,7 @@ using Server.Accounting;
namespace Server.Engines.Reports
{
public abstract class BaseInfo : IComparable
public abstract class BaseInfo : IComparable<BaseInfo>
{
private string m_Display;
@ -51,19 +51,14 @@ namespace Server.Engines.Reports
}
}
public int CompareTo(object obj)
public int CompareTo(BaseInfo cmp)
{
BaseInfo cmp = obj as BaseInfo;
int v = cmp.GetPageCount(cmp is StaffInfo ? PageResolution.Handled : PageResolution.None,
DateTime.UtcNow - SortRange, DateTime.UtcNow)
int v = cmp?.GetPageCount(cmp is StaffInfo ? PageResolution.Handled : PageResolution.None,
DateTime.UtcNow - SortRange, DateTime.UtcNow) ?? 0
- GetPageCount(this is StaffInfo ? PageResolution.Handled : PageResolution.None,
DateTime.UtcNow - SortRange, DateTime.UtcNow);
if (v == 0)
v = string.Compare(Display, cmp.Display);
return v;
return v == 0 ? string.Compare(Display, cmp.Display) : v;
}
public int GetPageCount(PageResolution res, DateTime min, DateTime max)
@ -95,4 +90,4 @@ namespace Server.Engines.Reports
{
}
}
}
}

View file

@ -133,7 +133,7 @@ namespace Server.Engines.Reports
if (ladder == null)
return chart;
List<LadderEntry> entries = ladder.Entries;
for (int i = entries.Count - 1; i >= 0; --i)
@ -205,7 +205,7 @@ namespace Server.Engines.Reports
if (prefs == null)
return chart;
List<Arena> arenas = Arena.Arenas;
for (int i = 0; i < arenas.Count; ++i)
@ -528,7 +528,7 @@ namespace Server.Engines.Reports
return report;
}
public class SkillDistribution : IComparable
public class SkillDistribution : IComparable<SkillDistribution>
{
public int m_NumberOfGMs;
public SkillInfo m_Skill;
@ -538,10 +538,10 @@ namespace Server.Engines.Reports
m_Skill = skill;
}
public int CompareTo(object obj)
public int CompareTo(SkillDistribution sd)
{
return ((SkillDistribution)obj).m_NumberOfGMs - m_NumberOfGMs;
return sd?.m_NumberOfGMs ?? 0 - m_NumberOfGMs;
}
}
}
}
}