Commit Graph

2881 Commits

Author SHA1 Message Date
nhmall
817b4686ce Revert "move struct propname to a header file"
This reverts commit 402b2bf5c8.
2022-09-06 08:01:50 -04:00
nhmall
402b2bf5c8 move struct propname to a header file
In doing so, avoid repeated layout declaration in cmd.c
2022-09-06 07:22:55 -04:00
Patric Mueller
8bf5654eed tty and curses: support italic as text attribute 2022-09-04 22:33:25 +02:00
Michael Meyer
51d568319b Use const char * for read_simplemail 'mbox' param
Nothing about read_simplemail is incompatible with using const, and the
lack of const required some contortions (copying ADMIN_SERVER_MSG to
another buffer with nonconst() to prevent a compiler warning).

This was the last place nonconst() was used, so I removed it.
2022-09-01 17:02:30 +03:00
copperwater
f71bff3285 Standardize all core and obj functions with relative coords
This is a large iteration on a previous implementation of making
nh.getmap() parse its coordinates as relative to the last defined map or
room rather than absolute to the entire level. Now, everything in the
nh.* and obj.* functions interprets coords as relative rather than
absolute. (By default; if no map or room has been defined, or if the lua
code is executing after level creation is done, they will interpret the
coordinates as absolute).

The general motivation is basically the same - routines that use
absolute coordinates are difficult to use in level creation routines,
because then the designer has to remember to convert the relative
coordinate to an absolute one (and that was impossible before
nh.abscoord was added, particularly in themed rooms). And once
nh.getmap() takes relative coordinates, it would be very strange to have
all the other functions (setting timers, burying objects, etc) remain
with absolute ones.

