Commit Graph

6369 Commits

Author SHA1 Message Date
Pasi Kallinen
74565c890d Split readobjnam into multiple functions
Also add several new tests for it
2020-11-29 19:08:30 +02:00
Pasi Kallinen
f2218839a3 Move some function names to start of line 2020-11-29 14:10:25 +02:00
PatR
df8e2dcd74 -Wshadow fix
Not caused by a hidden macro this time...

|mon.c:1549:10: warning: declaration shadows a variable in the
|      global scope [-Wshadow]
|    long flags = 0L;
|         ^
|../include/flag.h:392:29: note: previous declaration is here
|extern NEARDATA struct flag flags;
2020-11-28 20:15:30 -08:00
Pasi Kallinen
fb188dc1aa Unify mfndpos monster movement flags 2020-11-28 12:49:18 +02:00
PatR
5361958bdc more "golem rust in peace"
Be prepared for life-saving to contradict "<mon> falls to pieces".
Purely hypothetically at present (with no plans to change) since
golems don't benefit from amulets of life-saving.
2020-11-28 02:19:28 -08:00
PatR
9ecbee4a4c remove unused variable from getobj() split
and do a bit of reformatting.
2020-11-27 17:59:46 -08:00
Pasi Kallinen
36d977f61f Unify HP loss and passing out from overexertion 2020-11-27 23:43:59 +02:00
PatR
daf1381cc2 autodescribe vs MSGTYPE
I was baffled about why moving the cursor across a fire elemental
kept putting up --More-- until I remembered that I once used
 MSGTYPE=stop "[Ff]ire"
to test Qt's handling for that.  Turns out that I left it in my
config file.  autodescribe feedback should not be honoring that;
honoring MSGTYPE=norepeat is not as clear-cut but this disables
it too.

User sounds were also kept enabled during autodescribe but I have
no way to test them.  Like norepeat, disabling just falls into
place.

The pline.c change is unrelated.  It just eliminates a wide line
(from adding 'g.') in the source by using a shorter variable name.
2020-11-27 11:10:44 -08:00
Pasi Kallinen
bbb3d35252 Unify enlightenment self-knowledgeable effect 2020-11-27 19:59:16 +02:00
Pasi Kallinen
2a7cb3c4b6 Split some parts of getobj into functions 2020-11-27 18:10:47 +02:00
PatR
bb9df368af fix github issue #401 - roast/rust/rot in peace
This tries to fix the problem of the extra message when a tame
golem is completely destroyed (paper or straw golem burned, iron
golem rusted, wood or leather golem rotted) being issued at odd
times.  I basically punted on the visibility aspect since the
original logic was strange:  you had to be able to see both the
attacker's and defender's spots and at least one of those two
monsters.  Now mon-attacks-mon visibility requires that you be
able to see one of the two and if you don't see both, the unseen
one will be referred to as "it".  The "may the iron golem rust
in peace" message is independent of that and may be displayed
after "you have a sad feeling", but now that's intentional and
will refer to an unseen pet by name or monster type, not "it".

This needs a lot of testing and hasn't attempted to address
issue #402:  only some attacks that should compeletely destroy
a golem actually do so.  (So a hit by fire elemental against a
paper golem does, but passive fire counterattack when a paper
golem hits a fire elemental doesn't, nor does a wand of fire
or being hit by Firebrand.)

Fixes #401
2020-11-27 02:38:17 -08:00
PatR
8d91a9f764 more options help
"Name of your starting pet when it is a kitten" could be
construed as meaning that it will no longer apply once the
kitten grows into a housecat.  Use "if" instead of "when".

The 'other settings' were in alphabetical order except for
"status condition fields" which presumably started out as
"condition fields".  Move it into proper place for current
description.
2020-11-26 18:47:45 -08:00
PatR
ec153a27bd options help
The revamped options handling was't doing dynamic help properly.
After listing the booleans, it listed them again amongest the
compound options.  Since their description field is Null, that
could be a big problem.  sprintf(buf,"%s",NULL) on OSX produces
"(null)" but most sprintf()'s would probably crash instead.

The 'other' options (autopickup exceptions, menucolors, &c) were
not listed at all.  (I don't remember whether that was also the
case before the revamp.)  Now they're listed but not explained.

The 'msg_window' description was unhelpful; this replaces it.
A couple of others were longer than necessary so they've been
shortened.  The rest of optlist.h is reformatting wide lines.

