Commit Graph

13762 Commits

Author SHA1 Message Date
nhmall
c84e0ba6e1 rework TTY_PERM_INVENT; update window port interface
Change the inner workings of the experimental TTY_PERM_INVENT.

Switch to delivering the content to tty for the experimental perm_invent
via the existing window port interface (start_menu(), add_menu(), end_menu).

This also adds a new window port interface call ctrl_nhwindow() for
delivering information to the window port, and/or obtaining specific
information from the window port. The information and requests can
be extended as required. To be documented later once the changes settle
down.

Due to the intrusive nature of these changes and the possibility of
some bugs in the new code, I'm going to leave TTY_PERM_INVENT commented
out in the repository for a day or two.  Anyone wishing to test it out
can do so by uncommenting TTY_PERM_INVENT in config.h.
2022-07-03 00:35:32 -04:00
PatR
67e80cc329 pull request #804 - "Continue eating?" prompt \
should be skipped when current bite finishes meal

Pull request from entrez.  Treat resuming an interrupted meal with one
bite left similarly to starting a meal that only takes one bite.

Closes #804
2022-07-02 15:34:53 -07:00
Michael Meyer
ee002ee91e Don't prompt to continue eating with one bite left
There was already handling in place to prevent showing the "continue
eating?" prompt for one-gulp food (like a wraith corpse), since the hero
would finish eating the food on that turn regardless of what the player
answered to the prompt.  Resuming an interrupted multi-bite meal with
only a single bite remaining had the same problem, but wasn't accounted
for in the special "one gulp" handling.  Modify the condition so it
checks for the number of bites remaining in the food, not the number of
bites total, and show the prompt only when there's more than one bite
left.
2022-07-02 15:27:49 -07:00
PatR
cf52d034cc pull request #802 - water running
Pull request from entrez:  allow rush/run to move over water if
wearing discovered water walking boots.  (Having walked over water
while wearing them but without them being discovered isn't sufficient.
Hypothetically there could some other method of acquiring water
walking ability.)  #802 supersedes #454.

Closes #802
2022-07-02 15:12:12 -07:00
Michael Meyer
6d222e88b0 Allow travel on water with IDed water walking
If you have a known source of water walking (i.e. are wearing formally
IDed water walking boots), allow travel to path you over water and allow
running over water.  A transition from land to water will still cause
the hero to stop in modes other than the shift+dir "move until you hit
something" running mode, so that you don't careen across the entire
level unless you really want to.

Also, fix running over water when levitation or flying is equipped.
This stopped working after f88dce6970, only allowing the hero to move
one square at a time.  And prevent travel from pathing the hero into a
wall of water even if flying or levitation is equipped, since they don't
allow you to bypass that terrain.
2022-07-02 15:10:54 -07:00
PatR
00c0baf3d1 pull request #801 - triggering landmines \
by monsters is based on their weight

Pull request from entrez:  instead of straight 2/3 chance for a monster
to trigger a landmine, base the chance on monster's weight.

Closes #801
2022-07-02 15:03:52 -07:00
Michael Meyer
141b568944 Make monsters trigger landmines based on weight
The 1/3 likelihood of a monster setting off a landmine seemed a little
arbitrary to me, especially in that it applied equally to all monsters,
from giants to insects.  Change the flat 33% chance to one based on the
monster's body weight, so that lightweight monsters have little to no
chance of setting off a mine, with the likelihood increasing from there
with the monster's weight.

With a trigger weight of 400, as it is in this commit, a dingo has a 0%
chance of setting off a landmine, a gelatinous cube the same 33% chance
as before, an elf a 50% chance, a human a 72% chance, and something the
size of a dragon (ignoring the reduced likelihood for flying monsters) a
91% chance.
2022-07-02 15:02:32 -07:00
PatR
896686e860 boulder sanity check
From entrez, pushing a boulder into the water on Plane of Water
resulted in a sanity check warning about a boulder at water location
(every turn until bubble movement eventually pushed it back out of
the water).  Make boulders in that situation always fail to plug the
water and vanish rather not attempt to plug and remain intact.

