Fixes dictionary uses (#7)

This commit is contained in:
Kamron Batman 2018-11-02 08:16:42 -07:00 committed by GitHub
parent d4a52344f2
commit 916d404c51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
161 changed files with 1211 additions and 1722 deletions

View file

@ -70,10 +70,7 @@ namespace Server.Spells
public static int GetRegistryNumber(Type type)
{
if (m_IDsFromTypes.ContainsKey(type))
return m_IDsFromTypes[type];
return -1;
return m_IDsFromTypes.TryGetValue(type, out int value) ? value : -1;
}
public static void Register(int spellID, Type type)
@ -99,6 +96,7 @@ namespace Server.Spells
}
catch
{
// ignored
}
if (spm != null)
@ -113,10 +111,11 @@ namespace Server.Spells
Type t = m_Types[spellID];
if (t == null || !t.IsSubclassOf(typeof(SpecialMove)) || !SpecialMoves.ContainsKey(spellID))
if (t == null || !t.IsSubclassOf(typeof(SpecialMove)))
return null;
return SpecialMoves[spellID];
SpecialMoves.TryGetValue(spellID, out SpecialMove move);
return move;
}
public static Spell NewSpell(int spellID, Mobile caster, Item scroll)
@ -167,4 +166,4 @@ namespace Server.Spells
return null;
}
}
}
}