Commit Graph

40 Commits

Author SHA1 Message Date
PatR
1df88e4c65 fix #H3820 - vault guard's "I repeat" message
Reported seven and a half years ago:  if you are in a vault but not
carrying any gold and the guard arrives, you're told "Follow me."
Then if you pick up gold while the guard is still in the wall breach
rather than out in the corridor, you would be told "I repeat, drop
that gold and follow me!"  "Repeat" refers to the follow part but
sounds as if it refers to the drop-gold part which isn't actually
being repeated.  Keep track of whether the guard has issued a drop
gold demand and use that to vary the wording of subsequent "I repeat"
message.

Modifies monst->mextra->egd so save and bones files are invalidated.
2022-09-09 11:45:30 -07: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
PatR
5fbe1de2a7 hero_seq
'moves' is actually turns and there hasn't been any straightforward
way to track actual hero moves.  Add hero_seq for that.  It isn't a
counter but is distinct each time the hero makes a move.  I wanted
it for curses ^P support but so far use it for checking stethoscope
usage and for shopkeeper behavior when items in a shop are broken by
the hero.

Increment EDITLEVEL due to change in save file contents.
2021-12-26 00:16:55 -08:00
PatR
d9bbad8e6e fix github issue #606 - shop wall repair
triggering an impossible warning about "wall_angle: unknown" due
to the known conflict between door state and wall info which both
overlay the flags field for map locations.

Reported and diagnosed by vultur-cadens:  if a shop's wall was dug
open, followed by use of locking magic to plug the gap with a door,
and then unlocking that door, the D_CLOSED door flag was left as
invalid wall_info when shop damage was repaired.  Map re-display
complained.  Leaving the door locked or opening it after unlocking
did not result in any complaint because the values for those door
states do not conflict with wall angle values.

The problem was reproducible and is now fixed by adding an extra
field to the shop damage structure.  A similar change has been
made to the vault guard's 'fake corridor' structure but I have no
test case for that so don't know whether it makes any difference.
At least it doesn't seem to have broken anything.

Existing save and bones files are invalidated by the fixes.

Fixes #606
2021-10-15 15:43:23 -07:00
PatR
519f00e3c4 ^X feedback when held by unseen monster
When swallowed and blind, the swallowing monster is described
accurately, but being held rather than swallowed describes the
monster as "it".  That's normal, but the status feedback section
of ^X output lists
|You are held by it.
which looks pretty weird.  Change that to be
|You are held by an unseen creature.
2021-04-13 14:50:12 -07:00
nhmall
f963c5aca7 switch source tree from k&r to c99 2021-01-26 21:06:16 -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
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
nhmall
e524fc4fc8 clarify what was meant by "special" in a comment 2020-07-31 10:57:20 -04:00
nhmall
8b2750ab60 lower the code upkeep for mextra and oextra pointer additions 2020-07-31 09:42:17 -04:00
nhmall
6b7979fa72 add note to zero out new mextra and oextra fields
Closes #375
2020-07-31 08:31:09 -04:00
copperwater
922321b251 Add instructions to zero mextra struct pointer in mextra documentation
It doesn't mention anywhere that newmextra() is responsible for
initializing struct mextra with null pointers to the various
sub-structs. So, when one follows the instructions and doesn't know or
remember to do this, they'll get segfaults when something tries to read
the uninitialized pointer to their new struct.
2020-07-30 23:07:30 -04:00
nhmall
5d5d8069d4 Merge branch 'NetHack-3.6' 2019-11-27 01:27:11 -05:00
PatR
3130676077 alignment of mimicked or polymorphed altars
A reddit thread about an unaligned altar in an aligned temple was
a tipoff that mimics posing as altars didn't have any particular
alignment.  The look-at code was misusing an operloaded field of the
underlying terrain.  Pick an alignment at random when taking on the
appearance of an altar, store it in the mimic's mon->mextra->mcorpsenm
field, and have look-at use that.

Also, dropping a ring of polymorph into a sink can transform it, and
one possible outcome is an altar.  In this case, the alignment is
part of the location's topology, but code setting that up was using
Align2amask(rn2(foo)).  That's a macro which evaluates its argument
more than once.  The first evaluation was effectively a no-op.  If
the second evaluation picked lawful then the result was lawful as
intended.  But if the second picked non-lawful and the third picked
lawful, the result would end up as none-of-the-above (a value of 3
when it needs to be a single-bit mask of 1, 2, or 4).
2019-11-25 15:01:40 -08:00
nhmall
8df0a63938 Merge branch 'NetHack-3.6' 2019-10-20 09:51:35 -04:00
PatR
bf7e955645 mimicking slime molds
Mimic-as-slime_mold needs to keep track of the fruit index the same
way that mimic-as-corpse keeps track of corpse's monster type.  The
mimic description was changing (for '/' and ';' feedback) whenever
the player assiged a new fruit name.

