Commit Graph

204 Commits

Author SHA1 Message Date
nhmall
b89e792873 Some Windows gcc fixes 2024-11-30 19:06:05 -05:00
nhmall
fa9210aa65 Windows: free more allocated memory before exit
This gets rid of the final leak complaint on Windows as of Nov 13, 2024
2024-11-13 13:48:50 -05: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
PatR
05cbbc7181 fix PR #1254 - avoid signed integer overflow
Pull request from mkuoppal:  avoid integer overflow when user types
digits and they're combined into a number by successively multiplying
intermediate value by 10 and adding new digit.  Needed to avoid
triggering undefined behavior if the value overflows the largest
signed integer (actually long int).

This is a much more general fix than the code in the pull request,
which imposed an arbitrary limit for one aspect of tty input.

I'm not convinced that integer.h was the right place to add the new
AppendLongDigit() macro.  I may not have caught all the places where
it is needed.  files.c accumulates a value from digits but uses
unsigned int, so overflow won't trigger undefined behavior (although
it presumably ends up with a different value than what was intended).
options.c and coloratt.c accumulate smaller integers and have a limit
on the number of digits they'll use, so can't overflow.

Fixes #1254
2024-06-09 14:17:14 -07:00
nhmall
15db874f71 CHANGE_COLOR palette option adjustments
It was too early to call the windowport change_color() routine
while processing the config file. The windowport was not yet
fully operational.

Now the palette option processing will just place the rgb
value into the appropriate ga.altpalette[CLR_MAX] entry.

init_sound_disp_gamewindows(void) [allmain.c] calls
change_palette() [coloratt.c] and it will call the windowport
change_color() function for each ga.altpalette[] entry that
has been set.

Notes:
The rgb values stored in ga.altpalette[] have the NH_ALTPALETTE bit set
so that the rgb value of 0 can be stored and be distinguishable from
a "not set" entry.

The NH_ALTPALETTE bit is cleared from the rgb value in change_palette()
prior to calling the windowport change_color() function.

The syntax for palette is colorname/r-g-b.
For example: palette:black/12-12-12

colorname must be one of the NH_BASIC_COLOR names or a suitable
alias for one of those 16 entries.

Some of the windowport CHANGE_COLOR functions had the wrong parameters,
perhaps due to bitrot. Those have been corrected to match the prototype.
2024-04-12 21:57:27 -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
nhmall
b6b9bb0f27 follow-up to curses windowcolors
Make sure the windowcolors option can be specified more than
once without a config file warning.

Make the struct holding the details a little more extendable.
2024-03-17 14:18:14 -04:00
RainRat
a3658f85ac fix typos 2024-02-28 20:15:56 -08:00
nhmall
b4f578495c more pointer style consistency 2024-02-20 13:04:32 -05:00
nhmall
0dfe92ac61 more italic support
There might be some follow-ups to this.
2024-01-29 08:40:05 -05:00
nhmall
3eb0fab317 Windows error checking and warnings 2023-12-27 14:56:03 -05:00
nhmall
a82a897da3 avoid ctrl_nhwindow-related impossible
Remove the impossible(), so that new functionality can be added
incrementally without requiring every window-port to be visited up front.
2023-11-16 21:00:59 -05:00
nhmall
bc2c2f5138 follow-up to correct syntax error in Windows build 2023-11-16 00:12:41 -05:00
nhmall
86067dcffd use ctrl_nhwindow() for menu prompt style
This implements the mechanics to use the ctrl_nhwindow() interface
capability to pass down a setting change from the core to the active
window port, without resorting to accessing a core global variable
from within the window port, and without altering the interface..

The passed setting is honored in the tty and curses window ports.

X11 and mswin receive and store the values, but no implementation
to change the menu prompt style is there yet.

Qt does not store the values or have an implementation.

The setting change is done in allmain.c immediately after
creating the WIN_INVEN window.
2023-11-16 00:10:06 -05:00
Pasi Kallinen
dd5ca5b058 Change menu_headings to accept color and attribute
Instead of just accepting an attribute, it's now possible to
use a color, or both color and attribute, for example:

OPTIONS=menu_headings:inverse
OPTIONS=menu_headings:red
OPTIONS=menu_headings:red&underline

