Commit Graph

592 Commits

Author SHA1 Message Date
nhmall
88f6df2d8b some tabs to spaces
cd src
    grep -P -n '\t' *.c | grep -v "1:"
    cd ../include
    grep -P -n '\t' *.h | grep -v "1:"
    cd ..

side note: win/Qt/*.cpp are full of tabs
2022-10-26 14:21:23 -04:00
Ray Chason
c801f3ce00 Write Unicode to text save file 2022-10-16 22:57:28 -04:00
Ray Chason
f7aa79f939 Copy Unicode to the clipboard 2022-10-16 22:32:11 -04:00
Ray Chason
c5674fd10c Fix crashes when copying to clipboard 2022-10-16 21:42:42 -04:00
Ray Chason
426ef4d8d2 Add Unicode support to the map 2022-10-16 21:42:18 -04:00
Pasi Kallinen
fd9745f9c6 Command repeating by using cmd queues
This replaces the old pushq/saveq arrays (which were used to save
the keys pressed by the user for repeating a previous command)
with a new command queue.  This means there's no hard-coded limit
to the saved keys, and it can repeat extended commands which are
not bound to any key.
2022-08-09 11:54:45 +03:00
nhmall
c84e0ba6e1 rework TTY_PERM_INVENT; update window port interface
Change the inner workings of the experimental TTY_PERM_INVENT.

Switch to delivering the content to tty for the experimental perm_invent
via the existing window port interface (start_menu(), add_menu(), end_menu).

This also adds a new window port interface call ctrl_nhwindow() for
delivering information to the window port, and/or obtaining specific
information from the window port. The information and requests can
be extended as required. To be documented later once the changes settle
down.

Due to the intrusive nature of these changes and the possibility of
some bugs in the new code, I'm going to leave TTY_PERM_INVENT commented
out in the repository for a day or two.  Anyone wishing to test it out
can do so by uncommenting TTY_PERM_INVENT in config.h.
2022-07-03 00:35:32 -04:00
nhmall
3004cf2d34 be more consistent with coordinates 2022-07-02 09:10:03 -04:00
nhmall
30b557f7d5 change xchar to other typedefs
One of the drivers of this change was that screen coordinates require a
type that can hold values greater than 127. Parameters to the window
port routines require a large type in order to be able to have values
a fair bit larger than COLNO and ROWNO passed to them, particularly for
their use to the right of the map window.

This splits the uses of xchar into 3 different situations, and adjusts
their type and size:

                        xchar
                          |
               -----------------------
               |          |          |
            coordxy     xint16     xint8

coordxy: Actual x or y coordinates for various things (moved to 16-bits).

xint16:  Same data size as coordxy, but for non-coordinate use (16-bits).

xint8:   There are only a few use cases initially, where it was very
         plain to see that the variable could remain as 8-bits, rather
         than be bumped to 16-bits.  There are probably more such cases
         that could be changed after additional review.

Note: This first changed all xchar variables to coordxy. Some were
reviewed and got changed to xint16 or xint8 when it became apparent that
their usage was not for coordinates.

This increments EDITLEVEL in patchlevel.h
2022-06-30 23:48:18 -04:00
nhmall
f228fefabd updated window_procs
Add a non-string identifier to window_procs for use in runtime
identification of the current window port being used.

Use a macro WPID to add the identification at the top of the
various existing window_procs declarations. It expands to the
existing text string, as well as the newly added field wp_id
with a wp_ identifier.

For example, WPID(tty) expands to: "tty", wp_tty

The generated wp_tty must be present in the wp_ids enum at
the top of include/winprocs.h.

The WINDOWPORT(x) macro has been updated to expand to a simple
value comparison (port.wp_id == wp_x), instead of a
string comparison.
2022-06-29 23:21:19 -04:00
nhmall
2770223d10 interface groundwork for core-side color decisions
(user-side decisions really, but as it stands right now
user-side decisions/options are made and processed by the core)

add a parameter to add_menu so color can be passed
2022-06-25 13:21:51 -04:00
nhmall
736e9f14f8 groundwork for an interface change
Add a new window-port interface function
     perminvent_info *
     update_invent_slot(winid window, int slot, perminvent_info *);

That should be nice and flexible and allow exchanges of useful
information between the core and the window port. Information
to be exchange can be easily modified in include/wintype.h as
things evolve.

Information useful to the core can be exchanged from the
window-port in struct to_core.

Information useful from the core to the window-port can be
passed in struct from_core.

I'm not going to update any docs until much later after things
are fully working and settled.

This also doesn't fix or have anything to do with existing
TTY_PERM_INVENT issues.
2022-06-23 14:01:35 -04:00
PatR
916cd4a57d fix #2779 - Windows GUI pulldown help menu \
specifies duplicate accelerator keystrokes

Reported and diagnosed nine and half years ago but never fixed.

In the WinGUI-specific help menu (under the titlebar, not nethack's
'?' command), both "&Long description of the game" and "&Longer list
of game options" use &L as accelerator.  Typing 'L' or 'l' highlights
one of the entries, then <enter> is needed to execute it or typing
another 'L' or 'l' unhighlights it and highlights the other.  Other
accelerators in that menu execute their entries immediately, without
the need for <enter>.

Change the first one to "Long description of the &game" so that 'G'
or 'g' becomes its accelerator.

That menu is missing several things that have been added to the menu
for '?'.  I put in placeholder comments for them but won't pursue
them further.

Untested.
2022-06-19 16:55:39 -07:00
nhmall
4a8deefaa3 replace leading tabs in several more files 2022-05-30 12:38:22 -04:00
nhmall
f8b8495144 more version buf 2022-05-12 19:56:16 -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
PatR
31affa0722 ^A/#repeat vs extended commands
Fix '#repeat' for tty; both it and ^A can repeat an extended command.

Fix both for curses; they can repeat an extended command instead of
just repeating the initial '#' to start getting an extended command.

X11 (tested), Qt (tested), and probably Windows GUI (not tested)
behave the same as before:  ^A (or #repeat) after an extended command
just repeats the # to run the dialog to get an extended command.

I hope this introduces fewer bugs than it fixes but I don't think I'd
bet on that....
2022-04-16 01:52:12 -07:00
PatR
ffd84583d0 menuinvertmode for win32/Windows GUI
Catch up with tty, curses, X11, and Qt:  menuitem_invert_test()
applies to select as well as invert and if menuinvertmode is 2 then
it also applies to unselect.

Not tested.
2022-03-19 15:49:55 -07:00
nhmall
5d4fc4591d more .gitattributes updates 2022-02-04 11:01:20 -05:00
Feiyun Wang
4827540305 Make WinMain() to call mingw_main() instead of main() for mingw32 version. 2022-01-27 18:33:52 -05:00
Feiyun Wang
3de2b825b0 Fix mingw32 building errors. 2022-01-27 18:33:52 -05:00
Alva Melkerson
dc7dff1d7e Update NetHackW.c
Updated some comments that referred to an old file name
2021-11-11 17:35:11 -06: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
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
216c26aaef do vs2017 warnings.h a little differently than vs2019
fixes #545
2021-07-07 09:05:22 -04:00
nhmall
0a10bd632d change references from winnt to windows
rename sys/winnt to sys/windows
move vs (visual studio) folder out of win/win32 and into sys/windows
rename include/ntconf.h to include/windconf.h
rename winnt.c to windsys.c
place visual studio projects into individual subfolders.

This will hopefully resolve GitHub issue #484 as well.
2021-06-03 23:26:00 -04:00
nhmall
e69808987e support for build with current Lua version 5.4.3
On some platforms this may require:
	make spotless
	make fetch-lua

I did attempt to force a reminder message about the latter to
Makefile.top this time, and hope that works correctly for everyone.
2021-06-02 19:12:47 -04:00
Pasi Kallinen
967c7e5b0b Fix compile error on Windows
Fixes #508
2021-05-09 11:43:55 +03:00
PatR
dd49431296 \#perminv, 1 of 2: groundwork
Give the window-port side of *_update_inventory() an argument.
Calls in the core still omit that; invent.c's update_inventory()
is the only place that cares.
2021-03-13 18:17:00 -08:00
PatR
8fff588ab3 X11 persistent inventory again: initial display
If 'perm_invent' is preset in player's options, have X11 show the
persistent inventory window from the start instead of waiting for
an 'i' command.  moveloop() prolog needed a tweak do deal with it
cleanly.

Require WC_PERM_INVENT in order to honor the perm_invent option.
X11 and curses already set that, tty and curses don't support it,
so only Windows GUI needed to be updated for it.
2021-02-14 00:57:34 -08:00
Bart House
1efae34cc7 Disable warning 4774 for lua source files. 2021-02-04 11:28:41 -08:00
nhmall
7b454f8ba3 Windows format string bits 2021-02-02 21:55:34 -05:00
nhmall
5b1d668c44 enable -Wformat-nonliteral for linux and equivalent for windows compilers
Whitelist all the verified existing triggers:
makedefs.c: In function ‘name_file’
attrib.c: one compiler balks at a ? b : c for fmtstring
cmd.c: In function ‘extcmd_via_menu’
cmd.c: In function ‘wiz_levltyp_legend’
do.c: In function ‘goto_level’
do_name.c: In function ‘coord_desc’
dungeon.c: In function ‘overview_stats’
eat.c:  one compiler balks at a ? b : c for fmtstring
end.c:  one compiler balks at a ? b : c for fmtstring
engrave.c: In function ‘engr_stats’
hack:c one compiler balks at a ? b : c for fmtstring
hacklib.c: one compiler balks at a ? b : c for fmtstring
insight.c: one compiler balks at a ? b : c for fmtstring
invent.c: In function ‘let_to_name’
light.c: In function ‘light_stats’
mhitm.c: In function ‘missmm’
options.c: In function ‘handler_symset’
options.c: In function ‘basic_menu_colors’
options.c: In function ‘optfn_o_autopickup_exceptions’
options.c: In function ‘optfn_o_menu_colors’
options.c: In function ‘optfn_o_message_types’
options.c: In function ‘optfn_o_status_cond’
options.c: In function ‘optfn_o_status_hilites’
options.c: In function ‘doset’
options.c: In function ‘doset_add_menu’
options.c: In function ‘show_menu_controls’
options.c: In function ‘handle_add_list_remove’
pager.c: In function ‘do_supplemental_info’
pager.c: In function ‘dohelp’
region.c: In function ‘region_stats’
rumors.c: sscanf usage
sounds.c: In function ‘domonnoise’
spell.c: In function ‘dospellmenu’
timeout.c: In function ‘timer_stats’
topten.c: In function ‘outentry’, fscanf, sscanf, fprintf usage
windows.c: In function ‘genl_status_update’
zap.c: one compiler balks at a ? b : c for fmtstring
win/curses/cursstat.c: In function ‘curses_status_update’
win/tty/wintty.c: In function ‘tty_status_update’
win/win32/mswproc.c: In function ‘mswin_status_update’
2021-02-02 19:03:12 -05:00
nhmall
102007d7cf visual studio project update; also recover.c 2021-02-01 13:24:14 -05:00
nhmall
322293993f follow-up to remove some remnant wingem.h references
this should correct the broken mingw tty build
2021-01-31 13:44:15 -05:00
Bart House
9862e19a36 Disable warning for LUA files in Visual Studio builds. 2021-01-29 20:49:37 -08:00
nhmall
ca1f7c88d4 deal with some win/win32 warnings
win/win32/mhdlg.c(137)   : warning C4456: declaration of 'wbuf' hides
                           previous local declaration
win/win32/mhdlg.c(62)    : note: see declaration of 'wbuf'
win/win32/mhdlg.c(875)   : warning C4189: 'gender': local variable is
                           initialized but not referenced
win/win32/mhdlg.c(874)   : warning C4189: 'race': local variable is
                           initialized but not referenced
win/win32/mhdlg.c(876)   : warning C4189: 'alignment': local variable is
                           initialized but not referenced
win/win32/mhdlg.c(873)   : warning C4189: 'role': local variable is
                           initialized but not referenced
win/win32/mhinput.h(24)  : warning C4201: nonstandard extension used:
                           nameless struct/union
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/mhinput.h(24)  : warning C4201: nonstandard extension used:
                           nameless struct/union
win/win32/mhinput.h(24)  : warning C4201: nonstandard extension used:
                           nameless struct/union
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/mhmenu.c(62)   : warning C4201: nonstandard extension used:
                           nameless struct/union
win/win32/mhmenu.c(1082) : warning C4456: declaration of 'monitorScale'
                           hides previous local declaration
win/win32/mhmenu.c(995)  : note: see declaration of 'monitorScale'
win/win32/mhmenu.c(1142) : warning C4456: declaration of 'wbuf' hides
                           previous local declaration
win/win32/mhmenu.c(986)  : note: see declaration of 'wbuf'
win/win32/mhmenu.c(1082) : warning C4189: 'monitorScale': local variable
                           is initialized but not referenced
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/mhmsgwnd.c(700): warning C4701: potentially uninitialized
                           local variable 'size' used
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/mhsplash.c(158): warning C4189: 'verstrsize': local variable
                           is initialized but not referenced
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/mhstatus.c(353): warning C4057: 'function':
                           'const unsigned char *' differs in indirection
                           to slightly different base types from 'const char *'
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/mhmsg.h(70)    : warning C4200: nonstandard extension used:
                           zero-sized array in struct/union
win/win32/NetHackW.c(181): warning C4456: declaration of 'buf' hides
                           previous local declaration
win/win32/NetHackW.c(90) : note: see declaration of 'buf'
win/win32/NetHackW.c(189): warning C4456: declaration of 'buf' hides
                           previous local declaration
win/win32/NetHackW.c(90) : note: see declaration of 'buf'
2021-01-29 13:00:00 -05:00
nhmall
f01b4f0bf0 a couple of old-style function declarations in Windows code 2021-01-27 21:52:55 -05:00
nhmall
f963c5aca7 switch source tree from k&r to c99 2021-01-26 21:06:16 -05:00
Bart House
a124114bce NetHackW: fix rendering of animations
Animations render by changing map state and calling delay.  When we delay,
we must ensure map windoow has been updated to show latest state before
we delay.
2021-01-23 12:04:16 -08:00
Bart House
d6b435a1d8 NetHackW: fix focus flashing when using far look
Changed when we update the map window back buffer.  We now defer all
back buffer renderig until mswin_map_update is called.  We update
the window only within the main message loop thus we should only
get fully coherent map state rendered prior to getting input.
2021-01-23 11:44:35 -08:00
Bart House
2b91931207 Fix delayed rendering of cursor with farlook in NetHackW. 2021-01-19 19:09:40 -08:00
nhmall
c9673b3d9e more window port interface adjustments
further adjustments to the window port interface to pass a pointer
to a glyph_info struct which describes not just the glyph number
itself, but also the ttychar, the color, the glyphflags, and the
symset index.

This affects two existing window port calls that get passed glyphs
and does the parameter consistently for both of them using the
glyph_info struct pointer:
	print_glyph()
	add_menu().

The recently added glyphmod parameter is now unnecessary and has been
removed.
2021-01-05 10:09:37 -05:00
nhmall
1d94e65e45 finish mapglyph() removal 2021-01-02 09:22:53 -05:00
nhmall
18116d4a7b update for 2021 2021-01-01 22:07:54 -05:00
nhmall
1c2c5dae1b remove vision tables from Windows and msdos builds 2020-12-28 22:07:00 -05:00
nhmall
0c3b9642e4 pmnames mons gender naming plus a window port interface change
add MALE, FEMALE, and gender-neutral names for individual monster species
to the mons array. The gender-neutral name (NEUTRAL) is mandatory, the
MALE and FEMALE versions are not.

replace code uses of the mname field of permonst with one of the three
potentially-available gender-specific names.

consolidate some separate mons entries that differed only by species into a
single mons entry (caveman, cavewoman and priest,priestess etc.)

consolidate several "* lord" and "* queen/* king" monst entries into
their single species, and allow both genders on some where it makes some
sense (there is probably more work and cleanup to come out of this at some
point, and the chosen gender-neutral name variations are not cast in stone
if someone has better suggestions).

related function or macro additions:
    pmname(pm, gender) to get the gender variation of the permonst name. It
    guards against monsters that haven't got anything except NEUTRAL naming
    and falls back to the NEUTRAL version if FEMALE and MALE versions are
    missing.

    Ugender to obtain the current hero gender.
    Mgender(mtmp) to obtain the gender of a monster

While the code can safely refer directly to pmnames[NEUTRAL] safely in the
code because it always exists, the other two (pmnames[MALE] and
pmnames[FEMALE] may not exist so use:
    pmname(ptr, gidx)
      where -ptr is a permonst *
            -gidx is an index into the pmnames array field of the
             permonst struct
pmname() checks for a valid index and checks for null-pointers for
pmnames[MALE] and pmnames[FEMALE], and will fall back to pmnames[NEUTRAL] if
the pointer requested if the requested variation is unavailable, or if the
gidx is out-of-range.

Allow code to specify makemon flags to request female or male (via MM_MALE
and MM_FEMALE flags respectively)to makedefs, since the species alone doesn't
distinguish male/female anymore. Specifying MM_MALE or MM_FEMALE won't
override the pm M2_MALE and M2_FEMALE flags on a mons[] entry.

male and female tiles have been added to win/share/monsters.txt.
The majority are duplicated placeholders except for those that were
separate mons entries before. Perhaps someone will contribute artwork in the
future to make the male and female variations visually distinguishable.

tilemapping via has the MALE tile indexes in the glyph2tile[]
array produced at build time. If a window port has information that the
FEMALE tile is required, it just has to increment the index returned
from the glyph2tile[] array by 1.

statues already preserved gender of the monster through STATUE_FEMALE
and STATUE_MALE, so ensure that pmnames takes that into consideration.

I expect some refinement will be required after broad play-testing puts it to
the test.

    consolidate caveman,cavewoman and priest,priestess monst.c entries etc

This commit will require a bump of editlevel in patchlevel.h because it alters
the index numbers of the monsters due to the consolidation of some. Those
index numbers are saved in some other structures, even though the mons[] array
itself is not part of the savefile.

Window Port Interface Change

Also add a parameter to print_glyph to convey additional information beyond
the glyph to the window ports. Every single window port was calling back to
mapglyph for the information anyway, so just included it in the interface and
produce the information right in the display core.

The mapglyph() function uses will be eliminated, although there are still some
in the code yet to be dealt with.

win32, tty, x11, Qt, msdos window ports have all had adjustments done to
utilize the new parameter instead of calling mapglyph, but some of those
window ports have not been thoroughly tested since the changes.

Interface change additional info:

    print_glyph(window, x, y, glyph, bkglyph, *glyphmod)
            -- Print the glyph at (x,y) on the given window.  Glyphs are
               integers at the interface, mapped to whatever the window-
               port wants (symbol, font, color, attributes, ...there's
               a 1-1 map between glyphs and distinct things on the map).
            -- bkglyph is a background glyph for potential use by some
               graphical or tiled environments to allow the depiction
               to fall against a background consistent with the grid
               around x,y. If bkglyph is NO_GLYPH, then the parameter
               should be ignored (do nothing with it).
                -- glyphmod provides extended information about the glyph
               that window ports can use to enhance the display in
               various ways.
                    unsigned int glyphmod[NUM_GLYPHMOD]
               where:
                    glyphmod[GM_TTYCHAR]  is the text characters associated
                                          with the original NetHack display.

                    glyphmod[GM_FLAGS]    are the special flags that denote
                                          additional information that window
                                          ports can use.

                    glyphmod[GM_COLOR] is the text character
                                       color associated with the original
                                       NetHack display.

Support for including the glyphmod info in the display glyph buffer
alongside the glyph itself was added and is the default operation.
That can be turned off by defining UNBUFFERED_GLYPHMOD at compile time.
With UNBUFFERED_GLYPHMOD operation, a call will be placed to map_glyphmod()
immediately prior to every print_glyph() call.
2020-12-26 11:23:23 -05:00
nhmall
fe3eb92411 win32: avoid game exit dialog lacking any explanation 2020-12-23 20:31:54 -05:00
nhmall
8c42d306f7 purge trampoli.h 2020-12-13 10:27:49 -05:00
nhmall
d008d6c995 use .Substring to limit maintenance to major Lua version releases only 2020-12-11 22:35:37 -05:00