That wasn't noticeable when applying a stethoscope because
mimic-as-slime_mold always yielded "that fruit is really a mimic".
Change it to report the fruit's type instead of generic "fruit".
2019-10-19 17:38:27 -07:00
nhmall
98acd55fcc Merge branch 'NetHack-3.6.2' 2019-01-14 18:16:19 -05:00
PatR
64821f4ad5 more enums with explicit values
As before, it's an aid to finding things if you're looking for something
by its numeric value.
2019-01-13 17:19:39 -08:00
Bart House
be5cdcf77a killer, level and rooms move to instance globals. 2018-12-24 19:50:08 -08:00
keni
d8c49ec9d1 Add updated copyright lines, part 1. 2018-04-25 15:00:13 -04:00
Pasi Kallinen
552647fb36 Use more enums
We're already using enums, so convert some already existing defines.
2016-10-10 16:18:20 +03:00
PatR
ca02008d03 fix #H4219 - renegade Angel banter
Lawful angels deliver taunt messages from a pool of messages which
might mention the lawful god; demons and non-lawful angels draw from
another pool which doesn't mention any gods.  Since it is odd for a
'renegade' angel to claim to be operating for its god, choose taunts
from the other pool of messages for renegade lawful angels.

Not related:  some formatting fixups in include/mextra.h.
2016-02-28 18:47:01 -08:00
nhmall
c4d45d6960 make some mextra guard macros available
Changes to be committed:
	modified:   doc/fixes36.1
	modified:   include/mextra.h
2016-01-03 10:48:47 -05:00
Pasi Kallinen
f056bdb429 Comment typofixes, pt 2 2015-10-17 13:15:46 +03:00
Sean Hunt
1c081b1647 Remove stale version control lines. 2015-05-25 09:21:31 +09:00
Sean Hunt
8b57d96fd2 Reformat .h files.
I did my best to exempt some of the bigger aligned blocks from the reformatting
using the /* clang-format off */ and /* clang-format on */ tags. Probably some
that shouldn't have been formatted were anyway; if you encounter them, please
fix.

