Commit Graph

219 Commits

Author SHA1 Message Date
Bart House
041e55467a objnam.c globals moved to instance globals. 2018-11-23 15:22:55 -08:00
Bart House
0d59f1a22b Fix compiler warnings in macos build. 2018-11-23 15:22:54 -08:00
Bart House
865c4d5a7d restore.c globals moved to instance_globals. 2018-11-23 15:22:54 -08:00
PatR
27fe555bc1 src/ formatting
Clean up quite a bit of minor things found with simple grep patterns:
operator at end of continued line instead of beginning of continuation
(and a few comments which produced false matches, so that they won't
do so next time), trailing spaces (only one or two of those), tabs (a
dozen or so of those), several casts which didn't have a space between
the type and the expression (I wasn't systematic about finding these).

I think the only code change was in the function for the help command.
2018-11-17 16:40:53 -08:00
Pasi Kallinen
f9f1236f26 Fix some buffer underflows 2018-11-08 21:02:24 +02:00
PatR
f25f92c271 wishing bit
Allow wishing for "cookie" or "pie" to succeed since we have items
those can match.

Unrelated:  allow ^G of "genie" for similar reason.
2018-10-19 01:47:29 -07:00
PatR
64ebb9ceba fix #7414 - bug with Japanese names for Samurai
Description for use when an item hasn't been seen up close yet falls
back to real name if there is no separate description, but was doing
so before real name substitution for samurai.
 actualn = foo;
 dn = description ? description : actualn;
 if (Samurai)
  actualn = bar;
So player saw a flail (via 'dn') until dknown bit got set, then
nunchaku (via 'actualn' after it got set to samurai-specific value).

Wait until after substitution of Japanese real names before falling
back to real name when there's no description.
2018-09-25 18:01:44 -07:00
PatR
18d56724f9 'unbreak' wishing probabilities
Fixing rnd_otyp_by_namedesc() for use by get_shiny() broke its use
by readobjnam().  Make the chance for 0% generation objects to have
non-zero chance of being selected be a parameter.
2018-09-22 16:46:27 -07:00
PatR
b6e3f01855 shiny object probabilities
The wishing code uses 'oc_prob + 1' so that probability 0 (never
random) objects are eligible to be selected if their name matches
a wish; collecting 'shiny' objects shouldn't do that.  (No effect
on play since there aren't any shiny objects with 0% random chance.)

rn2() takes int, and total oc_prob for entire objects[] array is
15000, so don't accumulate the target probability in a long.
2018-09-22 14:57:55 -07:00
Pasi Kallinen
39d10d96df Prevent leash showing unseen monster as "it" 2018-09-22 15:55:26 +03:00
nhmall
a18ae517f8 some orctown follow-up bits, fix Bad fruit #0 and some minor tuning 2018-09-21 11:31:01 -04:00
PatR
4336427745 fix #H7396 - wishing for "orange"
Wishing for "orange" might grant an orange, but it might give an
orange gem, orange potion, or orange spellbook instead (but never
orange dragon scales or orange dragon scale mail).  Force the food
object to be an exact match so wishing always produces an orange.
2018-09-18 16:30:58 -07:00
Pasi Kallinen
e031800880 Use is_hole macro to check for trapdoors and holes 2018-09-15 17:57:57 +03:00
PatR
78a4edcc0f suit_simple_name()
Unlike cloak_simple_name() and helm_simple_name(), suit_simple_name()
wasn't guarding against Null.  Current usage never trips up against
that, but when I added a new use in doseduce() [pending], it caused
a crash.
2018-08-03 20:07:21 -07:00
PatR
777d9d922d restore vs perm_invent
Redo how updates of permanent inventory window are suppressed during
restore.  Reverses part of e9f1e03271
which included a simpler attempt to deal with this.

It looks like we should have been getting impossible "unpaid_cost:
object wasn't on any bill" but segfault was reported; I haven't tried
to figure out why.  The band in xname() ought to be redundant now but
is included for bulletproofing.
2018-07-05 16:06:31 -07:00
PatR
3c979cb0a5 more glob wishing
Wishing for "<size> glob of black pudding" worked, and wishing for
"black pudding glob" worked, but wishing for "<size> black pudding
glob" didn't work.  Fix that.

Also, remove a bit of spaghetti introduced by the previous patch.
And once we know we're wishing for a glob, we can skip a big chunk
of wish parsing and special case handling.
2018-06-19 18:39:08 -07:00
PatR
9415797c65 fix githib issue #108 - wishing for mimic corpse
Fixes #108

"small"/"medium"/"large" prefix was being stripped off during wish
parsing so that it could be used to control glob size.  But those
are also prefixes for monster and/or object names.  Wishing for
"small mimic corpse" or "large mimic" corpse failed with "nothing
matching that description exists" when it tried to satisfy "mimic
corpse".  (Asking for "giant mimic corpse" worked as intended.)

Not mentioned in the report:  wishing for "large {dog, cat, kobold}
corpse" produced the corpse of corresponding normal sized critter
instead of that of a large one.

Noticed while testing the fix:  wishing for "glob" failed rather
than pick a random glob type.  Wishing for "glob of grey ooze"
failed even though "grey ooze" is recognized as a variant spelling
for the gray ooze monster.  Wishing for "<monster type> glob" also
failed even when the monster type was viable for globs.  This fixes
all of those even though no one will ever notice....

Wishing for "small box" (and "medium box") no longer yields a large
box, it fails with "nothing matching..." instead.  I was ambivalent
about the earlier change which had the unintended side-effect of
making them synonyms for "large box" so haven't tried to revive it.
2018-06-19 17:21:21 -07:00
nhmall
cc1d43fad4 integrate aklys feature introduced in 3.6.1 into display
(cherry picked from commit 3fe8325f14)
2018-05-15 06:29:40 -04:00
keni
d8c49ec9d1 Add updated copyright lines, part 1. 2018-04-25 15:00:13 -04:00
Pasi Kallinen
2548d68dd3 Fix some warnings
Remove an unused variable, add missing FALLTHRUs, and use the same
FALLTHRU wording where it wasn't recognized by gcc
2018-03-30 19:42:50 +03:00
PatR
906818f5cb wishing for containers
Noticed while investigating the broken chest whose lock was already
broken:  wishing for locked, unlocked, or broken chest (or large box)
was treated as asking for something unknown.  Add support for those
three prefixes, although they only have meaning for chest and box.
If more that one is specified in the same wish, whichever one comes
last overrides the others.

Also, "empty" was already an accepted prefix (for tins); honor it for
containers too.

Lastly, wishing for "box" failed.  Give a large box instead.  I went
back and forth about whether to do the same for "small box" and ended
up not including it, but turns out that small/medium/large prefix for
globs ends up making "small box" and "medium box" match "box" which
has now become a synonym for "large box".  I'm not sure whether that
is a bonus or a bug; small box is clearly not the same thing as large
box, but getting the only available box when asking for any box seems
better than claiming not to understand the request.
2018-03-19 17:59:24 -07:00
nhmall
7238803b25 revert box naming 2018-03-19 07:13:07 -04:00
nhmall
5b03dccb19 missed one, transcription error 2018-03-18 10:29:45 -04:00
nhmall
ff67fac614 remove a couple where normal man->men rules should apply 2018-03-18 10:09:45 -04:00
nhmall
d8b12eefe7 just a couple of additional pluralization bits 2018-03-18 09:24:38 -04:00
nhmall
e7ed6508cd more message adjustments to chests with broken locks 2018-03-18 08:49:25 -04:00
nhmall
e07c6b5b77 broken large box wording change
> When you try to #force a large box or chest whose lock is already broken from a
> previous #force, the game tells you "There is a broken large box here, but its
> lock is already broken." It's minor, but this implies that the box being broken
> is separate from the lock being broken (as well as that the box itself *can* be
> broken).

change the wording to "lock-damaged box" and suppress
", but its lock is aleady broken" when "lock-damaged box" has
already been displayed.

(Nobody particularly likes the wording "lock-damaged box" either, but at least
it seems less misleading)
2018-03-17 23:05:52 -04:00
nhmall
f2d92426cc more plural refinement 2018-03-16 22:34:13 -04:00
nhmall
c42dc27330 ox tweak 2018-03-15 22:19:28 -04:00
nhmall
467e3bfdab more pluralization bits
Handle more *man and *men cases.

Some plural usage of completely made up fruit names that should
be entered in singular form but have what appears to be a
valid plural name it will end up singularized. Not much
we can do about that for ficticious words.

For instance, if you try to name your fruit bigmen or snakemen
and you intended that to be the singular name, NetHack will likely
singularize it to bigman or snakeman.

Many real dictionary words that end in "men", however, should
be handled a wee bit better now. A real word such as stamen,
for example.
2018-03-15 22:02:41 -04:00
PatR
877f403734 fix plural of box
"boxen" may be hacker slang for plural of "box", but "foxen" is
definitely not the plural of "fox".  Restrict the "ox"->"oxen"
entry to full word "ox", not "*ox" suffix.
2018-03-15 13:05:08 -07:00
nhmall
6586e9204b pluralization special case tweak
mongoose -> mongooses, not mongeese
2018-03-10 11:28:01 -05:00
nhmall
5fece7b175 pluralization bits 2018-03-10 10:43:34 -05:00
PatR
cac4344754 doname() bookkeeping
doname() for a corpse was using two obufs instead of just one.
2017-09-25 17:17:06 -07:00
PatR
a573134d7e fix #H3013 - grammar bug with named fruit
Reported nearly four years ago for 3.4.3, original subject was
\#H3013: NetHack grammar bug when taking unpaid fruit from chest

Player used OPTIONS=fruit:Quorn and the capitalized value confuses
the() into thinking it's a proper name which shouldn't be preceded
by an article, resulting in "Quorn will cost you N zorkmids" when
removing it from a chest in a shop, followed by "X - a Quorn (unpaid)"
as it went into inventory.  It is a product name, but when used as a
fruit it shouldn't be treated as a proper name.  (Quorn is a meat
substitute rather than anything related to fruit.)  Teach the() about
named-fruits, so that we'll get "The Quorn will cost you N zorkmids."

