PatR [Thu, 5 Mar 2020 21:55:45 +0000 (13:55 -0800)]
avoid #wizrumorcheck crash on bad rumor input
If either rumors.tru or rumors.fal was empty when makedefs made
'rumors', init_rumors() will set true_rumor_size to -1 to indicate
that rumors aren't available. It also closes the input file, and
then #wizrumorcheck closed that again, triggering a crash in the
dlb code.
Fortune cookies and oracles work ok (just not very interesting)
when rumors aren't available. Only the check command had trouble
with that.
PatR [Sat, 22 Feb 2020 09:41:04 +0000 (01:41 -0800)]
fix github issue #302 - divide by 0 crash
The traceback points directly to the problem: divide by 0 happens
if the 'bogusmon' file only contains the "do not edit" line, which
would happen if 'bogusmon.txt' is empty. makedefs probably ought to
complain about that.
There is now one hardcoded bogus monster to fall back to: 'bogon'.
Random tombstone epitaphs report divide by 0 if their text source is
empty, but it is done by rn2() rather than rn2_for_display_rng() so
is just a warning for pre-release code. It would crash for release
version though.
I tried placing an empty engravings file and expected similar results
but didn't see any response. Not sure what that means.
After the fix, empty epitaph file yields blank result so graves that
want a random epitaph won't have any epitaph.
PatR [Mon, 2 Mar 2020 23:58:42 +0000 (15:58 -0800)]
Mister Fantastic's sea monster form
While polymorphed and underwater, an eel bite killed the hero who
rehumaized and crawled out of the water, then the eel continued with
its second attack and "wrapped itself around you" even though no
longer adjacent. That's a long reach....
| ...@.
| .;}..
| .}}..
Make any additional attacks silently miss if hero changes location
during the attack sequence of a monster who has pinpointed the hero.
PatR [Mon, 2 Mar 2020 23:16:50 +0000 (15:16 -0800)]
conditional status condition tracking
If 'sinking-into-lava' is disabled as a displayed status condition
but general 'trapped' is enabled, then display 'trapped' when in lava.
Similarly, if 'grabbed-by-eel' is disabled but more general 'held' is
enabled, display 'held' when grabbed.
PatR [Mon, 2 Mar 2020 23:05:06 +0000 (15:05 -0800)]
panictrace_libc
Try to make the tracebacks generated via PANICTRACE's libc method
be more readable. There tends to be a lot of blank space in the
middle of lines, depending on the length of the program's or
libraries' file names, which can make lines wrap and the whole
thing sometimes be harder to make out. Narrow it by squeezing out
some spaces from each line before writing to reduce the chance of
line wrapping. That isn't guaranteed to make things ledgible but
seems to help quite a bit. Also, force the line number inserted
by nethack to be two digits so when spanning from line 9 to line 10
it doesn't cause the field positions to shift by a column. (Using
'#panic' doesn't have enough stack frames to illustrate that.)
I think the original libc formatting was designed for the address
column to hold a 32-bit value ('0x' prefix and 8 hex digits), and
eventually extending that to handle 64 bits ('0x' prefix and 16 hex
digits) made things wider than intended. But the gradual increase
in the length of function names we use is also a factor.
PatR [Sun, 1 Mar 2020 22:36:28 +0000 (14:36 -0800)]
fix github issue #309 - random role segfault
Role selection is insanely complex. I had to use a debugger to force
the relevant routine to be executed.
The analysis was correct: it could use rn2(14) to pick a role (valid
values 0 through 12) and randomly getting 13 would lead to a crash.
The terminating element of roles[] passes all the ok_role(), ok_race(),
etc tests. Explicitly exclude that element when collecting the roles
to choose from.
PatR [Sun, 1 Mar 2020 14:46:37 +0000 (06:46 -0800)]
throw-and-return vs !fixinv
Implement the request that a wielded+thrown aklys be given the same
inventory letter when it returns and is caught and rewielded, even for
the !fixinv setting where inventory letters don't stick. Works for
Valkyrie-thrown Mjollnir and returning (ie, didn't hit) boomerangs as
well as for aklys.
I'm not sure how useful this really is, because on the rare occasions
that it either doesn't return or fails to be caught, it won't be given
the same letter when subsequently picked up. So the player who relies
on it will still be vulnerable to using the wrong letter next time a
throw is attempted. But at least picking it up explicitly displays
the new inventory letter, unlike catching it upon return.
PatR [Fri, 28 Feb 2020 21:30:59 +0000 (13:30 -0800)]
haste timeout, vomit countdown feedback
Change a couple of messages. When speed/haste-self times out:
"you feel yourself slowing down" -> "you feel yourself slow down"
because the former was too close to the turn-to-stone countdown and
the loss of speed is immediate rather than gradual.
The vomiting countdown causes confusion and stun; vary the messages
for those if already confused or stunned:
"you feel slightly confused" -> "you feel slightly more confused";
"you can't seem to think straight" -> "you can't think straight".
PatR [Thu, 27 Feb 2020 19:51:10 +0000 (11:51 -0800)]
X11/winstat.c formatting
Separate out the reformatting from other changes I'm working on
for X11 "fancy status". Splits a few wide lines but mostly just
switches to the X11 idiom of combining
XSetArg(arglist[argcount], ...);
argcount++;
onto one line:
XSetArg(arglist[argcount], ...); argcount++;
Pasi Kallinen [Wed, 26 Feb 2020 17:55:53 +0000 (19:55 +0200)]
Demon lords and princes suppress teleporting in Gehennom
Instead of having the demon lair levels unconditionally no-teleport,
grant demon lords and princes the ability to suppress teleportation
in Gehennom on the level they are on.
nhmall [Wed, 26 Feb 2020 05:19:08 +0000 (00:19 -0500)]
February 2020 options.c overhaul
combine boolean and compound options into a single allopt[] array for
processing in options.c.
move the definitions of the options into new include/optlist.h file which
uses a set of macros to define them appropriately.
during compile of options.c each option described in include/optlist.h:
1. automatically results in a function prototype for an optfn called
optfn_xxxx (xxxx is the option name).
2. automatically results in an opt_xxxx enum value for referencing
its index throughout options.c (xxxx is the option name).
3. is used to initialize an element of the allopt[] array at index
opt_xxxx (xxxx is the option name) based on the settings in the
NHOPTB, NHOPTC, NHOPTP macros. Those macros only live during the
compilation of include/optlist.h.
each optfn_xxxx() function can be called with a req id of: do_init, do_set,
get_val or do_handler.
req do_init is called from options_init, and if initialization or memory
allocation or other initialization for that particular option is needed,
it can be done in response to the init req.
req do_set is called from parseoptions() for each option it encounters
and the optfn_xxxx() function is expected to react and set the option
based on the string values that parseoptions() passes to it.
req get_val expects each optfn_xxxx() function to write the current
option value into the buffer it is passed.
req do_handler is called during doset() operations in response to player
selections most likely from the 'O' option-setting menu, but only if the
option is identified as having do_handler support in the allopts[]
'has_handler' boolean flag. Not every optfn_xxxx() does.
function special_handling() is eliminated. It's code has been redistributed
to individual handler functions for the option or purpose that they serve.
moved reglyph_darkroom() function from options.c to display.c
PatR [Wed, 26 Feb 2020 00:04:41 +0000 (16:04 -0800)]
fix nhlsel.c warning
A recent change has resulted in complaints about 'sel' not being
used in
struct selectionvar *sel = l_selection_check(L, 1);
struct selectionvar *ret;
int p = (int) luaL_checkinteger(L, 2);
lua_pop(L, 1);
(void) l_selection_clone(L);
ret = l_selection_check(L, 1);
selection_filter_percent(ret, p);
This preserves the semantics of that code while getting rid of the
warning, but I have no idea whether it makes any sense.
PatR [Tue, 25 Feb 2020 01:07:01 +0000 (17:07 -0800)]
flipping current level with #wizlevelflip
Give wizard mode player control over how a level gets transposed by
prompting for the desired outcome.
Refreshing the screen showed that remembered, no longer in view wall
corners and T walls were shown with their old orientation instead of
being transposed along with the level. This fixes that, but does so
by adding a chunk of code that will be irrelevant for normal play.
PatR [Sun, 23 Feb 2020 01:40:55 +0000 (17:40 -0800)]
adopt github pull request #286 - rndmonst()
Eliminate the cache that was supporting rndmonst() and pick a random
monster in a single pass through mons[] via "weighted reservoir
sampling", a term I'm not familiar with.
It had a couple of bugs: if the first monster examined happened to
be given a weighting of 0, rn2() would divide by 0. I didn't try
to figure out how to trigger that. But the second one was easy to
trigger: if all eligible monsters were extinct or genocided, it
would issue a warning even though the situation isn't impossible.
Aside from fixing those, the rest is mostly as-is. I included a bit
of formatting in decl.c, moved some declarations to not require C99,
and changed a couple of macros to not hide and duplicate a call to
level_difficulty().
PatR [Sat, 22 Feb 2020 09:41:04 +0000 (01:41 -0800)]
fix github issue #302 - divide by 0 crash
The traceback points directly to the problem: divide by 0 happens
if the 'bogusmon' file only contains the "do not edit" line, which
would happen if 'bogusmon.txt' is empty. makedefs probably ought to
complain about that.
There is now one hardcoded bogus monster to fall back to: 'bogon'.
Random tombstone epitaphs report divide by 0 if their text source is
empty, but it is done by rn2() rather than rn2_for_display_rng() so
is just a warning for pre-release code. It would crash for release
version though.
I tried placing an empty engravings file and expected similar results
but didn't see any response. Not sure what that means.
After the fix, empty epitaph file yields blank result so graves that
want a random epitaph won't have any epitaph.
Pasi Kallinen [Thu, 20 Feb 2020 17:18:54 +0000 (19:18 +0200)]
Allow flipping levels horizontally or vertically
When a special level is created, there's a chance it gets flipped
horizontally and/or vertically.
Add new level flags "noflip", "noflipx", and "noflipy" to prevent
flipping the level. Add a wiz-mode command #wizlevelflip to test
the flipping on current level - although this doesn't flip everything,
as level flipping is meant to happen during level creation.
nhmall [Thu, 20 Feb 2020 06:22:27 +0000 (01:22 -0500)]
some more status condition follow-up
- Don't display 'Held' when swallowed.
- Don't display 'Held' when the hero is doing the holding; add a condition display
entry "UHold" for that (the opt_in option is "holding")
- Allow resorting of the 'O' menu for status condition fields. Default is alphabetical, but you
can sort by condition field ranking now.
PatR [Wed, 19 Feb 2020 23:47:55 +0000 (15:47 -0800)]
Wounded_legs condition
Mounting a steed while legs are wounded would offer to cure them
but wasn't going through the heal_legs() routine so didn't update
the status line when Wounded_legs condition is enabled.
Move some common code for describing left/right/both legs into a
new routine used for feedback by jumping, kicking, and ridiing.
For ^X, distinguish between one wounded leg and both but don't
bother with left vs right when it is just one.
PatR [Tue, 18 Feb 2020 21:33:00 +0000 (13:33 -0800)]
monster sound changes
MS_MOO was placed among the humanoid sounds, resulting in a minotaur
being able to articulate "I'm hungry". Move it to the animal sounds,
which causes almost all the sounds to be renumbered.
Give MS_MOO to rothes.
Change mumak from MS_ROAR to new sound MS_TRUMPET and mastodon from
silent to that.
I changed MS_ORC from a synonym for MS_GRUNT into a distinct type
which also just grunts. Grunt is in the animal group of sounds and
orc is now in the 'other' group (neither animal nor understandable
humanoid). [There are a bunch of other humanoid monsters (gnomes and
ogres, for example) that still use MS_GRUNT. They aren't animals so
that's not right.]
Have pets who beg for food but happen to have 'other' sounds between
animal and humanoid be described as looking hungry instead of being
skipped.
Hat tipped to a peaceful humanoid will behave as non-peaceful if
Conflict is active (without giving the monster a resistance check).
Despite mons[].msound getting new values, save files should be ok.
PatR [Tue, 18 Feb 2020 11:14:22 +0000 (03:14 -0800)]
fix #K376 - tipping cap
Allow #tip to do something if you pick your worn helmet instead of
a container. It's mostly just a variation of #chat but probably adds
several new bugs....
Patric Mueller [Mon, 17 Feb 2020 09:27:38 +0000 (10:27 +0100)]
Stop monsters from interacting with protected items on the floor
This fixes the issue of chests with the wand of wishing on the castle level
being stolen by soldiers.
Commit b12ea03d1 revealed that searches_for_item() didn't check for onscary()
and allowed monsters to pick up items even though they were protected by a
scroll of scare monsters.
PatR [Sun, 16 Feb 2020 21:04:12 +0000 (13:04 -0800)]
controlling u.ustuck
Setting or clearing u.ustuck now requires that context.botl be set,
so make a new routine to take care of both instead of manipulating
that pointer directly.