Commit Graph

2229 Commits

Author SHA1 Message Date
nhmall
67bc0a78ce Merge branch 'mextra-note' of https://github.com/copperwater/NetHack into copperwater-mextra-note 2020-07-31 08:25:42 -04:00
copperwater
922321b251 Add instructions to zero mextra struct pointer in mextra documentation
It doesn't mention anywhere that newmextra() is responsible for
initializing struct mextra with null pointers to the various
sub-structs. So, when one follows the instructions and doesn't know or
remember to do this, they'll get segfaults when something tries to read
the uninitialized pointer to their new struct.
2020-07-30 23:07:30 -04:00
PatR
c64049306d candy bar wrappers
Adopt the suggestion that candy bar stacks which get split should
keep the same wrapper text for both halves of the stack.  The patch
stuck with using obj->o_id to manage the wrapper which prior to the
patch wasn't a factor in merging and splitting.  Switch to obj->spe
instead, comparable to tin varities, so mergability is already
taken care of.

End of game disclosure tacks on T-shirt text to formatted items.
Do the same for candy bar wrappers.
2020-07-30 19:25:57 -07:00
PatR
827e40705d X11+Qt vs config.h
This lets combined X11 and Qt compile cleanly (when set up with
hints/macosx10.10-qt and built with 'make WANT_WIN_X11=1 USE_XPM=1')
but linking fails at present.  (It can't find X11 library routines
despite specifying the same -L/opt/X11/lib that X11 without Qt uses.
The C++ linker is being used but the code that calls those routines
is compiled as C, not C++ so name mangling shouldn't be an issue.)
2020-07-29 18:23:54 -07:00
PatR
afbcf3f9a9 monk's to-hit penalty for wearing a suit
If hero is a monk who is wearing a suit, have ^X mention the to-hit
penalty for that in the status section even though it isn't a normal
status line item.  Combat feedback makes it annoyingly obvious, but
player might forget if MSGTYPE=hide is used to suppress the "Your
armor is rather cumbersome..." message.
2020-07-20 03:00:28 -07:00
nhmall
9b58010880 turn off clang -Wshadow when processing some qt headers
removes recently added win/Qt/qt_undef.h and win/Qt/qt_redef.h
adds win/Qt/qt_pre.h win/Qt/qt_post.h
2020-07-18 08:31:51 -04:00
nhmall
84b598e489 get rid of some shadowed variable warnings with Qt under OSX
In file included from ../win/Qt/qt_bind.cpp:20:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:4:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qglobal.h:1302:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qflags.h:121:41: warning: declaration shadows a
      variable in the global namespace [-Wshadow]
    Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
                                        ^
[…]

../include/flag.h:390:29: note: previous declaration is here
extern NEARDATA struct flag flags;
                            ^
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:36:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qcache.h:191:15: warning: declaration shadows a
      variable in the global namespace [-Wshadow]
        Node *u = n;
              ^
../include/decl.h:219:23: note: previous declaration is here
E NEARDATA struct you u;
                      ^
[…]

In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:45:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qtextlayout.h:47:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qcolor.h:44:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qrgb.h:66:46: warning: declaration shadows a
      variable in the global namespace [-Wshadow]
inline Q_DECL_CONSTEXPR QRgb qRgb(int r, int g, int b)// set RGB value
                                             ^
../include/decl.h:1208:27: note: previous declaration is here
E struct instance_globals g;
                          ^
[…]

In file included from ../win/Qt/qt_glyph.cpp:21:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:48:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qpalette.h:107:49: warning: declaration shadows a
      variable in the global namespace [-Wshadow]
    inline void setCurrentColorGroup(ColorGroup cg) { data.current_group = cg; }
                                                ^
../include/decl.h:1216:30: note: previous declaration is here
E const struct const_globals cg;
                             ^
2020-07-16 22:20:23 -04:00
PatR
ee7fbc4a61 mind flayer vs headless target
When a mind flayer scores a hit against a headless target (or worm's
tail), there's a message that says that the attack hits and that the
target is unharmed.  Since an ordinary mind flayer has 3 such attacks
per turn and a master mind flayer has 5, it can become excessively
verbose.

This doesn't eliminate the attacks until a hit fails to do harm, so
ordinary misses still get repeated if they happen first.  Once a
successful hit doesn't do anything, any remaining AT_TENT+AD_DRIN
attacks are silently skipped.  That way feedback isn't as verbose
and mind flayers don't seem to be quite so stupid about using their
tentacles when those won't work.  Unfortunately they need to relearn
the lesson every turn they attack.
2020-07-14 05:43:51 -07:00
nhmall
77815e87ee follow-up to patchlevel and build status consolidation
Also remove redundant prototype of has_color in wintty.h now that
it is in extern.h.

has_color() became an actual function when an array of color capabilities
got added to the windowport interface a while back (it checks that array).
2020-07-07 21:00:11 -04:00
nhmall
8e945073aa clear up a couple of warnings
src\mapglyph.c(330): warning C4013: 'has_color' undefined; assuming extern returning int
src\options.c(4820): warning C4101: 'tmpwin': unreferenced local variable
src\options.c(4821): warning C4101: 'any': unreferenced local variable
2020-07-07 20:37:06 -04:00
nhmall
c95fe8c32b Merge branch 'NetHack-3.7' into header-order3.7 2020-07-07 20:10:25 -04:00
nhmall
2c571dcfe7 more outdated code move follow-up 2020-07-06 09:37:26 -04:00
nhmall
3cecb97da6 consolidate build status /patchlevel info settings in one place - patchlevel.h 2020-07-06 09:12:22 -04:00
PatR
34e11c0139 missing prototype for MONITOR_HEAP config
|alloc.c:159:1: warning: no previous prototype for function 'dupstr'

after adding -Wmissing-prototypes to my CFLAGS (plus MONITOR_HEAP
defined in config.h).

I don't why I never noticed this before.  It wasn't triggered by any
recent changes.
2020-07-06 03:51:15 -07:00
nhmall
6c0d522b1a relocate some more outdated code 2020-07-05 09:27:59 -04:00
nhmall
62d9c49338 fixes entry for removal of SYSFLAGS and MFLOPPY 2020-07-05 08:58:09 -04:00
nhmall
5a437b336a remove SYSFLAGS and MFLOPPY code
A check into github issue 364 confirmed that
ba6edbe5dc
had incorrectly updated the bwrite sizeof entry for sysflags.

The SYSFLAGS and MFLOPPY code is all in the outdated part of the tree, so just
remove it rather than re-correct it.

Closes #364
Closes #207
2020-07-05 08:50:13 -04:00
PatR
9c97bc44df more sokoban conduct
The initial implementation of sokoban conduct neglected xlogfile.
2020-07-03 03:20:25 -07:00
PatR
8801ec34eb fix github pull request #355 - Sokoban cheating
Track sokoban cheating (taking actions that incur a luck penalty).
The pull request only reported the number of times (possibly zero)
that the player broke nethack's sokoban rules when reporting the
"you obtained the Sokoban prize" achievement, which is when the
count is most meaningful, but this implements it as a full-fledged
conduct instead.  This way the #conduct command can be used after
"creative nethacking" to check immediately whether an action has
violated the Sokoban rules so a player willing to put in a bit of
effort can eventually learn which actions have a negative impact.

The new conduct is only shown during games where the character has
entered the Sokoban branch, but once that has happened it gets shown
no matter the location at the time of #conduct or end of game.

Most of this wasn't in the pull request:  expanding the Guidebook to
give more information about sokoban and its conduct.

Bump EDITLEVEL to invalidate to-be-3.7 save files because u.uconduct
has been extended.

Fixes #355
2020-07-03 02:21:30 -07:00
nhmall
e4b18f0545 fix github issue 361 to make user_sounds useful even if MSGTYPE is hidden
fixes #361

Also, experminental introduction of vt_sounddata to enable tty to pass
a sound file index to the terminal side of things where perhaps someone
can add code to something like hterm to take the information relayed by
NetHack to trigger user_sounds locally even if playing on a server.

Compile time option TTY_SOUND_ESCCODES required to build that support in.

It should be independent of TTY_TILE_ESCCODES.
2020-07-02 15:49:45 -04:00
PatR
bb566e8a04 fix stone-to-flesh on petrified long worm
montraits() didn't have any handling for long worm tails, makemon()
didn't have any provision for creating a long worm without a tail,
replmon() uses place_wegs() to put tail segments on the map when
replacing a dummy new monster with the mtraits one but place_wsegs()
wasn't updating the head segment since it isn't put on the map.

That turned out to be key because there is always an extra segment
co-located with the monster and when its coordinates were wrong,
worm_known() gave bad results for visibility checking.  The
statue-goes-away message was the one for not being able to see the
monster that it just animated into, even though 'w' appeared at the
spot.  It took quite a while to track down what was going on there.

Sanity checking for worms has been updated and could conceivably
start triggering complaints about things that it used ignore.
2020-06-03 03:00:13 -07:00
PatR
503df6823d fix github issue #354 - stealarm() impossible
A thieving monster could be killed while the hero was busy taking
off armor which needs multiple turns (normally a suit) and if that
happened on the same turn as the take-off finished, the warning
"stealarm(): dead monster stealing" was issued.  Cited case was
having the thief be killed by a stinking cloud but it could happen
if the death was caused by a pet or by some other monster trying
to attack the hero.  If the thief died sooner, the situation was
silently ignored.  So this could have been fixed by just getting
rid of the impossible() feedback.

'stealmid' and 'stealoid' should have been static in steal.c rather
than global and as such should have been moved into 'struct g'.
This moves them there and then takes advantage of having access to
'stealmid' outside of steal.c.  That's just a minor optimization
since m_detach() could call new thiefdead() unconditionally and the
latter could check whether the dead monster matches 'stealmid'.

Fixes #354
2020-06-01 06:17:07 -07:00
PatR
8a91a22df9 fix issue #351 - summoned critters while Hallu
If a monster uses the 'summon insects' spell (which will resort to
snakes if all 'a' class critters are genocided or extinct) while the
hero is hallucinating, report the summoning of something unusual
rather than of insects or snakes.  I bypassed "random creature"
direct to "hallucinatory creature" for the something unusual.

Fixes #351
2020-05-30 22:48:18 -07:00
PatR
54bea16f0e Revert "fix issue #351 - summoned critters while Hallu"
This reverts commit e430669f50.
It accidentally included my local config.h settings.
2020-05-30 22:35:35 -07:00
PatR
e430669f50 fix issue #351 - summoned critters while Hallu
If a monster uses the 'summon insects' spell (which will resort to
snakes if all 'a' class critters are genocided or extinct) while the
hero is hallucinating, report the summoning of something unusual
rather than of insects or snakes.  I bypassed "random creature"
direct to "hallucinatory creature" for the something unusual.

Fixes #351
2020-05-30 22:24:21 -07:00
PatR
8c1120261a fix github issue #352 - geno'd monsters in quest
The recent change to mkclass() was letting genocided monsters be
created when role-specific monsters were chosen for quest levels.

makemon(Null) -> rndmonst() -> qt_montype() -> mkclass() -> mk_gen_ok()
was accepting members of the quest-specified class even when they
should have been rejected.  I'm still not sure why the revised bit
manipulation didn't work as intended; the re-revised code does.

G_IGNORE was a bug waiting to happen since it gets passed to
mkclass() as a mons[].geno flag but is used to control the use of
mvitals[].mvflags values.  It's still being misused but at least
it doesn't conflict with any of the other flags now.

Fixes #352
2020-05-30 16:00:29 -07:00
PatR
e9f53ab7f6 fix #K1139 - corpse removed from ice box by monst
Rot and revive timers are turned off when a corpse gets put inside
an ice box.  They get turned back on when taken out of the ice box
by the hero but were being left off if taken out by a monster.
That resulted in corpses of arbitrary type behaving like lizard
corpses and never rotting away.

This fixes that.  It also changes troll corpse behavior.  Once put
in an ice box, a troll corpse will not get a new revive timer when
taken out, just an ordinary rot timer.
2020-05-30 13:33:16 -07:00
PatR
298331fe04 improved regexp handling
If regex_compile() fails, free the regexp before doing anything else
in case failure reason is "out of memory".  Feedback to the user is
highly likely to panic or crash after memory runs out; this should
let the regex failure message be issued and the game continue.

User sound regular expressions were never freed.  This frees them
when FREE_ALL_MEMORY is enabled.
2020-05-23 12:51:01 -07:00
PatR
41ae223585 hyphenated Unix user names
Fix for $USER, $LOGNAME, getlogin() values that have dashes in them:
keep dash and whatever follows as part of the name instead of stripping
it off for role/race/gender/alignment.

Before:
% USER=test-bar-fem ./nethack
|Shall I pick your female Barbarian's race and alignment for you?
and character ended up named 'test'.

After:
% USER=test-bar-fem ./nethack
|Shall I pick character's race, role, gender and alignment for you?
and character ends up named 'test-bar-fem'.  However,
% ./nethack -u test-bar-fem
still behaves like the 'before' case.
|Shall I pick your female Barbarian's race and alignment for you?

Dash handling is only changed when the dash comes from user name (or
from envionment overriding user name), not from direct player input
or run-time config file.
2020-05-12 16:38:12 -07:00
PatR
4ca707ecf4 fix -Wmissing-prototypes warning
drawing.c doesn't include extern.h, so the def_char_... functions
it defines aren't preceded by a prototype.  Having such guaantees
that code in other files sees the same argument types as in the
defining code.
2020-05-09 15:51:38 -07:00
PatR
59818fb6ab implement #986 - camera flash 'tweak'
Implement the suggested feature that a camera's flash actually update
hero's memory of the map as it traverses across the level.  Turned
out to be more work than anticipated despite having the code for a
thrown or kicked lit candle or lamp to build upon.

Among other things it needed to update the circle code to handle
previously unused radius 0 to operate on the center point only.  I've
never touched that before and hope this hasn't introduced any bugs.

Also removes several instances of vision code operating on column #0.
(At least one is still present.)
2020-05-09 13:07:35 -07:00
nhmall
d564fa8ac7 extern.h obsolete bit 2020-05-06 17:03:06 -04:00
nhmall
7178d2c9e2 extern.h updates to reflect drawing.c split 2020-05-06 16:40:24 -04:00
nhmall
aa3a859bef remove obsolete global variable declaration 2020-05-06 12:44:12 -04:00
nhmall
c831522e94 Xcode fixes 2020-05-06 11:35:55 -04:00
PatR
a51e44e532 move lua context out of dungeons[]
and out of save files so restore doesn't need to clear stale data.
Behavior should be the same as before, except that when entering
the endgame branch and discarding the main dungeon and its other
branches, lua theme context is now discarded for those too.
2020-05-05 18:06:00 -07:00
PatR
19529ffb2f extern.h bits
Clean up a few things I recently noticed:
  obsolete monstr.c was still present;
  mdlib.c was out of alphabetical order;
  monst_global_init() was listed under the wrong file.
2020-05-05 12:39:24 -07:00
PatR
116642ce1e track eight more achievements
Record reaching experience level 3, 6, 10, 14, 18, 22, 26, and 30,
the levels where the character gets a new rank title, and report
those as achievements at end of game.  These achievements persist
even if enough levels to lose a rank are lost, and if lost ranks
are regained the original achievement is the one that gets tracked
and disclosed.
2020-05-04 16:35:40 -07:00
PatR
16562b2892 displacer beast as food
Make eating a displacer beast corpse or a tin of displacer beast
meat confer temporary Displacement lasting 6d6 turns.
2020-05-04 09:50:11 -07:00
PatR
88461e1923 makemon and goodpos flags
I added another goodpos flag to simplify handling displacer beast
and that pushed the total number of makemon and goodpos flags past
16.  'int' and 'unsigned' might be too small, so change the flags
and several function arguments to 'long'.
2020-05-04 09:19:37 -07:00
nhmall
e440e9569d change is_safepet macro name
Leaving the word "pet" in the macro name, when it applied to non-pets
seemed too contradictory, even for NetHack.
2020-05-03 21:52:41 -04:00
PatR
b8da4e9294 amulet tiles
Replace the octagonal amulet placeholder for the two new tiles.
Give the "cubical amulet" a hint of being cube shaped and rename
"pentagonal amulet" to "perforated amulet" because it's easier to
draw that way.

Bump EDITLEVEL now for the extra objects and monsters because I
forgot to do so earlier.
2020-05-03 16:34:54 -07:00
PatR
7817e69c41 two new monsters from slash'em
Adds two monsters originally from slash'em.  I used the slash'em
tiles this time, also its code as a starting point but made various
revisions.  Both the tiles could benefit from some touch-ups.

displacer beast:  blue 'f'.  Attempting a melee hit (ie, trying to
  move to its spot) has a 50:50 chance for it to swap places with you.
  Fairly tough monster to begin with, then half your ordinary attacks
  effectively miss and if you try to face a mob by retreating to a
  corridor or backing into a corner you can end up being drawn back
  into the open.  I added bargethrough capability, and also it won't
  be fooled about hero's location by Displacement.  [It only swaps
  places during combat when contact is initiated by the hero, not
  when attacked by another monster or when attacking.]

