aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java16
2 files changed, 12 insertions, 6 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
index 3c262856..8c5376d7 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
@@ -167,6 +167,6 @@ public class DungeonRoom {
return (shape >>(roomPt.y *4 +roomPt.x) & 0x1) > 0;
}
public boolean canAccessRelative(int x, int z) {
- return (shape >>((z/32) *4 +(x/32)) & 0x1) > 0;
+ return x>= 0 && z >= 0 && (shape >>((z/32) *4 +(x/32)) & 0x1) > 0;
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
index 41967e6c..c4bc596c 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
@@ -61,6 +61,8 @@ public class RoomMatcher {
private boolean tryMatching(DungeonRoomInfo dungeonRoomInfo, int rotation) {
if (dungeonRoomInfo.getColor() != dungeonRoom.getColor()) return false;
+ System.out.println("Matching "+dungeonRoomInfo.getName()+" At "+rotation);
+
int[][] res = dungeonRoomInfo.getBlocks();
for (int i = 0; i < rotation; i++)
res = ArrayUtils.rotateCounterClockwise(res);
@@ -72,6 +74,7 @@ public class RoomMatcher {
Block b = dungeonRoom.getRelativeBlockAt(x,0,z);
if (b == null || Block.getIdFromBlock(b) != data) {
+ System.out.println("Failed At "+x+"."+z + " "+data+" found " + Block.getIdFromBlock(b) +" found");
return false;
}
}
@@ -93,11 +96,14 @@ public class RoomMatcher {
for (int z = 0; z < data.length; z++) {
for (int x = 0; x < data[0].length; x++) {
- if (!(offset <= x && widthX - offset > x && offset <= z && heightZ - offset > z)) {
- data[z][x] = -1;
- continue;
- }
- if (!(dungeonRoom.canAccessRelative(x + offset - 1, z + offset - 1) && dungeonRoom.canAccessRelative(x - offset, z - offset))) {
+// if (!(offset < x && widthX - offset > x && offset < z && heightZ - offset > z)) {
+// data[z][x] = -1;
+// continue;
+// }
+ if (!(dungeonRoom.canAccessRelative(x + offset, z + offset)
+ && dungeonRoom.canAccessRelative(x - offset -1 , z - offset-1)
+ && dungeonRoom.canAccessRelative(x + offset , z - offset-1)
+ && dungeonRoom.canAccessRelative(x - offset -1 , z + offset))) {
data[z][x] = -1;
continue;
}