Commit Graph

736 Commits

Author SHA1 Message Date
nhmall
5a7d780db6 Merge branch 'NetHack-3.6.2' 2019-03-20 09:28:48 -04: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
896f5f9774 Merge branch 'NetHack-3.6.2' 2019-02-19 07:48:19 -05: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
nhmall
9bb43c39fb Merge branch 'NetHack-3.6.2' 2019-02-13 15:09:02 -05: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
nhmall
c32ed0689c Merge branch 'NetHack-3.6.2' 2019-02-02 21:15:37 -05: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
nhmall
0617dd89da Merge branch 'NetHack-3.6.2' 2019-01-31 19:56:56 -05: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
05ec7f36a8 Merge branch 'NetHack-3.6.2' 2019-01-29 22:34:07 -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
nhmall
fd410148c5 Merge branch 'NetHack-3.6.2' 2019-01-29 07:27:56 -05: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
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
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
66a5010070 Merge branch 'NetHack-3.6.2' 2019-01-23 00:42:41 -05: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
nhmall
98acd55fcc Merge branch 'NetHack-3.6.2' 2019-01-14 18:16:19 -05: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
nhmall
ba67274dbf Merge branch 'NetHack-3.6.2' 2019-01-05 10:28:34 -05: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
nhmall
ebabf16ad0 Merge branch 'NetHack-3.6.2' 2019-01-04 23:08:49 -05: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
fac470096b Merge branch 'NetHack-3.6.2' 2018-12-29 12:37:27 -05: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
nhmall
178aae42f4 Merge branch 'NetHack-3.6.2' 2018-12-27 22:47:26 -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
nhmall
fb42fb47c8 Merge branch 'NetHack-3.6.2' 2018-12-27 17:42:14 -05: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
Bart House
ed096f74c3 shk followmsg moved to instance globals. early_init introduced. 2018-12-25 17:46:52 -08:00
nhmall
a229a8a56d Merge branch 'NetHack-3.6.2' 2018-12-24 06:44:27 -05: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
Bart House
c8ae68b06a Merge branch 'win-wip3.7' into win-wip3.7-bart
Conflicts:
	src/o_init.c
2018-12-22 13:22:58 -08:00
PatR
4159dd985a fix #2468 - killer bees without a queen
Seven year old suggestion was to have a killer bee eat royal jelly if
there was no queen around, then after a short delay it would become a
queen.  This does that, with "no queen around" being "no queen bee on
current dungeon level" and the transformation happening immediately
with the "short delay" taking place after.

Pet killer bees will target nearby royal jelly if there's no queen,
hostile killer bees will only eat it if they happen to walk on the
same spot as one.  Both types accept either tame or hostile queen bee
as an existing queen.

Killer bees eating royal jelly will drop dead if queen bees have been
genocided, and aren't smart enough to avoid the instinct to eat such
if/when that happens to be the situation.
2018-12-21 16:59:01 -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
Bart House
74caa8d8e4 Moved pray.c globals to instance_globals. 2018-12-19 20:00:35 -08:00
Bart House
912886a73f First set of changes to move globals to instance_globals. 2018-12-19 20:00:35 -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
nhmall
902f76d1fa more win32 gui fuzzer work 2018-12-15 19:31:42 -05: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
Bart House
0cd50847fb Changes to get fuzzer working in NetHackW. 2018-12-12 21:46:14 -08:00