Skip to content

Commit

Permalink
Fixed bug: if you use a potion of detect things and enter the room, t…
Browse files Browse the repository at this point in the history
…he discovered item may disappear or change to other kind of items

g.put_objects() sometimes created duplicate objects in same [row][col].
  • Loading branch information
katono committed Sep 22, 2014
1 parent a7ade67 commit 0ecf0e4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion autoload/rogue/level.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ local function hide_boxed_passage(row1, col1, row2, col2, n)
for j = 0, 9 do
row = g.get_rand(row1 + row_cut, row2 - row_cut)
col = g.get_rand(col1 + col_cut, col2 - col_cut)
if g.dungeon[row][col][g.TUNNEL] then
if g.dungeon_equals(g.dungeon[row][col], g.TUNNEL) then
g.dungeon[row][col][g.HIDDEN] = g.dungeon_desc[g.HIDDEN]
break
end
Expand Down
2 changes: 1 addition & 1 deletion autoload/rogue/monster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ function g.move_mon_to(monster, row, col)
end
if g.dungeon[row][col][g.DOOR] and
g.get_room_number(row, col) ~= g.cur_room and
g.dungeon[mrow][mcol][g.FLOOR] and g.blind == 0 then
g.dungeon_equals(g.dungeon[mrow][mcol], g.FLOOR) and g.blind == 0 then
g.mvaddch(mrow, mcol, ' ')
end
if g.dungeon[row][col][g.DOOR] then
Expand Down
4 changes: 2 additions & 2 deletions autoload/rogue/object.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ local function put_gold()
for j = 0, 49 do
local row = g.get_rand(g.rooms[i].top_row+1, g.rooms[i].bottom_row-1)
local col = g.get_rand(g.rooms[i].left_col+1, g.rooms[i].right_col-1)
if g.dungeon[row][col][g.FLOOR] or
g.dungeon[row][col][g.TUNNEL] then
if g.dungeon_equals(g.dungeon[row][col], g.FLOOR) or
g.dungeon_equals(g.dungeon[row][col], g.TUNNEL) then
plant_gold(row, col, is_maze)
break
end
Expand Down
15 changes: 14 additions & 1 deletion autoload/rogue/room.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ function g.gr_row_col(mask)
return r, c
end

function g.dungeon_equals(dun, t)
local found = false
for k, v in pairs(dun) do
if k == t then
found = true
else
return false
end
end
return found
end

function g.gr_room()
local i
repeat
Expand All @@ -226,7 +238,8 @@ function g.party_objects(rn)
while (not found) and (j < 250) do
row = g.get_rand(g.rooms[rn].top_row+1, g.rooms[rn].bottom_row-1)
col = g.get_rand(g.rooms[rn].left_col+1, g.rooms[rn].right_col-1)
if g.dungeon[row][col][g.FLOOR] or g.dungeon[row][col][g.TUNNEL] then
if g.dungeon_equals(g.dungeon[row][col], g.FLOOR) or
g.dungeon_equals(g.dungeon[row][col], g.TUNNEL) then
found = true
end

Expand Down

0 comments on commit 0ecf0e4

Please sign in to comment.