genetic engineer:  green 'Q'.  Its attack causes the target to be
  polymorphed unless that target resists.  Hero will almost always
  have magic resistance by the time this monster is encountered, but
  it can make conflict become risky by hitting and polymorphing other
  monsters.  Slash'em flagged it hell-only but I took that flag off;
  I also took away its ability to teleport.  Slash'em polymorphs the
  hero if a genetic engineer corpse is eaten; that's included and I
  introduced that for monsters too.

I added both of these to the list of candidates for monster spell
'summon nasties' and for post-Wizard harassment.

I also gave all the 'f's infravision.  Probably only matters if the
hero polymorphs into a feline.

Displacer beast is originally from AD&D which depicts it as a six-
legged cougar with a pair of tentacles; it has Displacement rather
be able to affect an attacker's location.  I think genetic engineer
is original to slash'em where it expands Q class but seems mainly to
be the base monster for Dr.Frankenstein (a unique monster with a
one-level side-branch lair in slash'em's incarnation of Gehennom).
2020-05-03 14:13:08 -07:00
PatR
3c6deed5e9 eliminate hack.h usage from win/share/*.c
Switch win/share/*.c from hack.h to config.h plus miscellaenous
other headers.  It's possible that there is conditional code that
didn't get exercised in my testing.  The Unix Makefiles don't deal
with safeproc.c or tileset.c so I just compiled those without any
attempt to link.
2020-05-03 10:52:54 -07:00
PatR
8caaf894e5 makedefs vs dungeon.h
This works for me.  It might be better to move d_level into its
own header and include that instead including dungeon.h.
2020-05-02 16:50:50 -07:00
nhmall
e15b30e9c5 Revert "build fix for platforms that have no LUA awareness during makedefs compile"
This reverts commit eb704832a9.

That fix was insufficient.

The addition of
    lua_State *themelua;
to the dungeon struct in dungeon.h prevents the build of host-side utilities that
include "hack.h" via the CROSSCOMPILER_HOST. Unfortunately, it is no longer possible
to cross-compile NetHack 3.7. That includes the cross-compiled MSDOS build.
2020-05-02 17:17:40 -04:00
nhmall
eb704832a9 build fix for platforms that have no LUA awareness during makedefs compile
gcc -c -O -I../include -I../sys/msdos -DDLB  -DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_HOST -ohost_o/makedefs.o ../util/makedefs.c
In file included from ../util/makedefs.c:18:0:
../include/dungeon.h:68:5: error: unknown type name ‘lua_State’
     lua_State *themelua;   /* themerms compiled lua */
     ^
