Commit Graph

2387 Commits

Author SHA1 Message Date
PatR
8affbf5a24 options parsing madness
I should have reenabled curses before committing an earlier change;
it broke compile.

Make all optfn_FOO() be static in options.c;
fix newly added prototype for optfn_cursesgraphics();
fix conditionals for optfn_palette(), both prototype and function.

Also, add missing prototype for a sound routine.
2021-01-23 15:42:00 -08:00
PatR
ab74ed2c20 SELECTSAVED handling
By default, enable the SELECTSAVED option for everyone instead
of just for Windows or Qt.  And make Qt obey the 'selectsaved'
run-time option.

It can be disabled in config.h if necessary.
2021-01-23 15:02:11 -08:00
nhmall
093c53bead fix missing prototype warning for Qt SELECTSAVED
For whatever reason, Qt relies on late #define of SELECTSAVED
inside files.c.

The prototype in extern.h is therefore not picked up with
as a result of #include "hack.h"

Options were:
1. remove the conditional #if defined(SELECTSAVED) around the
   prototype in extern.h entirely
2. Move the forced #define of SELECTSAVED above the #include "hack.h"
3. Alter the conditional in extern.h to also include the condition for
   the forced #define of SELECTSAVED inside files.c

This goes with option #3.
2021-01-23 09:37:47 -05:00
Dean Luick
16ba1a583a Update nhUse
There is no longer any compiler reason to disable nhUse - remove
nhUse's conditional definition.

Update the nhUse definition to "use" a variable without it needing
to be an integer.

This change removes some gcc compiler unused variable and parameter
warnings.
2021-01-20 22:18:34 -06:00
PatR
cb407eeb61 yet more obj->spe documentation (lamps, candles)
Another mystery.  Candles and oil lamps have obj->spe set to 1
but that isn't used by begin_burn() and such so I don't know why.

Magic lamp has spe set to 1 to indicate that there is a djinni
inside, but letting the djinni out converts it into an oil lamp.
I don't know if there is any case where it might actually be 0.
(Wishing yields an oil lamp rather than an empty magic lamp so
that isn't it.  Cancellation magic doesn't affect it either.)
2021-01-19 15:07:58 -08:00
Dean Luick
8143d55d76 Create and use a snprintf wrapper in the core code
Use a wrapper around snprintf to consilidate all use, add
error checking, and remove gcc 9 warnings about not checking
the result.

Replace the prevous use of snprintf added to weapon.c with the
new scheme.

Update a second spot that has a gcc sprintf warning.  While
there, simplify the code.
2021-01-15 11:33:47 -06:00
PatR
85d3aa4a97 obj->spe usage again
uball->spe used to be used during restore way back in 2.3e.
There hasn't been any any point in setting it when starting
punishment and clearing it when ending punishment for decades
so get rid of that.

Nearly as ancient--but not quite--back in 3.10 patchlevel N,
obj->spe was set to -1 when the Amulet of Yendor was saved in
a bones file.  That was to flag it as fake, before the cheap
plastic imitation got added as a separate object.

So obj->spe isn't "special for uball and amulet" any more.
2021-01-08 15:45:04 -08:00
PatR
9dee1fb521 \#include "fnamesiz.h"
The inclusion shouldn't really come before *conf.h because the
things it sets up could depend on those.  This is better, but
having Amiga 90% dead and 10% comatose seems to be more trouble
that it's worth.
2021-01-08 14:59:36 -08:00
PatR
129ff12245 'make depend' fix
The gone but still referenced state of amiconf.h broke 'make depend'.
Fixing that turns it into a comment in the generated dependencies
but that ran into a problem with it being followed by fnamesiz.h
instead of being last in the list containing it.  So in addition to
the depend fix, move #include "fnamesiz.h" from config.h to global.h
in order to have it come before amiconf.h.
2021-01-08 13:33:27 -08:00
PatR
d625fca828 obj.h - expand documentation of obj->spe uses
Started out adding spe==2 for eggs but ended up changing other
things too.

FIXME?  The line "special for uball and amulet" baffles me:

    uball->spe is set to 1 during punishment (with an ambiguous
comment "special ball (see save)"), and back to 0 afterwards, but
otherwise seems to be unused.

    "and amulet" is ambiguous; it should either be "and the Amulet"
