mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
Fix animations being cleared when joining another world with the same texture pack. (Thanks 123DontMessWitMe)
This commit is contained in:
parent
867e204825
commit
ea997f2eae
@ -91,7 +91,6 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void DownloadTexturePack( string url ) {
|
void DownloadTexturePack( string url ) {
|
||||||
if( game.DeniedUrls.HasUrl( url ) ) return;
|
if( game.DeniedUrls.HasUrl( url ) ) return;
|
||||||
game.Animations.Dispose();
|
|
||||||
DateTime lastModified = TextureCache.GetLastModifiedFromCache( url );
|
DateTime lastModified = TextureCache.GetLastModifiedFromCache( url );
|
||||||
|
|
||||||
if( url.Contains( ".zip" ) )
|
if( url.Contains( ".zip" ) )
|
||||||
@ -118,19 +117,23 @@ namespace ClassicalSharp {
|
|||||||
if( game.AsyncDownloader.TryGetItem( "terrain", out item ) ) {
|
if( game.AsyncDownloader.TryGetItem( "terrain", out item ) ) {
|
||||||
if( item.Data != null ) {
|
if( item.Data != null ) {
|
||||||
Bitmap bmp = (Bitmap)item.Data;
|
Bitmap bmp = (Bitmap)item.Data;
|
||||||
|
game.World.TextureUrl = item.Url;
|
||||||
|
game.Animations.Dispose();
|
||||||
|
|
||||||
if( !FastBitmap.CheckFormat( bmp.PixelFormat ) ) {
|
if( !FastBitmap.CheckFormat( bmp.PixelFormat ) ) {
|
||||||
Utils.LogDebug( "Converting terrain atlas to 32bpp image" );
|
Utils.LogDebug( "Converting terrain atlas to 32bpp image" );
|
||||||
game.Drawer2D.ConvertTo32Bpp( ref bmp );
|
game.Drawer2D.ConvertTo32Bpp( ref bmp );
|
||||||
}
|
}
|
||||||
game.ChangeTerrainAtlas( bmp );
|
game.ChangeTerrainAtlas( bmp );
|
||||||
TextureCache.AddToCache( item.Url, bmp );
|
TextureCache.AddToCache( item.Url, bmp );
|
||||||
game.World.TextureUrl = item.Url;
|
|
||||||
} else if( Is304Status( item.WebEx ) ) {
|
} else if( Is304Status( item.WebEx ) ) {
|
||||||
Bitmap bmp = TextureCache.GetBitmapFromCache( item.Url );
|
Bitmap bmp = TextureCache.GetBitmapFromCache( item.Url );
|
||||||
if( bmp == null ) // Should never happen, but handle anyways.
|
if( bmp == null ) {// Should never happen, but handle anyways.
|
||||||
ExtractDefault();
|
ExtractDefault();
|
||||||
else if( item.Url != game.World.TextureUrl )
|
} else if( item.Url != game.World.TextureUrl ) {
|
||||||
|
game.Animations.Dispose();
|
||||||
game.ChangeTerrainAtlas( bmp );
|
game.ChangeTerrainAtlas( bmp );
|
||||||
|
}
|
||||||
|
|
||||||
if( bmp != null ) game.World.TextureUrl = item.Url;
|
if( bmp != null ) game.World.TextureUrl = item.Url;
|
||||||
} else {
|
} else {
|
||||||
@ -140,15 +143,18 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
if( game.AsyncDownloader.TryGetItem( "texturePack", out item ) ) {
|
if( game.AsyncDownloader.TryGetItem( "texturePack", out item ) ) {
|
||||||
if( item.Data != null ) {
|
if( item.Data != null ) {
|
||||||
|
game.World.TextureUrl = item.Url;
|
||||||
|
game.Animations.Dispose();
|
||||||
|
|
||||||
TexturePackExtractor extractor = new TexturePackExtractor();
|
TexturePackExtractor extractor = new TexturePackExtractor();
|
||||||
extractor.Extract( (byte[])item.Data, game );
|
extractor.Extract( (byte[])item.Data, game );
|
||||||
TextureCache.AddToCache( item.Url, (byte[])item.Data );
|
TextureCache.AddToCache( item.Url, (byte[])item.Data );
|
||||||
game.World.TextureUrl = item.Url;
|
|
||||||
} else if( Is304Status( item.WebEx ) ) {
|
} else if( Is304Status( item.WebEx ) ) {
|
||||||
byte[] data = TextureCache.GetDataFromCache( item.Url );
|
byte[] data = TextureCache.GetDataFromCache( item.Url );
|
||||||
if( data == null ) { // Should never happen, but handle anyways.
|
if( data == null ) { // Should never happen, but handle anyways.
|
||||||
ExtractDefault();
|
ExtractDefault();
|
||||||
} else if( item.Url != game.World.TextureUrl ) {
|
} else if( item.Url != game.World.TextureUrl ) {
|
||||||
|
game.Animations.Dispose();
|
||||||
TexturePackExtractor extractor = new TexturePackExtractor();
|
TexturePackExtractor extractor = new TexturePackExtractor();
|
||||||
extractor.Extract( data, game );
|
extractor.Extract( data, game );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user