diff --git a/Entities/Player.cs b/Entities/Player.cs index 4e2ce8cb6..8a5a8738f 100644 --- a/Entities/Player.cs +++ b/Entities/Player.cs @@ -111,15 +111,26 @@ namespace ClassicalSharp { if( item != null && item.Bmp != null ) { Bitmap bmp = item.Bmp; Window.Graphics.DeleteTexture( ref renderer.PlayerTextureId ); - renderer.PlayerTextureId = Window.Graphics.LoadTexture( bmp ); - // Custom mob textures. - renderer.MobTextureId = -1; - if( Utils.IsUrl( item.Url ) && item.TimeAdded > lastModelChange ) { - renderer.MobTextureId = renderer.PlayerTextureId; + + try { + SkinType = Utils.GetSkinType( bmp ); + renderer.PlayerTextureId = Window.Graphics.LoadTexture( bmp ); + renderer.MobTextureId = -1; + + // Custom mob textures. + if( Utils.IsUrl( item.Url ) && item.TimeAdded > lastModelChange ) { + renderer.MobTextureId = renderer.PlayerTextureId; + } + } catch( NotSupportedException ) { + string formatString = "Skin {0} has unsupported dimensions({1}, {2}), reverting to default."; + Utils.LogWarning( formatString, SkinName, bmp.Width, bmp.Height ); + renderer.MobTextureId = -1; + renderer.PlayerTextureId = -1; + SkinType = Window.DefaultPlayerSkinType; } - SkinType = Utils.GetSkinType( bmp ); bmp.Dispose(); } + } DateTime lastModelChange = new DateTime( 1, 1, 1 ); diff --git a/Network/NetworkProcessor.cs b/Network/NetworkProcessor.cs index 85435b83b..0ed6c72d8 100644 --- a/Network/NetworkProcessor.cs +++ b/Network/NetworkProcessor.cs @@ -347,7 +347,7 @@ namespace ClassicalSharp { map = null; gzipStream.Close(); if( sendWomId && !sentWomId ) { - SendChat( "/womid WoMClient-2.0.6" ); + SendChat( "/womid WoMClient-2.0.7" ); sentWomId = true; } gzipStream = null; diff --git a/Utils/Utils.cs b/Utils/Utils.cs index 658001abf..0fef3ad10 100644 --- a/Utils/Utils.cs +++ b/Utils/Utils.cs @@ -6,7 +6,7 @@ using OpenTK; namespace ClassicalSharp { // NOTE: These delegates should be removed when using versions later than NET 2.0. - // ################################################################ + // ################################################################ public delegate void Action(); public delegate void Action( T1 arg1, T2 arg2 ); public delegate void Action( T1 arg1, T2 arg2, T3 arg3 ); @@ -212,13 +212,18 @@ namespace ClassicalSharp { } public static SkinType GetSkinType( Bitmap bmp ) { - if( bmp.Width == 64 && bmp.Height == 32 ) { + if( bmp.Width == bmp.Height * 2 ) { return SkinType.Type64x32; - } else if( bmp.Width == 64 && bmp.Height == 64 ) { - bool isNormal = bmp.GetPixel( 54, 20 ).A >= 127; - return isNormal ? SkinType.Type64x64 : SkinType.Type64x64Slim; + } else if( bmp.Width == bmp.Height ) { + // Minecraft alex skins have this particular pixel with alpha of 0. + if( bmp.Width >= 64 ) { + bool isNormal = bmp.GetPixel( 54, 20 ).A >= 127; + return isNormal ? SkinType.Type64x64 : SkinType.Type64x64Slim; + } else { + return SkinType.Type64x64; + } } else { - throw new NotSupportedException( "unsupported skin: " + bmp.Width + ", " + bmp.Height ); + throw new NotSupportedException( "unsupported skin dimensions: " + bmp.Width + ", " + bmp.Height ); } } @@ -226,7 +231,7 @@ namespace ClassicalSharp { for( int y = 0; y < size; y++ ) { int* srcRow = src.GetRowPtr( srcY + y ); int* dstRow = dst.GetRowPtr( dstY + y ); - for( int x = 0; x < size; x++ ) { + for( int x = 0; x < size; x++ ) { dstRow[dstX + x] = srcRow[srcX + x]; } }