or "and amulets".  I assume it probably referred to the former but
it doesn't seem to be used for either kind as far as I can tell.
2021-01-07 14:02:52 -08:00
copperwater
0b638592a4 Refactor getobj() to use callbacks on candidate objects
This replaces the arcane system previously used by getobj where the
caller would pass in a "string" whose characters were object class
numbers, with the first up to four characters being special constants
that effectively acted as flags and had to be in a certain order.
Because there are many places where getobj must behave more granularly
than just object class filtering, this was supplemented by over a
hundred lines enumerating all these special cases and "ugly checks", as
well as other ugly code spread around in getobj callers that formatted
the "string".

Now, getobj callers pass in a callback which will return one of five
possible values for any given object in the player's inventory. The
logic of determining the eligibility of a given object is handled in the
caller, which greatly simplifies the code and makes it clearer to read.
Particularly since there's no real need to cram everything into one if
statement.

This is related to pull request #77 by FIQ; it's largely a
reimplementation of its callbacks system, without doing a bigger than
necessary refactor of getobj or adding the ability to select a
floor/trap/dungeon feature with getobj. Differences in implementation
are mostly minor:
- using enum constants for returns instead of magic numbers
- 5 possible return values for callbacks instead of 3, due to trying to
  make it behave exactly as it did previously. PR #77 would sometimes
  outright exclude objects because it lacked semantics for invalid
  objects that should be selectable anyway, or give slightly different
  messages.
- passing a bitmask of flags to getobj rather than booleans (easier to
  add more flags later - such as FIQ's "allow floor features" flag, if
  that becomes desirable)
- renaming some of getobj's variables to clearer versions
- naming all callbacks consistently with "_ok"
- generally more comments explaining things

The callbacks use the same logic from getobj_obj_exclude,
getobj_obj_exclude_too and getobj_obj_acceptable_unlisted (and in a few
cases, from special cases still within getobj). In a number of them, I
added comments suggesting possible further refinements to what is and
isn't eligible (e.g. should a bullwhip really be presented as a
candidate for readying a thrown weapon?)

This also removed ALLOW_COUNT and ALLOW_NONE, relics of the old system,
and moved ALLOW_ALL's definition into detect.c which is the only place
it's used now (unrelated to getobj). The ALLOW_ALL functionality still
exists as the GETOBJ_PROMPT flag, because its main use is to force
getobj to prompt for input even if nothing is valid.

I did not refactor ggetobj() as part of this change.
2021-01-07 11:06:58 -05:00
Pasi Kallinen
bc8dd92621 Monster ranged attacks and staying away from hero
Move the check for monsters that want to stay away from hero
due to having a ranged attack into a separate function.

Add monsters with polearms and breath attacks to it.
Monsters with breath attacks stay away only if they haven't
used their breath recently, or if they are injured.
2021-01-06 14:38:39 +02:00
nhmall
2d1cf9591f place a reminder in glyph_info comment 2021-01-05 11:00:07 -05:00
nhmall
4cbf95b350 typo in comments 2021-01-05 10:44:19 -05: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
Dean Luick
3ffd330c31 Remove vision tables from makedefs
Update makdefs source and its man page.

Remove all mentions of the vision table files from:
o .gitattributes
o .gitignore
o Files
o Cross-compiling

Add a brief note in the fixes file.
2021-01-03 13:37:25 -06: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
Michael Meyer
47884d63ac Merge branch 'NetHack-3.7' into fix322 2020-12-30 14:05:16 -05:00
Dean Luick
a4e7646f4c Remove src and unix VISION_TABLES
Remove all references to the unused vision tables in the main source
and unix build.  Leave makedefs able to generate the vision tables.
makdefs will be cleaned up in a different commit, once all ports
are clear of dependencies.
2020-12-29 20:38:37 -06:00
nhmall
f30bb8aaa4 another monster gender name handling tweak
ensure that monster female name variation ends up as a female during ^G

arbitrate when there is a conflict between gender term (male or female) and
a gender-tied monster name (cavewoman) during ^G; gender term wins
2020-12-28 14:02:22 -05:00
nhmall
fd13f2a2f2 monster gender-related follow-ups
remove unintentionally left M2_MALE flag on dwarf lord/lady/leader

provide a way to verify gender information relayed from the core
in debug mode on tty via #wizmgender debugging extended command
2020-12-27 10:45:13 -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
PatR
0ec355bdb4 fix github issue #426 - binding special commands
Binding 'repeat' (DOAGAIN, or redo) to a different key than ^A
didn't work as intended because the code that used it was
checking for DOAGAIN (a key value from config.h) instead of
g.Cmd.spkeys[NHKF_DOAGAIN] (the key currently bound to repeat).

