testing a whim

This commit is contained in:
mark 2007-09-14 06:40:55 +00:00
parent 9f07fb8c53
commit 9ac7b27606
2 changed files with 51 additions and 6 deletions

View file

@ -109,8 +109,12 @@ namespace Server
private static bool m_MultiProcessor;
private static int m_ProcessorCount;
public static bool MultiProcessor { get { return m_MultiProcessor; } set { m_MultiProcessor = value; } }
public static int ProcessorCount { get { return m_ProcessorCount; } set { m_ProcessorCount = value; } }
public static bool MultiProcessor { get { return m_MultiProcessor; } }
public static int ProcessorCount { get { return m_ProcessorCount; } }
private static bool m_Unix;
public static bool Unix { get { return m_Unix; } }
public static string FindDataFile( string path )
{
@ -422,15 +426,19 @@ namespace Server
if( s.Length > 0 )
Console.WriteLine( "Core: Running with arguments: {0}", s );
int processorCount = Environment.ProcessorCount;
m_ProcessorCount = Environment.ProcessorCount;
if( processorCount > 1 )
if( m_ProcessorCount > 1 )
m_MultiProcessor = true;
if( m_MultiProcessor || Is64Bit )
Console.WriteLine( "Core: Optimizing for {0} {2}processor{1}", processorCount, processorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : "" );
m_ProcessorCount = processorCount;
int platform = (int)Environment.OSVersion.Platform;
if ( ( platform == 4 ) || ( platform == 128 ) ) { // MS 4, MONO 128
m_Unix = true;
Console.WriteLine( "Core: Unix environment detected" );
}
while( !ScriptCompiler.Compile( m_Debug, m_Cache ) )
{

View file

@ -177,7 +177,9 @@ namespace Server.Network {
public static readonly ICompressor Compressor;
static Compression() {
if ( Core.Is64Bit )
if ( Core.Unix )
Compressor = new CompressorUnix();
else if ( Core.Is64Bit )
Compressor = new Compressor64();
else
Compressor = new Compressor32();
@ -277,6 +279,41 @@ namespace Server.Network {
}
}
public sealed class CompressorUnix : ICompressor {
[DllImport( "libz" )]
private static extern string zlibVersion();
[DllImport( "libz" )]
private static extern ZLibError compress( byte[] dest, ref int destLength, byte[] source, int sourceLength );
[DllImport( "libz" )]
private static extern ZLibError compress2( byte[] dest, ref int destLength, byte[] source, int sourceLength, ZLibQuality quality );
[DllImport( "libz" )]
private static extern ZLibError uncompress( byte[] dest, ref int destLen, byte[] source, int sourceLen );
public CompressorUnix() {
}
public string Version {
get {
return zlibVersion();
}
}
public ZLibError Compress( byte[] dest, ref int destLength, byte[] source, int sourceLength ) {
return compress( dest, ref destLength, source, sourceLength );
}
public ZLibError Compress( byte[] dest, ref int destLength, byte[] source, int sourceLength, ZLibQuality quality ) {
return compress2( dest, ref destLength, source, sourceLength, quality );
}
public ZLibError Decompress( byte[] dest, ref int destLength, byte[] source, int sourceLength ) {
return uncompress( dest, ref destLength, source, sourceLength );
}
}
public enum ZLibError : int {
VersionError = -6,
BufferError = -5,