paulofmandown / rotLove

Roguelike Toolkit in Love. A Love2D/lua port of rot.js
http://paulofmandown.github.io/rotLove/
Other
258 stars 25 forks source link

Many doors in ROT.Map.Dungeon.Uniform/Digger #24

Closed Rakaneth closed 7 years ago

Rakaneth commented 7 years ago

image

I am getting multiple doors along room perimeters sometimes when using the getRooms/getDoors callbacks to generate doors, as in the screenshot above.

timothymtorres commented 7 years ago

Can you provide more info, possibly the pieces of code you are using to generate the map? This should make it easier to pinpoint the bug.

Rakaneth commented 7 years ago
function Map.create(options)
  options = options or {}
  local width = options.width or 30
  local height = options.height or 30
  local m = Map:new(width, height)
  local floors = options.floors or Map.TILES.STONEFLOOR
  local walls = options.walls or Map.TILES.STONEWALL
  local genType = options.genType or 'uniform'
  local name = options.name or m.defaultName
  local ti

  if genType == 'cellular' and not options.connected then 
    options.connected = true 
  end

  local generators = {
    uniform   = ROT.Map.Uniform(width, height, options, RNG.rng),
    digger    = ROT.Map.Digger(width, height, options, RNG.rng),
    cellular  = ROT.Map.Cellular(width, height, options, RNG.rng),
    icey      = ROT.Map.IceyMaze(width, height, RNG.rng),
    arena     = ROT.Map.Arena(width, height, RNG.rng),
  }

  m.id = name
  m.dark = options.dark

  local cb = function(x, y, v)
    if v == 1 then 
      ti = walls
    else 
      ti = floors
    end
    m:setTile(ti, x, y)
  end
  local isWall = function(gen, x, y) return not m:tile(x, y).walk end 
  local d = generators[genType]
  if genType == 'cellular' then 
    d:randomize(.5) 
    for _ = 1, 4 do d:create(cb) end 
  else
    d:create(cb)
  end
  if genType == 'uniform' or genType == 'digger' then
    local rooms = d:getRooms()
    for _, r in ipairs(rooms) do
      r:addDoors(d, isWall)
    end
    local doors = d:getDoors()
    for _, dr in ipairs(doors) do
      m:setTile(Map.TILES.CLOSEDOOR, dr.x, dr.y)
    end
  end
  if not GAME.maps then GAME.maps = {} end
  GAME.maps[name] = m
  return m
end
paulofmandown commented 7 years ago

If you pull in the latest commit, this should be ok now. Let me know if I broke it harder though! I have a bad habit of doing that

Rakaneth commented 7 years ago

I have updated to the latest commit and I am still seeing a multidoor issue. multidoor2

paulofmandown commented 7 years ago

I can't really duplicate it anymore. Do you know what the width, height, and options values are when it's happening?

Rakaneth commented 7 years ago

In the example above, it would be {width = 30, height = 30, options = {}}