Commit Graph

1552 Commits

Author SHA1 Message Date
PatR
68542da636 curses: save/restore message history
Have the curses interface save and restore message history for use
by ^P.  It doesn't spit the saved messages out into the visible
message window after restore; that's too distracting.
2019-03-29 17:03:03 -07:00
PatR
14d8ed199e tty: panning while clipped
Noticed while testing statuslines on a small terminal window.  Using
the cursor to pick locations that panned the map to view a new subset
would end up showing a new view of the regular map rather than a
different section of what was currently displayed.  For farlook that
caused monsters to take on new hallucinatory forms which was fairly
inconsequential, but for #terrain and various forms of detection it
reverted to the ordinary map instead of showing the map features that
the player requested or the temporarily revealed monsters and such.

Most interfaces keep track of the whole map and just show their view
of the new subset when panning, similar to redisplay after being
covered up and then re-exposed, but tty isn't doing that.  I made
same change to Amiga as to tty since the code it was using was very
similar.  I haven't touched any of the other interfaces and assume
that they don't need this.  I've verified that curses and X11 don't.
2019-03-29 14:35:36 -07:00
PatR
d1dade164e tty statuslines:3
Implement the 'statuslines' option for tty.  2 and 3 line status are
similar to curses.  Tty's version doesn't include insertion of extra
spaces for enhanced readability, or ignoring 'showexp' when space is
needed for other fields, or right justifying 'score' and suppressing
it when there isn't room for the entire number.  It continues to have
abbreviated condition and encumbrance descriptions that curses lacks
which get used when the normal ones take up too much space.

'statuslines' can be set with 'O' so it is feasible to switch back
and forth between 2 and 3 lines on the fly.  But only if the display
is at least 25 lines (actually ROWNO+4) or else CLIPPING is enabled
at build time.

This fixes the bug where after resorting to abbreviated condition
values it sometimes (always?) wouldn't switch back after more room
became available.  Abbreviated encumbrance values had problems too
(lack of leading space and not changing value if encumbrance changed
to anything other than unencumbered) and this fixes that as well.
2019-03-29 04:21:18 -07:00
PatR
ee53a9fea6 curses message recall, memory leaks
Using ^P right after resize or 'O' of align_message, align_status,
statuslines, or windowborders would result in
'curses_display_nhmenu: attempt to display empty menu'
because some memory cleanup I added several weeks back was being
executed when the curses interface tore down and recreated its
internal windows.

This fixes ^P handling by making sure that that menu (which is just
text but uses a menu to support '>'/'<'/'^'/'|' scrolling) will never
be empty and it also fixes the window deletion to not throw away
message history until it's final deletion at exit time.

^P uses a popup window to display previous messages and it was never
deleting that window, just creating a new one each time.  Same with
the routine which displays an external help file.  Using either or
combination of both close to 5000 times would probably make internal
window creation get stuck in an infinite loop.  Delete those windows
after they're used so it'll never be put to the test.

