Commit Graph

320 Commits

Author SHA1 Message Date
nhmall
1c177dcb39 a couple of inconsistencies
make pmatchregex regex_error_desc return type match cppregex.cpp and
posixregex.c

make the extern declaration for loadsyms[] in options.c match the
one in symbols.c.
2022-09-14 20:23:48 -04:00
PatR
ab32ec4ad6 config_error_add()'s terminating period
Have the config error reporting routine check whether the message
it's delivering already has end-of-sentence punctuation instead of
adding that unconditionally.
2022-07-05 23:20:58 -07:00
PatR
dda4cd0530 regex handling
Change the regex_error_desc() interface.  Have the caller pass in
a pointer to a buffer of at least BUFSZ characters and have
regex_error_desc() populate that.  No need for static buffers or
extra dynamic alloction.

Also, change it to never return Null.  None of its callers were
checking for that and could have passed Null to config_error_add()
or raw_print().  printf("%s", NULL) produces "null" on OSX but other
systems would probably crash if a Null result ever actually occurred.

The error explanation returned by cppregex included a trailing period.
config_error_add() adds one, so the message ended up with two.  Have
regex_error_desc() check for final period and strip it off if found.
(My test case used a menucolor pattern of "[" which triggers an error
about mismatched brackets.)

Reformat cppregex.cpp; treat 'extern "C" {' as if it isn't introducing
a nested block.  Fix the '#include <hack.h>' that 'make depend' was
ignoring.
2022-07-01 13:08:43 -07:00
nhmall
751b6e646f Revert "follow-up: use only the memory that's required"
This reverts commit 4a0654c708.
2022-06-30 22:38:14 -04:00
nhmall
66a1e19d26 Revert "follow-up 2: follow the conventional approach"
This reverts commit 6920632df0.
2022-06-30 22:37:12 -04:00
nhmall
43941afe19 Revert "follow-up 3"
This reverts commit cd57dfa5ff.
2022-06-30 22:36:45 -04:00
nhmall
cd57dfa5ff follow-up 3 2022-06-30 13:27:46 -04:00
nhmall
6920632df0 follow-up 2: follow the conventional approach 2022-06-30 13:15:58 -04:00
nhmall
4a0654c708 follow-up: use only the memory that's required 2022-06-30 13:10:56 -04:00
nhmall
0fd999a6b5 cppregex regex_error_desc()
Address sanitizer caught a use after free.
cppregex.cpp regex_error_desc() was not returning a pointer
to a static buffer, yet the posixregex was. Follow suit.
2022-06-30 13:02:07 -04:00
nhmall
a518d82c54 no quotes in WINDOWPORT macro invocation 2022-06-29 22:13:28 -04:00
nhmall
4a8deefaa3 replace leading tabs in several more files 2022-05-30 12:38:22 -04:00
nhmall
cb0c21e91d ENHANCED_SYMBOLS
A new feature, enabled by default to maximize testing, but one which can
be disabled by commenting it out in config.h

With this, some additional information is added to the glyphmap entries
in a new optional substructure called u with these fields:
    ucolor          RGB color for use with truecolor terminals/platforms.
                    A ucolor value of zero means "not set." The actual
                    rgb value of 0 has the 0x1000000 bit set.
    u256coloridx    256 color index value for use with 256 color
                    terminals, the closest color match to ucolor.
    utf8str         Custom representation via utf-8 string (can be null).

There is a new symset included in the symbols file, called enhanced1.

Some initial code has been added to parse individual
OPTIONS=glyph:glyphid/R-G-B entries in the config file.

The glyphid can, in theory, either be an individual glyph (G_* glyphid)
for a single glyph, or it can be an existing symbol S_ value
(monster, object, or cmap symbol) to store the custom representation for
all the glyphs that match that symbol.

Examples:
   OPTIONS=glyph:G_fountain/U+03A8/0-150-255

