v0.6.4: various bugfixes:
- fixed corrupted mimics causing save/load crashes - fixed crashes when destroy is called on the same group twice - syncronized texture cache methods - added safety checks to - SummoningTrap - WaterOfHealth - WndAlchemy - WndBag
This commit is contained in:
parent
4c3709a9d9
commit
8ff3db2088
|
@ -44,7 +44,7 @@ public class TextureCache {
|
|||
bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
|
||||
}
|
||||
|
||||
public static SmartTexture createSolid( int color ) {
|
||||
public synchronized static SmartTexture createSolid( int color ) {
|
||||
final String key = "1x1:" + color;
|
||||
|
||||
if (all.containsKey( key )) {
|
||||
|
@ -63,7 +63,7 @@ public class TextureCache {
|
|||
}
|
||||
}
|
||||
|
||||
public static SmartTexture createGradient( int... colors ) {
|
||||
public synchronized static SmartTexture createGradient( int... colors ) {
|
||||
|
||||
final String key = "" + colors;
|
||||
|
||||
|
@ -88,11 +88,11 @@ public class TextureCache {
|
|||
|
||||
}
|
||||
|
||||
public static void add( Object key, SmartTexture tx ) {
|
||||
public synchronized static void add( Object key, SmartTexture tx ) {
|
||||
all.put( key, tx );
|
||||
}
|
||||
|
||||
public static void remove( Object key ){
|
||||
public synchronized static void remove( Object key ){
|
||||
SmartTexture tx = all.get( key );
|
||||
if (tx != null){
|
||||
all.remove(key);
|
||||
|
@ -100,7 +100,7 @@ public class TextureCache {
|
|||
}
|
||||
}
|
||||
|
||||
public static SmartTexture get( Object src ) {
|
||||
public synchronized static SmartTexture get( Object src ) {
|
||||
|
||||
if (all.containsKey( src )) {
|
||||
|
||||
|
@ -119,17 +119,17 @@ public class TextureCache {
|
|||
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
public synchronized static void clear() {
|
||||
|
||||
for (Texture txt:all.values()) {
|
||||
for (Texture txt : all.values()) {
|
||||
txt.delete();
|
||||
}
|
||||
all.clear();
|
||||
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
for (SmartTexture tx:all.values()) {
|
||||
public synchronized static void reload() {
|
||||
for (SmartTexture tx : all.values()) {
|
||||
tx.reload();
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class TextureCache {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean contains( Object key ) {
|
||||
public synchronized static boolean contains( Object key ) {
|
||||
return all.containsKey( key );
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,10 @@ public class Group extends Gizmo {
|
|||
}
|
||||
}
|
||||
|
||||
members.clear();
|
||||
members = null;
|
||||
if (members != null) {
|
||||
members.clear();
|
||||
members = null;
|
||||
}
|
||||
length = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ public class WaterOfHealth extends WellWater {
|
|||
@Override
|
||||
protected boolean affectHero( Hero hero ) {
|
||||
|
||||
if (!hero.isAlive()) return false;
|
||||
|
||||
Sample.INSTANCE.play( Assets.SND_DRINK );
|
||||
|
||||
hero.HP = hero.HT;
|
||||
|
|
|
@ -62,14 +62,16 @@ public class Mimic extends Mob {
|
|||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( ITEMS, items );
|
||||
if (items != null) bundle.put( ITEMS, items );
|
||||
bundle.put( LEVEL, level );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
items = new ArrayList<>( (Collection<Item>) ((Collection<?>) bundle.getCollection( ITEMS ) ));
|
||||
if (bundle.contains( ITEMS )) {
|
||||
items = new ArrayList<>((Collection<Item>) ((Collection<?>) bundle.getCollection(ITEMS)));
|
||||
}
|
||||
adjustStats( bundle.getInt( LEVEL ) );
|
||||
super.restoreFromBundle(bundle);
|
||||
}
|
||||
|
|
|
@ -77,10 +77,12 @@ public class SummoningTrap extends Trap {
|
|||
|
||||
for (Integer point : respawnPoints) {
|
||||
Mob mob = Dungeon.level.createMob();
|
||||
mob.state = mob.WANDERING;
|
||||
mob.pos = point;
|
||||
GameScene.add( mob, DELAY );
|
||||
mobs.add( mob );
|
||||
if (mob != null) {
|
||||
mob.state = mob.WANDERING;
|
||||
mob.pos = point;
|
||||
GameScene.add(mob, DELAY);
|
||||
mobs.add(mob);
|
||||
}
|
||||
}
|
||||
|
||||
//important to process the visuals and pressing of cells last, so spawned mobs have a chance to occupy cells first
|
||||
|
|
|
@ -302,7 +302,7 @@ public class WndAlchemy extends Window {
|
|||
public void destroy() {
|
||||
synchronized ( inputs ) {
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
if (inputs[i].item != null) {
|
||||
if (inputs[i] != null && inputs[i].item != null) {
|
||||
if (!inputs[i].item.collect()) {
|
||||
Dungeon.level.drop(inputs[i].item, Dungeon.hero.pos);
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class WndBag extends WndTabbed {
|
|||
}
|
||||
|
||||
// Items in the bag
|
||||
for (Item item : container.items) {
|
||||
for (Item item : container.items.toArray(new Item[0])) {
|
||||
placeItem( item );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user