Commit Graph

313 Commits

Author SHA1 Message Date
nhmall
1f99638bbf ren nhconst.h -> weight.h
The speed related values were not used, except for NORMAL_SPEED,
which has been moved back to permonst.h
2025-03-19 17:14:07 -04:00
nhmall
a943c4c10b replace some weight-related magic numbers
adds a header file include/nhconst.h  (I'm open to a better name)
2025-03-19 13:29:58 -04:00
nhmall
be5143bb74 window-port updates
Remove start_screen() and end_screen() from the
Window-port interface.

They were only ever used by tty, and there was a comment
carried to several window-ports about how they "really
should go away. They are tty-specific"

term_start_screen() and term_end_screen() are part of
terminal/NO_TERMS supporting routines now.
2025-01-04 23:38:34 -05:00
nhmall
37758c7e48 some tty updates
Add a note about NO_TERMS to include/wintty.h for clarity.

Rename tty_startup and tty_shutdown to term_startup() and
term_shutdown(). They are found in termcap.c for !NO_TERMS
like most of the other term_ routines, as well as having
versions for several of the NO_TERMS platforms. They aren't
part of the tty_interface called from the core. The tty
implementation does call and rely on them.

Remove some conditional #ifdef's around term_shutdown()
(formerly tty_shutdown()) and just ensure that all the
tty platforms have an implementation that they can link
with, even if it is just a stub presently.

Put the protype for nethack_exit in extern.h to reduce
maintenance to a single spot, and remove it from other
locations. A warning in the msdos cross-compile led to
this change.
2025-01-04 19:01:34 -05:00
nhmall
50aff17f94 follow-up bit for sys/msdos/fetch-cross-compiler.sh 2024-12-29 13:54:06 -05:00
nhmall
7b4445f040 make msdos lib/djgpp/target folder more hierarchical
Instead of flat, have bin, lib and include folders for
the native DOS pieces.

If you have been cross-compiling for MSDOS, you will
need to carry out the following to bring things up-to-date:

    sys/msdos/fetch-cross-compiler.sh
    make CROSS_TO_MSDOS=1 WANT_DEBUG=1 package
2024-12-29 12:11:03 -05:00
nhmall
45b2a6c49a more C standard progress
There was a transcription error in the comments in cstd.h for
the standard list of header files, where only the description
remained for <stdlib.h>, not the name of the file itself.

Remove several extraneous inclusions of the standard C99 headers.

Tested on the following afterwards:
Linux (using hints/linux.370) including tty, curses, qt6, and X11
macOS (using hints/macOS.370) including tty, curses, qt5, and X11
Windows MSYS2 using sys/windows/GNUmakefile
Windows Visual Studio using sys/windows/Makefile.nmake
msdos cross-compile on Ubuntu using djgpp cross-compiler
2024-12-20 10:32:38 -05:00
nhmall
5a3795184f use bash for sys/msdos/fetch-cross-compiler.sh
bash allows arrays thus preventing duplication during fetching
2024-12-16 13:35:05 -05:00
nhmall
0a5948fffc follow-up on msdos cross-compile
Obtain gdb.exe during the execution of sys/msdosfetch-cross-compiler.sh
ahead of the build, so that the Makefile just has to move it into place.
2024-12-15 20:08:10 -05:00
nhmall
2965ce4bc5 msdos build correction
ENHANCED_SYMBOLS is defined by default in config.h.
The msdos build tried to #undef ENHANCED_SYMBOLS
in tilemap.c, but doing it in there created a mismatch
between the data struct definition for glyph_map in wintype.h
and the initializers generated in tilemap.c

Move the msdos build catch for ENHANCED_SYMBOLS to
one single place in config1.h so that the code and data agree.
2024-12-15 09:53:50 -05:00
nhmall
bdeddbe63b update sys/msdos/Install.dos 2024-12-04 15:12:27 -05:00
nhmall
0792e5fe9e expand implicit fallthrough detection to non-gcc compilers
gcc has recognized various "magic comments" for white-listing
occurrences of implicit fallthrough in switch statements for
a long time:

    The range and shape of "falls through" comments accepted are
    contingent upon the level of the warning. (The default level is =3.)

    -Wimplicit-fallthrough=0 disables the warning altogether.
    -Wimplicit-fallthrough=1 treats any kind of comment as a "falls through" comment.
    -Wimplicit-fallthrough=2 essentially accepts any comment that contains something
     that matches (case insensitively) "falls?[ \t-]*thr(ough|u)" regular expression.
    -Wimplicit-fallthrough=3 case sensitively matches a wide range of regular
     expressions, listed in the GCC manual. E.g., all of these are accepted:
        /* Falls through. */
        /* fall-thru */
        /* Else falls through. */
        /* FALLTHRU */
        /* ... falls through ... */
       etc.
    -Wimplicit-fallthrough=4 also, case sensitively matches a range of regular
     expressions but is much more strict than level =3.
    -Wimplicit-fallthrough=5 doesn't recognize any comments.

Plenty of other compilers did not recognize the gcc comment convention,
and up until now the compiler warning for detecting unintended
fallthrough had to be suppressed on other compilers. That's because the code
in NetHack has been relying on the gcc approach, and only the gcc approach.

The C23 standard introduces an attribute [[fallthrough]] for the
functionality, when implicit fallthrough warnings have been enabled.

Several popular compilers already support that, or a very similar attribute
style approach, today, even ahead of their C23 support:

       C compiler                       whitelist approach
       ---------------------------   -------------------------------------
       C23 conforming compilers         [[fallthrough]]

       clang versions supporting
       standards prior to
       C23                              __attribute__((__fallthrough__))

       Microsoft Visual Studio
       since VS 2022 17.4.
       The warning C5262 controls
       whether the implict
       fallthrough is detected and
       warned about with
       /std:clatest.                    [[fallthrough]]

This adds support to NetHack for the attribute approach by inserting a
macro FALLTHROUGH to the existing cases that require white-listing, so
other compilers can analyze things too.

The definition of the FALLTHROUGH macro is controlled in include/tradstdc.h.

The gcc comment approach has also been left in place at this time.
2024-11-30 14:16:27 -05:00
nhmall
fb70aadbb5 improve copy_bytes() maintenance
Remove the copy_bytes() function from files.c and util/recover.c
and place a single copy into hacklib.
2024-10-05 15:55:20 -04:00
nhmall
0eb7f109e0 follow-up, program_state 2024-07-13 16:31:35 -04:00
nhmall
6c0ae092c6 distinguish global variables that get written to savefile
The g? structs had a mix of variables that were written to
the savefile, and those that were not.

For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.

This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.

Details:

    gb.bases            -> svb.bases
    gb.bbubbles         -> svb.bbubbles
    gb.branches         -> svb.branches
    gc.context          -> svc.context
    gd.disco            -> svd.disco
    gd.dndest           -> svd.dndest
    gd.doors            -> svd.doors
    gd.doors_alloc      -> svd.doors_alloc
    gd.dungeon_topology -> svd.dungeon_topology
    gd.dungeons         -> svd.dungeons
    ge.exclusion_zones  -> sve.exclusion_zones
    gh.hackpid          -> svh.hackpid
    gi.inv_pos          -> svi.inv_pos
    gk.killer           -> svk.killer
    gl.lastseentyp      -> svl.lastseentyp
    gl.level            -> svl.level
    gl.level_info       -> svl.level_info
    gm.mapseenchn       -> svm.mapseenchn
    gm.moves            -> svm.moves
    gm.mvitals          -> svm.mvitals
    gn.n_dgns           -> svn.n_dgns
    gn.n_regions        -> svn.n_regions
    gn.nroom            -> svn.nroom
    go.oracle_cnt       -> svo.oracle_cnt
    gp.pl_character     -> svp.pl_character
    gp.pl_fruit         -> svp.pl_fruit
    gp.plname           -> svp.plname
    gp.program_state    -> svp.program_state
    gq.quest_status     -> svq.quest_status
    gr.rooms            -> svr.rooms
    gs.sp_levchn        -> svs.sp_levchn
    gs.spl_book         -> svs.spl_book
    gt.timer_id         -> svt.timer_id
    gt.tune             -> svt.tune
    gu.updest           -> svu.updest
    gx.xmax             -> svx.xmax
    gx.xmin             -> svx.xmin
    gy.ymax             -> svy.ymax
    gy.ymin             -> svy.ymin

Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
          gf.ftrap, gl.light_base, gt.timer_base
2024-07-13 14:57:50 -04:00
nhmall
7f2af9698f put wintty.c and termcap.c logic to previous 2024-03-25 09:38:54 -04:00
nhmall
750cf7f619 rename glyphmap nhcolor field to customcolor 2024-03-24 11:04:31 -04:00
nhmall
8efc329db2 DOS stubs for unfilled functionality 2024-03-23 16:55:56 -04:00
nhmall
5c43c81018 attempt to fix DOS cross-compile 2024-03-23 15:56:04 -04:00
nhmall
ba00dc9066 sever extracolors from utf8map and ENHANCED_SYMBOLS
move the custom color data into its own field in the glyphmap
and disassociate it from the unicode/utf8 stuff.

move the glyphcache stuff during options processing and parsing
into new file glyphs.c and out of utf8map.c, and make it
general, and not part of ENHANCED_SYMBOLS.

Do the groundwork for allowing glyph color customizations to
work when any symset is loaded and not restrict it only to
the enhanced1 H_UTF8 symsets.

The customizations in effect are still affiliated with a particular
symset.

Also closes #1224, but the PR itself references a data structure
made obsolete by this commit. The curses comment from the PR was
added into the code.

The PR also made several suggestions, but only the first
one has been included in this commit (and no longer based on
the handler), that being:
"allow defining colors if other symbol handling modes are used
(possibly limited to the standard 16 colors)."

FredrIQ also wrote the following suggestions in PR#1224:

Something I was also contemplating, unrelated to implementation of this
support in curses, would be the ability for the following:

allow defining colors if other symbol handling modes are used (possibly limited to the standard 16 colors)
allow defining attributes (for example: glyph:G_pet_female_kitten:U+0066/red/underline)
allow specifying glyphs as wildcards for defining global color/attribute changes

Something I also want to see are keywords for "don't change the current defined data". If this
were to be added, you could for example do this:
OPTIONS=glyph:G_*_fox:U+0064/blue
OPTIONS=glyph:G_statue_*:basechar/gray/underline
for "make all foxes use a blue color, make all statues gray with underline" without needing
to specify the relevant character for every statue. This ("basechar", "basefg", etc)
should perhaps also be added for MENUCOLORS and statushilites, so that you can, for
example, underline all items being worn without needing to specify a bunch of
near-duplicate rules for combining BUC colors + underline worn items
as per #1064
2024-03-23 15:36:22 -04:00
Pasi Kallinen
4030ef13a0 Curses: implement the windowcolors option
Allow changing the curses windows foreground and background colors,
for example:

OPTIONS=windowcolor:menu #8000F0/20F080 message grey/blue
2024-03-17 18:41:52 +02:00
nhmall
50811037f3 split some code into separate files
new .h files: hacklib.h selvar.h stairs.h

new .c files: calendar.c, getpos.c, report.c, selvar.c, stairs.c,
              strutil.c, wizcmds.c

cleanup of hacklib.c and mdlib.c

hacklib contains functions that do not have to link with the core

relocate wiz commands from cmd.c to wizcmds.c

relocate CRASHREPORT stuff to report.c

relocate getpos stuff from do_name.c to getpos.c

remove temporary struct definition from extern.h

cross-compile PRE-section split into cross-pre1.370 and cross-pre2.370

Windows sys/windows/Makefile.nmake and sys/windows/Makefile.mingw32 and
visual studio project file updates

Unix sys/unix/Makefile.src, sys/unix/Makefile.utl

populate selvar.c and selvar.h

build on MS-DOS (not cross-compile) Makefile updates
for sys/msdos/Makefile.GCC (untested)

vms updates for above (untested)
2024-03-07 11:01:04 -05:00
RainRat
a3658f85ac fix typos 2024-02-28 20:15:56 -08:00
nhmall
90fcce8903 follow-up to only attempt unzip if download was ok 2023-12-18 14:59:01 -05:00
nhmall
c197dfe29b include symify.exe in the NetHack msdos package
Before using this updated packaging you will need
to do the following (one time):
    sh sys/msdos/fetch-cross-compiler.sh

And you'll need to update your Makefiles as follows.

On Linux:
    sh sys/msdos/setup.sh sys/unix/hints/linux.370

or on macOS;
    sh sys/msdos/setup.sh sys/unix/hints/macOS.370

Create the msdos package with:
    make CROSS_TO_MSDOS=1 package
2023-12-18 14:48:10 -05:00
nhmall
fc4f0a603d Merge branch 'vesa-fixes' of https://github.com/chasonr/NetHack into NetHack-3.7 2023-12-07 10:07:24 -05:00
nhmall
e639c4bdaa A recent patch 634f4928 introduced new tty behavior,
where calling term_start_color(NO_COLOR) would have the same
effect as calling term_end_color().

That change only included a change for termcap, but not any of
the NO_TERMS configurations. (NO_TERMS is defined for an
implementation where termcap is not used).

This attempts to make sys/msdos/video.c and sys/windows/consoletty.c
honor the change.

The msdos change has not yet been tested.

No attempt was made to alter the term_start_color() implementations
within the outdated tree.
2023-12-07 09:34:05 -05:00
Ray Chason
1f52205ee2 Fix crashes and weirdness in VESA text mode 2023-12-06 09:05:23 -05:00
nhmall
04082a2033 Remove TEXTCOLOR build option 2023-11-22 16:01:58 -05:00
nhmall
c85900320c fetch dos extender from a different location
CI was having difficulty connecting
2023-11-15 12:33:07 -05:00
Pasi Kallinen
f74f7988ff MSDOS: implement valid location highlighting
... for VGA and VESA tiled map.
2023-11-13 12:40:10 +02:00
nhmall
47bca92e6c follow-up Install.dos: consistent sample dir path 2023-11-11 12:27:03 -05:00
nhmall
7b2bf56f40 update Install.dos 2023-11-11 12:01:28 -05:00
Pasi Kallinen
614e6c9d5e MSDOS: implement inverse text attribute 2023-10-24 18:34:15 +03:00
Pasi Kallinen
76471e890b MSDOS: Fix VESA mode text background color 2023-10-24 09:37:36 +03:00
nhmall
f625d2efcf more tabs to spaces 2023-08-16 10:22:10 -04:00
nhmall
e1bae750de update DOS cross-compiler version 2023-06-27 10:49:35 -04:00
nhmall
b35d8a34ed update Lua version supported 2023-05-28 22:58:47 -04:00
nhmall
2185d325c4 header file changes hack.h, decl.h/.c, system.h, wintty.h
- Move secondary preprocessor defines down further in config.h
so that they can be overridden via [platform]conf.h which is
included from global.h, specifically:
    LIVELOGFILE when LIVELOG is defined
    DUMPLOG_FILE when DUMPLOG is defined

- Minimize platform-specific, or compiler-specific code in hack.h and decl.h.

- reorganize src/decl.c to align with include/decl.h.

- a new header file cstd.h added, containing calls to C99
standard header files.

- hack.h, decl.h, and decl.c have been cleaned up and had code
moved so that things line up as follows:

     hack.h     defines values that are available to all
                NetHack source files, contains enums for use in all
                NetHack source files, and contains a number of
                struct definitions for use in all NetHack source files.
                It does not contain variable declarations or variable
                definitions.

     decl.h     contains the extern declarations for variables that
                are defined in decl.c. These variables are global and
                available to all NetHack source files. The location of
                the variables within decl.h was random, so give it some
                order for now.

     decl.c     contains the definition of the variables declared in
                decl.h, and initializes them where appropriate. The
                variable definitions are laid out in much the
                same order as their declarations in decl.h.

- wintty.h: There were some varying terminal-related prototypes in
system.h, and that was the only thing left that demanded that
system.h be included. Those have been replaced by an #include
<term.h> in include/wintty.h to get the more current (and hopefully
more correct) prototypes, rather than hardcoding them in NetHack
sources.

For edge-case platform compatiblity, there is no #include <term.h>
if the build defines NO_TERMCAP_HEADERS. In that case one set of
hardcoded prototypes is still used in include/wintty.h.

The added #include "term.h" is also bypassed for NO_TERMS builds (builds
that don't link to terminfo/termcap at all, but still present a tty
interface using platform or window-port specific functions to fulfill
the same role as that of terminfo/termcap).

