Merging of core and scripts
I'm thinking about making an executable that compiles the scripts subfolder and a core one(with the core code) into an executable only. The compiler would be removed from the core code, which would only load the world, making starting the server up faster and recompiles optional. Other advantages:
-Being able to remove some extra interface code (like IAccount) that makes some casts mandatory to integrate core and scripts
-Being able to use code defined in scripts in the core (for example, using a check in the item packet to see if the PlayerMobile has IsHallucinating true..)
-Being able to change stuff in the core easily (like accesslevels), recompiling with just a double click
-Making it easier to send just a Server.exe file and the Data/Saves to your host, instead of sending the entire scripts folder
So, what do you guys think about it?
EDIT:
Did it! With only one method modified in the core It isn't half as optimized as it could be, and definately not well tested but it does the job
With this mod the server still verifies scripts on startup, dunno if I should move that to the compiler to make it even faster...
WARNING: Do not try this out on a real shard, this is test only, only try it if you know what you're doing..
On ScriptCompiler.cs, use this Compile method instead of the original one:
And you can get the Source/Project for VS2003 of the compiler (most of it was straight from the core and could use some useless-method-deletion to leave only the needed parts):
http://www.nogard.net/Compiler.zip
I'm thinking about making an executable that compiles the scripts subfolder and a core one(with the core code) into an executable only. The compiler would be removed from the core code, which would only load the world, making starting the server up faster and recompiles optional. Other advantages:
-Being able to remove some extra interface code (like IAccount) that makes some casts mandatory to integrate core and scripts
-Being able to use code defined in scripts in the core (for example, using a check in the item packet to see if the PlayerMobile has IsHallucinating true..)
-Being able to change stuff in the core easily (like accesslevels), recompiling with just a double click
-Making it easier to send just a Server.exe file and the Data/Saves to your host, instead of sending the entire scripts folder
So, what do you guys think about it?
EDIT:
Did it! With only one method modified in the core It isn't half as optimized as it could be, and definately not well tested but it does the job
With this mod the server still verifies scripts on startup, dunno if I should move that to the compiler to make it even faster...
WARNING: Do not try this out on a real shard, this is test only, only try it if you know what you're doing..
On ScriptCompiler.cs, use this Compile method instead of the original one:
Code:
public static bool Compile( bool debug )
{
int a = 0;
m_Assemblies = new Assembly[] { Core.Assembly };
Console.Write( "Scripts: Verifying..." );
Core.VerifySerialization();
Console.WriteLine( "done ({0} items, {1} mobiles)", Core.ScriptItems, Core.ScriptMobiles );
ArrayList invoke = new ArrayList();
for (a=0;a<m_Assemblies.Length;++a)
{
Type[] types = m_Assemblies[a].GetTypes();
for ( int i = 0; i < types.Length; ++i )
{
MethodInfo m = types[i].GetMethod( "Configure", BindingFlags.Static | BindingFlags.Public );
if ( m != null )
invoke.Add( m );
//m.Invoke( null, null );
}
}
invoke.Sort( new CallPriorityComparer() );
for ( int i = 0; i < invoke.Count; ++i )
((MethodInfo)invoke[i]).Invoke( null, null );
invoke.Clear();
World.Load();
for (a=0;a<m_Assemblies.Length;++a)
{
Type[] types = m_Assemblies[a].GetTypes();
for ( int i = 0; i < types.Length; ++i )
{
if ( !types[i].Equals( typeof( Server.Network.NetState ) ) )
{
MethodInfo m = types[i].GetMethod( "Initialize", BindingFlags.Static | BindingFlags.Public );
if ( m != null )
invoke.Add( m );
//m.Invoke( null, null );
}
}
}
invoke.Sort( new CallPriorityComparer() );
for ( int i = 0; i < invoke.Count; ++i )
((MethodInfo)invoke[i]).Invoke( null, null );
return true;
}
And you can get the Source/Project for VS2003 of the compiler (most of it was straight from the core and could use some useless-method-deletion to leave only the needed parts):
http://www.nogard.net/Compiler.zip