(Your platform/terminal font needs to be able to include/display the
character, of course.)

The NetHack core code does parsing and storing the customized
entries, and adding them to the glyphmap data structure.

Any window port can utilize the additional information in the glyphinfo
that is passed to them, once code is added to do so.

Also, consolidate some symbol-related code into symbols.c, and remove it from
files.c and options.c
2022-05-07 10:25:13 -04:00
nhmall
a7009e2a54 obsolete nhlan.c follow-up
- visual studio project files
- .gitattributes
2022-02-15 15:22:34 -05:00
nhmall
c0a4b38bf6 remove obsolete function and references 2022-02-15 08:13:27 -05:00
nhmall
6005717e6d cut error 2022-02-13 09:10:53 -05:00
nhmall
99ffd027ae remove NHAccess symset, github issue #638
Closes #638
2022-02-13 09:07:41 -05:00
nhmall
a25259a97a more obsolete file references 2022-02-04 15:52:42 -05:00
nhmall
9684b75f54 whitelist some macOS clang format-nonliteral warnings 2021-02-02 19:50:07 -05:00
nhmall
a6631e3bb0 suppress a particular warning for an individual function; useful for non-gcc
Microsoft and other non-GNU compilers don't recognize gcc tricks
like  /*NOTREACHED*/ to suppress individual warnings. clang recognizes most
of them because it tries to be gcc-compatible. Because of that, a lot of
potentially useful warnings have had to be completely suppressed in the
past in all source files when using the non-gcc compatible compilers.

Now that the code is C99, take advantage of a way to suppress warnings for
individual functions, a big step up from suppressing the warnings
altogether.

Unfortunately, it does require a bit of ugliness caused by the
insertion of some macros in a few spots, but I'm not aware of
a cleaner alternative that still allows warnings to be enabled
in general, while suppressing a warning for known white-listed
instances.

Prior to the warning-tiggering function, place whichever one of
the following is needed to suppress the warning being encountered:

DISABLE_WARNING_UNREACHABLE_CODE
DISABLE_WARNING_CONDEXPR_IS_CONSTANT

After the warning-triggering function, place this:

RESTORE_WARNINGS

Under the hood, the compiler-appropriate warning-disabling
mechanics involve the use of C99 _Pragma, which can be used
in macros.

For unrecognized or inappropriate compilers, or if
DISABLE_WARNING_PRAGMAS is defined, the macros expand
to nothing.
2021-02-01 12:54:19 -05:00
nhmall
f963c5aca7 switch source tree from k&r to c99 2021-01-26 21:06:16 -05:00
nhmall
5dcc328759 be more consistent with CROSS_TO_target macro names for cross-compiles
-DCROSS_TO_MSDOS	msdos cross-compile (djgpp cross-compiler)
-DCROSS_TO_AMIGA	Amiga cross-compile
-DCROSS_TO_WASM		wasm cross-compile (emscripten)
2020-10-08 13:49:24 -04:00
nhmall
cb223271cb add cross-compile recipe for amiga
Disclaimer: This is a minimal recipe, just to get someone else
started if they have a desire to get a full cross-compile of
NetHack-3.7 going for the Amiga. Some NetHack code bitrot was
corrected, and it does seem able to compile the game itself
to a point. See caveats below.

