Skip to content

Commit d7bb2ba

Browse files
committed
Merge branch 'NetHack-3.6' of https://github.com/NetHack/NetHack
2 parents fedef75 + 73c2922 commit d7bb2ba

File tree

6 files changed

+64
-121
lines changed

6 files changed

+64
-121
lines changed

dat/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rumors
99
bogusmon
1010
engrave
1111
epitaph
12+
grep*.tmp
1213
x11tiles
1314
nhtiles.bmp
1415
*.lev

doc/evilhack-changelog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3318,7 +3318,7 @@ The following changes to date are:
33183318

33193319
### Version 0.8.4
33203320

3321-
- Latest merges from 'vanilla' NetHack 3.6.7 official release (as of April 15th, 2024)
3321+
- Latest merges from 'vanilla' NetHack 3.6.7 official release (as of May 11th, 2024)
33223322
- Initial preparation for new version (0.8.4)
33233323
- Fix: prevent the Amulet of Yendor from being teleported whilst in the
33243324
Sanctum

doc/fixes36.7

+5-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ vms: update winprocs.h to ensure that CLR_MAX is defined; necessary for
4747
compiling vmsmail.c which uses winprocs.h but not hack.h
4848
curses: when #quitting, just before the high scores are about to be shown
4949
status_window was NULL and dereferenced, so add checks (issue #1090)
50-
when make was invoked with -j makedefs instances could end up running in
51-
parallel and could trample on each other's temp files; default to
52-
using mkstemp(); allow a port runtime library implementation that lacks
53-
mkstemp() to define HAS_NO_MKSTEMP to revert to the old behaviour;
54-
provide a work-alike mkstemp() implementation for windows visual studio
55-
so there is no requirement to define HAS_NO_MKSTEMP there
50+
unix: update Makefile.dat so that if parallel make is used, it will build
51+
the data files "engrave", "epitaph", and "bogusmon" sequentially;
52+
'makedefs -s' builds all three at once and doing parallel instances
53+
of that can produce seemingly mysterious problems by stomping on
54+
each other's results
5655
fix the mingw32 build of NetHack 3.6.7 by updating sys/winnt/Makefile.gcc,
5756
sys/winnt/winnt.c and sys/winnt/stubs.c
5857

src/objnam.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,17 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
10261026
releaseobuf(obufp);
10271027
}
10281028

