Commit Graph

2054 Commits

Author SHA1 Message Date
nhmall
67e7632e38 Merge branch 'libnethack-target-fixes' of https://github.com/dextercd/NetHack into pr645 2021-12-28 08:41:35 -05:00
nhmall
a194194039 more possible build fixes
Once again, I need to commit these first and observe the CI results
afterwards to verify the results.
2021-12-28 08:04:59 -05:00
nhmall
e9424445f6 possible build fix catch-up for Windows Makefile.gcc
Verification once CI attempts a build as no local testing capability
2021-12-27 21:43:46 -05:00
nhmall
019adaefb1 Xcode build fix 2021-12-27 21:33:01 -05:00
nhmall
6c0bc4fe25 another Makefile.msc comment tidbit 2021-12-24 09:37:52 -05:00
nhmall
19ef16a882 Makefile.msc comment tidbit 2021-12-24 09:36:43 -05:00
nhmall
c0f9d93ea4 update Windows test build to Visual Studio 17.0.4 2021-12-24 09:33:56 -05:00
PatR
459b1c1c8d switch makedefs from malloc() to alloc()
Avoids any need for MONITOR_HEAP hackery.  Link src/alloc.o and
util/panic.o into util/makedefs.

When replacing the realloc() call in fgetline(), I noticed that
fgetline() would miss the last line of an input file if it lacked a
terminating newline.  This was hard to test because OSX seems to be
supplying one when it is missing (VMS would do that too).  I had to
modify epitaph (my test bed) to take off the final character, run
'makedefs -s' under debugger control and strip away final newline
that stdio added back, build new nhdat and move it into place, then
run nethack and execute #wizrumorcheck all multiple times before
the fix and once more after it.  Much effort for little gain...

Plus some of the recent reformatting:  indent labels one space,
replace tabs with spaces, shorten or split wide lines.
2021-12-22 00:18:37 -08:00
Dexter Castor Döpping
07715c3bad Place libnh targets in $(TARGETPFX) 2021-12-15 22:59:22 +01:00
Dexter Castor Döpping
967dcbccf4 Fix build failing for libnh when using TARGETPFX
Compiling with WANT_LIBNH=1 and TARGETPFX=(...) failed because ioctl.o
could not be found.

This is because the targets are specified with the $(TARGETPFX) but the
libnh targets consumed these targets without the $(TARGETPFX).
2021-12-15 22:59:22 +01:00
nhmall
3bb9f91a1e get Xcode build working 2021-12-03 15:01:22 -05:00
nhmall
359f4dfc65 tested with visual studio 17.0.2 2021-12-03 10:19:18 -05:00
PatR
5224d85ad3 compile-time format checking
We've had a few pull requests fixing format/argument mismatches
lately.  I did't notice when PRINTF_F(format_index,first_arg_index)
attribute use and the checking gcc and clang do with it got removed,
but that was very useful.  Putting it back triggers a whole bunch
of "format string is not literal" warnings, but that's because
'-Wformat-nonliteral' was explicitly added to the *.2020 hints.
Checking pline/You/&c arguments in the cases where the format is a
literal is more valuable than the complaints for sprintf being fed
a generated format, so reinstate PRINTF_F usage and turn off the
check for non-literal format strings.
2021-11-26 21:50:44 -08:00
nhmall
dc4b98ebdc more windows keyhandling follow-up 2021-11-23 17:14:10 -05:00
nhmall
0a97cc5c5e windows console changes - eliminate *key.dll
Incorporate the functionality of the loadable DLL's (nhraykey.dll,
nhdefkey.dll, and nh340key.dll) into the consoletty.c code and
remove the dll building
2021-11-16 15:27:33 -05:00
nhmall
876e36d18c cut and paste error 2021-11-13 10:42:25 -05:00
nhmall
f19112e6b1 update Install.windows for vs 2022 compiler
Include visual studio 2022 in the list of compilers tested for build
- nmake Makefile.msc tested
2021-11-13 10:39:00 -05:00
nhmall
8063ad94d7 vs 2022 is current version as of November 8, 2021 2021-11-13 10:32:33 -05:00
nhmall
aa8fd3ab3c detect visual studio 2019 16.11.5 after build test 2021-11-03 10:47:01 -04:00
nhmall
710e3bae06 visual studio 2022 preview 7 2021-10-28 22:40:46 -04:00
nhmall
c6f5b41e51 move compiler override note above the autodetection 2021-10-23 12:30:02 -04:00
nhmall
b44b5e35a8 re-enable -Wunreachable-code under clang
whitelist the valid cases showing up