In a couple places, code is changed to account for coordinates that are
relative to a *room* (which uses g.coder->croom->[lx,ly] as an offset,
instead of relative to a *map*, which uses [xstart,ystart].
Specifically, selection.iterate did not account for this, and without
this the ice themed room timer was not being started in the proper
place.

All tests are updated to respect the new behavior. Most of the modified
functions are not actually used anywhere in level files; the one
exception is starting a timer in a themed room, and that has been
adjusted.

Documentation updated as well to clarify when various things are tossing
around relative and absolute coordinates, both in comments and in
lua.adoc.
2022-08-31 18:26:05 +03:00
PatR
d4f0450afe fix the tty message spacing anomaly for messages \
delivered across level change checkpointing

Reported by entrez.  Simplest test case:  give level 1 a short
annotatation, level teleport to level 2, and level teleport back to
level 1.  The message window will show

|You materialize on another level.  You remember this level as <note>.

but ^P message history will show

|You materialize on another level.
|  You remember this level as <note>.

Spaces inserted to separate two messages that fit together on the
top line become part of the second message when saving a checkpoint
during level change flushes the top line into message history.

Change insurance checkpointing to record the full message history
without flushing the current top line so that toggling 'checkpoint'
doesn't affect what shows up on the screen or in message recall.
2022-08-30 15:01:49 -07:00
PatR
11c8d5cd5e Unix: command line --windowtype:foo fix
initoptions(), including initoptions_finish(), was running to
completion with the default window system before windowtype from the
command was parsed and activated.  When the default window system
is tty without MS-DOS the map type gets set to ascii; command line
--windowtype:X11 doesn't switch it back to the X11 default of tiled.

So,
| NETHACKOPTIONS=windowtype:X11 nethack
ran nethack in tiles mode but
| nethack --windowtype:X11
ran it in text mode (assuming .nethackrc left tiles vs text with the
default setting).

I think this fix is quite iffy but it seems to work as intended....
It reclassifies '--windowtype' as an "early option" in unixmain.c,
and the options.c code ultimately processes it twice.
2022-08-28 00:09:50 -07:00
nhmall
c92a3b0653 fix glyph_to_cmap() odd macro results
Some discrepencies between glyph_is_cmap and glyph_to_cmap
arose after b14b830b because the change resulted in
glyph_is_cmap matching on zap beams which weren't accounted
for in the glyph_to_cmap macro. It is unlikely that
glyph_to_cmap will ever be used on such a glyph, but at least
have glyph_to_cmap return a sane value rather than drop through
to the last-resort value (currently NO_GLYPH) which is far
outside the range of the defsyms[] array indices.
2022-08-27 08:23:24 -04:00
nhmall
d5abf903fa Revert "fix some (not all) glyph_to_cmap odd ret"
This reverts commit bb4474bbaf.
2022-08-26 15:06:59 -04:00
nhmall
bb4474bbaf fix some (not all) glyph_to_cmap odd returns
I think some of these discrepencies between glyph_is_cmap and
glyph_to_cmap started after b14b830b because the additional
ranges added by that didn't have a corresponding return in
glyph_to_cmap.
2022-08-26 14:08:03 -04:00
Pasi Kallinen
5e9ed7a290 Some selection optimizations
- Add bounds, so that we don't process any locations outside
  as those locations are known to be unset
- The bounds are only recalculated if needed
- Replace instances of selection_not where we actually want
  a new selection with all locations set
2022-08-26 12:43:40 +03:00
PatR
e815498f07 git issue #838 - old time manipulation for BSD
Issue #838 from clausecker, relayed by copperwater:  old workarounds
for lack of type 'time_t' from pre-standard days aren't suitable any
more.  One of the instances was incorrect (diagnosed by entrez) and
no one had noticed for years (or possibly just ignored a compiler
warning).

Remove most of the old cruft from hacklib.c and some from system.h
but put in commented workarounds in unixconf.h in case someone needs
to resurrect it.  It would have been better to do things this way
back in the old days.

Resurrecting some non-Unix port might need to clone the unixconf.h
bits in its own *conf.h, but that probably won't be necessary for a
standard C compliant system.

Closes #838
2022-08-25 23:35:36 -07:00
Pasi Kallinen
51ac21bc88 Make mouse clicklook report only the specific tile
Previously the mouse clicklook mentioned every tile that matched
the character symbol, leading to overload of information and
if playing with tiles, it was mostly useless. Also the most
important bit - the tile info - was last in the text.

Now mouse clicklook only reports the exact tile information
that was clicked on.
2022-08-25 17:17:42 +03:00
Patric Mueller
2deb119ee0 curses: implement a dialog for the windowborders option 2022-08-24 21:03:36 +02:00
Pasi Kallinen
7c8ccb8ccd Prevent getpos queueing mouse commands
My change to allow binding the mouse buttons made getpos
push the mouse commands into a command queue, so when you
were asked for a map location, clicked on it with a mouse,
you'd first get the expected effect, and then (most likely)
immediately traveled there.

Change getpos to clear the commands bound to the mouse buttons,
and restore the binds afterwards.
2022-08-24 14:21:27 +03:00
Pasi Kallinen
edae8273b9 Explicitly list the random breath types 2022-08-24 10:29:59 +03:00
PatR
422a06f01f black and white ice, sink
When moat and lava use the same screen symbol and color is Off, lava
is rendered in inverse video.  It used to be similar for floor and
ice, but that got broken last year.  Fix inverse ice, and now that
fountain and sink might be same symbol (recent IBMgraphics change),
render sinks in inverse if they match fountains and color is Off.

I started to give sink its own mapglyph flag but then got lazy and
used the same value as ice.  That can be amended if some interface
wants to use some more elaborate distinction than inverse video.
2022-08-23 16:01:35 -07:00
Pasi Kallinen
c42e73fd9c Allow binding mouse buttons
Instead of hardcoding mouse button actions, allow the user to
bind mouse buttons to extended commands.  For example the new
defaults are:

BIND=mouse1:therecmdmenu
BIND=mouse2:clicklook

Currently a bit rudimentary; the defaults should be OK, but
documentation is bit lacking, and in-game binding and option
saving are missing.

Allowed commands to bind are "nothing", "therecmdmenu", "clicklook",
and "mouseaction". Clicklook replaces the "clicklook" boolean option,
and mouseaction does what mouse 1 button used to do - a context sensitive
action.
2022-08-23 23:27:21 +03:00
Pasi Kallinen
3a255e86c4 Some lua selection userdata code cleanup 2022-08-23 17:34:29 +03:00
Patric Mueller
4aeb3875e2 Fix some coordxy declarations that should be xint16
By temporarily changing the type definition for each of xint16 and
coordxy to int32_t, the compiler was able to find several places where
the type definitions were wrong.
2022-08-23 09:10:17 +02:00
Pasi Kallinen
a9ca23e8f9 Random figurines are of harder monsters 2022-08-21 13:23:16 +03:00
Pasi Kallinen
fcf5c1ea50 Monsters see and remember when others trigger traps
No longer will there be a conga line of hill orcs stepping into
the same arrow trap one after another.
2022-08-21 11:51:19 +03:00
Pasi Kallinen
953d43f5ac Monster known traps bit twiddling 2022-08-21 11:36:39 +03:00
PatR
96e9534289 error() doesn't return
This will fix some complaints from static analysis.  Note that the
code it complained about wasn't incorrect and that's likely to be
the case of a lot of its complaints.
2022-08-20 15:42:04 -07:00
Pasi Kallinen
b0f3371147 Monsters try to escape from boulder forts
If a monster cannot move, for example because it's being
blocked off by boulders or walls, it will try to escape by some
method - such as a wand or scroll of teleportation.
2022-08-20 21:49:55 +03:00
Pasi Kallinen
ac5aadf0e3 Add #fuzzer wiz-mode command
Move the debug_fuzzer boolean out of the full options menu
and turn it into #fuzzer extended command
2022-08-20 08:34:52 +03:00
PatR
c1337773f5 'color' in simple options menu
'color' appears in the simplified O menu for curses, but was not
showing up for tty.  That's because it is hidden when tiles are in
use, and tty has had a bogus value for iflags.wc_tiled_map.

Presence of USE_TILES is not a reliable way to tell whether tiles
are available in a multi-interface binary.  Nor is the setting of
DEFAULT_WC_TILED_MAP from config.h.
2022-08-19 14:54:59 -07:00
nhmall
8fb6e0be83 fix comment 2022-08-19 10:00:47 -04:00
copperwater
df3fc20ed0 Fix: double documentation for 'tilenm' in PCHAR2 2022-08-19 06:16:47 -07:00
PatR
2108abd30d pets eating containers
Apply the patch from entrez that makes pet gelatinous cubes who eat
containers engulf rather than digest the contents, like non-tame
g.cubes.  Unlike the latter, tame ones will immediately drop the
stuff they just engulfed and might subsequently eat it all anyway.
2022-08-18 01:09:52 -07:00
nhmall
d3208fa1c3 correct an rng mistake in 6e0d55df from Jan 2019
Reported by entrez
2022-08-17 20:32:07 -04:00
Pasi Kallinen
c05a6f3199 Expose some debug flags in options
Show and allow changing the debugging flags in options:

debug_fuzzer: turn on the fuzzer
debug_hunger: prevent hunger
debug_mongen: prevent monster generation
debug_overwrite_stairs: allow level generation overwrite stairs

These are wizard-mode only, cannot be set via config file,
and the fuzzer cannot change these either.
2022-08-17 20:17:30 +03:00
PatR
b07fe59b3c attack/damage by trapper and lurker above
Change trappers and lurkers above to remove digestion damage.  They
fold themselves around rather than swallow the victim.  There were
are lot of places that assumed that an engulfer which is an animal
would swallow and digest the victim.  In hindsight, it might have
been simpler to take the M1_ANIMAL flag off of trappers and lurkers
above.

This adds a new digests() predicate for creatures with AT_ENGL+AD_DGST
(purple worm) and also enfolds() for AT_ENGL+AD_WRAP (both 't'-class
critters).

There are several minor fixes mixed in with this.  I didn't record
them as I went along but the two I remember are
1) if poly'd into a holder and holding on to a monster, the '<' and
   '>' commands refursed to work; release the held creature first
   and then treat those commands as normal;