Unfortunately, it means that someone who names their fruit after a
proper name used by the program, for example Mjollnir, can probably
induce other poorly worded messages (about the item rather than the
named-fruit).  the() is used all over the place and all it has to work
with is text, not the object whose formatted name produced that text.

I looked through a bunch of old cvs log messages last night, and
spotted one I wrote (in objnam.c) a dozen years ago where I suggested
forcing named-fruit values into lower case as they're being set up.
I don't remember that, but if we'd done it, this bug would have been
avoided.
2017-07-04 18:44:03 -07:00
PatR
7a8559a34d releaseobuf() fix
The object name formatting routines operate using a pool of buffers to
hold intermediate and/or final result.  Some routines consume multiple
intermediate buffers, so use releaseobj() to try to reuse just one in
order to avoid churning through too many and maybe clobbering live
data.  It worked as intended for routines that use nextobuf() directly
but wouldn't haved worked right for xname(), also doname() and other
xname() callers.  This fixes that.

There have never been any reports of garbled messages which could be
traced to clobbering of formatted object names, so this fix is mostly
academic.
2017-07-04 14:47:00 -07:00
PatR
ca84c8e0ff named-fruit manipulation
Add some new routines for dealing with fruit.  I had hoped they would
let the existing fruit handling be simplified quite a bit, but the
improvement wasn't great.  However, they're also groundwork for fixing
an old bug.
2017-07-03 18:57:50 -07:00
PatR
d7e7c620f5 wishing for tins
A couple of days ago when verifying the report about being forced to
pay for a second tin when eating one from a stack on a shop's floor,
wishing for 'tins' (rather than 'tins of foo meat') was repeatedly
producing tin wands instead.  The name "tin" and the wand description
"tin" in objects[] were being given 50:50 chance for either one by
the 3.6.1 wishing code.  Wishing for "tins of spinach" also gave me
a tin wand on the first attempt.  Handle 'tin(s)' more explicitly.