- If you want to obtain the cross-compiler and tools/libs for Amiga
         https://github.com/bebbo/amiga-gcc

  To our knowledge, a pre-built copy isn't available, so you have to
  obtain the source via git and build it on your system.

  The build prerequisite packages for Ubuntu are easily obtained:

    sudo apt install make wget git gcc g++ lhasa libgmp-dev \
        libmpfr-dev libmpc-dev flex bison gettext texinfo ncurses-dev \
        autoconf rsync

  The build prerequisite packages for macOS are apparently easily
  obtained via homebrew, but that was not tested:

    brew install bash wget make lhasa gmp mpfr libmpc flex gettext \
    texinfo gcc make autoconf

  After installing the prerequite packages and the cross-compiler
  it was a straightforward build:

        git clone https://github.com/bebbo/amiga-gcc.git
        cd amiga-gcc
        make update
    [Note that you may have to take ownership of the files in the
     bebbo repo via chown before succesfully carrying out the next
     steps]
        make clean
        make clean-prefix
        date; make all -j3 >&b.log; date
  The compiler pieces are installed in /opt/amiga by default which
  was satisfactory for our initial attempt, but if you want you can
  alter the prefix before you build if you want. That is all
  spelled out on the page at: https://github.com/bebbo/amiga-gcc

  The Amiga cross-compile can then be carried out by specifying
  CROSS_TO_AMIGA=1 on the make command line.

  For example:
       make CROSS_TO_AMIGA=1 all
       make CROSS_TO_AMIGA=1 package

You can explicitly include tty and curses support if desired, otherwise
you'll end up with a tty-only cross-compile build. The SDL1 pdcurses
support has not been tested.

       make WANT_WIN_TTY=1 WANT_WIN_CURSES=1 CROSS_TO_AMIGA=1 all

Also note that building the amiga targets using the make command
above, does not preclude you from building local linux or macOS
targets as well. Just drop the CROSS_TO_AMIGA=1 from the make
command line.

The cross-compiler hints additions are enclosed inside ifdef sections
and won't interfere with the non-cross-compile build in that case.

CAVEATS: The original NetHack Amiga build steps included the source for
some utilities that were built and executed on the amiga: txt2iff and
xpm2iff as part of the NetHack build procedure on amiga. Those did not
compile out-of-the-box on the linux host. They will either have to be:
    - ported to build and run on the linux or macOS cross-compile host

   or

    - their functionality will have to be rolled into amiga NetHack
      itself and executed on the target Amiga the first time the game
      is run, perhaps.

Good luck amiga aficionados, perhaps you'll be able to take this
initial effort forward and get NetHack-3.7 available on the amiga or
amiga-emulator. Let us know if you do, and we can roll changes in
if you provide them.
2020-09-28 17:30:22 -04:00
nhmall
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
nhmall
5a437b336a remove SYSFLAGS and MFLOPPY code
A check into github issue 364 confirmed that
ba6edbe5dc
had incorrectly updated the bwrite sizeof entry for sysflags.

The SYSFLAGS and MFLOPPY code is all in the outdated part of the tree, so just
remove it rather than re-correct it.

Closes #364
Closes #207
2020-07-05 08:50:13 -04:00
nhmall
bb1a0dd60b build warning for noreturn function that does return
The warning showed up with gcc on msdos (__DJGPP__)

end.c: In function 'nh_terminate':
end.c:1729:1: warning: 'noreturn' function does return
 }
 ^
2020-06-08 14:44:29 -04:00
nhmall
7b8c6d6b84 msdos has been tested with 3.7 2020-01-28 19:16:07 -05:00
nhmall
82bfec24f9 update some version bits 2020-01-28 19:09:40 -05:00
nhmall
033894d784 Merge branch 'NetHack-3.7' into NetHack-3.7-Jan2020 2020-01-27 08:52:17 -05:00
Pasi Kallinen
1783b9de3e Doc and sample config for MSDOS video resolution 2020-01-27 10:13:48 +02:00
nhmall
d5174323eb Merge 'NetHack-3.6' updates into NetHack-3.7-Jan2020 2020-01-14 22:09:29 -05:00
nhmall
a6c46bbd85 housekeeping items for 3.6.5 - first pass 2020-01-14 11:35:06 -05:00
nhmall
17feb01d8f Merge branch 'NetHack-3.6' 2019-12-17 14:39:15 -05:00
nhmall
74a5339a5e housekeeping updates for 3.6.4
typos

