PatR [Thu, 19 May 2022 21:40:27 +0000 (14:40 -0700)]
lua 'index'
Having the preprocessor rename a variable called 'index' to one
called 'strchr' is not the source of any bugs (in execution; it can
cause pain when trying to ask a debugger to display the value and
then be told no such thing exists). Change the name to 'indx' to
avoid any confusion.
If we switch to strchr() we should still avoid using 'index' as a
variable name.
PatR [Wed, 18 May 2022 08:17:14 +0000 (01:17 -0700)]
context-sensitive inventory item-action split
When picking an item from inventory and then picking 'I - adjust
inventory by splitting this stack' in the item-action menu,
yn_function("Split off how many?") is used to start getting the
count without needing to wait for <return>. It includes the response
in message history (so review of history will see that first digit).
The code then uses get_count() to obtain any additional digits. Tell
the latter to store "Count: N" in message history if N is different
from the first digit.
That's not as good as updating message history to replace the entry
showing the prompt with the first digit with one that shows the full
count but at least it's accurate when the count is 10 or more.
PatR [Tue, 17 May 2022 23:52:06 +0000 (16:52 -0700)]
restoring in Gehennom
When a game is restored while hero is Gehennom, give the "It is hot
here. You smell smoke..." message after the welcome back message.
For both entering Gehennom and restoring there, switch from "smell" to
"sense" in the second part of that message if poly'd into a form that
doesn't have sense of smell.
Some unrelated stuff that got caught up in this diff:
1) move welcome()'s call to l_nhcore_call() to the start of the routine
instead of placing that after a potential early return;
2) remove a redundant glyphmap flags reset line; the routine being
called starts by setting its flags field to 0 for level change so
caller doesn't need to do that;
3) look_here() is just a formatting bit.
PatR [Mon, 16 May 2022 16:46:36 +0000 (09:46 -0700)]
cmap_walls_to_glyph() and a couple of others
I wasted a bunch of time yesterday trying to figure out why a maze
level in Gehennom wasn't being shown with orange walls and ended up
reformatting a few glyph handling macros while hunting for the problem.
It turned out that the wall color choosing was working as intended.
I was looking at a maze bordered by solid stone (pale blue with Qt's
tiles, unlike tty's blank space) rather than by walls.
Anyway, a couple of the macros have had a little bit of common code
factored out rather than just be reformatted so I'm putting this in.
[For future, maybe stone should be given branch-specific coloring
similar to walls?]
PatR [Mon, 16 May 2022 16:41:21 +0000 (09:41 -0700)]
fix segfault with #therecmdmenu
The change to add a menu choice for naming an adjacent monster via
\#therecmdmenu was unintentionally requiring that the monster have
monst->mextra. So it worked on pets (regardless of whether they
were already named) because they have mextra for 'edog' extension,
but not on the majority of monsters. And when it failed the program
would crash with a 'segmentation fault' error.
Fix the check for whether a target monster already had a name when
deciding to use "name <mon>" or "rename <mon>" in the menu entry.
PatR [Mon, 16 May 2022 08:30:00 +0000 (01:30 -0700)]
fix github issue #764 - misplaced corpses
Reported by jeremyhetzler and confirmed by k2: dead monsters weren't
leaving corpses at the spot they died.
Don't set a monster's mx,my coordinates to 0,0 when taking it off the
map (unless it is migrating to another level; mx==0 is the bit of data
used to indicate that). Corpse drop happens after that and expects
the dead monster's former map coordinates to be intact.
PatR [Sun, 15 May 2022 19:20:10 +0000 (12:20 -0700)]
pull request #763 - noxious nemeses
Pull request from vultur-cadens: some of the quest nemeses death
messages mention releasing noxious gas or noxious fumes so create
a poison gas cloud for them.
PatR [Sat, 14 May 2022 10:30:45 +0000 (03:30 -0700)]
migrating monster fix
The change to zero out a monster's map coordinates when it is taken
off the map yesterday messed up migration between levels inside the
Wizard's tower. (Didn't apply when accompanying the hero between
levels, so probably unlikely to be noticed.)
Noticed while moving some replicated code into its own routine.
PatR [Fri, 13 May 2022 23:47:00 +0000 (16:47 -0700)]
more writing novels
Instead of always retaining a blank spellbook when failing to write a
novel, make 2/3 chance to retain and 1/3 chance to destroy. Same odds
(but separate chance) to attempt to write the Great Yendorian Novel
versus awful fan fiction.
PatR [Fri, 13 May 2022 23:04:02 +0000 (16:04 -0700)]
pull request #761 - writing novels
Pull request by entrez: don't create a Pratchett novel by writing
"novel" or "paperback book" on a known blank spellbook with a magic
marker.
Blanking a novel produces a blank spellbook; there isn't any blank
novel. That's intentional. Writing "novel" on a blank spellbook
and getting a randomly chosen Pratchett one wasn't intentional.
Michael Meyer [Fri, 13 May 2022 15:53:58 +0000 (11:53 -0400)]
Prevent hero from writing Pratchett books
The hero's ability to channel Pratchett and write his books with a magic
marker once she had read or IDed at least one of them seemed strange,
especially cases like an illiterate hero doing it as her first
introduction to the written word. Block the hero from writing random
novels with a marker.
The image of the hero sitting down in the dungeon to write a novel is
funny, so it feels like a good spot for a funny message. I'm not
sure if what I have there is perfect, but it can always be changed.
PatR [Fri, 13 May 2022 21:46:02 +0000 (14:46 -0700)]
display former possessions of dead monster
Reported directly to devteam by a hardfought player and also by
entrez. The recent mon_leaving_level() change resulted in objects
dropped by a dying monster not being displayed immediately.
It justed needed the relobj(mon, 0, FALSE) to relobj(mon, 1, FALSE)
change in m_detach() but this does some related cleanup in
mon_leaving_level()'s callers. wormgone() takes a long worm off the
map but leaves its stale coordinates set because some code relied on
that. This takes away the need for that but still doesn't actually
clear them.
This adds redundant 'return' statements at the end of a few void
functions that are longer than fits within a typical screen display.
They make searching for the end of the current routine in an editor
or pager easier without resorting to regular expressions and can
also be used to search for the beginning if/when preceding routine
ends in 'return' too.
PatR [Thu, 12 May 2022 21:42:20 +0000 (14:42 -0700)]
un-macro some of display.h
I recently captured preprocessor output for a file and the amount of
code being expanded--and subsequently compiled--for canspotmon() was
quite an eye opener. This converts most of the macros it uses into
function calls. The resulting executable generated for OSX (built
for x86_64 and containing four interfaces) is about 5.5% smaller! and
there wasn't any difference in speed that I could notice.
The knowninvisible() macro has been in error for as far back as the
git logs go (which include those for the second cvs repository, so
over 20 years now).
PatR [Wed, 11 May 2022 20:12:25 +0000 (13:12 -0700)]
redundant "shopkeeper disappears" message
Reported directly to devteam by entrez, the rloc() monst vanishes/
appears nearby/&c message was being given before "satisified, <shk>
suddenly disappears" making the latter redundant. As discussed, the
fix isn't as simple as suppressing one message or the other because
both are given conditionally.
This seems to solve it but has only been lightly tested.
PatR [Tue, 10 May 2022 22:53:24 +0000 (15:53 -0700)]
redo magic whistle feedback
Give more information when magic whistle is already discovered and
applying it affects multiple pets, without much increase in verbosity.
For each of the three categories
1) was already in view and moves to another spot still in view,
2) was out of view and arrives at a spot within view,
3) was in view but gets sent to a spot out of view,
show the pet by name (which might be "your <monst>" if it hasn't been
named) when there is just one, or "two creatures", "three...", "four...",
"several...", or "many..." when there are more than one. The first
category with more than 1 says "creatures". When there are additional
categories with more than 1, their part of the message says "others" if
prior part(s) already mention "creatures", or it says "other creatures"
if the prior part(s) only list pets by name.
For example
|Three creatures appear.
|Fido shifts location and Fang appears.
|Your pony shifts location and two other creatures appear.
|Many creatures shift locations, several others appear, and two others
disappear.
|Two creatures appear and two others disappear.
PatR [Mon, 9 May 2022 10:21:53 +0000 (03:21 -0700)]
magic whistle fix
Restore old behavior of magic whistle causing pets to be moved to
different locations even when already adjacent to the hero.
This lets rloc() give its relatively new, more verbose messages if
a magic whistle isn't discovered yet but suppresses those when
already discovered in order to issue its own message. For a single
pet that starts within view and arrives elsewhere within view it says
"shifts location" rather than "vanishes and reappears". For multiple
pets, it gives one summary message instead of a separate one for each
pet affected by whistling.
if (linestart) {
if (SYMHANDLING(H_UTF8)) {
/* FIXME: what is actually in that line? is it the \GNNNNNNNN or UTF-8? */
g_putch(*cp);
} else if ((*cp & 0x80) != 0) {
g_putch(*cp);
end_glyphout();
}
linestart = FALSE;
} else {
(void) putchar(*cp);
}
The new code didn't output a character if linestart was true and the character did
not have bit 0x80 set.
fixed code:
if (linestart) {
if (SYMHANDLING(H_UTF8)) {
/* FIXME: what is actually in that line? is it the \GNNNNNNNN or UTF-8? */
g_putch(*cp);
} else if ((*cp & 0x80) != 0) {
g_putch(*cp);
end_glyphout();
} else {
(void) putchar(*cp);
}
linestart = FALSE;
} else {
(void) putchar(*cp);
}
nhkeni [Sat, 7 May 2022 21:45:36 +0000 (17:45 -0400)]
Lua sandbox
Change table format to handle functions never to be included.
Clean up bit masks and tables of functions.
Remove some old comments and out-of-date code.
nhmall [Sat, 7 May 2022 17:08:02 +0000 (13:08 -0400)]
some follow-up for MSDOS build
The preprocessor directives in win/tty/wintty.c were crossed-up
under MSDOS build. I think I got them straightened out now.
For a crosscompile situation, the tilemap utility (which runs on
the host) needs to produce an output src/tile.c that is compatible
for the target platform.
Don't use ENHANCED_SYMBOLS under MSDOS, for now anyway.
nhmall [Sat, 7 May 2022 14:25:13 +0000 (10:25 -0400)]
ENHANCED_SYMBOLS
A new feature, enabled by default to maximize testing, but one which can
be disabled by commenting it out in config.h
With this, some additional information is added to the glyphmap entries
in a new optional substructure called u with these fields:
ucolor RGB color for use with truecolor terminals/platforms.
A ucolor value of zero means "not set." The actual
rgb value of 0 has the 0x1000000 bit set.
u256coloridx 256 color index value for use with 256 color
terminals, the closest color match to ucolor.
utf8str Custom representation via utf-8 string (can be null).
There is a new symset included in the symbols file, called enhanced1.
Some initial code has been added to parse individual
OPTIONS=glyph:glyphid/R-G-B entries in the config file.
The glyphid can, in theory, either be an individual glyph (G_* glyphid)
for a single glyph, or it can be an existing symbol S_ value
(monster, object, or cmap symbol) to store the custom representation for
all the glyphs that match that symbol.
PatR [Sat, 7 May 2022 07:25:03 +0000 (00:25 -0700)]
fix github issue #752 - characteristics init
Issue #752 by vultur-cadens: initialization of characteristics had
off by one errors when reducing over-allocation and when increasing
under-allocation, biasing Str over Cha.
This simplifies the code very slightly but it still seems somewhat
confusing to me.
PatR [Sat, 7 May 2022 01:41:54 +0000 (18:41 -0700)]
autounlock parsing confusion
For char *next; don't compare (next = index(...)) != '\0'.
'\0' has value 0 and 0 used in a pointer context is a null pointer.
So the code worked as intended even though it wasn't written as
what was intended. Fix: take off the char decoration.
PatR [Sat, 7 May 2022 01:30:06 +0000 (18:30 -0700)]
busy hero ignoring monster threat
Fix the problem reported by entrez of a zombie corpse reviving and
crawling out of the ground while the hero was busy doing something
(searching, digging, &c) and having the hero fail to react and just
keep doing whatever the thing was because the zombie was already
inside the range where a monster changes from no-threat to threat.
Done in the monster creation routine so any new monster (including
one revived from a corpse) that is visible,&c will cause the hero's
action to be interrupted. Teleport arrival probably needs this too.
Only interrupts an occupation, not other voluntary multi-turn
actitivy such as running or traveling. That would be trivial to
change ['if (g.occupation...' to 'if ((g.occupation || multi > 0)...']
but I'm not sure whether it ought to be extended to that.
PatR [Fri, 6 May 2022 21:44:57 +0000 (14:44 -0700)]
autounlock:untrap
Implement 'untrap' as an 'autounlock' action. Quite a bit more work
than anticipated. The new documentation is rather clumsy; too many
if-this and if-not-that clauses have intruded.
I'll be astonished if all the return values are correct....
[A couple of places were checking for (rx != 0 && ry != 0) to decide
whether they were performating an autounlock action at <rx,ry> but
that erroneously excludes the top line of the map if the current
level extends that far. Just check rx for zero/non-zero.]
PatR [Fri, 6 May 2022 20:27:11 +0000 (13:27 -0700)]
minor trapped container changes
When probing a trapped container, report that it is trapped.
Done with a one-line message in the zap code and also in the title
of the contents display if it isn't empty.
For wizard mode wishing, if both "trapped" and "broken" are specified,
produce an untrapped container with a broken lock.
Also for wizard mode wishing, ignore "trapped" if player wishes for
"trapped secret door".
Michael Meyer [Wed, 22 Sep 2021 20:57:29 +0000 (16:57 -0400)]
Designate high altars with dedicated altarmask bit
High altars and normal temple altars had identical altarmasks, so
there was no way to distinguish between the two based on the altarmask
alone. Instead, anywhere it was necessary to determine whether an altar
was a high altar included a check whether the hero was currently the
Astral Plane or Moloch's Sanctum, and assumed any temple altar was the
high altar.
Since there's an extra, unused bit in altarmask anyway, use it to
explicitly mark high altars -- the lua level files already distinguish
between normal temple altars and so-called 'sanctum' altars anyway, so
rather than throwing away this distinction when generating the level,
keep it in the altarmask and use it in place of various u.uz checks.
I think this would require incrementing EDITLEVEL again...
PatR [Thu, 5 May 2022 02:13:28 +0000 (19:13 -0700)]
autounlock overhaul
This gives the player more control over what autounlock does. It is
now a compound option rather than a boolean, and takes values of
autounlock:none
!autounlock or noautounlock (shortcuts for none)
autounlock:untrap + apply-key + kick + force (spaces are optional
or can be used instead of plus-signs, but can't mix "foo bar+quux")
autounlock (without a value, shortcut for autounlock:apply-key).
Default is autounlock:apply-key.
Untrap isn't implemented (feel free to jump in) so is suppressed from
the 'O' command's new sub-menu for autounlock. It's parsed and
accepted from .nethackrc but won't accomplish anything.
[Just musing: it should be feasible to kick in direction '.' to break
open a container or #force to an adjacent spot to break open a door.
If that was done, autounlock:kick+force (or more likely autounlock:
apply-key+kick+force when lacking a key) would resort to force if hero
couldn't kick due to wounded legs or riding.
This changes struct flags so increments EDITLEVEL again.
This includes pull requests #750 from entrez and #751 from FIQ but was
entered from scratch rather than using use their commits.
PatR [Sun, 1 May 2022 22:09:17 +0000 (15:09 -0700)]
pets and portals
Extend pull request #737,
commit d6ab241b8c39830de41c61f6fc2df5760d239cb9, to magic portals.
If hero is on or next to a magic portal, have pets behave as if food
they want is being carried, like PR #737 did for hero standing on
stairs. (To be on one, hero must have come through from the other
side and not moved off the receiving portal yet, or else is in the
endgame but no longer carrying the Amulet.)
savelev() gets run to clean up memory even if the player quits before
level 1 is created, and a change made yesterday panicked if it couldn't
figure out what level the hero is on. Caught by entrez, again....
If not actually writing a level's file, don't panic if both u.uz and
g.uz_save are 0. Having one of those be non-zero is only essential
when the level being processed is the Plane of Water or Plane of Air.
It is astounding that after all this time no one noticed that
incrementing EDITLEVEL wasn't doing the job it's intended to do.
Diagnosed by entrez: since VERSION_COMPATIBILITY was defined as
3.7.0-0 and up, increasing the fourth component wasn't resulting in
old 3.7.0-x files being rejected.
This increments EDITLEVEL yet again, because my testing after
commenting out VERSION_COMPATIBILITY still wasn't rejecting older
files. Proably because the oldest I had available already had the
verison info with the preceding EDITLEVEL so weren't actually out
of date yet.
Once I had old files be rejected, I discovered that the rejection
message was invisible (for tty on OSX). The message line showed
spaces, matching the length of the intended message, followed by
--More--. This fixes that too.
It's possible to get a strange command result of ECMD_CANCEL+ECMD_TIME.
If/when that happens don't just treat it as cancel, make sure that time
elapses.
If an invalid command is provided, clear the do-again queue so that ^A
won't attempt to try the same invalid command again.