From: nhmall Date: Thu, 30 May 2019 22:10:41 +0000 (-0400) Subject: Merge branch 'NetHack-3.6' X-Git-Tag: NetHack-3.7.0_WIP~394 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7437b0b6e65fc8e12b2a2d52139fa932dde455d8;p=nethack Merge branch 'NetHack-3.6' --- 7437b0b6e65fc8e12b2a2d52139fa932dde455d8 diff --cc include/hack.h index b8a747119,8cb0b7253..159abb571 --- a/include/hack.h +++ b/include/hack.h @@@ -17,20 -17,8 +17,17 @@@ #define OFF 0 #define BOLT_LIM 8 /* from this distance ranged attacks will be made */ #define MAX_CARR_CAP 1000 /* so that boulders can be heavier */ - #define DUMMY \ - { \ - 0 \ - } + #define DUMMY { 0 } /* array initializer, letting [1..N-1] default */ +/* The UNDEFINED macros are used to initialize variables whose + initialized value is not relied upon. + UNDEFINED_VALUE: used to initialize any scalar type except pointers. + UNDEFINED_VALUES: used to initialize any non scalar type without pointers. + UNDEFINED_PTR: can be used only on pointer types. */ +#define UNDEFINED_VALUE 0 +#define UNDEFINED_VALUES { 0 } +#define UNDEFINED_PTR NULL + /* symbolic names for capacity levels */ enum encumbrance_types { UNENCUMBERED = 0, diff --cc src/mon.c index 20ee07b74,de07a96a6..7a8ec71bf --- a/src/mon.c +++ b/src/mon.c @@@ -2597,10 -2600,8 +2598,8 @@@ struct monst *mtmp m_into_limbo(mtmp); return; } - if (!isok(mm.x, mm.y)) - return; rloc_to(mtmp, mm.x, mm.y); - if (!in_mklev && (mtmp->mstrategy & STRAT_APPEARMSG)) { + if (!g.in_mklev && (mtmp->mstrategy & STRAT_APPEARMSG)) { mtmp->mstrategy &= ~STRAT_APPEARMSG; /* one chance only */ if (!couldspot && canspotmon(mtmp)) pline("%s suddenly %s!", Amonnam(mtmp), diff --cc src/pickup.c index 84ac8e448,151a63808..19be7a71b --- a/src/pickup.c +++ b/src/pickup.c @@@ -2556,14 -2569,14 +2556,14 @@@ boolean more_containers; /* True iff #l * or * is empty. Do what with it? [:irs nq or ?] */ - for (;;) { /* repeats iff '?' or ":' gets chosen */ + for (;;) { /* repeats iff '?' or ':' gets chosen */ - outmaybe = (outokay || !current_container->cknown); + outmaybe = (outokay || !g.current_container->cknown); if (!outmaybe) (void) safe_qbuf(qbuf, (char *) 0, " is empty. Do what with it?", - current_container, Yname2, Ysimple_name2, + g.current_container, Yname2, Ysimple_name2, "This"); else - (void) safe_qbuf(qbuf, "Do what with ", "?", current_container, + (void) safe_qbuf(qbuf, "Do what with ", "?", g.current_container, yname, ysimple_name, "it"); /* ask player about what to do with this container */ if (flags.menu_style == MENU_PARTIAL diff --cc src/teleport.c index 956d19453,fe5689aeb..24a4bd186 --- a/src/teleport.c +++ b/src/teleport.c @@@ -36,7 -39,8 +36,8 @@@ unsigned gpflags * which could be co-located and thus get restricted a bit too much. * oh well. */ - if (mtmp != &g.youmonst && x == u.ux && y == u.uy + if (x == u.ux && y == u.uy - && mtmp != &youmonst && (mtmp != u.ustuck || !u.uswallow) ++ && mtmp != &g.youmonst && (mtmp != u.ustuck || !u.uswallow) && (!u.usteed || mtmp != u.usteed)) return FALSE; @@@ -126,9 -132,16 +129,16 @@@ unsigned entflags /* default to player's original monster type */ mdat = &mons[u.umonster]; } - fakemon = zeromonst; + fakemon = cg.zeromonst; set_mon_data(&fakemon, mdat); /* set up for goodpos */ + /* used to use 'if (range > ROWNO && range > COLNO) return FALSE' below, + so effectively 'max(ROWNO, COLNO)' which performs useless iterations + (possibly many iterations if is in the center of the map) */ + xmax = max(xx - 1, (COLNO - 1) - xx); + ymax = max(yy - 0, (ROWNO - 1) - yy); + rangemax = max(xmax, ymax); + /* setup: no suitable spots yet, first iteration checks adjacent spots */ good_ptr = good; range = 1; /* @@@ -858,9 -879,9 +876,9 @@@ level_tele( * we let negative values requests fall into the "heaven" loop. */ if (In_quest(&u.uz) && newlev > 0) - newlev = newlev + dungeons[u.uz.dnum].depth_start - 1; + newlev = newlev + g.dungeons[u.uz.dnum].depth_start - 1; } else { /* involuntary level tele */ - random_levtport: + random_levtport: newlev = random_teleport_level(); if (newlev == depth(&u.uz)) { You1(shudder_for_moment);