Fix being kicked by MCDzienny servers for 'out of date WoM version', fixed textures that aren't 64x32 or 64x64 crashing the client. (Thanks Cheesse)

This commit is contained in:
UnknownShadow200 2015-06-27 08:58:52 +10:00
parent 44617d1a26
commit f497f6b623
3 changed files with 30 additions and 14 deletions

View File

@ -111,15 +111,26 @@ namespace ClassicalSharp {
if( item != null && item.Bmp != null ) { if( item != null && item.Bmp != null ) {
Bitmap bmp = item.Bmp; Bitmap bmp = item.Bmp;
Window.Graphics.DeleteTexture( ref renderer.PlayerTextureId ); Window.Graphics.DeleteTexture( ref renderer.PlayerTextureId );
renderer.PlayerTextureId = Window.Graphics.LoadTexture( bmp );
// Custom mob textures. try {
renderer.MobTextureId = -1; SkinType = Utils.GetSkinType( bmp );
if( Utils.IsUrl( item.Url ) && item.TimeAdded > lastModelChange ) { renderer.PlayerTextureId = Window.Graphics.LoadTexture( bmp );
renderer.MobTextureId = renderer.PlayerTextureId; 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(); bmp.Dispose();
} }
} }
DateTime lastModelChange = new DateTime( 1, 1, 1 ); DateTime lastModelChange = new DateTime( 1, 1, 1 );

View File

@ -347,7 +347,7 @@ namespace ClassicalSharp {
map = null; map = null;
gzipStream.Close(); gzipStream.Close();
if( sendWomId && !sentWomId ) { if( sendWomId && !sentWomId ) {
SendChat( "/womid WoMClient-2.0.6" ); SendChat( "/womid WoMClient-2.0.7" );
sentWomId = true; sentWomId = true;
} }
gzipStream = null; gzipStream = null;

View File

@ -212,13 +212,18 @@ namespace ClassicalSharp {
} }
public static SkinType GetSkinType( Bitmap bmp ) { public static SkinType GetSkinType( Bitmap bmp ) {
if( bmp.Width == 64 && bmp.Height == 32 ) { if( bmp.Width == bmp.Height * 2 ) {
return SkinType.Type64x32; return SkinType.Type64x32;
} else if( bmp.Width == 64 && bmp.Height == 64 ) { } else if( bmp.Width == bmp.Height ) {
bool isNormal = bmp.GetPixel( 54, 20 ).A >= 127; // Minecraft alex skins have this particular pixel with alpha of 0.
return isNormal ? SkinType.Type64x64 : SkinType.Type64x64Slim; if( bmp.Width >= 64 ) {
bool isNormal = bmp.GetPixel( 54, 20 ).A >= 127;
return isNormal ? SkinType.Type64x64 : SkinType.Type64x64Slim;
} else {
return SkinType.Type64x64;
}
} else { } else {
throw new NotSupportedException( "unsupported skin: " + bmp.Width + ", " + bmp.Height ); throw new NotSupportedException( "unsupported skin dimensions: " + bmp.Width + ", " + bmp.Height );
} }
} }