The clang-format tags were left in on the basis that it's much easier to prune
those out later than to put them back in, and it means that, modulo my custom
version of clang-format, I should be able to run clang-format on the source tree
again without changing anything, now that Pat has fixed the VA_DECL issues.
2015-05-25 09:21:15 +09:00
karnov
2a907f894e Version number increment 2015-05-06 22:04:27 -04:00
keni
03140969ee Bulk recovery of file CVS headers and addition of NHDT- headers. 2015-02-26 09:19:03 -05:00
nethack.rankin
8df1e4d6cb fix #2253 - shk dismissing kops from other level (trunk only)
From a bug report, if you rob a shop, let the
angry shopkeeper catch up with you outside his shop, escape to another
level with adjacent shk tagging along, then pacify the shk by paying him
off, he will dismiss kops on the present level and return to his shop
but when you return to his shop level there'll still be kops chasing you
there.  This fix adds an extra flag to the eshk structure so that kops
can be dismissed a second time when the shk migrates back to shop level.
The first dismisal (on the "wrong" level) still takes place in case any
kops are around.  Neither dismissal actually occurs if there happens to
be another angry shk present on the level where dismissal is being done.
2011-04-15 01:55:42 +00:00
keni
df20791e59 Add RCS version lines 2009-05-06 10:45:32 +00:00
nethack.rankin
71219bf093 mimic statues & 2009 startup banner (trunk only)
A mimic posing as a statue was displayed as a tengu statue (and
recognizeable as such now that statues are displayed as the corresponding
monster rather than rock-class back tick), but the lookat code described
it as a giant ant statue (since there was no obj->corpsenm available to
indicate the monster type, it defaulted to 0).  This adds monst->mextra
field `mcorpsenm' so that mimics have a place to remember what sort of
statue or corpse they are mimicking.  And it picks a random monster type
when they take such forms so that the old tengu hack becomes irrelevant.

     newmextra() and newoextra() initialized pointers via memset(...,0)
which is not portable; switch to explicit assignments.  The wizard mode
code to display memory used for monsters and objects added in amounts
for the miscellaneous things pointed to by monst->mextra and obj->oextra
structs but didn't include memory for those structs themselves; add it.
Simplify monster save/restore slightly; there's no need for extra zeroes
to represent monst->mextra->X sizes when monst->mextra is null.

     Update the startup banner for 2009.  I should have done this with a
separate patch but I'm taking a shortcut.  :-]
2009-01-31 08:03:41 +00:00
nethack.allison
f55210be79 code change - oextra
move oattached and oname and other things that vary
the size of the obj structure into a separate
non-adjacent oextra structure, similar to what has
already been done for mextra. The obj structure
itself becomes a fixed size.

New macros:

#define ONAME(o)	((o)->oextra->oname)
#define OMID(o)		((o)->oextra->omid)
#define OMONST(o)	((o)->oextra->omonst)
#define OLONG(o)	((o)->oextra->olong)
#define OMAILCMD(o)	((o)->oextra->omailcmd)

#define has_oname(o)	((o)->oextra && ONAME(o))
#define has_omid(o)	((o)->oextra && OMID(o))
#define has_omonst(o)	((o)->oextra && OMONST(o))
#define has_olong(o)	((o)->oextra && OLONG(o))
#define has_omailcmd(o)	((o)->oextra && OMAILCMD(o))

changed macros:
has_name(mon) becomes has_mname(mon)  to correspond.

The CVS repository was tagged with
	NETHACK_PRE_OEXTRA
before commiting these, and
tagged with
	NETHACK_POST_OEXTRA
immediately after. The diff
between those two tags is this oextra patch.

The associated mail daemon changes to use an oextra
structure instead of a hidden command located in the
name after the terminating NUL, have not been tried
or tested.
2006-04-14 16:23:56 +00:00
nethack.allison
ecb98e019c eating gold in front of the vault guard (trunk only)
<email deleted> wrote:
> Eating gold in a vault (or polymorphing a pile of gold into 1 gold piece)
> doesn't anger the guard.

This addresses the eating part of that report, but the hero
has to get caught doing it.
2006-03-26 05:23:46 +00:00
nethack.allison
645d1b9921 finish a trailing sentence in a comment 2006-02-19 22:44:06 +00:00
nethack.rankin
0a52d1879f reduce temple verbosity (trunk only)
Cut down on the excessive verbosity generated when entering a temple.
The first time you enter a particular temple (or more accurately, the
temple attended by a particular priest), you still get the three message
sequence
  The <priest of foo> intones:
  Pilgrim, you enter a sacred place!
  You have a strange forbidding feeling...
or
  You experience a strange sense of peace.
except that the last one doesn't say "strange" any more.  On subsequent
visits to the same temple, you usually won't get the first introductory
message any more, often won't get the second entry one, and sometimes
won't even get the final one, depending upon how much time has elapsed
since the previous entry.  The old verbosity could really be infuriating
when attempting to lug corpses to the altar before they spoil.  Even
though the messages don't affect the passage of time, it always felt as
if they were slowing you down.  And even when you weren't in any hurry,
it required at least one and often 2 or even 3 responses to --More--
depending upon the length of the deity's name and whether some other
message was also delivered on the same turn (fairly common in minetown).

     Saving and restoring, or leaving the level and returning, resets
the priest's memory of when the messages were last given, so the next
entry after that behaves similar to the very first.  This was initially
intended for cleanup prior to saving bones data, but it seemed reasonable
to have it apply to the current game too.  Unattended temples now also
have a 25% chance of not giving any message when entering.  That one is
random rather than based on the passage of time since last entry; there's
no priest available to track the latter data.
2006-01-28 06:46:19 +00:00
nethack.rankin
3b127d31d9 mextra.h comments (trunk only)
Add an introductory comment for each type of extension.  Also move
ANGRY/NOTANGRY shopkeeper macros from old eshk.h out of the common header
and into shk.c so that their use doesn't end up spreading into other code.

     Not fixed:  entry #9 in the block comment at the top is truncated
mid-sentence.
2006-01-12 06:06:33 +00:00
nethack.allison
ce434a8cb7 formatting bit 2006-01-08 16:21:10 +00:00
nethack.allison
0bdb1fba28 mextra docs 2006-01-07 17:36:24 +00:00
nethack.allison
aea3c50163 mextra follow up bit 2
<Someone> noticed the leftover zeromextra, this removes it.

Using memset() on a possibly failed mextra allocation was inapprorpriate,
so replace the newmextra() macro with a function.

Prevent a crash in christen_monst() if mextra was not initialized.
2006-01-06 22:16:46 +00:00
nethack.allison
54ec47807a mextra.h 2006-01-06 20:52:04 +00:00