Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -3,167 +3,168 @@ using System.Collections.Generic;
namespace Server.Spells
{
public class SpellRegistry
{
private static Type[] m_Types = new Type[700];
private static int m_Count;
public class SpellRegistry
{
private static Type[] m_Types = new Type[700];
private static int m_Count;
public static Type[] Types
{
get
{
m_Count = -1;
return m_Types;
}
}
private static Dictionary<Type, int> m_IDsFromTypes = new Dictionary<Type, int>(m_Types.Length);
//What IS this used for anyways.
public static int Count
{
get
{
if ( m_Count == -1 )
{
m_Count = 0;
private static object[] m_Params = new object[2];
for ( int i = 0; i < m_Types.Length; ++i )
if ( m_Types[i] != null )
++m_Count;
}
private static string[] m_CircleNames =
{
"First",
"Second",
"Third",
"Fourth",
"Fifth",
"Sixth",
"Seventh",
"Eighth",
"Necromancy",
"Chivalry",
"Bushido",
"Ninjitsu",
"Spellweaving"
};
return m_Count;
}
}
public static Type[] Types
{
get
{
m_Count = -1;
return m_Types;
}
}
private static Dictionary<Type, int> m_IDsFromTypes = new Dictionary<Type, int>( m_Types.Length );
//What IS this used for anyways.
public static int Count
{
get
{
if (m_Count == -1)
{
m_Count = 0;
public static Dictionary<int, SpecialMove> SpecialMoves { get; } = new Dictionary<int, SpecialMove>();
for (int i = 0; i < m_Types.Length; ++i)
if (m_Types[i] != null)
++m_Count;
}
public static int GetRegistryNumber( ISpell s )
{
return GetRegistryNumber( s.GetType() );
}
return m_Count;
}
}
public static int GetRegistryNumber( SpecialMove s )
{
return GetRegistryNumber( s.GetType() );
}
public static Dictionary<int, SpecialMove> SpecialMoves{ get; } = new Dictionary<int, SpecialMove>();
public static int GetRegistryNumber( Type type )
{
if ( m_IDsFromTypes.ContainsKey( type ) )
return m_IDsFromTypes[type];
public static int GetRegistryNumber(ISpell s)
{
return GetRegistryNumber(s.GetType());
}
return -1;
}
public static int GetRegistryNumber(SpecialMove s)
{
return GetRegistryNumber(s.GetType());
}
public static void Register( int spellID, Type type )
{
if ( spellID < 0 || spellID >= m_Types.Length )
return;
public static int GetRegistryNumber(Type type)
{
if (m_IDsFromTypes.ContainsKey(type))
return m_IDsFromTypes[type];
if ( m_Types[spellID] == null )
++m_Count;
return -1;
}
m_Types[spellID] = type;
public static void Register(int spellID, Type type)
{
if (spellID < 0 || spellID >= m_Types.Length)
return;
if ( !m_IDsFromTypes.ContainsKey( type ) )
m_IDsFromTypes.Add( type, spellID );
if (m_Types[spellID] == null)
++m_Count;
if ( type.IsSubclassOf( typeof( SpecialMove ) ) )
{
SpecialMove spm = null;
m_Types[spellID] = type;
try
{
spm = Activator.CreateInstance( type ) as SpecialMove;
}
catch
{
}
if (!m_IDsFromTypes.ContainsKey(type))
m_IDsFromTypes.Add(type, spellID);
if ( spm != null )
SpecialMoves.Add( spellID, spm );
}
}
if (type.IsSubclassOf(typeof(SpecialMove)))
{
SpecialMove spm = null;
public static SpecialMove GetSpecialMove( int spellID )
{
if ( spellID < 0 || spellID >= m_Types.Length )
return null;
try
{
spm = Activator.CreateInstance(type) as SpecialMove;
}
catch
{
}
Type t = m_Types[spellID];
if (spm != null)
SpecialMoves.Add(spellID, spm);
}
}
if ( t == null || !t.IsSubclassOf( typeof( SpecialMove ) ) || !SpecialMoves.ContainsKey( spellID ) )
return null;
public static SpecialMove GetSpecialMove(int spellID)
{
if (spellID < 0 || spellID >= m_Types.Length)
return null;
return SpecialMoves[spellID];
}
Type t = m_Types[spellID];
private static object[] m_Params = new object[2];
if (t == null || !t.IsSubclassOf(typeof(SpecialMove)) || !SpecialMoves.ContainsKey(spellID))
return null;
public static Spell NewSpell( int spellID, Mobile caster, Item scroll )
{
if ( spellID < 0 || spellID >= m_Types.Length )
return null;
return SpecialMoves[spellID];
}
Type t = m_Types[spellID];
public static Spell NewSpell(int spellID, Mobile caster, Item scroll)
{
if (spellID < 0 || spellID >= m_Types.Length)
return null;
if ( t != null && !t.IsSubclassOf( typeof( SpecialMove ) ) )
{
m_Params[0] = caster;
m_Params[1] = scroll;
Type t = m_Types[spellID];
try
{
return (Spell)Activator.CreateInstance( t, m_Params );
}
catch
{
}
}
if (t != null && !t.IsSubclassOf(typeof(SpecialMove)))
{
m_Params[0] = caster;
m_Params[1] = scroll;
return null;
}
try
{
return (Spell)Activator.CreateInstance(t, m_Params);
}
catch
{
}
}
private static string[] m_CircleNames = {
"First",
"Second",
"Third",
"Fourth",
"Fifth",
"Sixth",
"Seventh",
"Eighth",
"Necromancy",
"Chivalry",
"Bushido",
"Ninjitsu",
"Spellweaving"
};
return null;
}
public static Spell NewSpell( string name, Mobile caster, Item scroll )
{
for ( int i = 0; i < m_CircleNames.Length; ++i )
{
Type t = ScriptCompiler.FindTypeByFullName($"Server.Spells.{m_CircleNames[i]}.{name}");
public static Spell NewSpell(string name, Mobile caster, Item scroll)
{
for (int i = 0; i < m_CircleNames.Length; ++i)
{
Type t = ScriptCompiler.FindTypeByFullName($"Server.Spells.{m_CircleNames[i]}.{name}");
if ( t != null && !t.IsSubclassOf( typeof( SpecialMove ) ) )
{
m_Params[0] = caster;
m_Params[1] = scroll;
if (t != null && !t.IsSubclassOf(typeof(SpecialMove)))
{
m_Params[0] = caster;
m_Params[1] = scroll;
try
{
return (Spell)Activator.CreateInstance( t, m_Params );
}
catch
{
}
}
}
try
{
return (Spell)Activator.CreateInstance(t, m_Params);
}
catch
{
}
}
}
return null;
}
}
}
return null;
}
}
}