This also does some reformatting.
2017-07-01 14:22:42 -07:00
Pasi Kallinen
02195d7351 Prevent a segfault with leashed vanished monster
It's apparently somehow possible to have a leash "attached" to
a monster not present on the current level. Complain instead of
segfaulting. (This is a post-3.6.0 bug)
2017-01-19 19:49:19 +02:00
Pasi Kallinen
f4632732ac Fix wishing for tins of specific type
I believe this bug already existed, but was only exposed by
my wishing parser change post-3.6.0
2016-12-14 18:28:01 +02:00
Pasi Kallinen
5da34b7db6 Fix segfault when looking at detected monster hiding under unknown armor
This segfault happened when a detected monster such as a garter snake was
hiding under an unknown/unseen armor of a type that has no description
field (eg. a leather armor), and you farlooked at the monster.

At the same time, simplifies the code a tiny bit.
2016-12-02 22:12:44 +02:00
PatR
a16000d80a fix #H4482 - "a some <foo> corpses"
farlook was changed (end of December) to use doname instead of xname
to yield more info for items which had already been seen up close,
but it gave away info about ones which hadn't.  So doname was changed
(end of April) to use "some" instead of precise quantity (when the
quantity is greater than 1) for the latter, but that doesn't work
well with corpse_xname() when the hero is blind, yielding "a some
<foo> corpses".  While testing the first fix attempt, I noticed that
pickup gave "you can only lift some of the some <foo> corpses".

