OSDN Git Service

add missing "#ifdef X11LARGETILE"
[jnethack/source.git] / src / dungeon.c
index 07fe969..ee21ae1 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 dungeon.c       $NHDT-Date: 1523308357 2018/04/09 21:12:37 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.87 $ */
+/* NetHack 3.6 dungeon.c       $NHDT-Date: 1559476918 2019/06/02 12:01:58 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.95 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -71,7 +71,6 @@ STATIC_DCL void FDECL(traverse_mapseenchn, (BOOLEAN_P, winid,
                                             int, int, int *));
 STATIC_DCL const char *FDECL(seen_string, (XCHAR_P, const char *));
 STATIC_DCL const char *FDECL(br_string2, (branch *));
-STATIC_DCL const char *FDECL(endgamelevelname, (char *, int));
 STATIC_DCL const char *FDECL(shop_string, (int));
 STATIC_DCL char *FDECL(tunesuffix, (mapseen *, char *));
 
@@ -182,6 +181,8 @@ boolean perform_write, free_data;
             next_ms = curr_ms->next;
             if (curr_ms->custom)
                 free((genericptr_t) curr_ms->custom);
+            if (curr_ms->final_resting_place)
+                savecemetery(fd, FREE_SAVE, &curr_ms->final_resting_place);
             free((genericptr_t) curr_ms);
         }
         mapseenchn = 0;
@@ -980,7 +981,7 @@ init_dungeons()
         if (dunlevs_in_dungeon(&x->dlevel) > 1 - dungeons[i].depth_start)
             dungeons[i].depth_start -= 1;
         /* TODO: strip "dummy" out all the way here,
-           so that it's hidden from <ctrl/O> feedback. */
+           so that it's hidden from '#wizwhere' feedback. */
     }
 
 #ifdef DEBUG
@@ -1201,6 +1202,13 @@ void
 u_on_newpos(x, y)
 int x, y;
 {
+    if (!isok(x, y)) { /* validate location */
+        void VDECL((*func), (const char *, ...)) PRINTF_F(1, 2);
+
+        func = (x < 0 || y < 0 || x > COLNO - 1 || y > ROWNO - 1) ? panic
+               : impossible;
+        (*func)("u_on_newpos: trying to place hero off map <%d,%d>", x, y);
+    }
     u.ux = x;
     u.uy = y;
 #ifdef CLIPPING
@@ -1215,7 +1223,7 @@ int x, y;
         u.ux0 = u.ux, u.uy0 = u.uy;
 }
 
-/* place you on a random location */
+/* place you on a random location when arriving on a level */
 void
 u_on_rndspot(upflag)
 int upflag;
@@ -1243,6 +1251,9 @@ int upflag;
         place_lregion(dndest.lx, dndest.ly, dndest.hx, dndest.hy,
                       dndest.nlx, dndest.nly, dndest.nhx, dndest.nhy,
                       LR_DOWNTELE, (d_level *) 0);
+
+    /* might have just left solid rock and unblocked levitation */
+    switch_terrain();
 }
 
 /* place you on the special staircase */
