Commit Graph

3469 Commits

Author SHA1 Message Date
nethack.rankin
5a874440a0 truncating string copy
The majority of our calls to strncpy are in the form
  (void) strncpy(dst, src, n);
  dst[n] = '\0';
so add a new routine, copynchars, which does that.  A few calls care
about strncpy's return value and at least one relies on it only copying a
substring without also terminating the output, but most don't care about
either and none seem to care that `n' ought to have type size_t instead of
int.  The new routine matches our usage better, but I haven't gone through
to change the existing strncpy calls.
2007-03-06 03:00:05 +00:00
nethack.rankin
2adc83e145 revised ascension bonus (trunk only)
Part of the final score is doubled for ascension.  Some players use
helm of opposite alignment in order to offer and ascend at the first astral
altar they reach.  This limits the score doubling to ascending with your
original alignment intact, penalizing (for the subset of players who care
about score) alignment manipulation.  Converting to a second alignment and
then using a helm of opposite alignment to switch back and offer to hero's
original deity yields a smaller bonus (one-and-a-half instead of doubling).
Offering to either of the other deities (either via permanent conversion
or temporarily switching via helm or both) gets no score bonus.
2007-03-04 02:18:59 +00:00
nethack.rankin
d70d44b67f pets accompanying ascension or dungeon escape
There was a report recently about "<pet> is still eating" coming out
on the console at end of game for player using X11 or Qt.  That happened
because the end-of-game pet handling takes place after the message window
has been closed.  It won't happen with the dev code any more because eating
no longer prevents pets from accompanying on final ascent or escape.  But
a pet carrying the Amulet should still fail to tag along and yield similar
result.  However, levl_follower() was changed (probably by me...) to have
pets not attempt to follow when they carried the Amulet, rendering code
in keepdogs()--which reported them as being confused--unreachable.  This
reverts levl_follower() to have Amulet-carrying monsters other than the
Wizard try to accompany the hero during level changes (and keepdogs still
prevents them from succeeding).  It also reorganizes keepdogs() a bit,
giving trapped followers an extra chance to escape from their trap and
preventing those who fail that chance from tagging along (previously,
non-pets ignored being trapped).

     After doing that, I got tty to behave similarly to the X11/Qt report:
a message behaved strangely.  In my case, it was delivered between a pair
of clearings of the screen and only visible by using terminal emulator's
scrolling buffer.  I think there's a wait_synch() missing somewhere, but
haven't tried to figure out where.  Instead, this makes the end-of-game
call to keepdogs() take place sooner, while pline() still works normally.
2007-03-03 06:20:14 +00:00
nethack.rankin
06853548e0 decl.{c,h} bookkeeping tidbit
Move the declaration of `current_wand' to where the other struct obj
pointers are, after decl.h's `#include "obj.h"'.
2007-03-03 05:07:53 +00:00
nethack.rankin
4091076bb8 questpgr followup 2007-03-03 04:56:33 +00:00
nethack.rankin
e3229e6d3b questpgr support for special level arrival messages (trunk only)
Suggested by <email deleted>.  The level compiler allows
MESSAGE directives to provide text given upon initial entry to particular
levels.  Modify the code that delivers them to support quest pager text
substitution.  It could also be tweaked to support deliver-by-popup-window
in addition to deliver-by-pline, but I didn't go that far.

     He also suggested revising the message for the Plane of Air, but it
seems ok to me.  Instead, I've changed the message for the Astral Plane to
announce that it holds "the High Temple of <your deity>" rather than the
quite lame "the High Temples of the aligned gods".
2007-03-03 04:51:47 +00:00
nethack.rankin
23eb08a462 shop bones
Dying at a shop doorway, or at the free spot one step in, while not
owing the shopkeeper anything would yield "<shk> gratefully inherites all
your possessions" but leave those possesions where the next hero could
just pick them up for free.  Move them all the way inside the shop, as
happens when the hero dies while owing the shk.  Also, if hero has gold
left after shopkeeper takes any payment owed, force it to go into shk's
inventory instead of having it end up in the pile of other stuff.

     finish_paybill() duplicated much of drop_upon_death(), but not the