2) throwing a non-weapon while engulfed by an ochre jelly reported
   "the <item> vanishes into the ochre jelly's /currents/".

This needs a lot more testing.  I found and fixed multiple minor
details before my own testing burned out.
2022-08-15 04:14:36 -07:00
copperwater
549dfb92ea Remove obsolete find_skates function
find_skates was still in use for its one intended case, but objdescr_is
has been around for a few years now and can do just as good a job
without having to hardcode the first and last boots in objects[].
2022-08-14 10:12:54 +03:00
Pasi Kallinen
9be2e581b7 Macros for checking is object artifact 2022-08-12 19:37:34 +03:00
PatR
3dac38eb0f look_here() arguments
Add LOOKHERE_NOFLAGS to use instead of 0 for look_here()'s 2nd arg.
Fix the call to look_here() that passed FALSE.
2022-08-10 18:02:57 -07:00
Pasi Kallinen
d91915dba3 Migration-safe monster movement iteration
The monster knockback could mess with the monster linked list while
the code was going through it for monster movements. (For example,
a monster knocked back another into a level teleport trap)

Add iter_mons_safe, which first grabs all the monster pointers in
the list into an array, and goes over that array instead of relying
on the "next monster" pointer. This is possible because dead monsters
are not removed from the linked list until after all the monsters
have moved.

Testing is very minimal, and I'm not sure the vault guard check
for migration is correct - it should probably check for more states?

Also the iterator could be improved by not continually allocating
and freeing the monster pointer array.
2022-08-10 11:04:04 +03:00
PatR
e9ec89a903 fix issue #836 - engulfing mounter hero
Reported by copperwater:  if an engulfer swallowed a mounted hero,
odd things could happen if the hero dismounted.  The steed would be
silently expelled and float-down flooreffects were attempted.

