Fix non 32bpp terrain atlases crashing the client, remove some leftover debug stuff.

This commit is contained in:
UnknownShadow200 2015-10-03 06:57:20 +10:00
parent e5cd574dae
commit 728785ed6c
8 changed files with 22 additions and 9 deletions

View file

@ -88,7 +88,14 @@ namespace ClassicalSharp {
public override void Dispose() {
g.Dispose();
g = null;
}
}
public override Bitmap ConvertTo32Bpp( Bitmap src ) {
Bitmap bmp = new Bitmap( src.Width, src.Height );
using( Graphics g = Graphics.FromImage( bmp ) )
g.DrawImage( src, 0, 0, src.Width, src.Height );
return bmp;
}
public override Size MeasureSize( string text, Font font, bool shadow ) {
GetTextParts( text );

View file

@ -24,6 +24,7 @@ namespace ClassicalSharp {
/// <summary> Disposes of any resources used by this class that are associated with the underlying bitmap. </summary>
public abstract void Dispose();
public abstract Bitmap ConvertTo32Bpp( Bitmap src );
public abstract Size MeasureSize( string text, Font font, bool shadow );

View file

@ -84,7 +84,6 @@ namespace ClassicalSharp {
return;
}
text = Path.ChangeExtension( text, ".cw" );
Console.WriteLine( text );
if( File.Exists( text ) ) {
MakeDescWidget( "&eFilename already exists" );

View file

@ -114,7 +114,7 @@ namespace ClassicalSharp {
AsyncDownloader = new AsyncDownloader( skinServer );
Graphics.PrintGraphicsInfo();
TerrainAtlas1D = new TerrainAtlas1D( Graphics );
TerrainAtlas = new TerrainAtlas2D( Graphics );
TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D );
Animations = new Animations( this );
TexturePackExtractor extractor = new TexturePackExtractor();
extractor.Extract( defaultTexPack, this );

View file

@ -179,7 +179,6 @@ namespace ClassicalSharp {
bool NeedsUpdate( int x1, int y1, int z1, int x2, int y2, int z2 ) {
byte b1 = game.Map.SafeGetBlock( x1, y1, z1 );
byte b2 = game.Map.SafeGetBlock( x2, y2, z2 );
Console.WriteLine( (Block)b1 + " : " + (Block)b2 );
return (!info.IsOpaque[b1] && info.IsOpaque[b2]) || !(info.IsOpaque[b1] && b2 == 0);
}
@ -198,7 +197,6 @@ namespace ClassicalSharp {
void ResetChunk( int cx, int cy, int cz ) {
if( cx < 0 || cy < 0 || cz < 0 ||
cx >= chunksX || cy >= chunksY || cz >= chunksZ ) return;
Console.WriteLine( cx + " : " + cy + " : " + cz );
DeleteChunk( unsortedChunks[cx + chunksX * ( cy + cz * chunksY )] );
}

View file

@ -23,12 +23,20 @@ namespace ClassicalSharp {
public int elementSize;
public int TexId;
IGraphicsApi graphics;
IDrawer2D drawer;
public TerrainAtlas2D( IGraphicsApi graphics ) {
public TerrainAtlas2D( IGraphicsApi graphics, IDrawer2D drawer ) {
this.graphics = graphics;
this.drawer = drawer;
}
public void UpdateState( Bitmap bmp ) {
if( !FastBitmap.CheckFormat( bmp.PixelFormat ) ) {
Utils.LogWarning( "Converting terrain atlas to 32bpp image" );
Bitmap newBmp = drawer.ConvertTo32Bpp( bmp );
bmp.Dispose();
bmp = newBmp;
}
AtlasBitmap = bmp;
elementSize = bmp.Width >> 4;
using( FastBitmap fastBmp = new FastBitmap( bmp, true ) ) {

View file

@ -41,7 +41,7 @@
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>

View file

@ -235,7 +235,7 @@ namespace Launcher {
data.Ip + " " + data.Port + " " + skinServer;
System.Diagnostics.Debug.WriteLine( "starting..." + args );
Process process = null;
UpdateOptions( data, classicubeSkins );
UpdateResumeInfo( data, classicubeSkins );
try {
if( Type.GetType( "Mono.Runtime" ) != null ) {
@ -282,7 +282,7 @@ namespace Launcher {
return new String( c );
}
internal static void UpdateOptions( GameStartData data, bool classiCubeSkins ) {
internal static void UpdateResumeInfo( GameStartData data, bool classiCubeSkins ) {
Options.Set( "launcher-username", data.Username );
Options.Set( "launcher-ip", data.Ip );
Options.Set( "launcher-port", data.Port );