README update
2019-12-17 14:11:52 -05:00
nhmall
bc8c1f8f56 remove field-level savefile code 2019-12-08 07:27:01 -05:00
nhmall
a9c946a05f Merge branch 'NetHack-3.6' 2019-12-01 19:30:09 -05:00
nhmall
d2d40289e6 update and/or clarify some version references 2019-12-01 19:07:28 -05:00
nhmall
d2128968fa Merge branch 'NetHack-3.7' into paxed-lua-v2-merged 2019-11-14 19:50:20 -05:00
nhmall
6c97b0f9a1 Merge branch 'NetHack-3.6' 2019-11-14 19:48:57 -05:00
nhmall
8e7888d631 introduce msdos build support for cross-compiling on other platforms 2019-11-14 14:10:56 -05:00
Pasi Kallinen
32f2fdb135 Remove leftover level compiler header 2019-11-07 19:40:41 +02:00
nhmall
bcb627100b Merge branch 'paxed-lua-merged3' into paxed-lua-v2-merged 2019-11-06 12:56:21 -05:00
Pasi Kallinen
9cd9280276 Lua: remove dgn_comp, use lua instead 2019-11-06 18:45:10 +02:00
Pasi Kallinen
fd55d9118e Use lua for special level files
Game is playable, and should compile on linux and Windows.
Assumes you have a lua 5.3 library available.

Removes level compiler and associated files.
Replaces special level des-files with lua scripts.
Exposes some NetHack internals to lua:
 - des-table with commands to create special levels
 - nh-table with NetHack core commands
 - nhc-table with some constants
 - u-table with some player-specific data (u-struct)
 - selection userdata

Adds some rudimentary tests.

Adds new extended command #wizloadlua to run a specific script,
and #wizloaddes to run a specific level-creation script.

nhlib.lua is loaded for every lua script.

Download and untar lua:
  mkdir lib
  cd lib
  curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz
  tar zxf lua-5.3.5.tar.gz

Then make nethack normally.
2019-11-06 18:43:20 +02:00
nhmall
3ccc6e5308 Merge branch 'NetHack-3.6' 2019-10-17 20:52:10 -04:00
PatR
e4f3559acc curses on unix - terminal reset needed after abort
Noticed while investigating the message loop.  If I had level files
from an interrupted game and was asked "Destroy old game?" when
starting a new one, answering 'n' left the terminal in an unusable
state.  Executing 'stty sane' (invisibly since input echo was off)
repaired things but the user shouldn't have to do that.

Change unixtty.c's error() to shut down windowing if that has been
initialized.  This might need some tweaking for tty, which will now
clear the screen before showing the startup error message.  Other
systems besides unix use unixtty.c so are affected, but I think the
change doesn't introduce anything that should cause trouble (aside
from the potential screen erasure).
2019-10-09 13:18:34 -07:00
nhmall
fe1b2d6e82 Merge branch 'NetHack-3.6' 2019-10-06 09:16:23 -04:00
PatR
0d76f68f2c tty xputc()
Another part of github issue 227.  Casting a function pointer when
passing it to another function is iffy when lying about the return
type.  tputs() expects a routine which returns int, so give it one.
Other xputc() usage is equivalent to putchar(), so define xputc()
with the same function signature as that has.

The tputs() declarations in system.h should probably be changed
(third argument is a function which takes an int rather than
unspecified parameters) but I've left them alone.  I made that change
to tputs() in sys/share/tclib.c though.

NT and MSDOS changes are untested.  tclib.c compiles ok with clang-
as-gcc on OSX but hasn't been tested with the port that uses it (VMS).
2019-10-05 16:49:34 -07:00
nhmall
8c20c52ecf remove STATIC_DCL, STATIC_OVL, STATIC_VAR, STATIC_PTR from sys/share 2019-07-14 17:28:48 -04:00
nhmall
efbe179f64 fix the msdos build for NetHack-3.7 2019-07-02 22:05:36 -04:00