mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
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:
parent
44617d1a26
commit
f497f6b623
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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, T2>( T1 arg1, T2 arg2 );
|
||||
public delegate void Action<T1, T2, T3>( 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];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user