This also changes the chance to plugging water from 90% to 50% when
dealing with a wall of water somewhere other than Plane of Water.
2022-07-02 11:54:31 -07:00
nhmall
75c5f3713f a couple of follow-ups 2022-07-02 09:21:58 -04:00
nhmall
3004cf2d34 be more consistent with coordinates 2022-07-02 09:10:03 -04:00
PatR
0bd5b3d39e teleport feedback for STRAT_APPEARMSG mon
Reported by entrez:  if a monster with the STRAT_APPEARMSG flag is
seen to teleport away from its current position, an arrival message
would always be given too.  If you couldn't see that arrival, you'd
get nonsensical "It suddenly appears!".

Minor fix:  when a monster is seen to vanish at one spot and appear
at another, if it was not close you'd get either "appears closer to
you" or "appears farther from you" even if the new spot was the same
distance as the old spot.
2022-07-01 15:53:53 -07:00
PatR
dda4cd0530 regex handling
Change the regex_error_desc() interface.  Have the caller pass in
a pointer to a buffer of at least BUFSZ characters and have
regex_error_desc() populate that.  No need for static buffers or
extra dynamic alloction.

Also, change it to never return Null.  None of its callers were
checking for that and could have passed Null to config_error_add()
or raw_print().  printf("%s", NULL) produces "null" on OSX but other
systems would probably crash if a Null result ever actually occurred.

The error explanation returned by cppregex included a trailing period.
config_error_add() adds one, so the message ended up with two.  Have
regex_error_desc() check for final period and strip it off if found.
(My test case used a menucolor pattern of "[" which triggers an error
about mismatched brackets.)

Reformat cppregex.cpp; treat 'extern "C" {' as if it isn't introducing
a nested block.  Fix the '#include <hack.h>' that 'make depend' was
ignoring.
2022-07-01 13:08:43 -07:00
nhmall
aebf77ada1 update visual studio project files 2022-07-01 11:47:02 -04:00
nhmall
1e17efe143 Windows console limits 2022-07-01 08:37:10 -04:00
nhmall
1de758179b don't alter perm_invent during fuzzer 2022-07-01 08:36:33 -04:00
nhmall
84baa5d7d4 comment update 2022-07-01 08:36:03 -04:00
nhmall
465db21c79 typedef follow-up 2022-07-01 08:23:31 -04:00
nhmall
30b557f7d5 change xchar to other typedefs
One of the drivers of this change was that screen coordinates require a
type that can hold values greater than 127. Parameters to the window
port routines require a large type in order to be able to have values
a fair bit larger than COLNO and ROWNO passed to them, particularly for
their use to the right of the map window.

This splits the uses of xchar into 3 different situations, and adjusts
their type and size:

                        xchar
                          |
               -----------------------
               |          |          |
            coordxy     xint16     xint8

coordxy: Actual x or y coordinates for various things (moved to 16-bits).

xint16:  Same data size as coordxy, but for non-coordinate use (16-bits).

xint8:   There are only a few use cases initially, where it was very
         plain to see that the variable could remain as 8-bits, rather
         than be bumped to 16-bits.  There are probably more such cases
         that could be changed after additional review.

Note: This first changed all xchar variables to coordxy. Some were
reviewed and got changed to xint16 or xint8 when it became apparent that
their usage was not for coordinates.

