Merge branch 'NetHack-3.6.2'

This commit is contained in:
nhmall
2018-12-19 06:47:30 -05:00
8 changed files with 103 additions and 85 deletions
+3
View File
@@ -286,6 +286,9 @@ while levitating inside a shop, throwing an unpaid item and having recoil move
the shopkeeper and summon kops the shopkeeper and summon kops
diluted potion of oil is less effective when filling lamps (adds less fuel) diluted potion of oil is less effective when filling lamps (adds less fuel)
or burning (lasts less long) or exploding (inflicts less damage) or burning (lasts less long) or exploding (inflicts less damage)
apply fix from grunthack to prevent panic "fakecorr overflow" when vault guard
couldn't figure out how to lead the hero from vault to civilization;
fixes longstanding bug C343-23
Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
+4
View File
@@ -405,6 +405,10 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
#if __GNUC__ >= 3 #if __GNUC__ >= 3
#define UNUSED __attribute__((unused)) #define UNUSED __attribute__((unused))
#define NORETURN __attribute__((noreturn)) #define NORETURN __attribute__((noreturn))
/* disable gcc's __attribute__((__warn_unused_result__)) since explicitly
discarding the result by casting to (void) is not accepted as a 'use' */
#define __warn_unused_result__ /*empty*/
#define warn_unused_result /*empty*/
#endif #endif
#endif #endif
+70 -56
View File
@@ -1,17 +1,17 @@
/* NetHack 3.6 vault.c $NHDT-Date: 1544608469 2018/12/12 09:54:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.57 $ */ /* NetHack 3.6 vault.c $NHDT-Date: 1545217597 2018/12/19 11:06:37 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.58 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
#include "hack.h" #include "hack.h"
STATIC_DCL struct monst *NDECL(findgd);
STATIC_DCL boolean FDECL(clear_fcorr, (struct monst *, BOOLEAN_P)); STATIC_DCL boolean FDECL(clear_fcorr, (struct monst *, BOOLEAN_P));
STATIC_DCL void FDECL(blackout, (int, int)); STATIC_DCL void FDECL(blackout, (int, int));
STATIC_DCL void FDECL(restfakecorr, (struct monst *)); STATIC_DCL void FDECL(restfakecorr, (struct monst *));
STATIC_DCL void FDECL(parkguard, (struct monst *)); STATIC_DCL void FDECL(parkguard, (struct monst *));
STATIC_DCL boolean FDECL(in_fcorridor, (struct monst *, int, int)); STATIC_DCL boolean FDECL(in_fcorridor, (struct monst *, int, int));
STATIC_DCL struct monst *NDECL(findgd);
STATIC_DCL boolean FDECL(find_guard_dest, (struct monst *, xchar *, xchar *));
STATIC_DCL void FDECL(move_gold, (struct obj *, int)); STATIC_DCL void FDECL(move_gold, (struct obj *, int));
STATIC_DCL void FDECL(wallify_vault, (struct monst *)); STATIC_DCL void FDECL(wallify_vault, (struct monst *));
STATIC_DCL void FDECL(gd_mv_monaway, (struct monst *, int, int)); STATIC_DCL void FDECL(gd_mv_monaway, (struct monst *, int, int));
@@ -232,6 +232,44 @@ char *array;
return '\0'; return '\0';
} }
STATIC_OVL boolean
find_guard_dest(guard, rx, ry)
struct monst *guard;
xchar *rx, *ry;
{
register int x, y, dd, lx = 0, ly = 0;
for (dd = 2; (dd < ROWNO || dd < COLNO); dd++) {
for (y = u.uy - dd; y <= u.uy + dd; ly = y, y++) {
if (y < 0 || y > ROWNO - 1)
continue;
for (x = u.ux - dd; x <= u.ux + dd; lx = x, x++) {
if (y != u.uy - dd && y != u.uy + dd && x != u.ux - dd)
x = u.ux + dd;
if (x < 1 || x > COLNO - 1)
continue;
if (guard && ((x == guard->mx && y == guard->my)
|| (guard->isgd && in_fcorridor(guard, x, y))))
continue;
if (levl[x][y].typ == CORR) {
lx = (x < u.ux) ? x + 1 : (x > u.ux) ? x - 1 : x;
ly = (y < u.uy) ? y + 1 : (y > u.uy) ? y - 1 : y;
if (levl[lx][ly].typ != STONE && levl[lx][ly].typ != CORR)
goto incr_radius;
*rx = x;
*ry = y;
return TRUE;
}
}
}
incr_radius:
;
}
impossible("Not a single corridor on this level?");
tele();
return FALSE;
}
void void
invault() invault()
{ {
@@ -252,49 +290,14 @@ invault()
if (++u.uinvault % VAULT_GUARD_TIME == 0 && !guard) { if (++u.uinvault % VAULT_GUARD_TIME == 0 && !guard) {
/* if time ok and no guard now. */ /* if time ok and no guard now. */
char buf[BUFSZ]; char buf[BUFSZ];
register int x, y, dd, gx, gy; register int x, y, gx, gy;
int lx = 0, ly = 0; xchar rx, ry;
long umoney; long umoney;
/* first find the goal for the guard */ /* first find the goal for the guard */
for (dd = 2; (dd < ROWNO || dd < COLNO); dd++) { if (!find_guard_dest((struct monst *)0, &rx, &ry))
for (y = u.uy - dd; y <= u.uy + dd; ly = y, y++) { return;
if (y < 0 || y > ROWNO - 1) gx = rx, gy = ry;
continue;
for (x = u.ux - dd; x <= u.ux + dd; lx = x, x++) {
if (y != u.uy - dd && y != u.uy + dd && x != u.ux - dd)
x = u.ux + dd;
if (x < 1 || x > COLNO - 1)
continue;
if (levl[x][y].typ == CORR) {
if (x < u.ux)
lx = x + 1;
else if (x > u.ux)
lx = x - 1;
else
lx = x;
if (y < u.uy)
ly = y + 1;
else if (y > u.uy)
ly = y - 1;
else
ly = y;
if (levl[lx][ly].typ != STONE
&& levl[lx][ly].typ != CORR)
goto incr_radius;
goto fnd;
}
}
}
incr_radius:
;
}
impossible("Not a single corridor on this level??");
tele();
return;
fnd:
gx = x;
gy = y;
/* next find a good place for a door in the wall */ /* next find a good place for a door in the wall */
x = u.ux; x = u.ux;
@@ -621,7 +624,7 @@ gd_move(grd)
register struct monst *grd; register struct monst *grd;
{ {
int x, y, nx, ny, m, n; int x, y, nx, ny, m, n;
int dx, dy, gx, gy, fci; int dx, dy, gx = 0, gy = 0, fci;
uchar typ; uchar typ;
struct rm *crm; struct rm *crm;
struct fakecorridor *fcp; struct fakecorridor *fcp;
@@ -705,7 +708,7 @@ register struct monst *grd;
levl[m][n].typ = egrd->fakecorr[0].ftyp; levl[m][n].typ = egrd->fakecorr[0].ftyp;
newsym(m, n); newsym(m, n);
grd->mpeaceful = 0; grd->mpeaceful = 0;
letknow: letknow:
if (!cansee(grd->mx, grd->my) || !mon_visible(grd)) if (!cansee(grd->mx, grd->my) || !mon_visible(grd))
You_hear("%s.", You_hear("%s.",
m_carrying(grd, TIN_WHISTLE) m_carrying(grd, TIN_WHISTLE)
@@ -848,10 +851,10 @@ register struct monst *grd;
goto proceed; goto proceed;
} }
} }
nextnxy: nextnxy:
; ;
} }
nextpos: nextpos:
nx = x; nx = x;
ny = y; ny = y;
gx = egrd->gdx; gx = egrd->gdx;
@@ -892,19 +895,30 @@ nextpos:
break; break;
} }
crm->typ = CORR; crm->typ = CORR;
proceed: proceed:
newspot = TRUE; newspot = TRUE;
unblock_point(nx, ny); /* doesn't block light */ unblock_point(nx, ny); /* doesn't block light */
if (cansee(nx, ny)) if (cansee(nx, ny))
newsym(nx, ny); newsym(nx, ny);
fcp = &(egrd->fakecorr[egrd->fcend]); if ((nx != gx || ny != gy) || (grd->mx != gx || grd->my != gy)) {
if (egrd->fcend++ == FCSIZ) fcp = &(egrd->fakecorr[egrd->fcend]);
panic("fakecorr overflow"); if (egrd->fcend++ == FCSIZ)
fcp->fx = nx; panic("fakecorr overflow");
fcp->fy = ny; fcp->fx = nx;
fcp->ftyp = typ; fcp->fy = ny;
newpos: fcp->ftyp = typ;
} else if (!egrd->gddone) {
/* We're stuck, so try to find a new destination. */
if (!find_guard_dest(grd, &egrd->gdx, &egrd->gdy)
|| (egrd->gdx == gx && egrd->gdy == gy)) {
pline("%s, confused, disappears.", Monnam(grd));
disappear_msg_seen = TRUE;
goto cleanup;
} else
goto nextpos;
}
newpos:
gd_mv_monaway(grd, nx, ny); gd_mv_monaway(grd, nx, ny);
if (egrd->gddone) { if (egrd->gddone) {
/* The following is a kludge. We need to keep */ /* The following is a kludge. We need to keep */
@@ -916,7 +930,7 @@ newpos:
/* to avoid a check at the top of this function. */ /* to avoid a check at the top of this function. */
/* At the end of the process, the guard is killed */ /* At the end of the process, the guard is killed */
/* in restfakecorr(). */ /* in restfakecorr(). */
cleanup: cleanup:
x = grd->mx, y = grd->my; x = grd->mx, y = grd->my;
see_guard = canspotmon(grd); see_guard = canspotmon(grd);
parkguard(grd); /* move to <0,0> */ parkguard(grd); /* move to <0,0> */
+3 -23
View File
@@ -3,7 +3,7 @@
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
/* /*
* System related functions for MSDOS, OS/2, TOS, and Windows NT * System related functions for MSDOS, OS/2, TOS
*/ */
#define NEED_VARARGS #define NEED_VARARGS
@@ -28,7 +28,7 @@
#define filesize filesize_nh #define filesize filesize_nh
#endif #endif
#if defined(MICRO) || defined(WIN32) || defined(OS2) #if defined(MICRO) || defined(OS2)
void FDECL(nethack_exit, (int)); void FDECL(nethack_exit, (int));
#else #else
#define nethack_exit exit #define nethack_exit exit
@@ -51,11 +51,7 @@ STATIC_DCL boolean NDECL(comspec_exists);
#endif #endif
#endif #endif
#ifdef WIN32 #if defined(MICRO)
extern int GUILaunched; /* from nttty.c */
#endif
#if defined(MICRO) || defined(WIN32)
void void
flushout() flushout()
@@ -391,7 +387,6 @@ char *name;
return; return;
} }
#ifndef WIN32
void void
getreturn(str) getreturn(str)
const char *str; const char *str;
@@ -420,7 +415,6 @@ VA_DECL(const char *, fmt)
VA_END(); VA_END();
return; return;
} }
#endif
/* /*
* Follow the PATH, trying to fopen the file. * Follow the PATH, trying to fopen the file.
@@ -507,10 +501,8 @@ msexit()
flushout(); flushout();
#ifndef TOS #ifndef TOS
#ifndef WIN32
enable_ctrlP(); /* in case this wasn't done */ enable_ctrlP(); /* in case this wasn't done */
#endif #endif
#endif
#ifdef MFLOPPY #ifdef MFLOPPY
if (ramdisk) if (ramdisk)
copybones(TOPERM); copybones(TOPERM);
@@ -526,18 +518,6 @@ msexit()
if (colors_changed) if (colors_changed)
restore_colors(); restore_colors();
#endif #endif
#endif
#ifdef WIN32
/* Only if we started from the GUI, not the command prompt,
* we need to get one last return, so the score board does
* not vanish instantly after being created.
* GUILaunched is defined and set in nttty.c.
*/
synch_cursor();
if (GUILaunched)
getreturn("to end");
synch_cursor();
getreturn_enabled = TRUE;
#endif #endif
wait_synch(); wait_synch();
return; return;
+3 -4
View File
@@ -233,7 +233,7 @@ VOBJ24 = $(O)track.o $(O)trap.o $(O)u_init.o $(O)uhitm.o
VOBJ25 = $(O)vault.o $(O)vis_tab.o $(O)vision.o $(O)weapon.o VOBJ25 = $(O)vault.o $(O)vis_tab.o $(O)vision.o $(O)weapon.o
VOBJ26 = $(O)were.o $(O)wield.o $(O)windows.o $(O)wizard.o VOBJ26 = $(O)were.o $(O)wield.o $(O)windows.o $(O)wizard.o
VOBJ27 = $(O)worm.o $(O)worn.o $(O)write.o $(O)zap.o VOBJ27 = $(O)worm.o $(O)worn.o $(O)write.o $(O)zap.o
VOBJ28 = $(O)win10.o $(O)safeproc.o $(O)windmain.o VOBJ28 =
DLBOBJ = $(O)dlb.o DLBOBJ = $(O)dlb.o
@@ -248,7 +248,8 @@ CURSESOBJ= $(O)cursdial.o $(O)cursinit.o $(O)cursinvt.o $(O)cursmain.o \
$(O)cursmesg.o $(O)cursmisc.o $(O)cursstat.o $(O)curswins.o $(O)cursmesg.o $(O)cursmisc.o $(O)cursstat.o $(O)curswins.o
!ENDIF !ENDIF
SOBJ = $(O)winnt.o $(O)pcsys.o $(SOUND) $(O)nhlan.o SOBJ = $(O)windmain.o $(O)winnt.o $(O)win10.o \
$(O)safeproc.o $(O)nhlan.o $(SOUND)
OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \ OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
$(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \ $(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \
@@ -1511,8 +1512,6 @@ $(O)\curswins.c: $(WCURSES)\curswins.c $(WCURSES)\curswins.h $(INCL)\wincurs.h
$(O)tos.o: ..\sys\atari\tos.c $(HACK_H) $(INCL)\tcap.h $(O)tos.o: ..\sys\atari\tos.c $(HACK_H) $(INCL)\tcap.h
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\atari\tos.c @$(CC) $(cflagsBuild) -Fo$@ ..\sys\atari\tos.c
$(O)pcsys.o: ..\sys\share\pcsys.c $(HACK_H)
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcsys.c
$(O)pctty.o: ..\sys\share\pctty.c $(HACK_H) $(O)pctty.o: ..\sys\share\pctty.c $(HACK_H)
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pctty.c @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pctty.c
$(O)random.o: ..\sys\share\random.c $(HACK_H) $(O)random.o: ..\sys\share\random.c $(HACK_H)
+20
View File
@@ -660,6 +660,26 @@ const char *window_opt;
} }
return 0; return 0;
} }
/*
* Add a backslash to any name not ending in /, \ or : There must
* be room for the \
*/
void
append_slash(name)
char *name;
{
char *ptr;
if (!*name)
return;
ptr = name + (strlen(name) - 1);
if (*ptr != '\\' && *ptr != '/' && *ptr != ':') {
*++ptr = '\\';
*++ptr = '\0';
}
return;
}
#endif /* WIN32 */ #endif /* WIN32 */
/*winnt.c*/ /*winnt.c*/
-1
View File
@@ -151,7 +151,6 @@
<ClCompile Include="$(SrcDir)zap.c" /> <ClCompile Include="$(SrcDir)zap.c" />
<ClCompile Include="$(SysShareDir)cppregex.cpp" /> <ClCompile Include="$(SysShareDir)cppregex.cpp" />
<ClCompile Include="$(SysShareDir)nhlan.c" /> <ClCompile Include="$(SysShareDir)nhlan.c" />
<ClCompile Include="$(SysShareDir)pcsys.c" />
<ClCompile Include="$(SysShareDir)random.c" /> <ClCompile Include="$(SysShareDir)random.c" />
<ClCompile Include="$(SysWinntDir)ntsound.c" /> <ClCompile Include="$(SysWinntDir)ntsound.c" />
<ClCompile Include="$(SysWinntDir)nttty.c" /> <ClCompile Include="$(SysWinntDir)nttty.c" />
-1
View File
@@ -146,7 +146,6 @@
<ClCompile Include="$(SrcDir)zap.c" /> <ClCompile Include="$(SrcDir)zap.c" />
<ClCompile Include="$(SysShareDir)cppregex.cpp" /> <ClCompile Include="$(SysShareDir)cppregex.cpp" />
<ClCompile Include="$(SysShareDir)nhlan.c" /> <ClCompile Include="$(SysShareDir)nhlan.c" />
<ClCompile Include="$(SysShareDir)pcsys.c" />
<ClCompile Include="$(SysShareDir)random.c" /> <ClCompile Include="$(SysShareDir)random.c" />
<ClCompile Include="$(SysWinntDir)ntsound.c" /> <ClCompile Include="$(SysWinntDir)ntsound.c" />
<ClCompile Include="$(SysWinntDir)stubs.c"> <ClCompile Include="$(SysWinntDir)stubs.c">