Enable USE_BUFFERING for the structlevel savefile write path on AMIGA
and TOS via a new SFSTRUCT_BUFFERING config define, with a 16 KB
setvbuf on the fdopen'd write stream so many small bwrite()s coalesce
into few dos.library Write() packets. Leaves mread() unbuffered.
Mainline UNIX/WIN32 are unchanged (setvbuf is gated on the new define);
MAC68K is not enabled, avoiding fdopen()/fclose() on its remapped
non-libc file handles.
Use LUA_VERSION_NUM, not LUA_VERSION_RELEASE_NUM, for the check.
Move the definitions of the versions supported by this release of
NetHack to the top of nhlua.c, rather than 2300 lines into the file.
Close#1633
In previous versions of NetHack, setting -DUSE_TILES enabled the tile
support, while setting -DSUPPRESS_GRAPHICS produced a NetHack that
would write its TTY output to standard output, and rely on ANSI.SYS or
similar to do screen control. (USE_TILES is now TILES_IN_GLYPHMAP.)
This change ensures that the current NetHack can be built the same
ways.
One twist is that previous NetHacks would drop all support for graphical
modes when tiles were not supported. Thus sys/msdos/vid{vga,vesa}.c have
very disordered use of TILES_IN_GLYPHMAP. There was no need to check
this. But now, the graphical modes also support Unicode. A non-tiled
build should have the graphical modes, with only the text functions
present, provided that ENHANCED_SYMBOLS is defined.
Some unused and locally used symbols were cleaned up along the way.
In 16 color mode, text colors are mapped onto the colors available in
the tileset. The mapping is a compromise, and is not one-to-one: cyan
and bright cyan are the same, and magenta and bright magenta are the
same.
This change defines a separate palette for use by the text map, and
switches palettes on any transition between text and tiled maps.
During a synchronous save operation initiated by the player (or
other trigger for dosave0()), the u.usteed_mid and u.ustuck_mid
values get set by savemonch(), and the monst pointers that
u.ustuck and u.usteed point to are no longer valid, but not
cleared.
The checkpoint operation, which also needs to ensure that
u.ustuck_mid and u.usteed_mid are set, must set them during
the checkpoint, which is okay because the u.usteed and
u.ustuck pointers _are_ valid during a checkpoint operation.
So, we need to distinguish between a save game sequence,
and a checkpoint sequence when writing out the u struct.
* In both the 16 color and the VESA mode, the tileset image is loaded
and split into individual tiles; the tiles are then processed into a
form that is compatible with the video mode in use. For 16 color mode,
a tile is processed each time it is displayed, leading to slow
redrawing. For VESA mode, each tile is processed at startup, leading
to long startup times. Both modes are changed so that the tile is
processed once, when it is first displayed, and the result is cached.
* Use memcpy when splitting the image into tiles.
* Only load the tileset once. In 16 color mode, for reasons I do not
understand, the gr_init function is called twice, leading to delay
in startup. This does not happen in VESA mode.
* src/glyphs.c: Don't produce names for swallow glyphs that can never
appear. This speeds up the building of the glyph index in
populate_glyphname_hash_indices.
* src/symbols.c: Build a sorted index for loadsyms so that it can be
searched with bsearch.
Benchmarking results, using the MS-DOS port on an emulated 386SX at
16 MHz; times are as measured with clock() from the entry to main()
to the appearance of the "Who are you?" prompt:
* Unmodified: 48.5 seconds
* With the loadsyms index: 40.4 seconds
* With impossible swallow glyphs left unnamed: 34.5 seconds
These changes should also be helpful for the Amiga and Atari ST ports.
The 16 color mode loads the font specified in font_map, and accepts it
only if its size is 8 by 16 pixels. This change avoids a null
dereference if the font is not found.
This change adds U+2299, U+2601 and U+2980 to the bundled fonts, so
that all symbols specified in the Extended2 symbol set are available.
Also, a few more directives are added to the files, so that FontForge
can load them and display their contents.
When corpses haven't stacked, and there is no player-discernable
reason why, provide some additional information in some cases,
but only when it is required.
Gender variance is the supported case in this commit.
Related to GitHub issue #1607.
This commit doesn't change the underlying mechanics to allow
the corpses to stack, but it does help the player understand
why that's the case in this instance.
In file included from ../include/hack.h:34,
from sp_lev.c:14:
In function ‘create_monster’,
inlined from ‘lspo_monster’ at sp_lev.c:3386:5:
../include/rm.h:528:32: warning: array subscript -1 is below array bounds of ‘struct monst *[80][21]’ [-Warray-bounds=]
528 | if (!svl.level.monsters[x][y]) \
| ~~~~~~~~~~~~~~~~~~^~~
sp_lev.c:2045:25: note: in expansion of macro ‘remove_monster’
2045 | remove_monster(x, y);
| ^~~~~~~~~~~~~~
../include/rm.h: In function ‘lspo_monster’:
../include/rm.h:476:19: note: while referencing ‘monsters’
476 | struct monst *monsters[COLNO][ROWNO];
| ^~~~~~~~
In function ‘create_monster’,
inlined from ‘lspo_monster’ at sp_lev.c:3386:5:
../include/rm.h:530:27: warning: array subscript -1 is below array bounds of ‘struct monst *[80][21]’ [-Warray-bounds=]
530 | svl.level.monsters[x][y] = (struct monst *) 0; \
| ~~~~~~~~~~~~~~~~~~^~~
sp_lev.c:2045:25: note: in expansion of macro ‘remove_monster’
2045 | remove_monster(x, y);
| ^~~~~~~~~~~~~~
../include/rm.h: In function ‘lspo_monster’:
../include/rm.h:476:19: note: while referencing ‘monsters’
476 | struct monst *monsters[COLNO][ROWNO];
| ^~~~~~~~