pull request #345 - theme room dimensions
"When a room is created and passed down to a contents function in Lua, the width and height properties of that room are computed by subtracting lx from hx and ly from hy, which means e.g. a room which is 8 floor squares wide and 5 tall appears to the contents function as having a width of 7 and height of 4. This patch fixes that off-by-one." I don't understand the details here: should a room's dimensions include its boundary walls or just the inner amount? This change didn't seem to cause any problems so I've put it in. Closes #345
This commit is contained in:
@@ -80,8 +80,8 @@ themerooms = {
|
||||
function()
|
||||
des.room({ type = "themed",
|
||||
contents = function(rm)
|
||||
for x = 0, rm.width do
|
||||
for y = 0, rm.height do
|
||||
for x = 0, rm.width - 1 do
|
||||
for y = 0, rm.height - 1 do
|
||||
if (percent(30)) then
|
||||
if (percent(50)) then
|
||||
des.object("boulder");
|
||||
@@ -99,8 +99,8 @@ themerooms = {
|
||||
function()
|
||||
des.room({ type = "themed",
|
||||
contents = function(rm)
|
||||
for x = 0, rm.width do
|
||||
for y = 0, rm.height do
|
||||
for x = 0, rm.width - 1 do
|
||||
for y = 0, rm.height - 1 do
|
||||
if (percent(30)) then
|
||||
des.trap("web", x, y);
|
||||
end
|
||||
@@ -118,8 +118,8 @@ themerooms = {
|
||||
"land mine", "sleep gas", "rust",
|
||||
"anti magic" };
|
||||
shuffle(traps);
|
||||
for x = 0, rm.width do
|
||||
for y = 0, rm.height do
|
||||
for x = 0, rm.width - 1 do
|
||||
for y = 0, rm.height - 1 do
|
||||
if (percent(30)) then
|
||||
des.trap(traps[1], x, y);
|
||||
end
|
||||
@@ -169,8 +169,8 @@ themerooms = {
|
||||
contents = function(rm)
|
||||
local terr = { "-", "-", "-", "-", "L", "P", "T" };
|
||||
shuffle(terr);
|
||||
for x = 0, (rm.width - 3) / 4 do
|
||||
for y = 0, (rm.height - 3) / 4 do
|
||||
for x = 0, (rm.width / 4) - 1 do
|
||||
for y = 0, (rm.height / 4) - 1 do
|
||||
des.terrain({ x = x * 4 + 2, y = y * 4 + 2, typ = terr[1], lit = -2 });
|
||||
des.terrain({ x = x * 4 + 3, y = y * 4 + 2, typ = terr[1], lit = -2 });
|
||||
des.terrain({ x = x * 4 + 2, y = y * 4 + 3, typ = terr[1], lit = -2 });
|
||||
@@ -219,7 +219,9 @@ themerooms = {
|
||||
function()
|
||||
des.room({ type = "themed", w = 5 + nh.rn2(3)*2, h = 5 + nh.rn2(3)*2,
|
||||
contents = function(rm)
|
||||
des.room({ type = "themed", x = (rm.width / 2), y = (rm.height / 2), w = 1, h = 1, joined = 0,
|
||||
des.room({ type = "themed",
|
||||
x = (rm.width - 1) / 2, y = (rm.height - 1) / 2,
|
||||
w = 1, h = 1, joined = 0,
|
||||
contents = function()
|
||||
if (percent(50)) then
|
||||
local mons = { "M", "V", "L", "Z" };
|
||||
@@ -245,7 +247,8 @@ themerooms = {
|
||||
contents = function(rm)
|
||||
local feature = { "C", "L", "I", "P", "T" };
|
||||
shuffle(feature);
|
||||
des.terrain(rm.width / 2, rm.height / 2, feature[1]);
|
||||
des.terrain((rm.width - 1) / 2, (rm.height - 1) / 2,
|
||||
feature[1]);
|
||||
end
|
||||
});
|
||||
end,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.307 $ $NHDT-Date: 1600863687 2020/09/23 12:21:27 $
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.308 $ $NHDT-Date: 1600909016 2020/09/24 00:56:56 $
|
||||
|
||||
General Fixes and Modified Features
|
||||
-----------------------------------
|
||||
@@ -342,6 +342,7 @@ replace worm tail placement code that reportedly led to a sanity_check warning
|
||||
[no actual code problem found; might be compiler bug for 'xchar']
|
||||
learn scroll of teleportation after reading even when random destination is
|
||||
right by starting spot
|
||||
fix off-by-one bug in dimensions of theme rooms
|
||||
|
||||
curses: 'msg_window' option wasn't functional for curses unless the binary
|
||||
also included tty support
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 sp_lev.c $NHDT-Date: 1599434249 2020/09/06 23:17:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.202 $ */
|
||||
/* NetHack 3.7 sp_lev.c $NHDT-Date: 1600909016 2020/09/24 00:56:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.203 $ */
|
||||
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -3844,7 +3844,8 @@ lua_State *L;
|
||||
lua_getfield(L, 1, "contents");
|
||||
if (lua_type(L, -1) == LUA_TFUNCTION) {
|
||||
lua_remove(L, -2);
|
||||
l_push_wid_hei_table(L, tmpcr->hx - tmpcr->lx, tmpcr->hy - tmpcr->ly);
|
||||
l_push_wid_hei_table(L, 1 + tmpcr->hx - tmpcr->lx,
|
||||
1 + tmpcr->hy - tmpcr->ly);
|
||||
lua_call(L, 1, 0);
|
||||
} else
|
||||
lua_pop(L, 1);
|
||||
|
||||
Reference in New Issue
Block a user