two-weapon hack to avoid curse() causing hero's secondary weapon to be
dropped while in the midst of removing it from inventory (but unlike the
old 3.4.1 panic for that, this one just triggered a warning about nonzero
worn mask).  It also lacked the named fruit fixup, whatever that does.
Make finish_paybill() call drop_upon_death() instead of copying it.
2007-03-02 03:28:25 +00:00
nethack.rankin
c5450cbe5e hangup revisited (trunk only)
More SAFER_HANGUP tweaking.  Delay its kicking in until main command
loop has been reached, and shut if off again once program is terminating.
2007-03-01 03:33:12 +00:00
nethack.rankin
a6b8d773de wizard mode wishing - moat & traps
When wishing for terrain, allow type "moat" as well as "pool".  And
when wishing for a trap, verify that trap creation succeeded instead of
always reporting that the requested type was made.
2007-02-27 04:59:25 +00:00
nethack.rankin
2dc918a6c4 exploding potion of acid left in bones
Noticed while looking at the dipping code:  #dip at a pool location
gives the chance to dip into the pool, and dipping a potion of acid into
such causes the acid to explode, causing damage and posibly killing the
hero.  Use-up handling was being done after the dip had finished, so the
potion would remain in final inventory during disclosure and end up in
the resulting bones file if there was one.
2007-02-24 05:45:34 +00:00
nethack.rankin
521469f27b mind flayer vs ghost (trunk only)
There's newsgroup discussion about a mind flayer sucking the brains
of a ghost, plus speculation that the fix for C343-121 has already taken
care of it.  I agree with them that ghost's brains are too insubstantial
to be hit by brainsuck damage from mind flayers' tentacles.  C343-121 is
vague enough to cover this; the corresponding fixes entry was more specific
and is augmented here.
2007-02-24 04:59:43 +00:00
cohrs
c99c3459c8 saved game memory initialization (dev only)
Qt windowport crashed on startup because a couple alloc() calls in files.c
were not zero'ing out the memory afterward.  This resulted in uninit'd
memory access if there were no saved games.  This bug is in new dev code.
2007-02-23 03:44:50 +00:00
nethack.rankin
bbee88dca3 fix #H248 - 'speed monster' zap message not always necessary
From a bug report:  zapping wand
of speed monster (or slow monster) at an immobile monster would give the
usual '<mon> is moving faster" (or slower) message even though the monster
couldn't move at all.  This fixes that for monsters who can never move
and also for monsters who are temporarily paralyzed or asleep, although I
wonder whether speed change magic ought to also snap the latter out of it.
2007-02-23 03:13:37 +00:00
cohrs
c0418d52d6 status hilite bits
I noticed an unused array and missing ifdef in generic hilite code.
2007-02-22 16:19:04 +00:00
nethack.rankin
dae9a9de82 directions (trunk only)
Some groundwork useful for the interface code I've been working on.
If we already have some direction to name-of-direction code somewhere, I
couldn't find it.
2007-02-22 05:24:05 +00:00
nethack.rankin
dd66bff416 couple of #tipping bits (trunk only)
Adjust some post-3.4.3 code.  Give feedback if you try to use #tip
on a statue--since it's a form of container, simple "nothing happens"
seems inappropriate.  (Unfortunately, the alternative used here isn't
much better.)  Also, you can use #tip to empty an inventory container
while swallowed; it was giving inappropriate levitation and drop-on-altar
behavior in that situation.
2007-02-22 05:16:58 +00:00
nethack.rankin
2feff50e33 lockpicking while engulfed
You can't begin or resume locking or unlocking a chest on the floor
while swallowed by a monster, but you could lock or unlock an adjacent
door in that situation.
2007-02-20 02:32:50 +00:00
nethack.rankin
e92b72dee5 surviving drawbridge destruction
From a bug report:  you could end up
standing on water/lava if you survived being on an open drawbridge while
it was destroyed.  This fixes the bridge destruction case; opening and
closing are handled differently and I left them alone.
2007-02-20 01:45:19 +00:00
nethack.rankin
4f528f2a7d #force fixes
Trunk and branch, noticed while working on an interface enhancement:
you could use #force to break the lock of a chest that's on the floor
while you're engulfed, also while levitating or mounted w/o riding skill.

     Trunk only:  refine an earlier fix that bills for breaking the lock
