Commit Graph

1527 Commits

Author SHA1 Message Date
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
PatR
992f141ab7 \#wizmakemap followup
Both u_on_rndspot() and losedogs() might result in having a monster
and the hero be at the same location.  Have wiz_makemap() use the
same fixup for that as goto_level().
2019-01-14 09:28:10 -08:00
PatR
64821f4ad5 more enums with explicit values
As before, it's an aid to finding things if you're looking for something
by its numeric value.
2019-01-13 17:19:39 -08:00
PatR
8b02e5b32b enum values
Give the enum lists in several header files explicit values.  Adding
or removing new entries will be more tedious, but doing that is rare
and being able to grep the headers for numeric values in addition to
names is very useful.

rm.h also has a bunch of tabs replaced with spaces.
2019-01-11 17:18:48 -08:00
PatR
bb86fa2bb7 hero infravision
Take a first step towards making the mons[] array be readonly.
The only other place that updates it is when changing succubus and
incubus AD_SSEX attacks to AD_SEDU ones and that can be handled
via existing getmattk(), but so far has proven to be trickier than
anticipated.
2019-01-09 18:10:55 -08:00
PatR
dd13b10cf2 make zeroany, zeromonst, zeroobj 'const'
They're never modified.  Minor complication:  &zeroobj is used as
a special not-Null-but-not-an-object value in multiple places and
needs to have 'const' removed with a cast in that situation.
2019-01-09 01:13:01 -08:00
PatR
ab1bee1778 fix #H7865 - shop prices for container contents
The recent attempt to have looking inside a container show shop
prices had multiple problems.  Worst one was showing shop prices as
if the hero would be buying for items already owned by the hero.
Item handling inside containers on shop floor was inconsistent:  if
shop was selling those items, they would include a price, but if not
selling--either already owned by hero or shopkeeper didn't care about
them--they were only marked "no charge" if hero owned the container.

This is definitely better but I won't be surprised if other obscure
issues crop up.  Gold inside containers on shop floor is always owned
by the shop (credit is issued if it was owned by the hero) but is not
described as such.
2019-01-05 03:21:39 -08:00
PatR
600261d81f fix github #172 - ^T inconsistencies; add m^T
Fixes #172

Casting teleport-away via ^T used different requirements for energy,
strength, and hunger than casting it via 'Z'.  The strength and hunger
requirements were more stringent, the energy one more lenient.  When
it rejected a cast attempt due to any of those, it used up the move,
but 'Z' didn't.