Recently added 'safe_wait' option was included in the Guidebook
but not in dat/opthelp; add it.
2020-11-26 02:20:00 -08:00
PatR
2db51cf8bd fix #K3016 - kicking a bag of gold in a shop
Kicking a container that had gold in it took the gold amount
away from hero's credit or added to hero's debt, then didn't
give a refund if the container and its gold landed within the
shop.  Throwing behaved likewise, just less verbosely.

The problem is caused by addtobill() treating gold specially
and then subfrombill() not being able to perform a reverse
operation.  Actually, it may be possible for subfrombill() to
do that, but verifying all its uses is too much work.  This
moves the gold handling for drop+selling into its own routine
and adds calls to that for the throwing and kicking refunds.
The other calls to subfrombill() outside of shk.c appear to be
ok as-is.  (The calls inside that file are the ones that still
need evaluation if the gold handling is to move to there.)

bill_dummy_object() now uses the same o_id assignment for its
dummy object as split_object() does for its new partial stack.
I don't know whether the old code led to any price glitches.
2020-11-25 14:33:14 -08:00
PatR
7e87abb66f wizard mode buglet: simultaneous Lev+Fly timeout
Noticed while working on Qt status highlighting:  if levitation
and flying timed out at the same time, first Lev timeout called
float_down() which reported
 You have stopped levitating and are now flying.
and then Fly timeout left stale "Fly" on the status line due to
an optimization which got subverted.  ('was_flying' flag was
False due to Fly being blocked by Lev; that's correct behavior,
but the flag is effectively a cached value that becomes stale
when the Lev timeout code executes.)

The bug was wizard mode only because #wizintrinsic is the only
way to get timed flying.
2020-11-24 10:43:12 -08:00
Pasi Kallinen
229930e505 Fixes and sanity checks for monster undetected and trapped states
Adds sanity checks for mtrapped and mundetected states.

Fixes cases where those were left in wrong state.

1. Trapped monster (eg. a nymph) teleported out of a trap
2. Monster was hiding under ball or chain, which then got removed
3. While restoring a level, a zombie corpse revived while monster
   was hiding under it
4. A general case where the only object was deleted off floor and
   a monster was hiding under it

Monsters hiding under ball or chain will now get revealed when
the b or c are moved.
2020-11-24 19:37:43 +02:00
PatR
f43421ae3c create monster creating concealed mimic revisisted
commit 03d7d64d15:
| [...] but fixing this specific case is trivial.

Not trivial enough to avoid getting the details wrong.  An old
commit log message (58137a608a,
June of 2006) claimed that this was fixed for bag of tricks but
that was for monsters in general; mimics could still be wrong.
2020-11-22 00:32:11 -08:00
PatR
3e9d8f9aa5 'showscore' vs containers
When SCORE_ON_BOTL is enabled, you could tell how much gold is
inside a container with unknown contents by having 'showsore' On
and watching how much the score changed on the status line when
picking the container up.
2020-11-21 17:37:01 -08:00
PatR
d48e730700 ki-rin body parts
Use horse/unicorn body parts.  The result for HAIR is "mane"
which is appropriate.  There's no field for SKIN so the question
of whether to specify "scales" is moot.  (Snakes and dragons
describe HAIR as "scales" but that wouldn't be right for ki-rin.)
2020-11-21 03:46:53 -08:00
PatR
03d7d64d15 create monster creating concealed mimic
From an old bug report (sent directly to devteam, June of 2017):
wand or scroll of create monster becomes discovered if it makes
a mimic that is concealed as an object or as furniture within
the hero's view.  Fixing this in the general case [when does
seeing a mimic as something other than a monster mean that the
mimic is being seen?] is a massive can of worms, but fixing this
specific case is trivial.
2020-11-20 18:56:35 -08:00
PatR
7b50590654 rename #wizlevelflip to #wizfliplevel
Since ^V is dead key for me with Qt on OSX, I use #wizlevelport
instead.  It's annoying to have to type all the way up to the
'p' for it to become distinct.  Rename the biggest conflict,
\#wizlevelflip to #wizfliplevel.  I still have to type as far
as the first 'e' for #wizlevelport but 6 characters are easier
to type than 10.

It wasn't in the Guidebook so I've left things that way.  I am
adding it to 'wizhelp' though.
2020-11-19 01:57:13 -08:00
PatR
27b93148c0 ki-rin's horn
Let ki-rin cure themselves (of being stunned, confused, or blinded)
with their own horn, and make them be poison resistant.  They
aren't unicorns but their horn is very much like a unicorn horn.
They're flagged no-corpse so this hasn't changed them to leave
behind a horn upon death.