Contrary to the github issue, re-bound prefix keys worked ok for
me if followed by a direction.  However, they behaved strangely
if followed by anything else.  If the keystroke was stolen from
some other command and that command hadn't been bound to another
key, following the prefix with a non-direction could end up
executing the command that used to own the key.  For example,
 BIND=d:nopickup
to use 'd' to move without auto-pickup would work if you used
d<direction> but if you used d<something-else> if would execute
the drop command.

The NHKF_REQMENU prefix could be bound to some key other than
'm' but it only worked as intended if the new key was a movement
prefix.

This also makes DOAGAIN be unconditional.  If it is deleted or
commented out in config.h, the default binding will be '\000' so
unusable (freeing up ^A for something), but still be available
to be bound to some key (perhaps even ^A).

This also includes an unrelated change to mdlib.c.  The comments
added to config.h will force a full rebuild.  Changing mdlib.c
now rather than separately will avoid forcing that twice.

Fixes #426
2020-12-25 13:57:05 -08:00
PatR
1971adbe45 feedback for monsters' health
For farlook description of a monster, and for "killed by monster"
when game ends, include an indication of the monster's health:
  uninjured          full health
  barely wounded     95%+ health
  slightly wounded   80%+
  wounded            20%..80%
  heavily wounded    20%-
  nearly deceased     5%-, or 1HP for really weak monsters
These descriptions and the criteria for choosing which one will
probably need some tuning.

Messages referring to the monster, including combat, do not
include the extra verbosity.
2020-12-23 10:43:58 -08:00
PatR
430edb5a74 option help
I stated out by changing dat/opthelp to stop shouting the boolean
defaults: [TRUE] -> [True], [FALSE] -> [False].  I ended up doing
a partical reconcilliation between ?g (dynamic list of options)
and ?h (dat/opthelp).  There were several inapplicable options in
the dynamic list, so this changes option_help() to avoid those.

I barely glanced at the compound options so they may not sync up.
2020-12-21 19:02:11 -08:00
PatR
ae23330adc AC and obj->spe limits: +127/-128 -> +99/-99
Cap overall AC at -99 instead of -128.  Put the same limit of 99
on enchantment and charge count of individual objects.

^X now reports if/when AC has reached its limit since players
could see that reaching that limit and then enchanting worn items
will change the worn items but not the total.  (Same thing would
have happened with -128, just without any explanation and less
likely to accomplish.)

Won't affect normal play for any reasonable definition of normal.
2020-12-21 14:09:17 -08:00
Pasi Kallinen
957990c14d More futureproofing hypotheticals
If you set COLNO larger than BUFSZ, few places cause a buffer overrun.
Add a new buffer size definition, COLBUFSZ, which is the larger of
COLNO and BUFSZ, used in places that care about a screen-wide string.
2020-12-20 12:32:29 +02:00
PatR
4cf6727b4e re-implement pull req #334 - sorting discoveries
The pull request changed \ and ` output to unconditionally show
discoveries in alphabetical order.  That's nearly useless except
when looking at prediscovered weapons and armor that fighter
types start out knowing.

This allows the player to choose sorting order via the new
'sortdiscoveries' option.  In addition to setting it via
config file or 'O', it can be set via 'm' prefix for \ and `.
Choices are:
 o - sort by class, by order of discovery in class (default);
 s - sort by 'sortloot' classification which groups sub-class
     items (so all helmets before any other armor, then all
     gloves, then boots, and so on); within each sub-class, or
     whole class for classes which don't subdivide so usefully,
     partly-discovered types (where a name has been assigned)
     come before fully ID'd types;
 c - sort by class, alphabetically within class;
 a - sort alphabetically across all classes.

Turned out to be a large amount of work for fairly little gain,
although I suspect that 'sortdiscoveries:s' will eventually be
more popular than the default.

Invalidates existing save files so that current sort setting can
persist across save/restore cycles.

Closes #334
2020-12-19 17:45:49 -08:00
PatR
aa7f01eed7 github pull request #417 - disclosing apron text
Adopt the patch to show the writing on any alchemy smocks in
hero's inventory during end of game disclosure.