When testing my fix, I wanted an easier way than a debugger to control
how ^T interacts with wizard mode, so finally got around to a first
cut at being able to invoke it via wizard mode but not override those
energy/strength/hunger requirements.  It uses the 'm' prefix to ask
for a menu.  'm^T' gives four options about how to teleport.  (There
are other permutations which aren't handled.)

Also noticed while testing:  ^T wouldn't attempt to cast teleport-away
if you didn't know the corresponding spellbook.  'Z' will attempt that
because it is possible to forget a book and still know its spell.
2019-01-03 17:37:00 -08:00
nhmall
cb25676c43 update for 2019 2019-01-01 11:48:30 -05:00
PatR
da40f55a9f 'O' vs bouldersym
The 'O' handling for bouldersym was updating the display value for
boulder even if the value had been rejected, and if it still had the
default of '\0', the map would end up with <NUL> characters.  (When
examined via '//' or ';', those matched dummy monster class #0 and
led to the impossible "Alphabet soup: 'an("")'" that was suppressed
yesterday.)

Attempting to set bouldersym to ^@ or \0 would also be rejected as
duplicating a monster symbol.  That is now accepted and used to reset
the boulder symbol to default.  However, other control characters are
also accepted--not due to this patch, they already are, and from a
config file in addition to via 'O'--so bouldersym can still disrupt
the map.  But that's no different from putting control characters
into a symbol set or setting them from config file via S_foo:^C.
2018-12-30 15:30:38 -08:00
nhmall
eed7c4bdd1 nttty topten output processing
switch back to using the safe routines
after tty port exits on Windows console
tty port.

Fixes H7758
1613
2018-12-29 12:26:33 -05:00
PatR
c056ca1b35 fix github issue #170 - stacks of non-missiles
Fixes #170

Monsters never throw athames or scalpels but some fake player monsters
on the Astral Plane are given those.  Since they're stackable the
quantity usually gets boosted but there's no point in having more than
one if they won't be thrown.

This could have been fixed by letting monsters throw those two items,
but I prevented the quantity from being boosted instead.
2018-12-27 18:36:26 -08:00
PatR
a6b4322034 fix #H7103 - shop pricing
Player came across a stack of 2 gray stones in a shop and kicked one.
That one ended up with a different (in his case, lower) price once it
was separate.  This behavior only applies to non-glass gems which add
a price variation derived from internal ID (obj->o_id) number.  Make
splitting stacks always yield the same price per item in the new stack
as was being charged in the old stack by choosing a similar o_id.  Do
it for all splits (that can vary price by ID, so just non-glass gems),
not just ones performed inside shops.

He picked up the lower priced one and dropped it back on the original
higher priced one; the combined stack took on the lower price.  That
will no longer happen if they come from splitting a stack, but this
fix doesn't address merging with different prices when they start out
as separate stacks.  (Unpaid items won't merge in inventory if prices
are different, but shop-owned items will merge on floor.)
2018-12-27 14:12:48 -08:00
PatR
7bc36ddef4 fix #H6942 - dropx vs hold_another_object
Dropping an existing fragile item while levitating will usually
break it.  Getting a new wished-for fragile item and dropping it
because of fumbling or overfull inventory never would.

Some callers of hold_another_object() held on to its return value,
others discarded that.  That return value was unsafe if the item
was dropped and fell down a hole (or broke [after this change]).
Return Null if we can't be sure of the value, and make sure all
callers are prepared to deal with Null.
2018-12-23 12:37:26 -08:00
PatR
0e58316109 fix #H2680 - IDing unpaid gem should adjust price
Another one from 6.5 years ago, identifying a type of gem should give
a new price for any unpaid gems of that type and adjust shopping bill
accordingly.  Report was for rubbing with touchstone and learning
worthless glass with price not changing until the learned 'gem' was
dropped.  Fix works for that and also other forms of identification
(and for amnesia, raising prices of forgotten gems); no dropping is
required for the price to change.

Theoretically could apply to any type of item, but prices of gems are
by far the most sensitive to whether or not they're identified.
2018-12-21 01:14:45 -08:00
PatR
f7dd3b8215 clang on OSX
The Unix Makefile.{src,utl} use the compiler name 'gcc' by default on
OSX, and that invokes clang which defines __GNUC__ to deal with gcc
extensions.  But when invoked via the Xcode IDE, it evidently uses its
own name instead, and wasn't defining __GNUC__.  tradstdc.h started
down the road of duplicating gcc features; switch to pretending to be
gcc instead.
2018-12-19 17:52:49 -08:00
PatR
81d73ce417 disable gcc's __attribute__((warn_unused_result))
Casting to (void) to discard a function return value doesn't satisfy
gcc's -Wunused-result (which we aren't enabling but is apparently
being activated for particular functions by glibc header files).  Turn
it into a no-op to suppress three dozen warnings from Travis builds.
2018-12-18 19:11:36 -08:00
PatR
011181a6ed make diluted oil less effective than normal oil
Suggested 6.5 years ago...
2018-12-18 17:16:05 -08:00
PatR
f9cef53758 yet more dropping while inside engulfer
I don't know why we have two different functions which do exactly
the same thing (checking whether an item is unpaid or is a container
that holds at least one unpaid item), but switch the #H2504 fix to
use 'the other one' and reverse one of the changes made when using
the inventory one.
2018-12-17 02:49:38 -08:00
PatR
a3a676a6bd more dropping unpaid shop items inside engulfer
I thought that the earlier fix for #H2504 was too easy for anything
shop related.  It didn't deal sensibly with containers owned by hero
but holding unpaid shop goods.
2018-12-17 00:45:00 -08:00
PatR
0fe6a731df fix #H2204 - mkclass() mon selection distribution
That #H number isn't a typo.  This finally fixes--at least improves--
something reported eight years ago.  The monster types chosen by
mkclass() could be way off in some circumstances.  Cited example was
repeated same-race sacrifice by chaotic hero on dungeon level 20; it
produced about twice as many incubi as succubi even though they're
the same as far as difficulty goes.  (No changes in the intervening
years had any discernable effect; that was still reproducible.)
The report also mentioned that ndemon() threw away the result from
mkclass() and retried quite often and suggested that mkclass() be
taught to filter by alignment when caller cared about that.