Default is still just inverse.
This lets the player change the menu heading color without
needing to use menu colors for them.

Also makes it so the core uses NO_COLOR instead of 0, for all
the menu lines which don't have any prefedefined color.

Tested for tty, curses, x11, qt, and win32
2023-11-13 07:33:56 +02:00
nhmall
07ba3904fd window-ports should respect flags.silent setting
Like tty_nhbell() in termcap.c, window-ports really should
respect the flags.silent setting.
2023-03-24 12:23:19 -04: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
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
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
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
nhmall
4a8deefaa3 replace leading tabs in several more files 2022-05-30 12:38:22 -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
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
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
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
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
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
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
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
nhmall
f365bdd254 some mingw bits to move its gui variation closer to building and running 2020-06-11 12:26:44 -04:00
nhmall
68fdc3bbcb February 2020 options.c overhaul
combine boolean and compound options into a single allopt[] array for
processing in options.c.

move the definitions of the options into new include/optlist.h file which
uses a set of macros to define them appropriately.

during compile of options.c each option described in include/optlist.h:
   1. automatically results in a function prototype for an optfn called
      optfn_xxxx (xxxx is the option name).
   2. automatically results in an opt_xxxx enum value for referencing
      its index throughout options.c (xxxx is the option name).
   3. is used to initialize an element of the allopt[] array at index
      opt_xxxx (xxxx is the option name) based on the settings in the
      NHOPTB, NHOPTC, NHOPTP macros. Those macros only live during the
      compilation of include/optlist.h.

each optfn_xxxx() function can be called with a req id of: do_init, do_set,
get_val or do_handler.

req do_init is called from options_init, and if initialization or memory
allocation or other initialization for that particular option is needed,
it can be done in response to the init req.

req do_set is called from parseoptions() for each option it encounters
and the optfn_xxxx() function is expected to react and set the option
based on the string values that parseoptions() passes to it.

req get_val expects each optfn_xxxx() function to write the current
option value into the buffer it is passed.

req do_handler is called during doset() operations in response to player
selections most likely from the 'O' option-setting menu, but only if the
option is identified as having do_handler support in the allopts[]
'has_handler' boolean flag. Not every optfn_xxxx() does.

function special_handling() is eliminated. It's code has been redistributed
to individual handler functions for the option or purpose that they serve.

moved reglyph_darkroom() function from options.c to display.c
2020-02-26 00:24:37 -05:00
nhmall
d81c096ce6 window port interface change - add mbehavior flags to start_menu()
Provide a way to communicate additional behaviors and/or appearances
desired from NetHack window port menus.

This is foundation work for changes to follow at a future date.
2020-02-20 20:12:51 -05:00
nhmall
d50c3577e9 some more status condition follow-up
- Don't display 'Held' when swallowed.
- Don't display 'Held' when the hero is doing the holding; add a condition display
  entry "UHold" for that (the opt_in option is "holding")
- Allow resorting of the 'O' menu for status condition fields. Default is alphabetical, but you
  can sort by condition field ranking now.
2020-02-20 01:22:27 -05:00
nhmall
2da95e4dc0 eliminate the uses of the manually maintained BL_MASK_BITS
Use CONDITION_SIZE which does not require manual updating.

Also attempts to adjust win32 graphics window port for
the new fields.

That port has its own field names and should be adjusted
to using the following which are declared extern in
include/botl.h.

   struct conditions[CONDITION_COUNT];
   int cond_idx[CONDITION_COUNT];

The former contains the fields that were port-specifically
added to the win32 graphical port and more, plus it is
centrally maintained and currently utilized by tty and curses.

The cond_idx[] array contains the ranked ordering of the
condition fields from highest ranking to lowest. Instead
of indexing like this:
	int i;
	for (i = 0; i < CONDITION_COUNT; ++i) {
	    ...conditons[i].enabled;
 	    ...condtions[i].text[0];
	}

you can use the ranked ordering like this:
	int i, ci;
	for (i = 0; i < CONDITION_COUNT; ++i) {
	    ci = cond_idx[i];
	    ...conditons[ci].enabled;
 	    ...condtions[ci].text[0];
	}
2020-02-08 20:40:38 -05:00