diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 335e1db93..3c2ba719b 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1714,7 +1714,7 @@ void Fence() for (int j = 1; j < DMAXY; j++) { // BUGFIX: Change '0' to '1' (fixed) for (int i = 1; i < DMAXX; i++) { // BUGFIX: Change '0' to '1' (fixed) - if (dungeon[i][j] == 7 && GenerateRnd(1) == 0 && SkipThemeRoom(i, j)) { + if (dungeon[i][j] == 7 && GenerateRnd(1) == 0 && !IsNearThemeRoom({ i, j })) { int rt = GenerateRnd(2); if (rt == 0) { int y1 = j; diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 4cff9c8dc..bc6cccb32 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -95,7 +95,7 @@ bool WillThemeRoomFit(int floor, int x, int y, int minSize, int maxSize, int *wi if (x + minSize > DMAXX || y + minSize > DMAXY) { return false; // Skip definit OOB cases } - if (!SkipThemeRoom(x, y)) { + if (IsNearThemeRoom({ x, y })) { return false; } @@ -750,15 +750,17 @@ void DRLG_LPass3(int lv) } } -bool SkipThemeRoom(int x, int y) +bool IsNearThemeRoom(Point testPosition) { + int x = testPosition.x; + int y = testPosition.y; for (int i = 0; i < themeCount; i++) { if (x >= themeLoc[i].room.position.x - 2 && x <= themeLoc[i].room.position.x + themeLoc[i].room.size.width + 2 && y >= themeLoc[i].room.position.y - 2 && y <= themeLoc[i].room.position.y + themeLoc[i].room.size.height + 2) - return false; + return true; } - return true; + return false; } void InitLevels() diff --git a/Source/gendung.h b/Source/gendung.h index 8c6400189..f96ea9314 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -335,7 +335,13 @@ void DRLG_HoldThemeRooms(); void SetSetPieceRoom(Point position, int floorId); void FreeQuestSetPieces(); void DRLG_LPass3(int lv); -bool SkipThemeRoom(int x, int y); + +/** + * @brief Checks if a theme room is located near the target point + * @param position Target location in dungeon coordinates + * @return True if a theme room is near (within 2 tiles of) this point, false if it is free. + */ +bool IsNearThemeRoom(Point position); void InitLevels(); void FloodTransparencyValues(uint8_t floorID); diff --git a/Source/objects.cpp b/Source/objects.cpp index 6047cf1c5..e83dde61a 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -890,7 +890,7 @@ void AddHookedBodies(int freq) continue; if (GenerateRnd(freq) != 0) continue; - if (!SkipThemeRoom(i, j)) + if (IsNearThemeRoom({ i, j })) continue; if (dungeon[i][j] == 1 && dungeon[i + 1][j] == 6) { switch (GenerateRnd(3)) {