of a shop-owned chest.  The item which the hero is forced to buy showed
up in the bill as unlockable, which is accurate after the fact but didn't
reflect the shop's item.  Fix by billing for chest before altering it.
2007-02-18 05:54:15 +00:00
nethack.rankin
db8db39f60 #tipping empty bag of tricks bit (trunk only)
Check in something from a month ago before I manage to lose it.
2007-02-18 05:29:21 +00:00
nethack.rankin
6712785369 explore/wizard mode docs (trunk only)
Update the brief explore mode section (it hasn't been a conditional
feature for quite some time, there's an extra way to access it now, and
new game started with -X is different from switching via the 'X' command)
in the Guidebook, and add a short debug mode subsection there.
2007-02-18 04:49:19 +00:00
nethack.rankin
1e7ace58f7 polyself weapon drop feedback
Don't say "you must drop your weapon" when it doesn't actually get
dropped.  And make "weapon" be more specific, comparable to the handing
for slippery fingers.
2007-02-18 03:33:43 +00:00
nethack.rankin
12cb6f5afe more wielded, in-use leash
Slippery fingers would cause a wielded, in-use leash to be dropped
without first unleashing.  The fixes entry for the polyself case applies
to this one too:
dropped wielded, in use leash should remain in inventory, since it's in-use
2007-02-18 03:24:58 +00:00
nethack.rankin
7abf238f1b probing vs Schroedinger's Cat (trunk only)
Someone in the newsgroup complained about zapping probing at a large
box dropped by a quantum mechanic and being told that it was empty rather
than that it held a corpse or live cat.  This sidesteps the issue by
reporting "the box seems empty" instead of "the box is empty", and not
setting its contents-known flag.  (That message is the main difference
between probing and the assorted other methods of observation [telepathy
and monster detection and possibly Warning for live cat, object detection
and food detection for dead cat's corpse] which might be expected to
trigger the cat's fate but don't.)  This also makes probing of self and
of monsters set the contents-known and locking-known flags for containers
in inventory, same as is done for probing which hits objects.  (Display of
container contents still only occurs for loose objects, not in inventory.)
2007-02-18 02:20:59 +00:00
nethack.rankin
0ceebfc4b5 nethack -X vs normal game (trunk only)
Reported to the beta-testers list by <Someone> last April:
restoring a normal game save file in explore mode let you keep the file,
then after exploring and quitting without saving, you could restore it
again in normal mode and take advantage of whatever information you'd
gained.  This makes nethack -X (or playmode:explore) defer the switch to
explore mode when used while restoring a normal mode save file.  It now
performs a normal restore (with save file deletion) and then acts as if
the user had given the 'X' command interactively, requiring confirmation
to actually switch into explore mode.
2007-02-17 05:43:18 +00:00
nethack.rankin
43f72cc357 yet more wizard mode handling (trunk only)
Reorganize the recent wizard mode control:  move set_playmode() from
xxxmain.c to the core, and have it call new authorize_wizard_mode() to do
the port-specific part.  If the set_playmode() call during startup doesn't
result in running in wizard mode (either because not allowed or user
didn't request it), it will be called again during restore if the save
file is from a wizard mode game.

     For ports which check character name for authorization, players will
have to use `nethack -u whatever -D' (or options for name and playmode) to
restore a wizard mode save file if WIZARD has been changed from "wizard".
plname[] from a wizard mode saved game will always have that value, so if
it's not the right one players will need to get authorized by the startup
code before loading the save file.
2007-02-17 05:25:36 +00:00
nethack.rankin
1659dd5634 more wizard/explore mode control (trunk only)
Wizard mode or explore mode can be forced on (via -D or -X on the
command line, or now via OPTIONS=playmode:debug|explore) when restoring
a saved game; explore mode handling was confined to restgamestate(), but
wizard mode handling was replicated in every main().  Treat `wizard' the
same as `discover'.  Also, prevent a new game started when restore fails
from using the old game's option settings if partial restore attempt got
far enough to load the flags struct.  And update bemain.c and macmain.c
to catch up with the others modified by the playmode patch.
2007-02-16 02:35:30 +00:00
nethack.rankin
5c0a06d6b0 OPTIONS=playmode:normal|explore|debug (trunk only)
[see cvs log for src/options.c for some additional info]
     Relief for the command-line impaired.  Allow player to request
explore or wizard mode via run-time config file or NETHACKOPTIONS.
Validation is left to xxxmain() and has been updated for Unix, VMS, and
ports which share pcmain.  Mac and Be appear to allow any user to access
wizard mode, and may not need any modification, although they'll continue
to have the old buglet of running with both wizard and discover flags set
if player uses `nethack -X -D'.  This may or may not work as-is for the
Qt interface depending upon whether it goes through one of the xxxmain()'s
mentioned above [someone needs to make sure that it doesn't allow Qt on
Unix to bypass the (username == WIZARD_NAME) test when user requests
wizard mode].
2007-02-15 05:22:54 +00:00
nethack.rankin
293d984946 OPTIONS=playmode:normal|explore|debug (trunk only)
Relief for the command-line impaired.  Allow player to request
explore or wizard mode via run-time config file or NETHACKOPTIONS.
Validation is left to xxxmain() and has been updated for Unix, VMS, and
ports which share pcmain.  Mac and Be appear to allow any user to access
wizard mode, and may not need any modification, although they'll continue
to have the old buglet of running with both wizard and discover flags set
if player uses `nethack -X -D'.  This may or may not work as-is for the
Qt interface depending upon whether it goes through one of the xxxmain()'s
mentioned above [someone needs to make sure that it doesn't allow Qt on
Unix to bypass the (username == WIZARD_NAME) test when user requests
wizard mode].

     playmode:discov[ery] is a synonym for explor[e] and playmode:wizard
is one for debug.  Using -X or -D on the command line overrides any
config file or environment playmode value.  (We might want to add -N or
something to force normal mode when config/env specifies something else.)

     This suffers from the same bug as `nethack -X' and `nethack -D':  a
player can save a game in normal mode, then restore in explore or debug
mode and choose to retain the save file, obtain information about the
current game (identifying inventory or using enlightenment or mapping out
previously visited levels and so on), quit, then restore the original save
file normally in order to take advantage of the undeserved information.
2007-02-15 05:21:24 +00:00
nethack.rankin
658c931aad wielded leash, monster bullwhip use
Simplify <Someone>'s patch (the part for the secondary weapon wasn't and
still isn't needed since dual-wielding can only occur when both primary
and alternate weapon slots contain weapons or weapon-tools, but we might
as well keep it).  There was at least one other case where wielded in-use
leash could be removed from inventory without becoming unleashed first:
a bullwhip-wielding monster could snatch it away.

     That lead to some other whip issues:  monsters who select disarming
via bullwhip as miscellaneous strategy had 80% chance of not using it on
any given turn, but had no chance to select another misc strategy on such
turns--they always resorted to ordinary nonMUSE behavior and usually just
attacked.  The adjacency check missed diagonal locations, also would aim
the disarm attempt accurately even when displacement or invisibility made
the hero's precise location unknown.  [I took the easy way out here and
only let them try to disarm when they know the hero's location.  It's
tempting to aim at the guessed location and sometimes accidentally disarm
a nearby monster, but disarming is an action which targets a particular
weapon rather than just a location.]  Lastly, disarming always targetted
hero's primary weapon, never a dual-wielder's secondary one.
2007-02-13 04:54:35 +00:00
cohrs
2fde3bce8e polymorph dropping in-use wielded leash part 2
forgot to handle the twoweapon case, and messed up the test logic (which
appeared to work in previous, incomplete testing)
2007-02-12 21:40:16 +00:00
cohrs
5c3651e055 polymorph dropping in-use wielded leash
From a bug report, if you polymorph into
something, like a killer bee, that causes you to drop your weapon, but the
weapon is a wielded, in-use leash, the leash would be dropped but retain
it's in-use state.  However, the leash was tied to you, so it seems it
should remain attached, just unwielded, just as it would if it hadn't been
wielded.  I've changed the behavior to do this.  I wonder whether one
should be able to wield an in-use leash.
2007-02-12 21:25:52 +00:00
nethack.rankin
0b95104f0e fix #Q417 - gelatinous cubes can engulf Rider corpses
From a bug report:  gelatinous cubes
could engulf Rider corpses, allowing g.cube and cargo to be teleported
away without triggering corpse revival, or to be hit with theft attack by
poly'd hero to get the corpse into inventory so it could then be put into
a container in order to prevent revival (or to be destroyed via bag of
holding explosion or cursed access).
2007-02-11 03:59:08 +00:00
nethack.rankin
aa97ea65b1 umpteenth hangup bit
From a bug report:  hangup during
screen updating at tail end of successful restore didn't create a new
save file when disconnecting.  Use his suggestion for moving the setting
of program_state.something_worth_saving sooner, before the save file is
deleted.  To do that, restlevelstate() needs to come sooner too.  I think
this is safe enough to include in the branch code.

     For the trunk, I'm not sure whether the SAFERHANGUP config will work