This fix is far from perfect.  farlook can still say "some <item>s"
but lookhere and pickup always say "N <item>s".  Picking up a stack
while blind will show "N <item>s" in inventory display, but dropping
it while still blind will revert to "some <item>s" for farlook.
2016-08-13 11:17:32 -07:00
PatR
b49830f4c1 fix #H4462 - grammar in corpse eating message
"The the Wizard of Yendor corpse tastes terrible."

"The" was supplied when formatting the sentence, "the" when formatting
the corpse object.  Same applied to several other monsters, those
flagged as unique and without personal name (Oracle, Cyclops, others).

This also changes the corpse eating message to not always specify the
taste as "terrible" when the eater is omnivorous.

It also makes corpses (and tins) of unique monsters be wishable in
wizard mode.  I had killed the Wizard at least half a dozen times
without a corpse being left, so used wishing instead.  Later retries
did finally leave one--lack of corpse turned out to just be by chance.
2016-08-03 17:59:10 -07:00
PatR
6632c380f3 fix #H4457 - grammar nitpick
"Your pair of speed boots glow silver for a moment." should be
"Your pair of speed boots glows silver for a moment.".  The fix
reverses a post-3.6.0 change to is_plural().  Also, add new
pair_of() to test for object formatted as "pair of Bars".  For verb
usage, that's definitely singular, but for pronoun usage, sometimes
plural seems better (although it might actually be incorrect).

I fixed up the formatting of a block comment in obj.h, but it is
still a candidate for tab cleanup.
2016-07-30 01:19:44 -07:00
PatR
1af081edc5 fix #H4388 - wishing conduct inconsistency
Make wishing for an artifact and not getting it because it already
exists break never-wished-for-artifact conduct.  The wish was made
even if the result wasn't what the player wanted.
2016-06-16 22:01:27 -07:00
Pasi Kallinen
8240db3445 Show in inventory which monster a leash is attached to 2016-06-02 16:35:21 +03:00
PatR
c68dfe8f52 wishing fix
rnd_otyp_by_namedesc() had an off by one error when choosing which
matching item to return, making it impossible to successfully wish
for the Amulet of Yendor, always yielding the plastic imitation.
  n == 2, maxprob == 2
  prob = rn2(maxprob); => 0 or 1
  i = 0; while (i < n - 1 && (prob -= ... + 1) > 0) i++;
always exited the loop on the first test of the condition because
subtracting 1 from 0 or 1 never yielded a result greater than 0.

It's still suboptimal:  "amulet of yendor" should find an exact match
and should never return "cheap plastic imitation of amulet of yendor"
from the partial match.

I think biasing the choice among multiple candidates based on their
generation probabilities only makes sense when all the candidates are
within the same class.  If scroll of light occurred in 5% of scrolls
and spellbook of light occurred in 10% of spellbooks (both percentages
pulled out of thin air), having "light" get a 2 out 3 chance to be a
spellbook doesn't seem right because scrolls are four times more
likely than spellbooks (in most of the dungeon; books aren't randomly
generated at all on the rogue level or in Gehennom).
2016-05-31 05:35:56 -07:00
Pasi Kallinen
e37da61b30 Fix valgrind complaints of uninitialized memory 2016-05-23 16:21:36 +03:00
PatR
1a47273ad5 formatting: tab removal 2016-05-20 17:01:40 -07:00
PatR
2f7a67483f fix bz424 - cannot wish for different size globs
Globs of pudding maintain an item quantity of 1 but vary in size
based on weight.  xname() formats with prefix of "small", <nothing>,
"large", and "very large" depending upon weight but wish processing
didn't recognize the prefix strings and reported "nothing fitting
that description exists".  Make wishing handle "small" (which is
actually the default), "medium" (since <nothing> isn't the default),
"large", and "very large".  They get ignored if the item isn't a
"glob of {gray ooze, brown pudding, black pudding, or green slime}".

Also, clean up recently added rnd_otyp_by_namedesc().
2016-05-09 18:56:31 -07:00