The memory cleanup I added for map/status/messages/invent was only
being preformed at end of game, not when saving.  Fix that too.
2019-03-24 17:50:26 -07:00
PatR
d989b36763 revamped curses status display
I've overhauled the status display for curses.  Horizontal layout
supports both 2 lines and 3 lines which can be changed dynamically
via using 'O' to set 'statuslines'.  Fields are spread out a little
more than they used to be, making it more readable--at least to me--
but the extra spaces get squeezed out when lines become too long.
If 'showexp' is on and either conditions or hunger+encumbrance go
off the right edge, experience points are suppressed (but the option
is left on, so they'll come back once there is room).

For traditional 2-line hozizontal status, if hunger+encumbrance+
conditions go off the right edge even after experience points are
knocked out, there will be a '+' in the rightmost column if there
are any conditions that are all the way off.  At present it doesn't
use the tty method of switching to abbreviated condition names to
reduce their legnth.  I'll probably tackle that eventually if no one
beats me to it.

For 3-line horizonal status, there was an older implementation (but
disabled via #if 0) with gold and score moving to the third line.
(I'm not sure how status conditions were handled.)  This one ignored
that and modified 2-line from scratch, moving alignment from line one
to line 2 and level description, time, and conditions from line 2 to
line 3.  It looks like this (view with a fixed-width font...).

Wizard the Hatamoto            St:16 Dx:15 Co:18 In:8 Wi:11 Ch:7    S:25
Lawful  $:21  HP:25(25)  Pw:6(6)  AC:4  Xp:2/21  Hungry Burdened
Dlvl:1  T:36                                     Blind Lev

Score is actually right aligned with the edge but I've deleted several
spaces to keep the line shorter here.  The status conditions line up
with the hunger slot as that shifts due to changes in gold/HP/power/AC/
experience, and conditions prefer that column even when hunger and/or
encumbrance are blank.  Howver, if the number of conditions increase to
the point where they would go off the edge, the whole list shifts left
instead of trying to stay lined up with hunger.  (It's just coincidence
that the lefthand parts of lines 2 and 3 seem to line up in this sample.
In general, they don't.)

The vertical layout has reordered most of the fields and now has a few
blank lines to separate those fields into some groups for readability.
Lines have the form of
Field-name  : Value
and when highlights apply, now they only affect the value portion.
Single digit characteristics are padded with a leading space so that
all six of them line up (for "18/xx", "/xx" protrudes to the right).
HP and Pw are aligned with each other.  Hunger and encumbrance share a
line.  When there are more than three conditions, they're shown three
per line instead of wrapping across lines.  And if too many lines are
present, it will squeeze out enough blank ones to fit.

To see the vertical status, you need a display size of at least 106
columns with 'windowborders' explicitly off, or 110 with them on; also
set option 'align_status' to 'right' or 'left'.  (With borders on,
including the default 'auto' setting, the vertical status appears at
width of 108 columns, but does so by hiding 2 columns of the map; using
110 columns avoids that.)  Resizing from outside the game or changing
align_status via 'O' both cause dynamic reconfiguration of the layout;
there's no need to save, make config changes, then restore.
2019-03-23 17:38:23 -07:00
PatR
5efea7115a curses options and status groundwork
More groundwork for overhauling the status display for curses, plus
a few functional changes.  It was doing a full status update for
every changed field (except conditions), instead of waiting for a
flush directive after gathering multiple changes at a time.  Since
it already does gather every change, the fix to wait is trivial.

This decouples 'hitpointbar' from 'statushilites'.  When highlighting
is off, it uses inverse video only.  When on, it behaves as before:
using inverse video plus the most recent color used to highlight HP
(which can vary if that has rules to highlight changes or percentage
thresholds) but ignoring any HP attribute(s).  This also enables the
latent 'statuslines' option and changes 'windowborders' option from
being settable at startup only to changeable during play.

'statuslines' can have a value of 2 (the default) or 3 and applies to
'align_status:bottom' or 'top'; it's ignored for 'left' and 'right'.
At the moment, setting it to 3 only allows status condition overflow
to wrap from the end of line to 2 to the beginning of line 3, and if
window borders are drawn they'll clobber the last character on line 2
and first one on line 3.  There's no point in trying to fix that
because it will go away when the main status overhaul changes go in.
Condition wrapping for vertical orientation (left or right placement)
was already subject to the same phenomenon and will be superseded too.

This also changes the meaning of the 'windowborders' value so could
impact players using source from git (or possibly beta binaries for
Windows, but not for OSX where curses interface wasn't included).
Old:
 0 = unspecified, 1 = On, 2 = Off, 3 = Auto (On if display is big
     enough, Off otherwise; reevaluated after dynamic resizing);
 Unspecified got changed to 3 during curses windowing initialization.
New:
 0 = Off, 1 = On, 2 = Auto;
 0 gets changed to 2 for default value at start of options processing.
So old value of 2 is changing meaning and explicit old value of 3 is
becoming invalid.  Implicit 3 changes to default 2.  Explicit 3 could
be the subject of a fixup but there isn't much point since 2 can't
have a similar fix.  Users who are using old 2 or explicit 3 will need
to update their run-time config files.

This adds 'statuslines' to the Guidebook and moves some other recently
added documentation of curses options from among the general options
(section 9.4) to "Window Port Customization options" (section 9.5).
None of them have been added to dat/opthelp which seems to be missing
all the wincap options.

Originally I made a lot of changes (mostly moving C99 declarations to
start of their blocks) to the old '#if 0' code at end of cursstat.c,
but have tossed those, except for one subtle bug that assumed 'int'
and 'long' are the same size.
2019-03-21 14:33:39 -07:00
PatR
7049145712 curses update
Miscellaenous stuff either groundwork for or noticed while updating
curses status.  The status changes themselves need some more testing.
One or two of the comments refer to that revised status which hasn't
been checked in yet.
2019-03-18 15:08:01 -07:00
PatR
44a7bfbab6 decode_mixed()'s return type
decode_mixed() writes its output into a 'char *' buffer that's passed
in to it and then returns that buffer.  Some excessively paranoid
error checking forced to return 'const char *'.  Relax that and use
'char *' so callers can work with the result without extra casts.
2019-03-18 14:38:30 -07:00
nhmall
963cb352bc Merge branch 'NetHack-3.6.2-beta01' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.6.2-beta01 2019-03-13 20:04:50 -04:00
nhmall
13c0428721 even more mingw 2019-03-13 19:59:57 -04:00
PatR
ccd6d1407e curses: hilite_pet, hilite_pile without color
The curses interface was ignoring video attributes (bold, inverse, &c)
when color is toggled off or if built with TEXTCOLOR disabled.  Honor
attributes regardless of whether color is displayed.

Also, toggling 'hilite_pet' On during play wouldn't do anything if the
curses-specific 'petattr' option had been left as None.  (It worked as
intended if set in starting options.)
2019-03-13 16:50:56 -07:00
nhmall
93201e9e24 first attempt at mingw w64 build for Windows 2019-03-12 21:14:43 -04:00
PatR
02b21865fd more UCHAR_P
When setting up an alternate definition for UCHAR_P to accommodate
DEC C's non-ANSI mode(s), leave the default definition to tradstdc.h.
DEC C's VAXC mode will end up expecting 'unsigned char' rather than
either 'int' or 'unsigned int'.  Not applicable for Unix but this
makes similar change there as is being made for VMS.
2019-03-08 11:48:31 -08:00
PatR
df84da3ec2 vms update
Suppress Isaac64 on VAX were there isn't an easy way to do 64-bit
arithmetic.  (Hard way isn't worth it for just an alternate RNG.)

Eliminate or suppress some diagnostics:

1) In strict ANSI mode, DEC C was reporting that '$' in identifier is
an extension (one time for each file in sys/vms/*.c).  (It doesn't do
that for the default 'relaxed ANSI' mode.)

2) DEC C uses WIDENED_PROTOTYPES but widens uchar (unsigned char)
differently depending upon the mode it is operating in.  (Applies to
Unix as well as VMS; based on documentation rather than testing.)

Update the comment in tradstdc.h about WIDENED vs UNWIDENED_PROTOTYPES.

An old comment in config1.h about a problem with the earliest version
of DEC C was probably based on an incorrect assumption of what was
really going, but I have no way to go back in time to verify that....
2019-03-07 17:12:01 -08:00
PatR
df3df3cb6f revise integer.h for vms
The VMS compiler supports C99 and defines __STDC_VERSION__ to the
corresponding value, but it doesn't supply <stdint.h> so isaac64.c
wouldn't compile.  It does supply another header containing what is
needed.
2019-03-06 11:37:52 -08:00
nhmall
6a81d78c56 Merge branch 'NetHack-3.6.2-beta01' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.6.2-beta01 2019-02-26 19:53:42 -05:00
nhmall
be3092bed4 some fish should lay their eggs in the water rather than on land
Generally, fish should lay their eggs in the water and
not on land, but the game was only allowing the opposite.

Eels are catadromous and lay their eggs in the Sargasso Sea,
not in the dungeon.
2019-02-26 19:49:24 -05:00
PatR
1a028d1197 curses run-time options
This started out as an attempt to document the curses options in the
Guidebook, but I didn't actually get that far.  Instead, integrate
the curses options better via more consistent WC/WC2 usage.  This
prevents 'guicolor' from showing up as a boolean option for non-curses
interface in curses+other binary.

For curses itself, let 'petattr' be set/reset via 'O'.  Also, accept
'Dim' as a possible pet highlight attribute since it already handles
all the other ordinary attributes.  I'm not sure what leftline and
rightline highlighting are supposed to do.  They were missing for
ncurses (or maybe they're misspelled for PDcurses?) but adding them
didn't produce any visible effect (using TERM=xterm-256color on OSX
with default font/character set).

Not addressed:
1) general confusion about compile-time vs run-time option filtering;
2) curses pet highlighting only works if 'color' option is enabled.
2019-02-26 15:16:42 -08:00
PatR
01c400a200 OSX has /dev/random
We aren't defining BSD for OSX but we probably should be.  This doesn't
go that far, just changes a couple of __APPLE__ for MACOSX (set up in
config1.h) and defines DEV_RANDOM as "/dev/random".
2019-02-18 15:34:09 -08:00
PatR
a6ff7210be fix #H8215 - monster intrinsics from worn gear
Fixes #177

The monst struct has 'mintrinsics' field which attempts to handle
both mon->data->mresists and extrinsics supplied by worn armor, but
polymorph/shape-change was clobbering the extrinsics side of things.
Potentially fixing that by changing newcham() to use set_mon_data(...,1)
instead of (...,0) solved that but exposed two other bugs.  Intrinsics
from the old form carried over to the new form along with extrinsics
from worn armor, and update_mon_intrinsics() for armor being destroyed
or dropped only worked as intended if the armor->owornmask was cleared
beforehand--some places were clearing it after, so extrinsics from worn
gear could persist even after that gear was gone.

So, fixing the set_mon_data() call in newcham() was a no go.  This
fixes update_mon_intrinsics() and adopts the suggested code from
github pull request #177 to have mon->mintrinsics only handle worn
gear instead of trying to overload innate intrinsics with that.  This
is a superset of that; the flag argument to set_mon_data() is gone
and mon->mintrinsics has been renamed mon->mextrinsics.  (The routine
update_mon_intrinsics() ought to be renamed too, but I didn't do that.)
2019-02-18 13:17:14 -08:00
PatR
fc2f2c51a4 VMS system.h bit
Avoid some duplicate declarations for VMS.  The one for lseek()
has become an issue--not fixed here--and this narrows it down to
one place.
2019-02-15 14:10:09 -08:00
PatR
4bb5560961 more #H8167 - late messages
Do late message suppression in a different fashion.  Also, there are
more messages than shk taking hero's possessions and guard taking
hero's gold that need to be suppressed if regular message delivery
is no longer possible:  "do not pass Go", "you arise from the grave
as a foo", "the corridor disappears", "you are encased in the rock".
Those last two are from vault handling but take place in a convoluted
manner:  paygd -> mongone -> grddead -> clear_fcorr.
2019-02-11 13:39:34 -08:00
PatR
d80fd8a014 curses status cleanup
Stop the last of the memory leaks occuring during basic usage.
2019-02-09 15:30:53 -08:00
PatR
d4d7901eff more curses memory
Message history now cleaned up at game end.  Status window cleanup is
not taking place because the core is suppressing it #if STATUS_HILITES.
2019-02-08 16:51:33 -08:00
PatR
190c90e95e tty ^P message recall
Extend 'putstr(WIN_MESSAGE, attribute, string)'s attribute so that
'custompline(SUPPRESS_HISTORY, ...)' can work with ^P's message
history like DUMPLOG history, in order to keep autodescribe feedback
and intermediate prompts for multi-digit count ('Count: 12', 'Count:
123') prompts out of recall history.  The old autodescribe behavior
could easily push all real messages out of the recall buffer when
moving the cursor around for getpos, and the count behavior looked
silly for a four or five digit gold count if you set the msg_window
option to 'full' or 'combination' and viewed them all at once.

Other interfaces may want to follow suit, but this doesn't force them
to make any changes.  I added a hook for "urgent messages" that might
be rendered in bold or red or some such and/or override the use of
ESC at --More-- from suppressing further messages, but there aren't
any custompline(URGENT_MESSAGE, ...) calls (potentially "You die...",
for instance) to exercise it.  Other people have implemented similar
feature it different ways and I'm not sure whether this one is really
the way to go since the core needs to categorize each message that it
deems to be urgent.  MSG_TYPE:stop may be sufficent, although MSG_TYPE
matching can entail a lot of regexp execution overhead at run-time.
2019-02-04 16:46:04 -08:00
PatR
7cc718ea0e fix #H7173 / github #101 - vault exit
Fixes #101

If you tell the vault guard your name, drop carried gold, wait one
turn, then pick up the gold again, the guard will move a step away
during the wait.  If you teleport away, the guard will seal vault
walls and then park himself on the one-square (so far) temporary
corridor adjacent to the vault wall.  Periodically he'll say "Move
along!" and the hero will hear it, regardless of location on the
level.  Unless you dig a corridor to rescue him, or one or more of
the vault's walls get breached again, he will never move.

The report emphasized that you could use this to steal the vault's
gold, but it relies on being able to teleport beyond the gaurd's
reach and if you can do that, you might as well do so before the
guard comes.  The stranded guard, and him saying "Move along!" when
no longer leading hero out of the vault, are more significant bugs.

Bonus fix:  if the game ends and the guard seals up the vault while
the hero is in a spot that gets fixed up (vault wall or temporary
corridor) don't give the "You are encased in the rock" message if
game end was due to death rather than quit.
2019-02-02 17:37:06 -08:00
PatR
2447be1e8e missing maybe_reset_pick update
Accidentally omitted from the commit for 'stale lock picking context'
8bf16b940e.
2019-01-31 16:50:17 -08:00
nhmall
446b0e69d5 add a descriptive comment to integer.h 2019-01-30 08:30:02 -05:00
nhmall
f2071a66f7 fix a likely typo/transcription error in integer.h 2019-01-29 22:12:09 -05:00
PatR
1b49f60ded warning fix
The new code provoked several warnings; this fixes one of them.
Moving the declaration of 'rolecount' would have been sufficient,
but I've gone another way.
2019-01-29 15:00:07 -08:00
Patric Mueller
b7edc7f8e8 Workaround for including stdint.h on older GCC versions
GCC doesn't set __STDC_VERSION__ for older versions. It is verified to
be set by default on 5.3.0.

Older versions set __INT64_MAX__ though (oldest version tested is
4.5.4).

If compilation with older GCC versions is required, set -std=c99. Even
3.4.6 is supported with this setting.
2019-01-29 15:10:01 +01:00
nhmall
457e4b68aa merge Alex's dual rng proposal with the isaac64 rng code and adjust
This is branched from Alex's hallu-rng-stability branch,
with two build corrections (detect.c, zap.c), and merged
with  the isaac64 branch that we have ready to go.

Alex's dual rng is supported by setting up the array
of multiple isaac64 contexts.

I stuck with Alex's approach of passing the rng function
name around as the parameter (rng or rn2_on_display_rng)
for the new additional parameter needed for
set_random(), init_random(), reseed_random(),
and init_isaac64().
2019-01-28 19:43:55 -05:00
nhmall
819ee796f2 Merge branch 'countermeasures' into alex-and-isaac 2019-01-28 18:37:50 -05:00
nhmall
f53d02f0bb Windows build bit 2019-01-28 09:44:35 -05:00
nhmall
22f8d864e2 ntconf.h ensure Rand is always something
order of preference:
USE_ISAAC64
RANDOM
C routine
2019-01-28 10:32:57 +01:00
nhmall
0aa4d62a2c detect rng seed strength at runtime based on algorithm not compile time based on platform features 2019-01-28 10:32:57 +01:00
nhmall
0a430cab11 every platform provides sys_random_seed() and SYS_RANDOM_SEED goes away 2019-01-28 10:32:57 +01:00
Patric Mueller
97b8d0a50b Don't define Rand() if isaac64 is used 2019-01-28 10:02:09 +01:00
nhmall
3f609bf9ad define Rand() in isaac4 config
Rand() was typically defined to random() or to rand().

gcc seems to provide a random() to link to on linux
when sys/share/random.c is linked in, but other platforms
such as Windows got an undefined refence to random()
when RANDOM wasn't defined.

The only direct use seems to be in get_rnd_txt() these
days, in rumors.c

Under the USE_ISAAC64 config, neither srandom()
nor srand() are being invoked to seed those routines,
and it really should be using isaac64 when USE_ISAAC64
is defined anyway.
2019-01-28 10:02:09 +01:00
nhmall
6c114640f5 some system-specific adjustments for RNG routines
move some system-specific seed-related stuff from hacklib.c to
a system-specific source file and #define SYS_RANDOM_SEED to
utilize it during build.

Windows changes for random seed generation using
crypto next gen (CNG) api routines.

Corresponding vms changes due to disentangling of VMS and
unix when the unix seed bits got moved (untested).
2019-01-28 10:02:08 +01:00
Patric Mueller
f9433b2a87 integrate isaac64 into nethack
Also removed the float code from isaac64 as they are not used in
NetHack.
2019-01-28 10:02:08 +01:00
Patric Mueller
c81db872fd add file for the isaac64 random number generator
This is the version from the Comprehensive C Archive Network, licensed
under the CC0 "No Rights Reserved" Creative Common License.
http://ccodearchive.net/info/isaac.html
2019-01-28 10:02:08 +01:00
Patric Mueller
b3fde3eb41 fix check for stdc version in include/integer.h 2019-01-28 10:02:08 +01:00
Patric Mueller
86d694c61b read rng seed from random number source device
Linux and BSD system have random number source devices that can be used
as source for a unguessable seed source.

Other platforms fall back to generate the seed with gettime().
2019-01-28 10:01:45 +01:00
Alex Smith
ce5184c3da Don't advance the main RNG during hallucination
This is based on the multiple-RNGs code fron NetHack4, but using
only the parts relevant to the display RNG (and with substantial
changes, both because of post-3.4.3 changes, and because Nethack4's
display code is based on Slash'EM's rather than NetHack's).
2019-01-28 04:45:26 +00:00
nhmall
55fdfb9200 domove_core() out of domove(); assess domove_core() results
new domove_core() assessment results

potentially smudge engravings

Proceed to wipe engraving after domove_core() now, but only under
all of the following conditions:
    - you can reach the floor
    - preceding domove_core() move attempt was marked as
      having succeeded in domove_core()
    - there is actually an engraving there to impact at
      your original spot, or your new spot, or both
2019-01-27 11:55:23 -05:00
PatR
d63c9d866c band-aid for #H4041 - build warning: has_colors()
Since no one has come up with a better fix for has_colors() being
implicitly declared, add a hack for suppressing a compiler complaint
about has_colors() on linux and/or sco unix that use sufficiently old
<curses.h>.

Report was right after release of 3.6.0 but my fix at the time broke
compile when using more recent <curses.h>.
2019-01-24 15:25:50 -08:00
PatR
deed117e7f fix #H6422 - hmonas against shades
I did much of this quite some time ago, as prequisite for a different
bug report about monsters vs shades, then set it aside.  It ended up
being more complicated than I anticipated.

When deciding whether various non-weapon attacks might hit a shade,
hmonas() was not checking for blessed or silver armor that should have
been applicable.  It did check boots when kicking, but not gloves or
rings (when no gloves) when touching, or outermost of cloak/suit/shirt
when hugging, or helmet when head-butting.  (The last one is actually
moot because nothing with a head-butt attack is able to wear a helm.)

The problem was more general than just whether attacks might hit and
hurt shades.  Various undead and/or demons are also affected by blessed
and/or silver attack but weren't for non-weapon attacks by poly'd hero.

At least two unrelated bugs are fixed:  a rope golem's AT_HUGS attack
gives feedback about choking but was fully effective against monsters
which fail the can_be_strangled() test.  And it was possible to hug a
long worm's tail, rendering the entire worm immobile.

The report also suggested that all artifacts be able to hit shades for
full effect, but by the time shades are encountered everyone has an
artifact so that would nullify a shade's most interesting ability.

TODO:  monster against hero and monster against other monster need to
have similar changes.
2019-01-22 18:15:49 -08:00
PatR
d0cc645961 vampshifter resurrection while being held
If poly'd hero is holding a bat/cloud/wolf which dies and revives as a
vampire, release the hold.
2019-01-22 17:54:58 -08:00
PatR
285606d4c6 more explicit enum values 2019-01-14 17:10:46 -08:00