well here.  It has to survive long enough under autopilot to enter moveloop
before the chance to save kicks in.
2007-02-11 03:36:15 +00:00
nethack.rankin
a9b7b19b95 more jumping (trunk only)
Allow jumping via spell when hero or steed has wounded legs.
Otherwise the previous fix for immobilized steed--and the existing code
requiring limbs for physical jump but not for spell jump--is inconsistent.
2007-02-11 01:50:56 +00:00
nethack.rankin
2343e77eb0 fix #Q382 - jumping possible while riding a sleeping pet (trunk only)
From a bug report:  when riding,
#jump command and jumping spell didn't check whether steed is able to move.
This makes #jump command, either magic boots or knight's innate ability,
fail if the steed can't move.  Spell still succeeds; its magic overrides
steed's immobility.  Fix is trunk only since it relies on a function that
isn't in the branch.

     Also, tweak hero movement to avoid an extra function call per move
when not riding.
2007-02-11 01:33:26 +00:00
nethack.rankin
00fc519903 sleeping gas trap vs steed
Noticed while checking out the report that you can #jump when riding
a sleeping steed:  hero's sleep resistance or magical breathing prevented
sleeping gas traps from hitting steed.  "You are enveloped in a cloud of
gas" but your steed is untouched?  That didn't make sense.
2007-02-11 01:23:28 +00:00
cohrs
33fde404e7 gcc compilation warning bits 2007-02-10 17:37:17 +00:00
cohrs
10e24ceeae H238 - spelling of Dr Dolittle 2007-02-10 17:30:24 +00:00
cohrs
fe43698867 Q387 - grammar fixes in Samurai quest
"Wakarimasu?" should be "Wakarimasu ka?"
2007-02-10 16:31:14 +00:00
nethack.rankin
7c64dbaf83 fix #Q404 - monster wielding cursed corpse
From a bug report, applying a bullwhip
towards a monster to try to steal its weapon would report that a cursed
cockatrice corpse was welded to the monster's hands even though corpses
wielded by the player never become welded.  Code for monsters deciding
what to wield knew that corpses don't weld; everywhere else seems to
assume that they only wield weldable weapons.  Add a routine to check
whether a wielded item is welded, similar to what's done for the hero.  I
fixed a couple of other spots besides use_whip() but didn't hunt all over.
2007-02-10 05:14:22 +00:00
nethack.rankin
262c1780b6 typo in previous patch 2007-02-10 04:19:41 +00:00
nethack.rankin
c937cc0091 finish_map prototype
There's a newsgroup posting about building for Windows using minGW
(gcc) within the cygwin Unix emulation environment, and it includes diffs
for the changes used.  One of the items being patched is a straight source
bug triggered by altering the definition of `boolean'.  finish_map()'s
prototype doesn't match its definition (uses boolean args but has XCHAR_P
in the prototype).
2007-02-10 04:18:52 +00:00
nethack.rankin
4168718d5d fix #Q159 - segfault with super long item names
From a bug report, putting an object with
really long specific and type names into a container with really long
specific and type names caused the program to crash.  pline() overflowed
the buffer it formatted into, and even though it was able to send that
for output and trigger a --More-- prompt, eventually a segfault occurred.
Give vpline and vraw_printf a much bigger working buffer, then truncate
the formatted text to BUFSZ - 1 characters so that we don't just push the
long line trouble into the separate interfaces.
2007-02-10 04:05:47 +00:00
nethack.allison
a83e2ba4a4 Q416 kicking gold (trunk only)
<email deleted> on Monday, January 29, 2007:
>Hero is able to kick a pile of gold (say, 100) and have the entire pile move at
>once in the same direction; very easy to avoid gold on traps.  Kicking gold
>should probably scatter the pieces in multiple directions or at least not be
>quite so easy.
2007-02-10 02:02:49 +00:00
nethack.rankin
eabf0f649e fix #Q367 - tinning Rider corpse when level is full
From a bug report:  if you try to tin a
Rider's corpse and revival fails, you still get the gimicky message about
War not preserving his enemies.  Give the suggested alternate message in
that case:  The corpse evades your grasp.  I hope that we can do better
than that, but I'm too burned out to think of anything.
2007-02-09 01:35:41 +00:00
nethack.rankin
c2a3a3a38b fix #H239 - doppleganger/mimic bug
From a bug report:  a shapechanger
which becomes a mimic would always stay as 'm' rather than take on object
or furniture shape.  Same applied to monsters which hide in other ways.
The code did that deliberately, but I don't think that it's actually
necessary so this lets them mimic/hide when they're in the right shape.
If they change form to non-mimic/hider while concealed, concealment ends.

     It would be fun to have shapechangers-as-mimics actually change their
mimicked shapes periodically, but this doesn't do that.  They'd probably
change to non-mimic quicker than they'd mimic something else so it's not
worth the effort.
2007-02-09 00:25:47 +00:00
nethack.rankin
1fe4018f3b fix #Q295 - post-choking food side-effects
From a bug report, but
just received:  if you choked while eating a cockatrice egg and survived,
the turn-to-stone sequence wouldn't be initiated.  For such eggs, turning
to stone starts when the food is finished rather than when it's started,
and fpostfx() wasn't called for food that triggered choking so the egg
went away without actually being finished.  Fortune cookies, lumps of
royal jelly, and a few other things suffered from the same situation.
2007-02-08 23:33:14 +00:00
nethack.rankin
8c982b0e05 typo in chest description
From a bug report:  "The" should be "Then".
2007-02-08 20:46:01 +00:00
nethack.rankin
e46663e456 weapon rustproofing status
From a bug report, hitting a rust monster with a
fireproof--but not identified as fireproof--weapon caused the rknown bit
to become set, identifying the item as fireproof.  That would also happen
for a monster's anything-proof weapon if it hit a rust monster, whether
you could see it happen or not.  The code involved is convoluted; I hope
this fix is correct.
2007-02-08 07:06:39 +00:00