Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 • committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -94,16 +94,16 @@ namespace Server
if (Insensitive.Equals(m_RaceNames[i], value))
return m_RaceValues[i];
if (int.TryParse(value, out int index))
if (index >= 0 && index < Races.Length && Races[index] != null)
return Races[index];
if (int.TryParse(value, out int index) && index >= 0 && index < Races.Length &&
Races[index] != null)
return Races[index];
throw new ArgumentException("Invalid race name");
}
private static void CheckNamesAndValues()
{
if (m_RaceNames != null && m_RaceNames.Length == AllRaces.Count)
if (m_RaceNames?.Length == AllRaces.Count)
return;
m_RaceNames = new string[AllRaces.Count];
@ -182,4 +182,4 @@ namespace Server
return female ? FemaleGhostBody : MaleGhostBody;
}
}
}
}