They were flagged as animals who neighed but they are also spell
casters.  I took the animal flag off (they're still no-hands so
shouldn't be able to use items; also, unicorns aren't flagged as
animals either) and changed sound to 'ms_spell'.
2020-11-18 11:16:21 -08:00
Pasi Kallinen
e100d1a137 More unpolyable unifying
... and fix the potion dipping case.
2020-11-17 18:00:43 +02:00
PatR
cb8baa1d1c Qt status overhaul: add support for 'statuslines'
Condense the Qt status slightly, moving Alignment field from the
Conditons line to the Characteristics line and the Time and Score
fields from their own possibly blank line to the HP,&c,Gold line.

That's for statuslines:2, which is the default.  statuslines:3
restores the previous layout.  I tried to make that become the
default for Qt but it got messy fast and I gave up.

I also tried to make changing 'statuslines' back and forth on the
fly work but failed.  I left the code in as #if DYNAMIC_STATUSLINES
but that isn't defined anywhere.  For the time being at least,
'statuslines' is config file or NETHACKOPTIONS only for Qt, not
changeable via 'O' like for curses and tty.

Change the option description for 'statuslines'.  That depended
upon whether curses was compiled in when it should depend on which
interface is active.  This moves the alternate info to Guidebook.
2020-11-17 05:07:09 -08:00
PatR
98075ebfe8 auto-cursing helmet vs perm_invent
I though that I noticed a problem but later couldn't reproduce
it, so this might not be redundant.  Update persistent inventory
when putting on a helmet causes it to become cursed.

Minor change:  if blind at the time, hero loses knowledge of BUC
state.
2020-11-16 18:08:02 -08:00
Pasi Kallinen
d81e1672aa Unify unpolyable objects to single define 2020-11-16 18:42:12 +02:00
Pasi Kallinen
ccb5bc4b55 Avoid hard-coded bit twiddling 2020-11-15 19:56:35 +02:00
Pasi Kallinen
d6384f4061 Use enums instead of magic values 2020-11-15 19:32:21 +02:00
Patric Mueller
56494d3479 Fix an implicit-fallthrough and maybe-uninitialized warning 2020-11-15 16:07:43 +01:00
Pasi Kallinen
deb730d9b5 More hypothetical type mismatches 2020-11-15 13:51:47 +02:00
Pasi Kallinen
289c8d654d Futureproofing hypothetical type mismatches
If we ever want huge maps with COLNO or ROWNO larger than signed char,
this will at least allow the game to compile and start when typedef'ing
xchar to int. Trying to use huge maps exposes more bugs.
2020-11-14 13:53:09 +02:00
PatR
e647eab6dc fix github issue #410 - mon throwing c'trice egg
If a monster threw a cocktrice egg that hit and petrified another
monster, the hero would credit (experience) and blame (possible
alignment penalty, &c) for it.

Fixes #410
2020-11-13 16:52:45 -08:00
PatR
6cbd2c5d85 warning fixes
Using 'ladder' as a variable conflicts with 'struct flag flags'
because of a macro in rm.h.  Also remove or hide a couple of
unused variables.

The hack.c diff is unrelated; just a reformatting bit that I had
laying around.
2020-11-13 14:11:54 -08:00
Pasi Kallinen
6ec55a3624 Rework stairs structure
Use a linked list to store stair and ladder information, instead
of having fixed up/down stairs/ladders and a single "special" (branch)
stair.

Breaks saves and bones.

Adds information to migrating objects and monsters for the dungeon
and level where they are migrating from.
2020-11-13 20:27:17 +02:00
PatR
e23f764d11 fix #K2924 - breaking a wand without free hands
Breaking a wand didn't require the hero to have free hands.
That's definitely a bug when they're both welded to the same
two-handed weapon.  It's debatable when welded separately to
a one-handed weapon and to a shield but simpler to pretend
there's no such distinction.

This also makes glass wand join balsa wand as "fragile".  Hero
doesn't need as much strength to break them as other wands and
the wording for breaking them is slightly different.

My fixes entry initially had a trailing space.  When I took
that out, I spotted a couple of others so take those out too.
2020-11-12 04:30:25 -08:00
PatR
ea0ef81ecd fix github issue #408 - stuck to distant mimic
Attacking a concealed mimic at range by applying a polearm
could make the hero be stuck to that mimic in addition to
bringing it out of hiding.  Only do that when adjacent.

This also adds a new sanity check when setting u.ustuck.
It may get triggered by other sticking activity since only
attacking has been tested.  The check must be explicitly
enabled by setting the wizard mode 'sanity_check' option.