This seems to even things out, although it also made harder monsters
chosen more often.  A test program generated these numbers when
picking a chaotic demon 10000 times (level 1 hero on dungeon level 20,
so not realistic; actually probably level 0 hero since the program
didn't initialize struct u.)  Third column is the number of times the
monster type was chosen with the old mkclass(), fourth is same for
the new one.
    mkclass() calls    27315 10000
286 succubus            2800  3309
288 incubus             5552  3262
291 marilith             973   780
292 vrock                477  1617
293 hezrou               150   626
294 bone devil            46   247
295 ice devil              2   107
296 nalfeshnee             0    23
297 pit fiend              0    15
298 sandestin              0     4
299 balrog                 0    10
Note that vrock has generation frequency 2 and marilith only 1, so
getting twice as many vrocks as mariliths should be expected.

I temporarily changed ndemon() to ask for lawful demons instead of
chaotic ones and got this.
    mkclass() calls    15762 10000
287 horned devil        3197  3375
289 erinys              4991  3339
290 barbed devil        1812  3286

I also ran it for dragons with any alignment (so the outcome was
never thrown away; 10000 calls were needed for 10000 picks) instead
of demons of specific alignment and am suspicious of the outcome.
    mkclass() calls    10000 10000
140 baby yellow dragon  1124     0
141 gray dragon         1096  1096
142 silver dragon       1073  1099
143 red dragon          1061  1126
144 white dragon        1077  1128
145 orange dragon       1141  1118
146 black dragon        1154  1049
147 blue dragon         1137  1123
148 green dragon        1137  1154
149 yellow dragon          0  1107
There may be a flaw in the test program.  Or else old mkclass() was
not very good at picking dragons.
2018-12-16 14:21:30 -08:00
PatR
dddbb66927 building lev_comp with USE_OLDARGS
The relatively recent change to lev_comp do deal with apparent junk
in some places in its generated data has triggered a bunch of
 "cast to 'vA' (aka 'const char *') from smaller integer type 'int'
 [-Wint-to-pointer-cast]"
from clang when building with USE_OLDARGS.  Probably should have
added a zillion explicit casts to long and 'L' suffix for 0 rather
than trying to handle both int and long.  Or maybe just turned off
that particular warning, which must be coming from -Wall or -Wextra.

This modification has no effect for USE_STDARG or USE_VARARGS configs.
2018-12-15 19:27:08 -08:00
nhmall
902f76d1fa more win32 gui fuzzer work 2018-12-15 19:31:42 -05:00
Bart House
266b5e3891 Small improvements to fuzzer for NetHackW.
Can toggle fuzzer on/off using "Pause" key if attached to debugger.
Extended command selected randomly.
2018-12-15 14:49:59 -08:00
Bart House
67037f18b5 Remove parameter names in declaration. 2018-12-13 21:23:43 -08:00
Bart House
106cc8acde Merge branch 'win-minor' of https://rodney.nethack.org:20040/git/NHsource into win-minor 2018-12-12 21:46:32 -08:00