I also added one more saying among the choices for alchemy
smock/apron.  It's based on a T-shirt descibed in a movie.
(I remember the description of the text but I don't remember
noticing anybody wearing the T-shirt that lead to that.)
Since so many of the smock quotes are about cooking, it seems
better to add it as an alchemy quote instead of just another
T-shirt where there'd be no context to explain it.

Closes #417
2020-12-14 03:30:58 -08:00
nhmall
8c42d306f7 purge trampoli.h 2020-12-13 10:27:49 -05:00
Pasi Kallinen
4729062846 Make Death revive faster
Death will revive faster than the other riders.
Make all the riders revive after 67 turns, instead of 500.
There was practically a zero chance a rider would revive at 500,
so keep it somewhat sensible.
2020-12-13 12:28:45 +02:00
Pasi Kallinen
ea93c17fa7 Monsters can revive corpses on floor with undead turning
... but only if the corpse is in direct line from the monster to hero
2020-12-11 19:49:25 +02:00
PatR
fd5ef1ecaa more key bindings
number_pad==1 adds
 '5' => 'G'
 M-5 => 'g'
 '0' => 'i'
number_pad==2 swaps 5 and M-5 and adds M-0
 '5' => 'g'
 M-5 => 'G'
 '0' => 'i'
 M-0 => 'I'

M-5 and M-0 were missing from the bound key handling; they still
used hardcoded digits even though the actions for plain 5 and
plain 0 can be bound to other keys these days.  This implements
the M-5 variation as NHKF_RUSH2.  Changing numpad from 1 to 2
or vice versa will swap the NHKF_RUN2 and NHKF_RUSH2 actions
regardless of what keys they're assigned to.  I haven't done
anything for unimplemented NHKF_DOINV2 though (and am not
planning to in case someone else wants to jump in...).

This also fixes the description of the 'I' command.  The extended
command name for that still misleadingly refers to "type" rather
than "class" though.
2020-12-10 15:06:26 -08:00
PatR
e1406a8c08 txt2key() - parsing key binding specifications
While testing some addtional ?i (list of key assignments)
changes, I wanted to give every key a binding.  When I tried
BIND=M-^A:exploremode
the text to key conversion didn't like that.  This adds support
for M-^x and M-C-x plus variations where dashes are omitted.

This adds support for ^? even though that isn't really a
control character.  I bound #terrain to it and surprising--to
me at least--the <delete> key worked to invoke that command.

Also changes 'char txt2key(...)' to be 'uchar txt2key(...)'.
2020-12-09 16:52:54 -08:00
PatR
9f79ad56d9 NOSUSPEND
Provide a hook to inhibit unixconf.h from defining SUSPEND
without the need to modify it:  #define NOSUSPEND in config.h
or add -DNOSUSPEND to CFLAGS.  Similar to long-standing NOSHELL
for inhibiting SHELL.
2020-12-08 12:58:36 -08:00
Pasi Kallinen
13359648dd Remove duplicate wallify_map code 2020-12-06 18:36:37 +02:00
Pasi Kallinen
0462a2088c Increment EDITLEVEL
Forgot to increment EDITLEVEL when I did the stairs change,
and again after fixing the Oracle bones stairs. Lets do it now.
2020-12-05 19:38:20 +02:00
Pasi Kallinen
b797baba7a Make return values use defines 2020-12-04 09:30:21 +02:00
Pasi Kallinen
3ef3b425ad Unify the ad type switches 2020-12-04 09:30:21 +02:00
Pasi Kallinen
88e333a3a8 Unify ad_ssex 2020-12-04 09:30:21 +02:00
Pasi Kallinen
1696019361 Unify ad_sedu 2020-12-04 09:30:21 +02:00
Pasi Kallinen
376593dad5 Unify ad_dise 2020-12-04 09:30:21 +02:00
Pasi Kallinen
4118a7ea44 Unify ad_samu 2020-12-04 09:30:21 +02:00
Pasi Kallinen
d679d3a029 Unify ad_dgst 2020-12-04 09:30:20 +02:00
Pasi Kallinen
e777bd9670 Unify ad_legs 2020-12-04 09:30:20 +02:00
Pasi Kallinen
337e7da049 Unify ad_stun 2020-12-04 09:30:19 +02:00
Pasi Kallinen
12ee144936 Unify ad_heal 2020-12-04 09:30:19 +02:00
Pasi Kallinen
4901c8027c Unify ad_were 2020-12-04 09:30:19 +02:00
Pasi Kallinen
a6a676f720 Unify ad_ston 2020-12-04 09:30:19 +02:00