If an earlier version of clang is showing more cases (particularly
if they don't make sense), the re-enabling of the warning in
sys/unix/hints/include/compiler.2020 can be made clang-version
specific instead. I had no way to test earlier versions.
2021-10-22 12:27:10 -04:00
nhmall
92f54e600d consoletty.c preprocessor directives
The preprocessing was a little messed up if VIRTUAL_TERMINAL_SEQUENCES was not
defined.
2021-10-12 21:15:54 -04:00
nhmall
1e78c296f3 remove a warning with gcc on Windows
"braces around scalar initializer"
2021-10-11 18:14:09 -04:00
nhmall
16c2df511d attempt to fix mingw build
This was detected by one of the CI builds.
2021-10-11 15:08:05 -04:00
nhmall
013f84f692 trailing blanks 2021-10-11 13:53:55 -04:00
nhmall
e5f7ba9fe5 Windows virtual terminal sequences
Microsoft has been making a recommendation that programs should switch
from using the classic low-level console API calls to virtual terminal
sequences for a couple of years.

References:
"Our recommendation is to replace the classic Windows Console API with virtual
terminal sequences. This article will outline the difference between the two
and discuss the reasons for our recommendation."
From:
Classic Console APIs versus Virtual Terminal Sequences
https://docs.microsoft.com/en-us/windows/console/classic-vs-vt

The online documentation for WriteConsoleOutputCharacter() and
WriteConsoleOutputAttribute() have this disclaimer on them:
"This document describes console platform functionality that is no longer a
part of our ecosystem roadmap. We do not recommend using this content in new
products, but we will continue to support existing usages for the indefinite
future. Our preferred modern solution focuses on virtual terminal sequences
for maximum compatibility in cross-platform scenarios. You can find more
information about this design decision in our classic console vs. virtual
terminal document."

Since NetHack started out as a terminal program, before there was a
Windows "classic" console API introduced with Windows NT, it seemed only
fitting that the Windows console port should evolve in the virtual terminal
direction.

This is a first stab at it. The performance won't be as instantaneous as
the low-level console API's. That's likely partly because of this consoletty.c
initial implementation, but it may also partly be because under the hood in
the OS, there's recognitions/translations/conversions going on. Microsoft
states it will continue to evolve the Windows Terminal and console, and
hopefully it will improve. Hopefully it isn't too slow to play. It still
attempts to take advantage of the back buffer stuff that Barton House
introduced to minimize screen updates. At this point, it can still be
recompiled without the virtual terminal support by defining NO_VT when
compiling consoletty.c, or by commenting out the definition of
VIRTUAL_TERMINAL_SEQUENCES at the top of sys/windows/consoletty.c

That's the informational news, and the negative news out of the way.

There's some good news too. Because the virtual terminal sequences
support include 24-bit color support, the Windows console under virtual
terminal sequence can provide a more pleasant set of colors to the NetHack
console interface. To that end, some color changes have been implemented
in consoletty.c now.

It makes the console port ready to accept and display 24-bit color from
the NetHack core, if that should ever happen, as well.

As usual with a first implementation, there may be some bugs. Reports
are welcome.
2021-10-11 09:48:48 -04:00
PatR
ccfddd47de fix Unix build with DEF_PAGER defined
Eliminate a couple of compile warnings produced when DEF_PAGER is
defined:  unixmain.c: g.catmore=DEF_PAGER; wintty.c: fd=open(...).

Override its use when DLB is also defined since an external pager
could access 'license' but not 'history', 'opthelp', &c when those
are in the dlb container file.

In the commented out value for DEF_PAGER, show a viable value for
the default configuration these days.
2021-10-05 01:11:24 -07:00
PatR
013f3770d1 hints/macOS.2020 - remote duplicate -DDLB 2021-10-04 19:43:04 -07:00
PatR
e52f38b3a3 Guidebook make sequencing
Be able to run 'make Guidebook{|.txt|.ps}' in the doc subdirectory
without requring a full install first.

makedefs is no longer one of the first things built when building
nethack, and even if it was, nobody should have to rebuild all of
nethack after 'make spotless' when they just want to create one
or more of the formatted Guidebooks.  The 'roff versions (.ps and
also .txt) use makedefs as a filter by default, so wouldn't build
if it wasn't there.