Fixes #408
2020-11-08 16:07:42 -08:00
PatR
0eee7b7edc Qt paper doll comments 2020-11-07 02:32:50 -08:00
PatR
bf2094d3dd remove obsolete 3.6 compat - Schroedinger's cat
Remove unneeded code.  Noticed while looking for an explanation
of the reported attempt to light eggs.
2020-11-04 10:17:21 -08:00
PatR
c8d05ac352 ignitable() macro
ignitable() was excluding magic lamp and then every place that
used it did so as 'ignitable(obj) || obj->otyp == MAGIC_LAMP'
so just include magic lamp.

I noticed that while hunting for an explanation for report #K2734
where returning to a previously visited level triggered the
warning "begin_burn: unexpected eggs".  I've decided that the
zombie apocalypse is probably the cause.  It inserted a new type
of timer in the list of such but it didn't bump EDITLEVEL to
invalidate save and bones files which relied on indices into the
old list.  I'm not sure whether we should bump that now.
2020-11-03 14:25:06 -08:00
PatR
750b86f0a8 comment accuracy 2020-10-31 12:49:13 -07:00
nhmall
6c62b991c2 Merge branch 'wasm-bug-fixes' of https://github.com/apowers313/NetHack into wasm-pr403 2020-10-31 09:22:55 -04:00
PatR
8907a5df9c more alignment conversion
The overview code could reveal the true alignment of an altar
if hero saw a mimic pretending to be an altar on that spot, or
reveal junk for the alignment when mimicking at altar on some
other spot.

Avoid passing macros that might evaluate their arguments more
than once to other macros which might also do that.  The hidden
code expansion can easily get out of hand (although in this case
it was modest).

Also, get rid of the unused MSA_foo alignment values since two
of them had the values swapped.  Lastly, make Amask2align() more
robust in case a value with the shrine bit set gets passed to it.
2020-10-30 17:46:21 -07:00
Pasi Kallinen
05263bc276 Fix memory leak when adding basic color menucolors 2020-10-30 23:04:22 +02:00
nhmall
01c4a50f98 warning and a bit of alignment-related header consolidation 2020-10-30 09:08:23 -04:00
Pasi Kallinen
91c46ab54b Restful sleep regenerates hp
When sleeping due to wearing an amulet of restful sleep,
hit points will regenerate, one point faster than with normal regeneration.
2020-10-29 19:14:32 +02:00
PatR
ec5772d6d2 Qt hitpointbar
Add support for the 'hitpointbar' to the Qt interface.  Rather
than rendering the status title (name+rank or name+monster_species)
using inverse video for leading substring to produce distinct left
and right sides, draw a horizontal bar above that field.

The left portion (current health) is thicker and uses red for <10%
or <5hp, orange for <25% or <10hp, yellow for <50%, green for <75%,
blue for <100%, and black for 100%.

The right portion (missing maximum health) is thinner and runs
from white (paired with red), light gray (paired with orange),
dark gray (with yellow), plain gray (which turns out to be darker
than dark gray, with green), dark blue (with blue), and black (but
black is never shown for injury portion because that's suppressed
when at full health).

Qt already supports a square frame around the hero's map tile that
changes color according to health.  Turning the hitpointbar option
Off or On has no effect on that.
2020-10-25 15:47:49 -07:00
Patric Mueller
4e1cf071ae List lamps and lanterns in charging prompt
Brass lanterns and oil lamps are always chargeable.
Magic lamps are only listed if they are not yet identified.
2020-10-25 19:25:39 +01:00
Pasi Kallinen
22ca1ae4da Fix monster hiding under hatching egg staying hidden 2020-10-24 18:32:08 +03:00
PatR
1b37ac6280 disclosure prompt phrasing
With to-be-3.7, if game ends without any achievements, the conduct
disclosure prompt is the same as it has always been
  Do you want to see your conduct?
If it ends after attaining one achievement (probably entering the
mines or acquiring the second rank title when gaining Xp level 3)
you're asked
  Do you want to see your conduct and achievement?
which looks awkward after the fact if 'y' reveals multiple conducts.

Instead of deciding whether to pluralize "conduct(s)", simplify the
prompt when one or more achievements have been attained to be
  Do you want to see your conduct and achievements?
That works even when there is only one achievement.
2020-10-24 03:17:19 -07:00
Patric Mueller
8cc75bf583 Fix "may be used uninitialized" warning 2020-10-24 11:38:22 +02:00