This increments EDITLEVEL in patchlevel.h
2022-06-30 23:48:18 -04:00
nhmall
751b6e646f Revert "follow-up: use only the memory that's required"
This reverts commit 4a0654c708.
2022-06-30 22:38:14 -04:00
nhmall
66a1e19d26 Revert "follow-up 2: follow the conventional approach"
This reverts commit 6920632df0.
2022-06-30 22:37:12 -04:00
nhmall
43941afe19 Revert "follow-up 3"
This reverts commit cd57dfa5ff.
2022-06-30 22:36:45 -04:00
nhmall
e2b77e51ad Revert "follow-up 4"
This reverts commit 9e38fb661d.
2022-06-30 22:36:21 -04:00
nhmall
9e38fb661d follow-up 4 2022-06-30 13:43:44 -04:00
nhmall
cd57dfa5ff follow-up 3 2022-06-30 13:27:46 -04:00
nhmall
6920632df0 follow-up 2: follow the conventional approach 2022-06-30 13:15:58 -04:00
nhmall
4a0654c708 follow-up: use only the memory that's required 2022-06-30 13:10:56 -04:00
nhmall
0fd999a6b5 cppregex regex_error_desc()
Address sanitizer caught a use after free.
cppregex.cpp regex_error_desc() was not returning a pointer
to a static buffer, yet the posixregex was. Follow suit.
2022-06-30 13:02:07 -04:00
nhmall
f228fefabd updated window_procs
Add a non-string identifier to window_procs for use in runtime
identification of the current window port being used.

Use a macro WPID to add the identification at the top of the
various existing window_procs declarations. It expands to the
existing text string, as well as the newly added field wp_id
with a wp_ identifier.

For example, WPID(tty) expands to: "tty", wp_tty

The generated wp_tty must be present in the wp_ids enum at
the top of include/winprocs.h.

The WINDOWPORT(x) macro has been updated to expand to a simple
value comparison (port.wp_id == wp_x), instead of a
string comparison.
2022-06-29 23:21:19 -04:00
nhmall
a518d82c54 no quotes in WINDOWPORT macro invocation 2022-06-29 22:13:28 -04:00
PatR
eaa3b35fcf pull request #797 - running past quest leader \
and not stopping if tossed out of the quest

Pull request from entrez:  a running or travelling hero who passes
next to the quest leader and gets tossed back through the portal for
some reason would keep on running on the far side.

Closes #797
2022-06-29 18:28:01 -07:00
Michael Meyer
721c4b77aa Fix: running through quest expulsion
If a player was in the process of running past the quest leader when she
got expelled from the quest, she would continue running out of the quest
portal on the portal level.  Interrupt any running (or other multi-turn
action) when expelling the hero from the quest level.
2022-06-29 18:17:07 -07:00
PatR
b25961fb13 pull request #792 - pet w/ engulf+digest \
can gain intrinsics by swallowing monsters whole

Pull request #792 from entrez:  monsters can gain instrinsics now but
the case for an engulfer digesting a live monster was overlooked.

Add the same for non-pet monsters digesting other monsters, likely
under the influence of conflict but possibly counter-attacking a pet.

Closes #792
2022-06-29 18:08:50 -07:00
Michael Meyer
0eadf8dfe1 Allow intrinsic gain from pet's digestion attack
Add possible pet intrinsic gain from swallowing a monster in one gulp
(in situations where a corpse is created and eaten by the engulfer),
making it equivalent in this regard to eating the corpse off the floor.

One possible extension or modification would be to reduce the chance of
receiving an intrinsic when the corpse is consumed via digestion attack,
similar to how the corpse nutrition is 50% of its normal value.  I
didn't incorporate that into this commit since the chance of receiving
an intrinsic is tied to monster level rather than nutrition, so I wasn't
sure if it made sense.
2022-06-29 17:40:46 -07:00
PatR
46652d3cef fix 'D' vs obj->bypass
Reported by entrez:  dropping items with the 'D' command sets
obj->bypass which prevents an otherwise compatible item from merging
with non-bypass floor stack.

'D' sets the bypass bit to avoid trouble if a dropped item triggers
an explosion that destroys some of inventory (making straightforward
invent traversal be unreliable).  Having bypass set prevented merging
with a floor stack that had that flag bit clear.  That was very
noticeable if a subset of a stack was picked up and then 'D' used to
drop it again, resulting in two stacks instead of recombining into
the original.