- some scattered, unnecessary #include "integer.h" were removed from
various files, since that's always included in current NetHack-3.7
sources, either directly from config.h or indirectly from #include
"hack.h".

- system.h references removed.

- new cstd.h added; the #include "system.h" references in Makefiles
and project files (Xcode, visual studio), were replaced
with #include "cstd.h" references. A "make depends" is probably
warranted.

Also:

 - Use of <term.h>, which defines clear_screen() as a macro, conflicts
with an actual function with that name in win/tty/termcap.c. The most
straight-forward course of action was to rename the NetHack function,
and change the references to it, from clear_screen() to
term_clear_screen(), so that was done.
2023-04-05 11:49:09 -04:00
PatR
998b5af644 non-Unix sysconf updates
For non-Unix systems, disable the "description of NetHack's command
line" entry in the help command's menu.
2023-02-21 11:15:08 -08:00
nhmall
2fc0d25d45 introduce support for coloring the frame behind a map location
Also includes support by paxed for polearm targeting using the
frame color.

Also renames USE_TILES to TILES_IN_GLYPHMAP which is a more
accurate description.

Not all window interfaces have full support for the color framing
of the background square yet.

MS-DOS needs further work (to bring it to both VESA and VGA, with
and without tiles.

Windows GUI is missing support.

X11 and Qt have been started, but may require further refinement.
2023-01-01 19:55:02 -05:00
nhmall
225af4ed4b CI ms-dos build: 1 warning was logged as 2 due to set -x 2022-12-02 00:23:46 -05:00
nhmall
df0c65ce41 more fetch-cross-compiler.sh tweaks 2022-12-02 00:20:41 -05:00
nhmall
233e4a41af exit return code 2022-12-01 21:46:19 -05:00
nhmall
a1cd77e39c in fetch-cross-compiler.sh, stop if required piece failed to download 2022-12-01 20:36:10 -05:00
nhmall
6b99a50821 fix a couple of ms-dos shadow declaration warnings 2022-11-29 23:43:42 -05:00
nhmall
02a48aa8cf split g into multiple structures
The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.

It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.

Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.

To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.

A global variable named 'amulets', would be found in ga.
    ga.amulets
     ^ ^
A global varable named 'move', would be found in gm.
    gm.moves
     ^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
    gv.val_for_n_or_more
     ^ ^
A global variable named 'youmonst' would be found in gy.
    gy.youmonst
     ^ ^
2022-11-29 21:53:21 -05:00
nhmall
9efa5d5b44 follow-up bit (in unused ms-dos code) 2022-11-23 18:57:14 -05:00
nhmall
937355038d some coordxy and other conversion warnings
When dist2() got changed to use coordxy parameters, a macro that uses
it in its definition was overlooked and it had (int) casts in it.
That caused a warning about possible data loss when the int
then got converted to coordxy for the dist2() call.

Give online2() coordxy parameters instead of int, like its bretheren.

Avoid a couple of implicit conversion warnings where ints were being assigned
to smaller uchar or ints being assigned to smaller short.

A couple of signed vs unsigned warnings on some rumor processing.

Avoid some signed vs unsigned warnings in mdlib/makedefs where a signed int
param eventually got used in an external call that took size_t.
Eliminate all of it by just having the outer NetHack routine also take
a size_t.

Lastly, insert some default C99 alternative time-related code
in mdlib/makedefs since asctime() and ctime() are being flagged as
deprecated in the upcoming C23 standard and will now start to trigger
warnings for anyone using a C23-compliant compiler.
2022-11-23 17:49:55 -05:00
nhmall
99a93fe50b some C99 changes
Instead of using index() macro defined to strchr, use C99 strchr.
Instead of using rindex() macro defined to strrchr, use C99 strrchr.

If you want to try building on a platform that doesn't offer those
two functions, these are available:
    define NOT_C99       /* to make some non-C99 code available */
    define NEED_INDEX    /* to define a macro for index()  */
    define NEED_RINDX    /* to define a macro for rindex() */
2022-10-29 10:54:25 -04:00