Commit Graph

14588 Commits

Author SHA1 Message Date
nhmall
995fae39b5 spurious warning with visual studio 2017
Don't force on a particular warning in the nmake Makefile if
compiling using the older visual studio 2017.

Resolves #950
2022-12-15 08:39:30 -05:00
PatR
e4145f7dc1 calling objects
An earlier attempted fix was not working as intended.  This
accomplishes what I was trying to do.  I haven't reverted
interesting_to_discover() to static within o_init.c.
2022-12-14 14:07:22 -08:00
PatR
96f5f03287 revise the role, race, gender, align options
Using role:!wizard to limit which roles would be candidates for
random selection didn't work as I expected.  It required a separate
option setting for role to exclude.  This implements how I thought
it worked:
|OPTIONS=role:!ranger !samurai !wizard
will exclude multiple roles with a space-separated list in a single
option setting.  It also adds support for
|OPTIONS=!role:ranger samurai wizard
to do the same thing.  (OPTIONS=!role:!ranger isn't allowed.)

I thought 'OPTIONS=role:barbarian caveman knight' could be used to
limit random selection to those choices, but that doesn't work and
I haven't attempted to implement it.

This also renames the 'align' option to 'alignment'.  That made the
truncation to 'align' become ambiguous, so it got added back as an
alias for the full name.

Guidebook.tex is lagging; I'm burned out.
2022-12-14 13:14:54 -08:00
nhmall
9dbb21cfcb update tested versions of Visual Studio 2022-12-14 2022-12-14 14:33:36 -05:00
PatR
39f3be94b4 pull request #945 - boulder vs shared shop wall
Pull request from entrez:  a boulder being sold by one shop could be
pushed into another shop if they had a shared wall with a gap in it.
Treat such as being stolen from the first shop rather than becoming
for-sale in the second shop.

[I haven't done much testing of the stolen_value() changes.]

Fixes #945
2022-12-14 08:28:31 -08:00
Michael Meyer
05117fa84f Fix: billing shop boulder pushed thru shared wall
I realized that the "move the boulder billing to 'used-up items'" part
of 20392a6 didn't properly handle boulder movement from one shop to
another via a gap in a shared wall, becuase it wasn't looking at the
complete in_rooms() array (plus, it only triggered if the new spot
wasn't in any shops at all).  When I tried to fix that, I realized that
stolen_value() was similarly not working reliably when passed a location
shared between two shops, and for the same reason: it was only using the
first character of the in_rooms() array.

I think this patch fixes both those things, but it would be worth
examining the change to stolen_value() carefully, to ensure getting the
roomno via the shkp won't change anything about its normal functioning.
I'm not totally sure about that -- I didn't notice any problems in some
brief tests of typical stolen_value() uses, but it seems like it
probably has some tricky edge cases.

At the very least, passing a boulder fully through a shared wall between
two shops one way, then back the other way, no longer triggers an unpaid
obj sanity check in my testing.
2022-12-14 08:27:48 -08:00
PatR
daeec9291c refine PR #946 - named armor
Move the new stuff from PR #946 out of xname() into new routine
armor_simple_name().

Noticed while testing:  tweak 'call object type' so that it doesn't
list instances of pre-discovered armor as likely candidates since
assigning a name to such wasn't showing up in the discoveries list.

Add "silver shield" as wishing synonym for "polished silver shield".
2022-12-14 07:37:04 -08:00
PatR
099e2f3d05 pull request #946 - named armor
Pull request from entrez:  use helm_simple_name() instead of
hard-coded "helmet", boots_simple_name() instead of "boots" and so
forth when formatting called but not yet discovered armor-class
objects for inventory, messages, &c.

Closes #946
2022-12-14 05:50:23 -08:00
Michael Meyer
eff2cba10d Use foo_simple_name for armor types in xname
This will distinguish between a hat and a helmet, shoes and boots, etc,
so that a "conical hat" doesn't turn into a "helmet called dunce" after
type-naming it, and so on.  Instead, more specific names will be used
for the base type, consistent with the terms used in various messages
(so "a hat called dunce").

Some of these don't seem like necessary distinctions to make, and some
of them probably don't make a difference at all (e.g. gloves vs
gauntlets, since "gauntlets" only shows up once you've IDed the item so
the user-assigned typename isn't visible), but it probably makes sense
to be consistent in using these functions if it's done for any armor
type.
2022-12-14 05:49:05 -08:00
nhmall
2ee061e02d cast away a new warning
role.c: In function 'plnamesuffix':
role.c:1615:19: warning: operand of '?:' changes signedness from 'int' to 'unsigned int'
due to unsignedness of other operand [-Wsign-compare]
1615 |                 ? (int) (eptr - gp.plname)
                         ^~~~~~~~~~~~~~~~~~~~~~~~

Since Strlen() (actually hacklib's Strlen_ function) returns 'unsigned' for the
second operand of the '?:', the compiler was having to change the signedness
of the first operand '(int) (eptr - gp.plname)' to 'unsigned' and issuing the
warning.

Cast the result of Strlen() to int to make both operands of the '?:' the same
('signed').
2022-12-13 19:17:00 -05:00
PatR
7096c68492 more interactive role selection
This ended up combining several unrelated changes.

Add missing 'fixes' entry for curses-specific item in New Features.

When answering "Shall I pick ... for you? [ynaq]", accept \m as well
as \n and space for choosing the default of 'y', same as normal
ynaq() would.  Also add '*' to '@' as not-shown potential answers;
they force 'random'.

When tty tore down any of the menus, things were reasonable if they
were short enough for corner windows, but tall ones that switch to
full screen weren't fully erased.  The parts of those outside of the
map window stayed behind when the tall menu was closed and cleared.
Mainly affects picking the "~ - reset filtering" choice but also
affected the role menu on 24 line tty screens.  (Didn't affect curses
because it tracks and refreshes its base window when some overlaying
window goes away.)

The role menu used 25 lines so required a second page for the case
of a 24 line screen on tty.  Dealing with that is a bit ugly but it
wasn't an issue when this form of role selection was tty-only (because
the info about choices made so far was displayed on the base window
rather than in an extra menu line back then) so I added a hack for it.
If the role menu will take one more line than the screen height, the
separator between 'random' (below 'Wizard') and 'pick race first' gets
squeezed out.  If the menu needs two more lines (doesn't happen now,
except by changing screen size to 23 lines for testing), a second line
gets squeezed out.  (Not attempted for curses because it wouldn't
help.  'windowborders' and one or two extra separators it adds make
menus taller.  I doubt if many players use curses on 24-line screens
but if they do, they'll be using something new rather than going from
something that used to fit on one page with 3.6.x.)
2022-12-13 15:59:05 -08:00
PatR
b2fe51490d tty-style role selection for curses
Move the tty role/race/&c selection from wintty.c to role.c and remove
its references to BASE_WINDOW.  Have curses call the same routine now
so that the player has the option to choose role, race, gender, and
alignment in any order and to confirm or override random settings
prior to starting play.  Also if you went through "who are you?" then
final confirmation includes an extra menu choice to rename the hero.

It still has the quirk of sometimes remembering some of the previous
aspects when you re-pick a new value for some aspect which already
been selected.

The menus pop up on top of the copyright screen and that looks a bit
strange.  I don't think core code has any way to erase that base
window without erasing the entire screen so to fix the strangeness
the window ports would need to do that before calling the selection
routine.  I didn't do that because the very first prompt, "Shall I
pick ... for you? [ynaq]" shows up in that window rather than in a
popup over it, and having it be all by itself on an otherwise blank
screen seemed to be even stranger.

X11 and Qt both have more sophisticated selection routines so I
haven't tried to switch either of them to use this.  They both use a
fancy role-selection-specific menu with all the aspects present at
once so this wouldn't fit without more work than I care to tackle.
2022-12-12 16:30:27 -08:00
PatR
cefd9a0c0a 'generic username' checking
Don't require the list of generic usernames in sysconf to need to be
ordered to guard against false substring matches.  If the list was
"nethacker nethack" and the tentative character name was "nethack",
it wouldn't be recognized as generic.  The old code forced the list
to be "nethack nethacker" for the matching to work correctly because
it only checked the first matching substring.  Either order works now.

It also failed to recognize a generic name if the player used
|nethack -u nethack-samurai-human-male-lawful
because it checked for generic names before stripping off the role
aspects.  Now that will at least recognize the name as generic and
prompt with "who are you?", but the role/race/&c info gets discarded.
2022-12-12 14:53:07 -08:00
nhmall
bc13b52d32 windconf.h mingw bit 2022-12-12 15:20:22 -05:00
nhmall
71c26361ff follow-up: make the ifdef logic a bit clearer 2022-12-12 14:37:40 -05:00
nhmall
9e91064659 makedefs temp files issue with mingw
The unlink call wasn't operating the same on a makedefs built
on mingw, and dat/mdXXXX files were being left behind post-build.

Provide an alternative way of doing the temporary files if
MD_USE_TMPFILE_S is defined during the compile of makedefs.c
2022-12-12 12:53:51 -05:00
nhmall
092068495b fixes update 2022-12-11 21:55:15 -05:00
nhmall
5ac96e9318 odd Windows lighting in lit rooms (issue #929)
bkglyph variable gets initialized to GLYPH_UNEXPLORED so ends
up being returned by get_bk_glyph() if something more interesting
wasn't chosen in the switch statement.

The Windows win32 interface will then use the tile mapped to
GLYPH_UNEXPLORED as a background. The tile is 16x16 all black
pixels. That looked very odd.

Treat GLYPH_UNEXPLORED as an out-of-range value.

Closes #929
2022-12-11 21:29:42 -05:00
PatR
608490ad98 more zapping while hiding-under
The previous commit had the up/down test backward.  Also the commit
log text described the old behavior incorrectly:  zapping down while
hiding-under skipped the top item but zapping up hit the whole pile.

Still not adequately tested.
2022-12-10 18:00:44 -08:00
PatR
0e1f1c653b fix #K3802 - sanity_check: boulder not on top
This should fix the problem of polymorphing or stone-to-fleshing a
pile of multiple boulders and having some underneath ones which get
changed resist and not get changed, producing a pile with one or more
non-boulders above one or more boulders.  If that situation arises,
re-stack the pile so that boulders are moved to the top.

This also revises zapping up or down while hiding under something
(if that is even possible; the types of creatures which can hide
under things can't zap wands or cast spells; maybe there are some
exceptions?).  Zapping up used to hit only the top item, but zapping
down hit the whole stack.  Now up still hits only the top, but down
skips the top and hits the rest.

Caveat: not adquately tested.
2022-12-10 17:48:55 -08:00
nhmall
9e2effe710 Merge branch 'unicode-performance' of https://github.com/chasonr/NetHack into NetHack-3.7 2022-12-10 17:15:31 -05:00
Ray Chason
b7a56b5895 Clean up dangling pointers when freeing glyphmap
Partially fixes issue #941.
2022-12-10 17:00:28 -05:00
Ray Chason
ea84598613 Remove some debug code 2022-12-10 13:13:28 -05:00
Ray Chason
aa1d130345 Revert adding bsearch to system.h 2022-12-10 12:27:18 -05:00
Ray Chason
c7431d6942 Reimplement glyph cache as a hash table 2022-12-10 12:27:18 -05:00
Ray Chason
d5bc738812 Replace Snprintf with faster Strcpy 2022-12-10 12:27:18 -05:00
Ray Chason
b9ef6e6bb9 Define a tail pointer for the glyph list
Use the tail pointer to add new glyphs, avoiding the need to traverse
the list.
2022-12-10 12:27:18 -05:00
Ray Chason
e556af78ec Use pointer assignments to generate glyph names 2022-12-10 12:25:56 -05:00
Ray Chason
d90cd6d7d2 Skip match_sym for G_ lines 2022-12-10 12:25:56 -05:00
Ray Chason
51ec42886e Fix -dumpglyphids on Unix
The order of the statements needs to be changed, so the -d is not
interpreted as requesting a directory.
2022-12-10 12:25:55 -05:00
Ray Chason
d70bdeab3b Fill the glyph cache when switching symbol sets 2022-12-10 12:25:55 -05:00
Ray Chason
7dc1106ec1 Sort the glyph cache and search it with bsearch
Also, recognize G_slime_mold and G_piletop_slime_mold when the fruit
has been set.
2022-12-10 12:25:55 -05:00
PatR
6a1f875b17 some extern.h reformatting
Wrap or re-wrap some wide lines.
2022-12-10 00:48:38 -08:00
PatR
7c0c0ba66a shop sanity check of the day...
If a pet picks up a no_charge item in a shop and gets teleported out,
clear that flag.  (It's already being cleared for non-pets as soon as
they pick any item up.)
2022-12-09 12:55:39 -08:00
PatR
9fa08b383f shopping objects, unpaid and no_charge, what else?
Revise sanity_check to acknowledge that buried objects might be unpaid
or no_charge.  (For unpaid, drop shop-owned object in a gap in the
shop wall or in the free spot; for no_charge, drop something the shk
doesn't care about, or drop any hero-owned item and decline to sell.
Dig a pit.  Push or drop a boulder to fill the pit.)

Change 'I' to look for unpaid objects on the floor and for buried ones
when deciding when to include 'u' in the list of candidate object
classes and pseudo-classes.

Change 'Iu' to mention buried unpaid objects as well as floor ones.
For both non-invent categories, show a combined count without cost
info.

Have sanity_check of monster inventory test for unpaid and no_charge.

When a monster (including pet) picks up an item that's marked unpaid
(so one dropped on shop boundary, not an ordinary for-sale one), take
it off hero's shopping bill.  If dropped--pet behavior or monster
death--inside the shop, it will become for-sale rather than no_charge
or back on bill.  [Removal from bill is needed to prevent an unpaid
object ending up outside the shop if a monster carries it out, and
current sanity_check complains about an unpaid item in mon->minvent.]
2022-12-09 04:18:20 -08:00
nhmall
4c32ca571a doc update 2022-12-08 10:46:36 -05:00
PatR
e335171071 no_charge sanity
When a shopkeeper becomes angry, clear the no_charge flag for all
floor objects on the level, even if they happen to be in another
shopkeeper's shop.  Should prevent sanity_check warnings if/when the
angry shk leaves the shop, and once the shk is pacified, items in
the shop that used to be available for free will become for-sale.
2022-12-08 02:36:50 -08:00
PatR
f1a471c139 some shk.c formatting 2022-12-08 01:06:09 -08:00
nhmall
873d08b7bc fix Makefile rule when building pdcurses library
Also, use Bill Gray's pdcursesmod for now.
2022-12-07 21:23:14 -05:00
PatR
4a965bbd83 boulder pushing feedback
Redo the details about giving or suppressing "with great effort you
push the boulder".  It works the same except that if push a different
boulder than previously, you'll get a new message.  If you do it
while riding, you have the same lack-of-message for successive pushes
instead of getting a message every turn.

Don't exercise strength when pushing a boulder if poly'd into a giant.
2022-12-07 16:45:35 -08:00
nhmall
3ac4e55f1f submodule update for pdcurses 2022-12-07 17:22:10 -05:00
PatR
bf5a089389 revise man page yet again
Rewrite much of the paragraph about the run-time config file.

Remove mention of '-p @' since it doesn't actually work.

Expand 'nethack -s' a bit.

Revise --showpaths.

Shuffle --scores, --version, --showpaths, and --usage into the same
order as usage feedback lists them, primarily scores first and usage
last.
2022-12-07 12:22:49 -08:00
Pasi Kallinen
85137bb76a Fix skipping attacks if hero moved away
Recent change by me caused a bug where a monster was trying
to attack after hero was moved away by the previous attacks.
2022-12-07 21:51:50 +02:00
nhmall
d18ce24320 more continuation alignment after g to g? (.h) 2022-12-07 11:31:11 -05:00
nhmall
8120b74051 realign macro continuation after g to g? expansion 2022-12-07 11:24:17 -05:00
Patric Mueller
68f9ef8aa6 Followup to "suicide by wand", remove redundant an() 2022-12-07 15:54:30 +01:00
PatR
0d4cf0323c shop wall repair vs unpaid shop goods
Take unpaid shop items off the bill if they're on the floor and
wall repair moves them from the shop boundary to all the way inside
the shop.

I don't think it's possible for items to be moved out of the shop
except for the very special case of moving into an adjacent shop
which shares the wall, so clearing no_charge for an item that is no
longer inside a shop is academic.
2022-12-07 02:02:08 -08:00
PatR
e48e08a93b topten.c comments 2022-12-06 17:41:44 -08:00
PatR
f52a8e48b1 suicide by wand
If hero zaps self with a wand and the result is fatal, report the
death as "zapped himself with <a wand of sometype>" rather than just
"zapped himself with a wand".
2022-12-06 11:41:24 -08:00
PatR
e724034995 unpaid sanity_check: leaving shop via recoil
Throwing while levitating or getting hit for knockback effect could
move hero carrying unpaid items out of a shop.  If that happened,
sanity_check complained that unpaid items weren't in a tended shop.

Check for entering and leaving special rooms during recoil same as
gets done for ordinary movement.  Leaving a shop via recoil or
knockback while owing a bill now gets treated as robbery immediately
rather than waiting until hero voluntarily moves to another spot
after recoil has finished.
2022-12-06 10:57:14 -08:00