From 591b96fb811528bb68ebd1e7e3aa146d6211aa74 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 20 Dec 2016 19:13:11 -0500 Subject: [PATCH] v0.5.0: fixed distance visibility not updating properly in some cases --- .../shatteredpixeldungeon/Dungeon.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index 049146032..99aa75ca3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -697,24 +697,30 @@ public class Dungeon { level.updateFieldOfView(hero, visible); - int cx = hero.pos % level.width(); - int cy = hero.pos / level.width(); + if (hero.buff(MindVision.class) != null || hero.buff(Awareness.class) != null) { + BArray.or( level.visited, visible, 0, visible.length, level.visited ); - int ax = Math.max( 0, cx - dist ); - int bx = Math.min( cx + dist, level.width() - 1 ); - int ay = Math.max( 0, cy - dist ); - int by = Math.min( cy + dist, level.height() - 1 ); + GameScene.updateFog(); + } else { - int len = bx - ax + 1; - int pos = ax + ay * level.width(); - for (int y = ay; y <= by; y++, pos+=level.width()) { - BArray.or( level.visited, visible, pos, len, level.visited ); + int cx = hero.pos % level.width(); + int cy = hero.pos / level.width(); + + int ax = Math.max( 0, cx - dist ); + int bx = Math.min( cx + dist, level.width() - 1 ); + int ay = Math.max( 0, cy - dist ); + int by = Math.min( cy + dist, level.height() - 1 ); + + int len = bx - ax + 1; + int pos = ax + ay * level.width(); + + for (int y = ay; y <= by; y++, pos+=level.width()) { + BArray.or( level.visited, visible, pos, len, level.visited ); + } + + GameScene.updateFog(ax, ay, len, by-ay); } - if (hero.buff(MindVision.class) != null || hero.buff(Awareness.class) != null) - GameScene.updateFog(); - else - GameScene.updateFog(ax, ay, len, by-ay); GameScene.afterObserve(); }