1029-
if (program_state.gameover) {
1029+
/* additional information shown during end-of-game inventory disclosure */
1030+
if (obj->otyp == T_SHIRT && program_state.gameover
1031+
/* o_id will be 0 for wizard mode attribute disclosure (formatted
1032+
via from_what() -> ysimple_name() -> minimal_xname() -> xname()
1033+
by the enlightenment code; moot here since T-shirts don't affect
1034+
any attributes (but for 3.7, aprons will have comparable text) */
1035+
&& obj->o_id
1036+
/* distantname is non-0 for do_screen_description() which is used
1037+
to produce tooltip text for HTMLDUMP (not supported by nethack) */
1038+
&& !distantname
1039+
) {
10301040
char tmpbuf[BUFSZ];
10311041

10321042
/* disclose without breaking illiterate conduct, but mainly tip off

sys/unix/Makefile.dat

+13-7
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,27 @@ quest.dat: quest.txt ../util/makedefs
112112
oracles: oracles.txt ../util/makedefs
113113
../util/makedefs -h
114114

115-
engrave: engrave.txt ../util/makedefs
115+
# note: 'makedefs -s' constructs three files at once: "epitaph", "engrave",
116+
# and "bogusmon", in that order, but traditional 'make' doesn't provide any
117+
# way for a Makefile to indicate that; make the third depend on the second
118+
# and the second depend on the first so that if someone runs parallel make
119+
# it will be forced to run three instances of 'makedefs -s' sequentially
120+
# rather than simultaneously; depending upon how 'make' checks timestamps,
121+
# this might result in building all three of them three times in a row
122+
# [that will still produce the correct result in the end, and the extra
123+
# overhead of doing it should be negligible]
124+
bogusmon: engrave bogusmon.txt ../util/makedefs
116125
../util/makedefs -s
117-
118-
epitaph: epitaph.txt ../util/makedefs
126+
engrave: epitaph engrave.txt ../util/makedefs
119127
../util/makedefs -s
120-
121-
bogusmon: bogusmon.txt ../util/makedefs
128+
epitaph: epitaph.txt ../util/makedefs
122129
../util/makedefs -s
123130

124-
vaults.dat: spec_levs
125-
126131
# note: 'options' should have already been made when include/date.h was created
127132
options: ../util/makedefs
128133
../util/makedefs -v
129134

135+
vaults.dat: spec_levs
130136

131137
spec_levs: ../util/lev_comp \
132138
bigroom.des castle.des endgame.des gehennom.des goblintown.des \

util/makedefs.c

+33-106
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@
5252
#define rewind(fp) fseek((fp), 0L, SEEK_SET) /* guarantee a return value */
5353
#endif
5454

55-
#ifndef HAS_NO_MKSTEMP
56-
#ifdef _MSC_VER
57-
static int FDECL(mkstemp, (char *));
58-
#endif
59-
#endif
60-
6155
#if defined(UNIX) && !defined(LINT) && !defined(GCC_WARN)
6256
static const char SCCS_Id[] UNUSED = "@(#)makedefs.c\t3.6\t2020/03/04";
6357
#endif
@@ -136,8 +130,6 @@ static struct version_info version;
136130
#define CLOSE_OFF_TABLE_STRING "99" /* for the close table */
137131
#define FAR_OFF_TABLE_STRING "0xff" /* for the far table */
138132

139-
#define FLG_TEMPFILE 0x01 /* flag for temp file */
140-
141133
#define sign(z) ((z) < 0 ? -1 : ((z) ? 1 : 0))
142134
#ifdef VISION_TABLES
143135
static char xclear[MAX_ROW][MAX_COL];
@@ -179,7 +171,7 @@ extern void NDECL(objects_init); /* objects.c */
179171
static void NDECL(link_sanity_check);
180172
static char *FDECL(name_file, (const char *, const char *));
181173
static void FDECL(delete_file, (const char *template, const char *));
182-
static FILE *FDECL(getfp, (const char *, const char *, const char *, int));
174+
static FILE *FDECL(getfp, (const char *, const char *, const char *));
183175
static void FDECL(do_ext_makedefs, (int, char **));
184176

185177
static void NDECL(make_version);
@@ -190,7 +182,8 @@ static char *FDECL(xcrypt, (const char *));
190182
static unsigned long FDECL(read_rumors_file,
191183
(const char *, int *, long *, unsigned long));
192184
static boolean FDECL(get_gitinfo, (char *, char *));
193-
static void FDECL(do_rnd_access_file, (const char *, const char *));
185+
static void FDECL(do_rnd_access_file,
186+
(const char *, const char *, const char *));
194187
static boolean FDECL(d_filter, (char *));
195188
static boolean FDECL(h_filter, (char *));
196189
static void NDECL(build_savebones_compat_string);
@@ -374,16 +367,19 @@ char *options;
374367
* post-3.6.5:
375368
* File must not be empty to avoid divide by 0
376369
* in core's rn2(), so provide a default entry.
370+
* [Second argument is used to construct a temporary file name
371+
* without worrying about whether the file name macros from
372+
* global.h have been modified with port-specific punctuation.]
377373
*/
378-
do_rnd_access_file(EPITAPHFILE,
374+
do_rnd_access_file(EPITAPHFILE, "epitaph",
379375
/* default epitaph: parody of the default engraving */
380376
"No matter where I went, here I am.");
381-
do_rnd_access_file(ENGRAVEFILE,
377+
do_rnd_access_file(ENGRAVEFILE, "engrave",
382378
/* default engraving: popularized by "The Adventures of
383379
Buckaroo Bonzai Across the 8th Dimenstion" but predates
384380
that 1984 movie; some attribute it to Confucius */
385381
"No matter where you go, there you are.");
386-
do_rnd_access_file(BOGUSMONFILE,
382+
do_rnd_access_file(BOGUSMONFILE, "bogusmon",
387383
/* default bogusmon: iconic monster that isn't in nethack */
388384
"grue");
389385
break;
@@ -429,39 +425,16 @@ const char *tag;
429425
}
430426

431427
static FILE *
432-
getfp(template, tag, mode, flg)
428+
getfp(template, tag, mode)
433429
const char *template;
434430
const char *tag;
435431
const char *mode;
436-
#ifndef HAS_NO_MKSTEMP
437-
int flg;
438-
#else
439-
int flg UNUSED;
440-
#endif
441432
{
442433
char *name = name_file(template, tag);
443-
FILE *rv = (FILE *) 0;
444-
#ifndef HAS_NO_MKSTEMP
445-
boolean istemp = (flg & FLG_TEMPFILE) != 0;
446-
char tmpfbuf[MAXFNAMELEN];
447-
int tmpfd;
448-
#endif
449-
450-
#ifndef HAS_NO_MKSTEMP
451-
if (istemp) {
452-
(void) snprintf(tmpfbuf, sizeof tmpfbuf, DATA_TEMPLATE, "mdXXXXXX");
453-
tmpfd = mkstemp(tmpfbuf);
454-
if (tmpfd >= 0)
455-
rv = fdopen(tmpfd, WRTMODE); /* temp file is always read+write */
456-
} else
457-
#endif
458-
rv = fopen(name, mode);
434+
FILE *rv = fopen(name, mode);
435+
459436
if (!rv) {
460-
Fprintf(stderr, "Can't open '%s'.\n",
461-
#ifndef HAS_NO_MKSTEMP
462-
istemp ? tmpfbuf :
463-
#endif
464-
name);
437+
Fprintf(stderr, "Can't open '%s'.\n", name);
465438
exit(EXIT_FAILURE);
466439
}
467440
return rv;
@@ -485,7 +458,7 @@ static int FDECL(grep_check_id, (const char *));
485458
static void FDECL(grep_show_wstack, (const char *));
486459
static char *FDECL(do_grep_control, (char *));
487460
static void NDECL(do_grep);
488-
static void FDECL(grep0, (FILE *, FILE *, int));
461+
static void FDECL(grep0, (FILE *, FILE *));
489462

490463
static int grep_trace = 0;
491464

@@ -836,7 +809,7 @@ char *buf;
836809
}
837810
#endif
838811

839-
static void grep0(FILE *, FILE *, int);
812+
static void grep0(FILE *, FILE *);
840813

841814
static void
842815
do_grep()
@@ -851,26 +824,14 @@ do_grep()
851824
exit(EXIT_FAILURE);
852825
}
853826

854-
grep0(inputfp, outputfp, 0);
827+
grep0(inputfp, outputfp);
855828
}
856829

857830
static void
858-
grep0(inputfp0, outputfp0, flg)
831+
grep0(inputfp0, outputfp0)
859832
FILE *inputfp0;
860833
FILE *outputfp0;
861-
#ifndef HAS_NO_MKSTEMP
862-
int flg;
863-
#else
864-
int flg UNUSED;
865-
#endif
866834
{
867-
#ifndef HAS_NO_MKSTEMP
868-
/* if grep0 is passed FLG_TEMPFILE flag, it will
869-
leave the output file open when it returns.
870-
The caller will have to take care of calling
871-
fclose() when it is done with the file */
872-
boolean istemp = (flg & FLG_TEMPFILE) != 0;
873-
#endif
874835
char buf[16384]; /* looong, just in case */
875836

876837
while (!feof(inputfp0) && !ferror(inputfp0)) {
@@ -910,12 +871,7 @@ int flg UNUSED;
910871
exit(EXIT_FAILURE);
911872
}
912873
fclose(inputfp0);
913-
#ifndef HAS_NO_MKSTEMP
914-
if (istemp)
915-
rewind(outputfp0);
916-
else
917-
#endif
918-
fclose(outputfp0);
874+
fclose(outputfp0);
919875
if (grep_sp) {
920876
Fprintf(stderr, "%d unterminated conditional level%s\n", grep_sp,
921877
grep_sp == 1 ? "" : "s");
@@ -1013,12 +969,13 @@ unsigned long old_rumor_offset;
1013969
}
1014970

1015971
static void
1016-
do_rnd_access_file(fname, deflt_content)
1017-
const char *fname;
972+
do_rnd_access_file(fname, basefname, deflt_content)
973+
const char *fname, *basefname;
1018974
const char *deflt_content;
1019975
{
1020-
char *line, buf[BUFSZ];
976+
char *line, greptmp[8 + 1 + 3 + 1];
1021977

978+
Sprintf(greptmp, "grep-%.3s.tmp", basefname);
1022979
Sprintf(filename, DATA_IN_TEMPLATE, fname);
1023980
Strcat(filename, ".txt");
1024981
if (!(ifp = fopen(filename, RDTMODE))) {
@@ -1045,13 +1002,9 @@ const char *deflt_content;
10451002
more likely to be picked than normal but it's nothing to worry about */
10461003
(void) fputs(xcrypt(deflt_content), ofp);
10471004

1048-
tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE, FLG_TEMPFILE);
1049-
grep0(ifp, tfp, FLG_TEMPFILE);
1050-
#ifndef HAS_NO_MKSTEMP
1051-
ifp = tfp;
1052-
#else
1053-
ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE, 0);
1054-
#endif
1005+
tfp = getfp(DATA_TEMPLATE, greptmp, WRTMODE);
1006+
grep0(ifp, tfp);
1007+
ifp = getfp(DATA_TEMPLATE, greptmp, RDTMODE);
10551008

10561009
while ((line = fgetline(ifp)) != 0) {
10571010
if (line[0] != '#' && line[0] != '\n')
@@ -1061,10 +1014,7 @@ const char *deflt_content;
10611014
Fclose(ifp);
10621015
Fclose(ofp);
10631016

1064-
#ifdef HAS_NO_MKSTEMP
1065-
delete_file(DATA_TEMPLATE, "grep.tmp");
1066-
#endif
1067-
1017+
delete_file(DATA_TEMPLATE, greptmp);
10681018
return;
10691019
}
10701020

@@ -2335,8 +2285,9 @@ do_oracles()
23352285
void
23362286
do_dungeon()
23372287
{
2338-
char *line;
2288+
char *line, greptmp[8 + 1 + 3 + 1];
23392289

2290+
Sprintf(greptmp, "grep-%.3s.tmp", "dun");
23402291
Sprintf(filename, DATA_IN_TEMPLATE, DGN_I_FILE);
23412292
if (!(ifp = fopen(filename, RDTMODE))) {
23422293
perror(filename);
@@ -2353,13 +2304,10 @@ do_dungeon()
23532304
}
23542305
Fprintf(ofp, "%s", Dont_Edit_Data);
23552306

2356-
tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE, FLG_TEMPFILE);
2357-
grep0(ifp, tfp, FLG_TEMPFILE);
2358-
#ifndef HAS_NO_MKSTEMP
2359-
ifp = tfp;
2360-
#else
2361-
ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE, 0);
2362-
#endif
2307+
tfp = getfp(DATA_TEMPLATE, greptmp, WRTMODE);
2308+
grep0(ifp, tfp);
2309+
ifp = getfp(DATA_TEMPLATE, greptmp, RDTMODE);
2310+
23632311
while ((line = fgetline(ifp)) != 0) {
23642312
SpinCursor(3);
23652313

@@ -2370,13 +2318,10 @@ do_dungeon()
23702318
(void) fputs(line, ofp);
23712319
free(line);
23722320
}
2373-
23742321
Fclose(ifp);
23752322
Fclose(ofp);
23762323

2377-
#ifdef HAS_NO_MKSTEMP
2378-
delete_file(DATA_TEMPLATE, "grep.tmp");
2379-
#endif
2324+
delete_file(DATA_TEMPLATE, greptmp);
23802325
return;
23812326
}
23822327

@@ -3009,24 +2954,6 @@ char *str;
30092954
return str;
30102955
}
30112956

3012-
#ifndef HAS_NO_MKSTEMP
3013-
#ifdef _MSC_VER
3014-
int
3015-
mkstemp(template)
3016-
char *template;
3017-
{
3018-
int err;
3019-
3020-
err = _mktemp_s(template, strlen(template) + 1);
3021-
if( err != 0 )
3022-
return -1;
3023-
return _open(template,
3024-
_O_RDWR | _O_BINARY | _O_TEMPORARY | _O_CREAT,
3025-
_S_IREAD | _S_IWRITE);
3026-
}
3027-
#endif /* _MSC_VER */
3028-
#endif /* HAS_NO_MKSTEMP */
3029-
30302957
/*
30312958
* macro used to control vision algorithms:
30322959
* VISION_TABLES => generate tables

0 commit comments

Comments
 (0)