Have Makefile.doc build makedefs when needed.

Clean up some dependencies in Makefile.utl.

Add a couple of comments to Makefile.src.
2021-09-27 01:30:53 -07:00
nhmall
f034f8ae86 Windows Makefile.gcc update
tilemap needs to link with tilemap.o monst.o objects.o drawing.o
2021-09-21 03:40:17 -04:00
nhmall
1f6c1d0f42 expand the glyphs
The walls for the mines, gehennom, knox, and sokoban had been
changed at the "tile"-level, with no awareness of the core game,
or non-tile interfaces.
- Expand the glyphs to include a set of walls for the main level
as well as each of those mentioned above.

Altars had been adjusted at the map_glyphinfo() level to substitute
some color variations on-the-fly for unaligned, chaotic, neutral,
lawful altars, and shrines. The tile interface had no awareness of
the feature.
- Expand the glyphs to include each of the altar variations that
had been implemented in the display code for tty-only. This required
the addition of four placeholder tiles in other.txt. Someone with
artistic skill will hopefully alter the additional tiles to better
reflect their intended purpose.

Explosions had unique tiles in the tile window port, and the display
code for tty tinkered with the colors, but the game had very little
awareness of the different types of explosions.
- Expand the glyphs to include each of the explosion types: dark,
noxious, muddy, wet, magical, fiery and frosty.

Pile-markers to represent a pile had been introduced at the
display-level, without little to no awareness by the core game.
- Expand the glyphs to include piletops, including objects,
bodys, and statues.

Recently male and female variations of tiles and monsters had been
had been introduced, but the mechanics had been mostly done at the
display-level through a marker flag. The window port interface then
had to increment the tile mapped to the glyph to get the female version
of the tile.
- Expand the glyphs to include the male and female versions of the
monsters, and their corresponding pet versions, ridden, detected
versions and statues of them.

Direct references to GLYPH_BODY_OFF and GLYPH_STATUE_OFF
in object_from_map() in pager.c were getting incomplete results.
- Add macros glyph_to_body_corpsenm(glyph) and
glyph_to_statue_corpsenm(glyph) macros for obtaining the corpsenm
value after passing the glyph_is_body() or glyph_is_statue() test.

Other relevant notes:

- The tile ordering in the win/share/*.txt tile files has been altered,
other.txt in particular.

- tilemap.c has had a lot of alterations to accommodate the expanded
glyphs. Output that is useful for troubleshooting will end up in
tilemappings.lst if OBTAIN_TILEMAP is defined during build.
It lists all of the glyphs and which tile it gets mapped to, and also
lists each tile and some of the references to it by various glyphs.

- An array glyphmap[MAXGLYPH] is now used. It has an entry for each
glyph, ordered by glyph, and once reset_glyphs(glyph) has been run, it
contains the mapped symindex, default color, glyphflags, and tile
index.
If USE_TILES is defined during build, the tile.c produced from the
tilemap utility populates the tileidx field of each array element with
a glyph-to-tile mapping for the glyph. Later on, when reset_glyphmap()
is run, the other fields of each element will get populated.

- The glyph-to-tile mapping is an added field available to a window
port via the glyphinfo struct passed in the documented interface. The
old glyph2tile[] array is gone. The various active window ports that
had been using glyph2tile[] have been updated to use the new interface
mechanism. Disclaimer: There may be some bug fixing or tidying
required in the window port code.

- reset_glyphmap() is called after config file options parsing
has finished, because some config file settings can impact the results
produced by reset_glyphmap().

- Everything that passes the glyph_is_cmap(glyph) test must
return a valid cmap value from glyph_to_cmap(glyph).

- An 'extern glyph_info glyphmap[MAX_GLYPH];' is inserted into the
top of only the files which need awareness of it, not inserted into
display.h. Presently, the only files that actually need to directly
reference the glyphmap[] array are display.c, o_init.c (for shuffling
the tiles), and the generated tile.c (if USE_TILES is defined).

- Added an MG_MALE glyphflag to complement the MG_FEMALE glyphflag.

- Provide an array for wall colorizations. reset_glyphmap() will draw
the colors from this array: int array wallcolors[sokoban_walls + 1];
The indices of the wallcolors array are main_walls (0), mines_walls
(1), gehennom_walls (2), knox_walls (3), and sokoban_walls (4).
In future, a config file option for adjusting the wall colors and/or
an 'O' option menu to do the same could be added. Right now, the
initializaton of the wallcolors[] array entries in display.c leaves the
walls at CLR_GRAY, matching the defsym color.

- Most of the display-level kludges for some of the on-the-fly
interface features have been removed from map_glyphinfo() as they
aren't needed any longer. These glyph expansions adhere more closely to
the original glyph mechanics of the game.

- Because the glyphs are re-ordered and expanded, an update to
editlevel will be required upon merge of these changes.
2021-09-18 19:51:04 -04:00
nhmall
fde51720f4 Windows Makefile.msc updates
Recognize latest version of Visual Studio Community 2017 version 15.9.39
Recognize latest version of Visual Studio Community 2019 version 16.11.3
The removal of the generated $(SRC)\tile.c file moved from
    nmake spotless
to
    nmake clean
2021-09-15 21:45:50 -04:00
nhmall
8ca0ce4b12 Makefile.gcc follow-up
Errors in the CI after dependency update
2021-09-14 23:39:22 -04:00
nhmall
3a5ba5a81a msdos Makefile.gcc dependency update
Copy the recently updated dependencies from sys/unix/Makefile.src
over to sys/msdos/Makefile.gcc.
2021-09-14 12:48:42 -04:00
nhmall
db9059f735 Windows Makefile.gcc dependency update
Copy the recently updated dependencies from sys/unix/Makefile.src
over to sys/windows/Makefile.gcc.
2021-09-14 12:36:29 -04:00
nhmall
ef1af7c951 Windows Makefile.msc dependency update
Copy the recently updated dependencies from sys/unix/Makefile.src
over to sys/windows/Makefile.msc.
2021-09-14 10:25:49 -04:00
PatR
84b4eb9888 Unix 'make depend'
I recently changed a comment in objclass.h and that should have
triggered a full or nearly full rebuild but only resulted in a
couple of files being recompiled.  Instead of trying to figure out
why, I just ran Makefile.src through 'make depend' to force it to
be up to date.

A side-effect is that version.c won't be unnecessarily recompiled
every time nethack gets relinked.  The reason for that (date.h
being regenerated with new data) is handled by date.c now.
2021-09-14 02:06:14 -07:00
nhmall
15ec24a524 windows visual studio project build tweaks 2021-09-13 11:32:59 -04:00
nhmall
a772751745 build failure detected in CI
The build in the CI was failing after commits today due to this error:
prob error for class 4 (28%)

It was caused by running
	makedefs -o

Remove unnecessary invocation of makedefs with outdated options from
aftermakedefs.proj
2021-08-28 23:10:49 -04:00
nhmall
6ffa912359 missed dependency 2021-08-23 22:18:55 -04:00
nhmall
61ed041c9e Windows VS build failure if DLB wasn't defined 2021-08-22 19:25:13 -04:00
nhmall
f785026006 remove test bit 2021-08-21 22:51:39 -04:00
nhmall
1c270ea31b build issue without DLB defined 2021-08-21 22:47:55 -04:00
nhmall
12f8be6452 more visual studio build tweaks 2021-08-21 15:53:21 -04:00
nhmall
d1e49d7d67 follow-up build fixes for Windows 2021-08-21 15:48:40 -04:00
nhmall
9bb96322a8 compile NetHack-3.7 without makedefs-generated .h files
This evolves and hopefully eases the game-build requirements by
removing game-compile dependencies on any header files generated
by the makedefs utility, including:

date.h dependency and its inclusion is removed and comparable functionality
is produced at runtime via new file src/date.c.

pm.h dependency and its inclusion is removed and comparable functionality is
produced by moving the monster definitions from monst.c into new header
file called monsters.h and altering them slightly. The former pm.h header
file #define PM_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.

onames.h dependency and	its inclusion is removed and comparable functionality
is produced by moving the object definitions from objects.c into new header
file called objects.h and altering them slightly. The former onames.h header
file #define values are now replaced with appropriate emitted enum entries
during the compiler preprocessing.

artilist.h has been slightly altered, and the former onames.h artifact-related
header file #define ART_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.

makedefs can still produce date.h (makedefs -v), pm.h (makedefs -p), and
onames.h (makedefs -o) for reference purposes. They won't be used during
the compiler.

The other uses for makedefs remain. They are used to prepare external
file content that the game utilizes, not prerequisite code for the
compile:
    makedefs -d    (database)
    makedefs -r    (rumors)
    makedefs -h    (oracles)
    makedefs -s    (epitaphs, engravings, bogusmons)

date.c

Pull the code for date/time stamping from mdlib.c into date.c.
Set date.o to be dependent on source files, header files, and .o files
so that date.o is rebuilt from date.c when any of those changes, thus
ensuring an accurate date/time stamp. It also includes git sha
functionality formerly done by makedefs writing #define directives
into include/date.h. For unix it passes the git info on
the compile line for date.c (via sys/unix/hints/linux.2020, macOS.2020)

nethack --dumpenums (optional, but on by default)

Allow developer to obtain some internal enum values from NetHack
without having to resort to an external utility such as
makedefs.

Uncomment #define NODUMPENUMS in config.h to disable this.

The updates to sys/windows/Makefile.gcc have not been tested yet.
2021-08-21 07:59:18 -04:00
nhmall
29aca6276e fix some VS warnings that recently appeared
..\src\explode.c(884): warning C4028: formal parameter 1 different from declaration

  That one stems from commit 6b60618e0e.
  Adjust the prototype in include/extern.h to match the function definition in
  src/explode.c

  Also, a recent update to the Microsoft Visual Studio 2019 causes the
  compiler to complain while compiling a vendor c++ header (string) if
  warning C4774 is enabled.

  We force that warning to be enabled during the Makefile build, even though
  it is not enabled by default.

  Only do so in the Makefile.msc for c source files, and not for c++
  (sys/share/cppregex.cpp).

  See below for an example of the compiler complaint.

  cppregex.cpp
  C:\Program Files (x86)\Microsoft Visual
  Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
  warning C4774: '_scprintf' : format string expected in argument 1 is
  not a string literal
  C:\Program Files (x86)\Microsoft Visual
  Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
  note: e.g. instead of printf(name); use printf("%s", name); because
  format specifiers in 'name' may pose a security issue
  C:\Program Files (x86)\Microsoft Visual
  Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
  note: consider using constexpr specifier for named string literals
  C:\Program Files (x86)\Microsoft Visual
  Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(583):
  note: see reference to function template instantiation 'std::string
  std::_Floating_to_string<float>(const char *,_Ty)' being compiled
          with
	[
	   _Ty=float
	]
2021-08-14 15:36:54 -04:00
nhmall
2baadd6a29 header files sym.h and defsym.h
There were multiple symbol-related lists that had to be kept
in sync in various places.

Consolidate some of that into a single new file
    defsym.h
with a set of morphing macros that can be custom-called from
the various places that use the sym info without maintaining
multiple occurrences. Most maintenance can be done there.

Rename monsym.h to sym.h since it looks after some
symbols not related to monsters now too.

The defsym.h header file is included in multiple places to
produce different code depending on its use and the controlling
macro definitions in place prior to including it.

Its purpose is to have a definitive source for
pchar, objclass and mon symbol maintenance.

The controlling macros used to morph the resulting code are
used in these places:
  - in include/sym.h for enums of some S_ symbol values
    (define PCHAR_ENUM, MONSYMS_ENUM prior to #include defsym.h)
  - in include/objclass.h for enums of some S_ symbol values
    (define OBJCLASS_ENUM prior to #include defsym.h)
  - in src/symbols.c for parsing S_ entries in config files
    (define PCHAR_PARSE, MONSYMS_PARSE, OBJCLASS_PARSE prior
    to #include defsym.h)
  - in src/drawing.c for initializing some data structures/arrays
    (define PCHAR_DRAWING, MONSYMS_DRAWING, OBJCLASS_DRAWING prior
    to #include defsym.h)
  - in win/share/tilemap.c for processing a tile file
    (define PCHAR_TILES prior to #include defsym.h).
2021-08-10 13:35:25 -04:00
nhmall
e16b98b61d NetHackW before and after tile additions
The NetHackW.res file wasn't being forced to be rebuilt if
the tiles were changed as they were recently.

Fix the Makefile.msc dependency so that it is.
Also have 'nmake clean' clear the generated *.res files.
2021-08-04 15:48:17 -04:00