]> granicus.if.org Git - nethack/commitdiff
Convert room 'joined' and 'needjoining' into booleans
authorcopperwater <aosdict@gmail.com>
Thu, 18 Feb 2021 23:55:10 +0000 (18:55 -0500)
committerPasi Kallinen <paxed@alt.org>
Fri, 19 Feb 2021 15:09:41 +0000 (17:09 +0200)
des.region() accepted booleans for the joined field, whereas des.room
accepted xchars. These were only being used as truth values, so this
converts the room ones into booleans for consistency. I don't think
accidentally using an int or a boolean wrongly would actually crash the
level generator, but consistency is good.

This converts an schar field in struct mkroom into a boolean; on most
systems these are probably 1-byte types and save files won't be broken,
but it might be best to treat this as a save breaker anyway.

dat/themerms.lua
doc/lua.adoc
include/mkroom.h
include/sp_lev.h
src/mklev.c
src/sp_lev.c

index fa85a44dfc9c7361fb124cc7e44a003c8f18b4d6..0004ff36a3fdde8223425ab39f68ad170111b959 100644 (file)
@@ -229,7 +229,7 @@ themerooms = {
                  contents = function(rm)
                     des.room({ type = "themed",
                               x = (rm.width - 1) / 2, y = (rm.height - 1) / 2,
-                              w = 1, h = 1, joined = 0,
+                              w = 1, h = 1, joined = false,
                                contents = function()
                                   if (percent(50)) then
                                      local mons = { "M", "V", "L", "Z" };
@@ -583,12 +583,12 @@ end });
                   end
                end
                p = placements[d(#placements)]
-               des.room({ type=ltype, x=p["lx"], y=p["ly"], w=3, h=3, filled=1, joined=0,
+               des.room({ type=ltype, x=p["lx"], y=p["ly"], w=3, h=3, filled=1, joined=false,
                            contents = function()
                      des.door({ state=shopdoorstate(), wall=p["lwall"] })
                   end
                });
-               des.room({ type=rtype, x=p["rx"], y=p["ry"], w=3, h=3, filled=1, joined=0,
+               des.room({ type=rtype, x=p["rx"], y=p["ry"], w=3, h=3, filled=1, joined=false,
                            contents = function()
                      des.door({ state=shopdoorstate(), wall=p["rwall"] })
                   end
index 5a8ef3c781eb9311cf550ea5e4c1d4a6eb6023c4..564205d025b57108b7d3239ee3d32a5b93c4ae71 100644 (file)
@@ -368,7 +368,7 @@ Initialize the map with a random generator of a certain type.
 Example:
 
  des.level_init({ style = "solidfill", fg = " " });
- des.level_init({ style = "mines", fg = ".", bg = "}", smoothed=1, joined=1, lit=0 })
+ des.level_init({ style = "mines", fg = ".", bg = "}", smoothed=true, joined=true, lit=0 })
  des.level_init({ style = "maze", corrwid = 3, wallthick = 1, deadends = false });
 
 === levregion
@@ -553,7 +553,7 @@ fields:
 | yalign    | Vertical alignment on a rough 3x3 grid. Default is "random".
 | lit       | Is the room lit or unlit? Defaults to -1 (random).
 | filled    | Is the room filled as per the room type. Defaults to 1 (filled).
-| joined    | Is the room joined to the rest of the level with corridors? Default is 1 (joined).
+| joined    | Is the room joined to the rest of the level with corridors? Default is true.
 | contents  | A function called with one parameter, a table with "width" and "height", the room width and height, excluding the walls. All coordinates in the function will be relative to the room.
 |===
 
index 07d2318aad7b12d41e366d810623f1ecec09ba60..8f184ab67744573ec630a3046c98e42c7dda7e26 100644 (file)
@@ -14,7 +14,7 @@ struct mkroom {
     schar orig_rtype;     /* same as rtype, but not zeroed later */
     schar rlit;           /* is the room lit ? */
     schar needfill;       /* sp_lev: does the room need filling? */
-    schar needjoining;    /* sp_lev */
+    boolean needjoining;  /* sp_lev: should the room connect to others? */
     schar doorct;         /* door count */
     schar fdoor;          /* index for the first door of the room */
     schar nsubrooms;      /* number of subrooms */
index 3121d543c8fb22dbdd9a75a280cfc4546072c97c..b27adb874bc0390430a29b76ec76f60496eef653 100644 (file)
@@ -185,7 +185,8 @@ typedef struct _room {
     Str_or_Len parent;
     xchar x, y, w, h;
     xchar xalign, yalign;
-    xchar rtype, chance, rlit, needfill, joined;
+    xchar rtype, chance, rlit, needfill;
+    boolean joined;
 } room;
 
 struct mapfragment {
index bfba3e0ce57a2d4a0c0693266adf5d6564d5905f..dde1b8165f843eaecbdc92cc1b624f82acacf12b 100644 (file)
@@ -65,7 +65,7 @@ mkroom_cmp(const genericptr vx, const genericptr vy)
 }
 
 /* Return TRUE if a door placed at (x, y) which otherwise passes okdoor()
- * checks would be connecting into an area that was declared as joined = 0.
+ * checks would be connecting into an area that was declared as joined = false.
  * Checking for this in finddpos() enables us to have rooms with sub-areas
  * (such as shops) that will never randomly generate unwanted doors in order
  * to connect them up to other areas.
index 58026e76e98e4f3a3b984336b00698bd807b78b0..efbc5d3395a51f6b39950156d28d89ae0d53dfb8 100755 (executable)
@@ -3480,7 +3480,7 @@ lspo_level_flags(lua_State* L)
 }
 
 /* level_init({ style = "solidfill", fg = " " }); */
-/* level_init({ style = "mines", fg = ".", bg = "}", smoothed=1, joined=1, lit=0 }) */
+/* level_init({ style = "mines", fg = ".", bg = "}", smoothed=true, joined=true, lit=0 }) */
 int
 lspo_level_init(lua_State* L)
 {
@@ -3694,7 +3694,7 @@ lspo_room(lua_State* L)
         tmproom.rlit = get_table_int_opt(L, "lit", -1);
         /* theme rooms default to unfilled */
         tmproom.needfill = get_table_int_opt(L, "filled", g.in_mk_themerooms ? 0 : 1);
-        tmproom.joined = get_table_int_opt(L, "joined", 1);
+        tmproom.joined = get_table_boolean_opt(L, "joined", TRUE);
 
         if (!g.coder->failed_room[g.coder->n_subroom - 1]) {
             tmpcr = build_room(&tmproom, g.coder->croom);
@@ -5430,7 +5430,7 @@ lspo_region(lua_State* L)
          * "lvflags_only" ==> filled=2, probably in a get_table_needfill_opt */
         needfill = get_table_int_opt(L, "filled", 0);
         irregular = get_table_boolean_opt(L, "irregular", 0);
-        joined = get_table_boolean_opt(L, "joined", 1);
+        joined = get_table_boolean_opt(L, "joined", TRUE);
         do_arrival_room = get_table_boolean_opt(L, "arrival_room", 0);
         rtype = get_table_roomtype_opt(L, "type", OROOM);
         rlit = get_table_int_opt(L, "lit", -1);