From 0182bae2a027c7435947fceaf7ad541a352f4341 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 20 Jan 2018 00:04:30 -0500 Subject: [PATCH] v0.6.3: fixed variosu bugs with fog of war and horn of plenty --- .../com/watabou/gltextures/TextureCache.java | 28 ++++++------------- .../items/artifacts/HornOfPlenty.java | 1 + .../shatteredpixeldungeon/tiles/FogOfWar.java | 6 ++-- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java b/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java index 0e37dad73..14c620ee2 100644 --- a/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java +++ b/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java @@ -87,29 +87,17 @@ public class TextureCache { } - //creates a smarttexture backed by a native intbuffer, not a bitmap. - //This is much faster is the texture needs to be frequently edited. - //texture is all black by default - public static SmartTexture createBufferTex( String key, int w, int h ){ - - key += "w" + w + "h" + h; - - if (all.containsKey( key )){ - - return all.get( key ); - - } else { - - BufferTexture tx = new BufferTexture(w, h); - all.put( key, tx); - return tx; - - } - } - public static void add( Object key, SmartTexture tx ) { all.put( key, tx ); } + + public static void remove( Object key ){ + SmartTexture tx = all.get( key ); + if (tx != null){ + all.remove(key); + tx.delete(); + } + } public static SmartTexture get( Object src ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java index db6fb62b3..6d7f9ed46 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java @@ -127,6 +127,7 @@ public class HornOfPlenty extends Artifact { if (charge >= 15) image = ItemSpriteSheet.ARTIFACT_HORN4; else if (charge >= 10) image = ItemSpriteSheet.ARTIFACT_HORN3; else if (charge >= 5) image = ItemSpriteSheet.ARTIFACT_HORN2; + else image = ItemSpriteSheet.ARTIFACT_HORN1; updateQuickslot(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java index b0b62c85c..56ca5afde 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java @@ -110,7 +110,9 @@ public class FogOfWar extends Image { width = width2 * size; height = height2 * size; - texture( TextureCache.createBufferTex("fog", width2, height2) ); + BufferTexture tx = new BufferTexture(width2, height2); + TextureCache.add(FogOfWar.class, tx); + texture( tx ); scale.set( DungeonTilemap.SIZE / PIX_PER_TILE, @@ -342,7 +344,7 @@ public class FogOfWar extends Image { public void destroy() { super.destroy(); if (texture != null){ - texture.delete(); + TextureCache.remove(FogOfWar.class); } } }