2020-05-01 20:36:11 -04:00
PatR
c17301a75c Sting vs level teleport revisted
This reverses all of c67f1dd710
except for the fixes37.0 entry and does a better job in a cleaner
fashion.  If Sting is going to start glowing and "you materialize
on a different level" is pending, give the materialize message
before the glowing message.  Otherwise handle both stop-glowing
and/or you-materialize in the normal fashion.
2020-04-27 10:49:34 -07:00
PatR
c67f1dd710 Sting vs level teleport's "materialize" message
When level teleporting, Sting/Orcrish/Grimtooth would start or stop
glowing based on occupants of the new level before "you materialize
on another level".  That wasn't necessarily incorrect for the glow
stopping but was clearly wrong for it starting.  This fix uses a flag
as a hack to avoid finding and changing all the calls to docrt() and
see_monsters().  It ought to be fixed properly....
2020-04-27 05:09:19 -07:00
PatR
09f9b3598f fix issue #339 - duplicate feature messages
while 'mention_decor' is enabled.  When stepping onto different
terrain and one or more objects remained on the new spot after
autopickup, describe_decor() was issuing its new-terrain message
right before look_here()'s similar under-the-objects message.  If
autopickup grabbed everything or there weren't any objects to begin
with, look_here() doesn't issue any dfeature (terrain) message.
describe_decor() isn't smart enought to know whether that is going
to happen.  Give look_here() a new flag argument so that its caller
can ask for the dfeature message to be skipped for the case where a
similar message has already been given.
2020-04-27 04:25:26 -07:00