diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java index 8dad62f14..8c927870d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java @@ -90,17 +90,17 @@ public class BeaconOfReturning extends Spell { @Override protected void onThrow(int cell) { - returnDepth = -1; if (Dungeon.hero.belongings.getItem(getClass()) == null){ - Notes.remove(Notes.Landmark.BEACON_LOCATION); + Notes.remove(Notes.Landmark.BEACON_LOCATION, returnDepth); } + returnDepth = -1; super.onThrow(cell); } @Override public void doDrop(Hero hero) { + Notes.remove(Notes.Landmark.BEACON_LOCATION, returnDepth); returnDepth = -1; - Notes.remove(Notes.Landmark.BEACON_LOCATION); super.doDrop(hero); } @@ -109,7 +109,7 @@ public class BeaconOfReturning extends Spell { returnBranch = Dungeon.branch; returnPos = hero.pos; - Notes.add(Notes.Landmark.BEACON_LOCATION); + Notes.add(Notes.Landmark.BEACON_LOCATION, returnDepth); hero.spend( 1f ); hero.busy(); @@ -181,7 +181,7 @@ public class BeaconOfReturning extends Spell { Game.switchScene( InterlevelScene.class ); } if (quantity == 1){ - Notes.remove(Notes.Landmark.BEACON_LOCATION); + Notes.remove(Notes.Landmark.BEACON_LOCATION, returnDepth); } detach(hero.belongings.backpack); Catalog.countUse(getClass()); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Notes.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Notes.java index 6d9a3fbbd..a158f77fa 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Notes.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Notes.java @@ -563,11 +563,15 @@ public class Notes { records.add( (Record) rec ); } } - + public static boolean add( Landmark landmark ) { - LandmarkRecord l = new LandmarkRecord( landmark, Dungeon.depth ); + return add( landmark, Dungeon.depth ); + } + + public static boolean add( Landmark landmark, int depth ) { + LandmarkRecord l = new LandmarkRecord( landmark, depth ); if (!records.contains(l)) { - boolean result = records.add(new LandmarkRecord(landmark, Dungeon.depth)); + boolean result = records.add(l); Collections.sort(records, comparator); return result; } @@ -575,11 +579,19 @@ public class Notes { } public static boolean contains( Landmark landmark ){ - return records.contains(new LandmarkRecord( landmark, Dungeon.depth)); + return contains( landmark, Dungeon.depth ); } - + + public static boolean contains( Landmark landmark, int depth ){ + return records.contains(new LandmarkRecord( landmark, depth)); + } + public static boolean remove( Landmark landmark ) { - return records.remove( new LandmarkRecord(landmark, Dungeon.depth) ); + return remove( landmark, Dungeon.depth ); + } + + public static boolean remove( Landmark landmark, int depth ) { + return records.remove( new LandmarkRecord(landmark, depth) ); } public static boolean add( Key key ){