Commit Graph

217 Commits

Author SHA1 Message Date
PatR
32890d1bc1 fix 'makedefs -z' for config using FILE_PREFIX
Apply user-contributed patch to make do_vision() handle FILE_PREFIX
correctly.  It was putting that value into the filename buffer, then
overwriting it with the ordinary filename instead of appending.

Deletion of just-made vis_tab.h when creation of vis_tab.c fails would
have failed too if FILE_PREFIX had been working.

The patch was against 3.4.3 and didn't apply cleanly to current code,
but it is a staightforward fix, although the file deletion case was
buggy (failed to clear "vis_tab.c" from buffer before reconstructing
"vis_tab.h" via appending stuff).  FILE_PREFIX seems to be Amiga-only
so I've only tested the usual case where it isn't defined.
2018-01-23 00:52:57 -08:00
PatR
8a45da0e8d feature options (#version output)
I've sometimes seen
  , and basic NetHack features.
as the last line of the features section from '#version'.  I thought
it was due to the way feature phrases were split into individual words
by makedefs, but it turned out to be due to inserting pattern matching
method at run-time.  That dynamic options update had a second problem:
if the final phrase "and basic NetHack features" was split across two
lines, the run-time substitution didn't find it and the pattern matching
entry ended up being left out.  This fixes both problems, but if future
dynamic entries become more complex, the phrase-splitting/word-wrapping
being done by makedefs may need to be moved into nethack.

Also, add entries for XLOGFILE and PANICLOG to makedefs' options and
re-order a couple of existing ones alphabetically (a failry hopeless
endeavor).
2017-10-02 18:25:09 -07:00
Pasi Kallinen
69f7a78dba Hilite Status: Improved
Allow defining multiple stops per field. Add hitpointbar.
2017-09-26 10:04:25 +03:00
Bart House
878a18388c Fixed coding error. strlen() returns size_t causing a size_t sized value pushed onto stack instead of long. On x64 builds, size_t != long. Caught via compiler warning in x64 build. 2017-09-04 12:41:53 +03:00
PatR
64f284dd61 USE_OLDARGS update (1 of 2)
Files modified:
    include/tradstdc.h, sp_lev.h, system.h
    util/lev_main.c

Silence a bunch of warnings generated by recent gcc which weren't there
with whatever version I had when 3.6.0 was being readied for release.
For lev_main, there were two basic types:  not enough arguments in calls
to lc_pline, lc_warning, and lc_error (since we weren't passing dummy
arguments as is done for add_opvars), and conversion from 'int' or
narrower to 'char *' (from -Wint-to-pointer-cast, which either wasn't
there yet in the older gcc, or wasn't included in -Wall back then).
[Note that for any configuration decrepit enough to actually need
USE_OLDARGS, such conversions will either work fine or else nethack
simply won't be viable.]

src/pline.c generates a bunch of warnings (for USE_OLDARGS).  The fix
for that will be (2 of 2).

To test, instead of mucking about with CFLAGS or sys/unix/hints, I've
been temporarily adding unconditional
|#undef USE_STDARG
|#undef USE_VARARGS
|#define USE_OLDARGS
to the end of config1.h and then doing my normal build--which is why
-Wall (or possibly -W) is drawing -Wint-to-pointer-cast warnings.
2017-08-02 18:23:42 -07:00
PatR
e3c4ac730d util updates: lev_main.c and recover.c
Change lev_comp's add_opvars() to be like pline(), where there's a
single visible opening brace and a second one hidden in VA_DECL2
that introduces a nested block, plus a single visible closing brace
with a hidden one in VA_END() to close the nested block.  This
addresses the erroneous report (sent directly to devteam, so no #H
number, subject "missing '{' in util/lev_main.c:634") that the code
for !USE_STDARG/!USE_VARARGS in add_opvars() wouldn't compile.

Also, fix the part of "#H5778: file descriptor leaks" dealing with
util/recover.c -- an open file not being closed after various errors.
I didn't take responsibility for this entry in the bugzilla list
since the report includes similar problems in other code that's not
addressed here.

And a blast from the past:  some reformatting fixups in recover.c.
The most interesting bit is for a block of dead code....
2017-07-30 17:34:52 -07:00
Alex Smith
1c026727fb Remove obsolete code allowing 1-indexing the monster list
Having selectable base indexes for the monster list doesn't seem
likely to be needed in the future any more, now that the code for
the monster list is stable. Additionally, the functionality in
question has bitrotted heavily (e.g. many "loops over all
permonsts" start at a hardcoded 0, which wouldn't work with a
1-indexed monster list). As a result, removing the relevant code
in makedefs makes it clearer what can and can't be assumed about
the code, reducing the risk of bugs in the future.

Thanks to FIQ for mentioning that this could be an issue.
2017-07-15 01:34:41 +01:00
Pasi Kallinen
7d8b4d4f97 Add end-of-game dumplogs
This is based on the "new" dumplog patch for 3.6.0, by Maxime Bacoux.

Define DUMPLOG to enable. By default only enabled for the TTY linux.
2017-02-19 15:33:27 +02:00
PatR
d69f0787be add '(uchar)' casts to ctype calls
This is from the pull request for the assertion failure fix.  It
did not mention how to reproduce the assertion failure, just added
casts to a bunch of isspace/isprint/tolower calls that didn't already
have such.

I removed an obsolete change for win/tty/topl.c and changed the
win/win32/mswproc.c code to avoid using an expression with side-effects
(*colorstring++) in calls to tolower() in case someone overrides that
with a macro which evaluates its argument more than once as some pre-
ANSI ones used to do.  Not tested, might have typos....

sys/wince/*.c still needs similar casts.
2016-07-19 05:40:09 -07:00
Sean Hunt
e687023e77 Merge remote-tracking branch 'github/UniQP/rcnt' into NetHack-3.6.0 2016-04-12 20:51:28 -04:00
PatR
c3ef98c4d1 REPRODUCIBLE_BUILD
Take the 4-5 line Debian patch and turn it into six dozen lines of
new code.  The submitted patch introduces use of several C library
routines that aren't presently in use, so would need testing by all
functional or nearly-functional ports to verify that it wouldn't
break anything.  It also switched the formatted build date+time
from localtime to UTC.  This makes the code conditional so it can
be ignored by anybody and avoid the risk of breakage.  And a lot of
the increase in size is comments attempting to explain what the new
conditional is for:  when REPRODUCIBLE_BUILD is defined, makedefs
will use getenv("SOURCE_DATE_EPOCH") (whose value is an integer
representing seconds since 1-Jan-1970) instead of current date+time
when generating date.h.  The purpose is to be able to rebuild at a
later date and produce an identical program, which doesn't happen
when compile time gets incorporated into the binary.

I've added some sanity checking to try to make sure the getenv()
value obtained isn't bogus.  And the version string put into date.h
will be slightly different, allowing someone who sees date.h or 'v'
output to tell whether SOURCE_DATE_EPOCH was involved:  showing
"<port> NetHack <version> last revision <date>" instead of the
usual "... last build <date>".

To test, checkout a new branch for building, make any local edits
to unixconf.h and config.h, including enabling REPRODUCIBLE_BUILD,
git add+commit them, then use
  SOURCE_DATE_EPOCH=`git log -1 --pretty=%ct` make install
Other ports will need a bit more work to set up the environment,
but can still use git to track file dates and supply the latest.
Building with alternate configurations could be accomplished by
using tags instead of 'log -1' or by using distinct build branches
where nothing is commited/merged/rebased after completed build.

Unresolved issue:  BUILD_DATE, VERSION_ID, and COPYRIGHT_BANNER_C
contain formatted date+time but omit timezone.  SOURCE_DATE_EPOCH
is assumed to be UTC but the formatted values don't say so, so it
might appear to be incorrect when compared with local time.  We
definitely don't want to start mucking about with timezones within
nethack, so I think we just live with this.  It's not an issue for
default configruation where REPRODUCIBLE_BUILD is left disabled.
2016-03-31 17:56:11 -07:00
PatR
9e0a9d96f9 makedefs lint
The Makefile race condition report included a link to a log file
of the build attempt, and it contained this:

makedefs.c: In function 'do_grep_control':
makedefs.c:611:26: warning: suggest parentheses around operand of '!'
 or change '|' to '||' or '!' to '~' [-Wparentheses]
 #define ST_LD(old, opp) (!!(old) | (!!(opp) << 1))
                          ^
makedefs.c:722:37: note: in expansion of macro 'ST_LD'
 grep_stack[++grep_sp] = ST_LD(grep_writing, !isif);
                         ^
They're using a more recent version of gcc than I am, because my
CFLAGS includes -Wparentheses (via -Wall) and I don't get that.

It's a little confusing, but I think it's whining that we might
have meant   !!((old) | (!!(opp) << 1))
rather than  (!!(old)) | (!!(opp) << 1).
The latter is what we get (and what we intended--no bug here).

I changed it to something that more directly reflects the intent
since it's not bit twiddling within some crucial innermost loop.
2016-03-28 17:23:00 -07:00
Sebastian Buchwald
7304c1de5c Remove unused variable. 2016-03-09 10:56:26 +01:00
PatR
ba7fbb6e8b lev_comp lint redux
The rest of this accidentally got pushed with the Reaper Man passages.
2016-02-17 14:08:19 -08:00
PatR
25d18ddeb8 lev_comp lint 2016-02-17 13:45:05 -08:00
PatR
ae5d556980 dgn_comp,lev_comp lint
Newer compiler found new things to complain about.
NHinternal/shared/sys/share/flexhack.h has been updated.

Generated sys/share/ sources have to be committed separately so
they happen after this update fills in new banner comment for
their source.
2016-02-13 17:56:57 -08:00
PatR
3b4f2fbfa7 makedefs.c lint
Add some missing prototypes and change some 'char *' function paramters
to 'const char *'.
2016-02-13 02:05:43 -08:00
PatR
7482be39e8 lev_comp update for older Unix system
Increase the lex paramaters in lev_comp.l and replace use of snprintf
with sprintf in lev_comp.y and lev_main.c.

Also some reformatting for lev_comp.y, but I gave up pretty quickly:
some early tab replacement and adjusting of the spacing for casts.
2016-01-19 16:27:39 -08:00
PatR
60b166aad8 more new status - update genl_status_update
Make genl_status_update behave approximately the same as basic bot2
when processing the second status line.  Preferred order:
Dlvl  Gold  Hp(HpMax) Pw(PwMax) AC  Xp  Time  Conditions
Alternate orders if above exceeds COLNO (note several extra spaces
get sequeezed out).  First one is used if everything except time fits,
second one is used if everything except experience (which can be wide
if 'showexp' option is on) and time fits, third is last resort:
Dlvl Gold Hp(HpMax) Pw(PwMax) AC Xp Conditions Time
Dlvl Gold Hp(HpMax) Pw(PwMax) AC Conditions Xp Time
Hp(HpMax) Pw(PwMax) AC Conditions Dlvl Gold Xp Time

Basic bot2 currently has Conditions as
Stone Slime Strngl FoodPois TermIll <hunger> <encumbrance> Blind Deaf
 Stun Conf Hallu Lev Fly Ride
genl_status_update has
<hunger> <encumbrance> Stone Slime Strngl FoodPois TermIll Blind Deaf
 Stun Conf Hallu Lev Fly Ride
which is as close as it can get with the current field organization.

Tested by temporarily changing tty_procs.status_init and .status_update
to use genl_* instead of tty_*.
2016-01-15 03:30:40 -08:00
Pasi Kallinen
65d780dc3d Add compile-time option MSGHANDLER
This was a feature request from a blind player; he wanted to
play a sound whenever a pline message was given.
2016-01-10 13:08:20 +02:00
Pasi Kallinen
e7d65a44cd TTY: Add compile-time option for tile data hinting
Several people have asked if 3.6.0 supports playing with tiles on
a public server. Because there's no way for the user's end to know
what that white @ is, this adds special console escape codes for
tile hinting.

The idea was originally a patch called TelnetTiles by Justin Hiltscher,
but this expanded version comes via NAO, where it's been in use for years.

This is basically an interim hack, which should go away when/if
we support actual client-server model.
2016-01-10 10:53:15 +02:00
Pasi Kallinen
50359a3552 Fix possible lev_comp segfault when map was too tall 2016-01-06 19:49:38 +02:00
PatR
ea6c2a49fe util/???_comp.l
A couple of minor changes, perparatory to regenerating sys/share/???_lex.c
with flex-latest plus new custom skeleton for same.
2015-12-05 22:59:56 -08:00
PatR
c134af7a77 lexer updates
Bump the number of nodes (%e) specified in lev_comp.l so that the lex
on Solaris doesn't choke.  flex doesn't use those paramters (%e, %p,
and a few others), so this change gets accepted but hasn't been
adequately tested to verify that it solves the problem.

Reformat some of the C code at the end of dgn_comp.l and lev_comp.l;
going through the whole thing isn't worth the effort, particularly
since flex generates such a mess in the rest of the code it produces.

I haven't updated sys/share/*_lex.c and they definitely need it now.
I've got an older version of flex than the one that was used on the
code that's there now, and the most recent version.  Both of those
produce different code--the stuff that's there now has been through
more testing so whatever version was used for it ought to be used for
new editions.
2015-11-28 03:38:03 -08:00
PatR
b30fce4f88 flag panic() and terminate() as "no return"
Mark panic() as never returning so that code analysis might be able
to do a smarter job.  It required splitting done() into two routines
since the first part really can return (but not if PANICKED was the
reason it got called).  done() is now much shorter and ends with a
call to new really_done(), and panic() skips done()'s might-return
part by calling really_done() directly.

Noticed in passing:  the "report error to <list of SYSCF WIZARDS>"
code calls a routine which uses alloc(), which won't work very well
if the reason for panic was because malloc() ran out of memory.
2015-11-22 08:33:42 -08:00
PatR
63dc6b3a31 lev_main cleanup
Use an alternate fix for the complaint from clang's static analyzer
(about potentially derefencing a null pointer, which can't happen
here because alloc() panics and quits rather than return Null), plus
some reformatting and removal of a chunk of unused code (strncmpi).

Also a formatting bit for lev_comp.y, making sys/share/lev_yacc.c
be out of date.  However, the generated code will be the same--except
for line numbers--so this shouldn't inhibit anybody's planned testing
waiting for the generated copy to be updated.
2015-11-20 18:58:48 -08:00
Pasi Kallinen
9518e74c93 Fix segfault if lev_comp could not alloc memory for opcode 2015-11-20 12:27:46 +02:00
PatR
8f0252c5d8 update util/.gitignore
Tell git to ignore the presence of the heaputil program in util/.
(It lives in NHinternal/devteam/util/heaputil.c but working with it
from there is inconvenient.)
2015-11-09 18:37:00 -08:00
PatR
9f19b60147 fix makedefs
If makedefs.c is compiled with MONITOR_HEAP defined, attempted calls to
free() resulted in link failure.  Since makedefs doesn't use alloc(),
call free() directly instead of redirecting to nhfree().

Also some assorted reformatting....
2015-11-09 01:47:18 -08:00
Pasi Kallinen
b0e4357c32 Fix lev_comp memory leaks 2015-11-01 00:28:28 +02:00
Pasi Kallinen
1a133be123 Fix makedefs memory leaks 2015-11-01 00:12:38 +02:00
Pasi Kallinen
65a30d2ba7 Fix C343-341: Stuck in minetown room
Bustling Town can be generated with inaccessible areas outside the
top edge of the fixed town map.  If you end up in one of those area
without any way to dig or teleport, you're stuck.

This adds a new level flag "inaccessibles" to force checking for
such inaccessible areas, and add secret doors, holes/trapdoors,
or some random escape item into the areas.
2015-10-13 19:00:22 +03:00
nhmall
37f0eafa93 support for link-time option in #version
Changes to be committed:
	modified:   src/version.c
	modified:   sys/share/cppregex.cpp
	modified:   sys/share/pmatchregex.c
	modified:   sys/share/posixregex.c
	modified:   util/makedefs.c

Some options in 3.6.0 are determined by what you link with.
The choice of regex support is one.
Let #version show that linked option along with the compile-time options.
2015-06-12 19:23:18 -04:00
PatR
49c997c22c makedefs lint
makedefs.c: In function 'fgetline':
makedefs.c:2630: warning: comparison between signed and unsigned
makedefs.c: At top level:
makedefs.c:2638: warning: ISO C does not allow extra ';' outside of a function

fgetline() makes my recent check for quest line truncation become
redundant, so strip that out.  I haven't taken the corresponding
macro out of qtext.h though.

[I didn't see any patch introducing 'fgetline'.  Was it hidden as
part of some big merge?]
2015-05-24 23:26:35 -07:00
Sean Hunt
1c081b1647 Remove stale version control lines. 2015-05-25 09:21:31 +09:00
Sean Hunt
8b57d96fd2 Reformat .h files.
I did my best to exempt some of the bigger aligned blocks from the reformatting
using the /* clang-format off */ and /* clang-format on */ tags. Probably some
that shouldn't have been formatted were anyway; if you encounter them, please
fix.

The clang-format tags were left in on the basis that it's much easier to prune
those out later than to put them back in, and it means that, modulo my custom
version of clang-format, I should be able to run clang-format on the source tree
again without changing anything, now that Pat has fixed the VA_DECL issues.
2015-05-25 09:21:15 +09:00
Sean Hunt
26ee7dc370 Convert the vibrating square to a trap
Patch due to ais523 in NetHack 4.

This is not ready to be merged yet; the vibrating square needs a tile
image for tiles builds.
2015-05-25 09:19:20 +09:00
nhmall
db2b1453bc fix a mistake on patch merge
Changes to be committed:
modified:   util/makedefs.c
2015-05-24 19:17:05 -04:00
Sean Hunt
b8bea3af20 Make the wand of wishing chest immune to trapping
This eliminates a source of very random, unpreventable frustration to
players.
2015-05-24 11:12:41 -04:00
nhmall
194fd2f78c merge two sets of patches to makedefs.c,qtext.h
Changes to be committed:
	modified:   include/qtext.h
	modified:   util/makedefs.c
2015-05-24 10:27:03 -04:00
Sean Hunt
84d63e169b Use the common regex engine in more places.
In particular, in autopickup_exceptions and user sounds.
2015-05-24 10:17:58 -04:00
Sean Hunt
49b9f6c926 Modify makedefs to use dynamic buffers for reading.
This will prevent crashing due to excessively long lines.
2015-05-24 10:17:28 -04:00
nhmall
f477645774 prep for sean's emailed patch 2015-05-24 10:16:38 -04:00
nhmall
57e404250a prep for sean's emailed patch 2015-05-24 10:09:44 -04:00
PatR
5f0a55f2cd makedefs -q fix
Make the input buffer for quest messages bigger so that the expanded
header line from nhsub won't be too long.  Also, makedefs will notice
and report too long lines ('makedefs -q' only) and sanely proceed with
the rest of the file instead of treating the excess part of a long
line as a separate line.
2015-05-23 23:11:41 -07:00
PatR
9e0e1ac5d1 remove accidentally added util/lev_main.i 2015-05-15 23:08:15 -07:00
PatR
fabf9cd901 VA_DECL/VA_END usage
Make the variadic functions look more like ordinary code rather than
have the function opening brace be hidden inside the VA_DECL() macro.
That brace is still there, but VA_DECL() now needs to be followed by
a visible brace (which introduces a nested block rather than the
start of the funciton).  VA_END() now provides a hidden closing brace
to end the nested block, and the existing closing brace still matches
the one in VA_DECL().

Sample usage:
void foo VA_DECL(int, arg)  --macro expansion has a hidden opening brace
{  --new, explicit opening brace (actually introduces a nested block)
  VA_START(bar);
  ...code for foo...
  VA_END();  --expansion now provides a closing brace for the nested block
}  --existing closing brace, still pairs with the hidden one in VA_DECL()

This should help if/when another round of reformatting ever takes place,
and also with editors or other tools that do brace/bracket/parenthesis
matching.

I had forgotten that there were variadic functions in sys/* and ended
up modifying a lot more files than intended.  The majority of changes
to those just inserted a new '{' line so that revised VA_END()'s '}'
won't introduce a syntax error.  A couple of them needed VA_END() moved
so that local variables wouldn't go out of scope too soon.  Only the
Unix ones have been tested.
2015-05-15 17:45:21 -07:00
Sean Hunt
97d6fade74 Reformat all C files.
I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
2015-05-09 13:43:16 -04:00
nhmall
20069798d4 Merge branch 'master' into win32-x64-working 2015-05-07 04:52:30 -04:00
karnov
2a907f894e Version number increment 2015-05-06 22:04:27 -04:00