@@ -1676,7 +1687,7 @@ const char *nam;
             *(eos(buf) - 6) = '\0';
         }
         /* hell is the old name, and wouldn't match; gehennom would match its
-           branch, yielding the castle level instead of the valley of the dead */
+           branch, yielding the castle level instead of valley of the dead */
         if (!strcmpi(nam, "gehennom") || !strcmpi(nam, "hell")) {
             if (In_V_tower(&u.uz))
                 nam = " to Vlad's tower"; /* branch to... */
@@ -1851,7 +1862,7 @@ struct lchoice *lchoices_p;
     for (br = branches; br; br = br->next) {
         if (br->end1.dnum == dnum && lower_bound < br->end1.dlevel
             && br->end1.dlevel <= upper_bound) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             Sprintf(buf, "%c %s to %s: %d",
                     bymenu ? chr_u_on_lvl(&br->end1) : ' ',
                     br_string(br->type),
@@ -1905,7 +1916,7 @@ xchar *rdgn;
         descr = unplaced ? "\92n\89º" : "\83\8c\83x\83\8b";
         nlev = dptr->num_dunlevs;
         if (nlev > 1)
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             Sprintf(buf, "%s: %s %d to %d", dptr->dname, makeplural(descr),
                     dptr->depth_start, dptr->depth_start + nlev - 1);
 #else
@@ -1923,7 +1934,7 @@ xchar *rdgn;
 */
                 Strcat(buf, ", \89º\82©\82ç\82Ì\93ü\82è\8cû");
             else
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                 Sprintf(eos(buf), ", entrance on %d",
                         dptr->depth_start + dptr->entry_lev - 1);
 #else
@@ -2001,7 +2012,7 @@ xchar *rdgn;
                 putstr(win, 0, "\95\82\93®\95ª\8aò");
                 first = FALSE;
             }
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             Sprintf(buf, "   %s to %s", br_string(br->type),
                     dungeons[br->end2.dnum].dname);
 #else
@@ -2015,7 +2026,7 @@ xchar *rdgn;
     /* I hate searching for the invocation pos while debugging. -dean */
     if (Invocation_lev(&u.uz)) {
         putstr(win, 0, "");
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Sprintf(buf, "Invocation position @ (%d,%d), hero @ (%d,%d)",
                 inv_pos.x, inv_pos.y, u.ux, u.uy);
 #else
@@ -2041,7 +2052,7 @@ xchar *rdgn;
                     trap->tx, trap->ty, u.ux, u.uy);
 
         /* only report "no portal found" when actually expecting a portal */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         else if (Is_earthlevel(&u.uz) || Is_waterlevel(&u.uz)
                  || Is_firelevel(&u.uz) || Is_airlevel(&u.uz)
                  || Is_qstart(&u.uz) || at_dgn_entrance("The Quest")
@@ -2136,7 +2147,7 @@ donamelevel()
     if (mptr->custom) {
         char tmpbuf[BUFSZ];
 
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Sprintf(tmpbuf, "Replace annotation \"%.30s%s\" with?", mptr->custom,
                 (strlen(mptr->custom) > 30) ? "..." : "");
 #else
@@ -2238,7 +2249,8 @@ int ledger_num;
     struct cemetery *bp, *bpnext;
 
     for (mptr = mapseenchn; mptr; mprev = mptr, mptr = mptr->next)
-        if (dungeons[mptr->lev.dnum].ledger_start + mptr->lev.dlevel == ledger_num)
+        if (dungeons[mptr->lev.dnum].ledger_start + mptr->lev.dlevel
+            == ledger_num)
             break;
 
     if (!mptr)
@@ -2282,7 +2294,7 @@ mapseen *mptr;
     bwrite(fd, (genericptr_t) &mptr->custom_lth, sizeof mptr->custom_lth);
     if (mptr->custom_lth)
         bwrite(fd, (genericptr_t) mptr->custom, mptr->custom_lth);
-    bwrite(fd, (genericptr_t) &mptr->msrooms, sizeof mptr->msrooms);
+    bwrite(fd, (genericptr_t) mptr->msrooms, sizeof mptr->msrooms);
     savecemetery(fd, WRITE_SAVE, &mptr->final_resting_place);
 }
 
@@ -2313,7 +2325,7 @@ int fd;
         load->custom[load->custom_lth] = '\0';
     } else
         load->custom = 0;
-    mread(fd, (genericptr_t) &load->msrooms, sizeof load->msrooms);
+    mread(fd, (genericptr_t) load->msrooms, sizeof load->msrooms);
     restcemetery(fd, &load->final_resting_place);
 
     return load;
@@ -2602,7 +2614,7 @@ recalc_mapseen()
                 if (ltyp == DRAWBRIDGE_UP)
                     ltyp = db_under_typ(levl[x][y].drawbridgemask);
                 if ((mtmp = m_at(x, y)) != 0
-                    && mtmp->m_ap_type == M_AP_FURNITURE && canseemon(mtmp))
+                    && M_AP_TYPE(mtmp) == M_AP_FURNITURE && canseemon(mtmp))
                     ltyp = cmap_to_type(mtmp->mappearance);
                 lastseentyp[x][y] = ltyp;
             }
@@ -2738,8 +2750,7 @@ recalc_mapseen()
 }
 
 /*ARGUSED*/
-/* valley and sanctum levels get automatic annotation once temple is entered
- */
+/* valley and sanctum levels get automatic annotation once temple is entered */
 void
 mapseen_temple(priest)
 struct monst *priest UNUSED; /* currently unused; might be useful someday */
@@ -2882,7 +2893,7 @@ branch *br;
 }
 
 /* get the name of an endgame level; topten.c does something similar */
-STATIC_OVL const char *
+const char *
 endgamelevelname(outbuf, indx)
 char *outbuf;
 int indx;
@@ -2936,7 +2947,7 @@ STATIC_OVL const char *
 shop_string(rtype)
 int rtype;
 {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     const char *str = "shop"; /* catchall */
 #else
     const char *str = "\93X"; /* catchall */
@@ -3053,7 +3064,7 @@ char *outbuf;
 #endif
 #define COMMA (i++ > 0 ? ", " : PREFIX)
 /* "iterate" once; safe to use as ``if (cond) ADDTOBUF(); else whatever;'' */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
 #define ADDNTOBUF(nam, var)                                                  \
     do {                                                                     \
         if (var)                                                             \
@@ -3140,7 +3151,7 @@ boolean printdun;
     if (mptr->custom)
         Sprintf(eos(buf), " \"%s\"", mptr->custom);
     if (on_level(&u.uz, &mptr->lev))
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Sprintf(eos(buf), " <- You %s here.",
                 (!final || (final == 1 && how == ASCENDED)) ? "are"
                   : (final == 1 && how == ESCAPED) ? "left from"
@@ -3234,7 +3245,7 @@ boolean printdun;
 */
         Sprintf(buf, "%s\83f\83\8b\83t\83@\83C\82Ì\90_\93a\81D", PREFIX);
     } else if (In_sokoban(&mptr->lev)) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Sprintf(buf, "%s%s.", PREFIX,
                 mptr->flags.sokosolved ? "Solved" : "Unsolved");
 #else
@@ -3252,7 +3263,7 @@ boolean printdun;
 */
         Sprintf(buf, "%s\92P\8f\83\82È\95\94\89®\81D", PREFIX);
     } else if (on_level(&mptr->lev, &qstart_level)) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Sprintf(buf, "%sHome%s.", PREFIX,
                 mptr->flags.unreachable ? " (no way back...)" : "");
 #else
@@ -3306,7 +3317,7 @@ boolean printdun;
 
     /* print out branches */
     if (mptr->br) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Sprintf(buf, "%s%s to %s", PREFIX, br_string2(mptr->br),
                 dungeons[mptr->br->end2.dnum].dname);
 #else