summaryrefslogtreecommitdiff
path: root/objects/room.lua
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-07 22:54:43 +0800
committerEltrac <hi@guhub.cn>2025-03-07 22:54:43 +0800
commita47d91f0dbd92a0c182d9a60e390930b3356a077 (patch)
treeb21cff978127bba7bad7c4ec6c55e2f10799986b /objects/room.lua
parent630365ae1308c6a8784c5f2b41db3c36107226f3 (diff)
fix: some rooms are not accessible due to door misplacement
Diffstat (limited to 'objects/room.lua')
-rw-r--r--objects/room.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/objects/room.lua b/objects/room.lua
index 5d113f9..1d2bfa2 100644
--- a/objects/room.lua
+++ b/objects/room.lua
@@ -147,13 +147,19 @@ function Room:connect(anotherRoom, way)
-- determine directions
-- if not specified, choose randomly
- local directions
+ local directions = {}
if type(way) == "string" then
directions = Way[way]
elseif type(way) == "number" then
directions = Way[Ways[way]]
else
- directions = Way[Ways[utils.any(self:getDoorlessDirections())]]
+ local dd1 = self:getDoorlessDirections()
+ local dd2 = anotherRoom:getDoorlessDirections()
+
+ repeat
+ directions[1] = utils.any(dd1)
+ directions[2] = OppositeDirection[directions[1]]
+ until utils.contains(dd2, directions[2])
end
if not directions then return false end