From: copperwater Date: Mon, 28 Sep 2020 16:48:34 +0000 (-0400) Subject: Prevent any type of terrain overwrite from replacing stairs/ladders X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9bb515f19614e34908a0669fc334ece30345dabd;p=nethack Prevent any type of terrain overwrite from replacing stairs/ladders Consider the following scenario: There's a level where there's a zone of des.replace_terrain() between the stairs and some other objective, and the terrain is something non-walkable like trees. There's a chance that the path is entirely blocked off by random replace_terrain, so you make the level set terrain to '.' along a randline (or normal line, or whatever) between the randomly placed stairs and the other side of the replace_terrain zone. The problem: this overwrote the stairs with a '.' as well. This can be worked around in the lua file by first picking the desired location of the stairs, then setting the terrain that overlaps with the stairs, then doing des.stair() after that, but this is awkward and hard to read. So this makes it impossible for anything calling SET_TYPLIT (only called in sp_lev.c) to overwrite stairs. I can't really think of a situation where a level designer would want to define stairs, then maybe overwrite them. --- diff --git a/include/sp_lev.h b/include/sp_lev.h index cf86388e3..ed3e20381 100644 --- a/include/sp_lev.h +++ b/include/sp_lev.h @@ -196,7 +196,8 @@ struct mapfragment { #define SET_TYPLIT(x, y, ttyp, llit) \ { \ if ((x) >= 1 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \ - if ((ttyp) < MAX_TYPE) \ + if ((ttyp) < MAX_TYPE && levl[(x)][(y)].typ != STAIRS \ + && levl[(x)][(y)].typ != LADDER) \ levl[(x)][(y)].typ = (ttyp); \ if ((ttyp) == LAVAPOOL) \ levl[(x)][(y)].lit = 1; \