Commit Graph

443 Commits

Author SHA1 Message Date
PatR
4510bc7e50 warn_unused_result in recover.c
There is only one warn_unused_result warning from gcc in recover.c,
so actually use that result.

Plus a bit of reformatting (tab replacement).
2018-12-18 14:01:57 -08:00
Patric Mueller
7d15535923 Fix always trapped castle chest 2018-12-15 22:40:30 +01:00
PatR
5d2686e7c1 lev_comp int vs long
Fix lev_comp's variable argument usage by changing it to make
add_opvars() expect an int rather than a long when given the "i"
indicator, and add "l" for really passing a long.  The ints are
conveted to longs when setting up the interpreter.  I think I changed
just about all the integer opvars to int, although there is one use
of "l" in lev_main.c just to make sure it works.  There could be
arguments that really do need to be 'long'; if so, the add_opvars()
calls for them will have to have its indicator string updated and
possibly add or remove some casts.

There's a lot of reformatting included but it's not consistent about
tab replacement.  Some of the changes are due to renaming long-named
'variable_definitions' to 'vardefs' to shorten a bunch of lines.

Updated sys/share/*_yacc.c will be checked in separately.  The ones
currently in the repository won't work with patched lev_main.c due to
that renamed variable.
2018-11-27 18:21:58 -08:00
nhmall
03e6c26af6 adjust sample config file when STATUS_HILITES isn't defined
On Windows, if you build without STATUS_HILITES defined,
you'll be greeted by the following barrage of errors when
you start the game.

On Windows, use makedefs to detect that STATUS_HILITES
isn't defined, and comment out the offending lines in
the sample config file.

Errors received before this change:

OPTIONS=statushilites
  * Line 197: 'statushilites' is not supported.

 OPTIONS=hilite_status:hitpoints/100%/gray&normal
  * Line 200: 'hilite_status' is not supported.

 OPTIONS=hilite_status:hitpoints/<100%/green&normal
  * Line 201: 'hilite_status' is not supported.

 OPTIONS=hilite_status:hitpoints/<66%/yellow&normal
  * Line 202: 'hilite_status' is not supported.

 OPTIONS=hilite_status:hitpoints/<50%/orange&normal
  * Line 203: 'hilite_status' is not supported.

 OPTIONS=hilite_status:hitpoints/<33%/red&bold
  * Line 204: 'hilite_status' is not supported.

 OPTIONS=hilite_status:hitpoints/<15%/red&inverse
  * Line 205: 'hilite_status' is not supported.

 OPTIONS=hilite_status:power/100%/gray&normal
  * Line 208: 'hilite_status' is not supported.

 OPTIONS=hilite_status:power/<100%/green&normal
  * Line 209: 'hilite_status' is not supported.

 OPTIONS=hilite_status:power/<66%/yellow&normal
  * Line 210: 'hilite_status' is not supported.

 OPTIONS=hilite_status:power/<50%/orange&normal
  * Line 211: 'hilite_status' is not supported.

 OPTIONS=hilite_status:power/<33%/red&bold
  * Line 212: 'hilite_status' is not supported.

 OPTIONS=hilite_status:cap/burdened/yellow/stressed/orange/strained/red&bold/ove
 rtaxed/red&inverse/overloaded/red&inverse&blink
  * Line 215: 'hilite_status' is not supported.

 OPTIONS=hilite_status:hunger/satiated/yellow/hungry/orange/weak/red&bold/fainti
 ng/red&inverse/fainted/red&inverse&blink
  * Line 218: 'hilite_status' is not supported.
 Hit <Enter> to continue.
2018-11-24 23:14:20 -05:00
nhmall
dbf2b0e852 Revert "Added nhassert() support."
This reverts commit 31dc1c9233.
2018-11-23 22:17:26 -05:00
nhmall
3cbc6d4cf5 Revert "Modified objects initialization to support re-entry."
This reverts commit c3eefefc99.
2018-11-23 22:16:24 -05:00
Bart House
c3eefefc99 Modified objects initialization to support re-entry. 2018-11-23 15:22:55 -08:00
Bart House
31dc1c9233 Added nhassert() support. 2018-11-23 15:22:51 -08:00
nhmall
b4be8852a4 suppress compiler warning differently 2018-11-20 20:30:44 -05:00
nhmall
4228cf534e follow-up bits 2018-11-20 19:09:05 -05:00
Bart House
be11d50d91 Added use of SCCS_Id to quite compiler warnings. 2018-11-20 10:33:36 -08:00
Bart House
aa48ed18e7 Initial check-in of work in progress xcode build of NetHack.
Buyer beware.  This is a check-point of the xcode work to allow others
to play.
2018-11-19 09:22:11 -08:00
nhmall
cb43061076 curses changes to existing files 2018-11-16 20:51:22 -05:00
Bart House
8944235282 Enforced the inclusion of windows headers before nethack headers.
Moved the code page 437 mapping table to winnt.c so that it could be
used in window and console clients.
Added check that fonts support unicode values we use from code page 437.
Use unicode to draw text if font supports it otherwise use ASCII.
2018-11-12 01:58:56 -08:00
nhmall
a0b53ee391 merge 2018-11-11 10:29:52 -05:00
Pasi Kallinen
afd793e9b7 Fix memory leak in makedefs 2018-11-08 17:38:36 +02:00
keni
f222023bd8 Deprecate "makedefs -m".
mons[].difficulty takes over for monstr[]
Invoking "makedefs -m" gives a deprecation message; it is also included
in the (now mostly empty) monstr.c.
Ports should now remove "makedefs -m" from their build procedures but this
commit does not include that change.
2018-10-20 23:14:33 -04:00
Ray Chason
8dbaafbb7b Ignore Win32 build products 2018-09-10 21:13:10 +03:00
nhmall
84d4fcc4c8 another beta bit 2018-05-16 23:31:27 -04:00
nhmall
05e84babb8 beta bit
Display the word beta in a better spot on the line
2018-05-16 23:23:08 -04:00
keni
09502df9f1 force expand unexpanded substitution variables 2018-04-25 15:36:11 -04:00
keni
d8c49ec9d1 Add updated copyright lines, part 1. 2018-04-25 15:00:13 -04:00
Pasi Kallinen
2548d68dd3 Fix some warnings
Remove an unused variable, add missing FALLTHRUs, and use the same
FALLTHRU wording where it wasn't recognized by gcc
2018-03-30 19:42:50 +03:00
nhmall
d4ea0f6ce6 date bit 2018-03-02 15:35:07 -05:00
nhmall
65655d2cee Incorporate some git information into NetHack
Incorporate some git information into NetHack so that it
is potentially visible to a player. That's useful when
collecting details about the version that they are
running and, if the gitinfo is present, it can tie the
code to a specific git commit in the repository.

This modifies 'makedefs -v' to check for the presence of a data file
called dat/gitinfo.txt and if it is there, parse out its
contents, then write additional lines to include/date.h beyond
what 'makedefs -v' was previously putting in there, similar to
this sample:

      #define NETHACK_GIT_SHA "0c84e564c78e2024e562d39539376ce2e21eec8e"
      #define NETHACK_GIT_BRANCH "NetHack-3.6.0"

The contents of an appropriate dat/gitinfo.txt are as follows,
and trailing/leading whitespace is not significant:

      githash = 0c84e564c78e2024e562d39539376ce2e21eec8e
      gitbranch = NetHack-3.6.0

It also adjusts the contents of the 'v' version information to
include the additional git info when available.

Also adds some hooks DEVEL/hooksdir and a perl file to DEVEL
for simplifying and automating the deposit of dat/gitinfo.txt
so that it generally reflects the most current git commit.

DEVEL/gitinfo.pl can be used to build dat/gitinfo.txt at any
time without doing a commit, merge, or checkout.
    	perl DEVEL/gitinfo.pl

command line --version and -version support

To complement the extra information being provided in the
version by the 'v' command, this also adds support for the
following new command line arguments:
    --version
     -version            Output the NetHack version string then exit.

    --version:paste      Output the NetHack version string and also copy it to
     -version:paste      the platform's paste buffer for insertion somewhere,
                         then exit.

If the paste variation of -version is requested on a platform that
hasn't incorporated any support for the capability, it will deliver
the version info then an error message, prior to exiting.

To support the extended -version:paste variation, a port needs to:
    - provide a port-specific routine to perform
      the paste buffer copy in a port code file.
    - #define RUNTIME_PASTEBUF_SUPPORT in the include/portconf.h header file.

    --skeleton--
    void port_insert_pastebuf(buf)
    char *buf;
    {
    	/* insert code to copy the version info from buf into
    	   platform's paste buffer in a supported way */
    }

macosx and Windows have both added support for RUNTIME_PASTEBUF_SUPPORT
2018-02-23 19:34:44 -05:00
nhmall
1eb5919a85 I noticed makedefs was segfaulting when argc == 1 2018-02-16 14:52:02 -05:00
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