Change the test for mergability to ignore bypass so items will merge
when one has it set and other doesn't.  And when successfully merging
set bypass on the combined stack if either part had that set.
2022-06-29 11:46:31 -07:00
PatR
4fb55653b2 pull request #806 - remove unnecessary variable
Pull request from argrath: in destroy_one_item(), 'physical_damage'
is set to False with no provision for changing that it True, so the
'if (physical_damage) xxx' is never executed.  Remove it.

Closes #806
2022-06-28 12:53:16 -07:00
SHIRAKATA Kentaro
8a78442e2d remove unnecessary code on destroy_one_item()
`physical_damage` is initialized to FALSE, and no codes change it.
2022-06-28 12:52:06 -07:00
PatR
1ff9ad5faf pull request #800 - displaying detected traps
Pull request from argrath:  move display of detected traps into
separate routine to eliminate some 'goto's.

Closes #800
2022-06-28 12:41:51 -07:00
SHIRAKATA Kentaro
a377a1fc67 split displaying trap map into separate function 2022-06-28 12:39:38 -07:00
PatR
bb238b5ef3 avoid becoming stunned due to level teleporting
Reported by entrez:  the code to have a hero become stunned for 1..3
turns when going though a level teleporter trap effectively negated
teleport control (except in wizard mode which is probably why this
slipped through).  Make the effect happen after level_tele instead of
before, change it from being stunned to being confused, and only
happen if hero lacks teleport control.

The association between confusion and level teleportation already
exists and this might be just enough of a hint for someone who isn't
aware of that yet to figure it out.  (Probably just wishing thinking.)

Magic portal traversal hasn't changed; it still causes brief stun.
2022-06-28 12:37:06 -07:00
nhmall
59cc1d18de fix build without TTY_PERM_INVENT defined 2022-06-27 17:43:47 -04:00
nhmall
480bb234e7 comment still not right 2022-06-27 08:34:41 -04:00
nhmall
3c130e8585 comment update 2022-06-27 08:21:37 -04:00
nhmall
af58acccd2 some tty perminvent follow-up() 2022-06-27 08:13:37 -04:00
PatR
4f781e7850 fix #K3627 - impossible placing long worm at <0,0>
When migrating, a long worm is removed from the map to take off the
tail, then its head is put back to be treated like other monsters.
If that occurred when being forced to re-migrate during failure to
arrive from a prior migration, it wouldn't have valid coordinates
and the place_monster attempt produced an impossible warning.
(Other types of monsters don't get removed and put back so didn't
trigger the problem.)

The routine to format a monster when the data is suspect mistakenly
thought it was dealing with a long worm tail because the monster
didn't match level.monsters[0][0], so the warning inaccurately
reported the problem as "placing long worm tail".
2022-06-26 12:22:09 -07:00
Brian Campbell
f9d7bc63bf Fix underflow in free_window_info
At the end this is called after `WIN_MESSAGE` is reset to `-1`, so we
need a check here.
2022-06-26 15:30:58 +01:00
nhmall
d2ca61a0a0 TTY_PERM_INVENT tweaks 2022-06-25 22:26:18 -04:00
nhmall
86bf8cfb45 initializers, take 2 2022-06-25 15:29:27 -04:00
nhmall
4c3fb47900 initializers 2022-06-25 15:16:57 -04:00
PatR
174cac42a6 partial vampire fix
From a followup comment to a reddit post:  a vampire who has gained
levels loses them when reverting to base form.  This fixes the case
where it grows into a vampire lord; change the base form from plain
vampire to lord when that happens.

It does not fix the case where shapechanging to fog or bat or wolf
and then back to base form yields a new vampire or vampire lord
instead of the one that built itself up.  Mainly affects pet vampires
since wild oees don't tend to grow very much.
2022-06-25 11:26:05 -07:00
nhmall
2770223d10 interface groundwork for core-side color decisions
(user-side decisions really, but as it stands right now
user-side decisions/options are made and processed by the core)

add a parameter to add_menu so color can be passed
2022-06-25 13:21:51 -04:00