It turns out that if the engulfer is classified as an animal (so
purple worm, lurker above, trapper), the hero got "plucked from
<steed>'s saddle" and was forcibly dismounted prior to completing
the engulf operation, but non-animals (vortices, air elemental,
ocher jelly, Juiblex) swallowed the hero+steed intact.  The most
straightforward fix to dismounting-while-engulfed issues is to change
engulfing to always pluck the hero from the saddle even when the
engulfer isn't an animal.

If there's no room on the level to place the former steed, it gets
killed off.  I looked at changing that to put the steed into limbo,
waiting to migrate back to the current level if hero leaves and
subsequently returns, but that breaks movemon()'s assumption that
when monsters are in the process of moving, only the currently moving
one can be taken off the fmon list to be placed on migrating_mons.

[The recently added monster knockback code violates that assumption
too when knocking the victim into a level changer trap.  It needs to
be fixed in one fashion or another.]
2022-08-09 16:22:50 -07: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
PatR
4e6d3aba4f fix #K3656 - chest in pit
Using #loot while in a pit allows looting containers in that pit.
Using open and specifying the hero's spot when not in a pit allows
looting containers at hero's spot.  But using open while in a pit
complained about not being able to reach out of the pit before player
had a chance to give hero's spot at the place of interest, so did not
allow looting any container there.

Get a target spot before rejecting use of 'open' while in a pit.
The alternate prompt might be tty-centric.
2022-08-07 16:02:44 -07:00
Pasi Kallinen
b635160297 Minor ranged attack tweak
Make monsters with magic and gaze attacks avoid hero,
just like spitters and breathers already did.
Some small code cleanup related to the ranged attacks.
2022-08-07 22:33:47 +03:00
Pasi Kallinen
83f8ec1c43 Give pyrolisk a bite attack 2022-08-06 10:55:04 +03:00
PatR
a84025c36c more abandoned migrations when entering endgame
The earlier commit just removed monsters from migrating_mons and left
them orphaned.  Also it ignored migrating objects.

Actually release the monsters that can no longer arrive at their
migration destinations.  Release their inventories too.

Release objects that can no longer arrive at migration destinations.
2022-08-05 16:55:05 -07:00
PatR
dc381d0560 discard migrating monsters when entering endgame
When the hero enters the planes branch, all the rest of the dungeon
gets discarded since it can no longer be reached.  At the time that
that takes place, throw away any migrating monsters waiting to arrive
on any of those levels.
2022-08-05 14:36:11 -07:00
Pasi Kallinen
fa1b326e31 Save changed key binds to config file 2022-08-05 13:07:26 +03:00
Pasi Kallinen
45613ea771 Experimental #saveoptions command
Add a #saveoptions extended command, to allow saving configuration
settings from within the game. This is still highly experimental,
and gives plenty of warnings before asking to overwrite the file.

Lack of option saving is one of the biggest complaints new players
have, so this should help with it.  More experienced players with
highly customized config file should not use this feature, as it
completely rewrites the file, removing all comments and non-config
lines.
2022-08-05 10:33:55 +03:00
PatR
e5ddf400c6 'O' tweaks
Reformat most of optlist.h.  In the process, fix a couple of
conditionally included items which were mis-classified as set_in_game
when excluded.  Add "permablind" as an alias for the "blind" option.
[I don't understand the size value of 70 for #if BACKWARD_COMPAT
{curses,DEC,IBM,Mac}_graphics but didn't alter that.]

Include 'pickup_types' in the behavior section; it's useful from
turn 1 and does get adjusted from time to time during play.

Include 'color' in the map section, but hide it for wc_tiled_map.

Include 'showscore' and 'statuslines=2|3' in the status section.
I didn't rebuild with SCORE_ON_BOTL enabled so the showscore part
hasn't been tested.
2022-08-04 16:53:31 -07:00
Pasi Kallinen
4ff9537b0d Rudimentary key rebinding in game options
Currently shown only in the full options list, as it's not
quite complete. (For example, it doesn't handle movement commands,
or the getpos keys)
2022-08-04 14:42:45 +03:00
Pasi Kallinen
bfd262ebe8 Add optionsfull extended command
This is the previous, full options list. Adding it as
an extended command, so users can do

BIND=O:optionsfull

to go back to the old behaviour.
2022-08-03 19:18:44 +03:00
Pasi Kallinen
f3591ea07d User-friendly options menu
Make the default options menu only show the most important
options, split into categories. The full, traditional menu
can be accessed by using the m-prefix.
2022-08-03 14:08:31 +03:00