Commit Graph

13159 Commits

Author SHA1 Message Date
PatR
f24a12dfa1 choosing 'menustyle'
When using 'O' to set the menustyle option, include a description of
each of the styles.  Makes the menu entries two lines of two columns
each:  first line contains the setting value and the first half of
its description; second line has blank left column and second half
of description in the right one.  Value on first line and single-line
description on second would have been simpler but this seems easier
to read--the four possible values don't have any clutter between them.

Also, mark the current value as pre-selected.
2022-03-17 11:33:29 -07:00
nhkeni
1151d54500 Add and use Strlen(), like strlen() but panics on unreasonably long strings. 2022-03-16 21:42:00 -04:00
nhkeni
ff1289e828 Add Strlen(), a strlen(3) that panics if string is stupid long and returns unsigned.
First batch of changes to use it to suppress warnings.
2022-03-16 21:34:21 -04:00
nhkeni
1e31fee0df Don't infringe on POSIX typedef namespace. 2022-03-16 21:31:26 -04:00
nhkeni
3e4ea0a2c3 Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7 2022-03-16 21:27:22 -04:00
nhkeni
b444085d38 ssize_t for Windows 2022-03-16 21:27:06 -04:00
PatR
df58dc30b9 tty: count for group accelerators
github issue #697 from copperwater points out that using a menu for
pickup and attempting to give a count to pickup a subset of gold was
ignoring the count and picking up all gold.  That was an unintended
side-effect of making '$' be a group accelerator for gold in addition
to being the 'letter' for a stack of gold (so that it can be chosen
even when not displayed on the current page, the way other groups
behave).

Picking groups via their accelerator ignored any pending count (in
tty; curses seems to apply the count).  Change tty to apply a pending
count to all menu entries that get toggled on via group accelerator.
It's intended to address the gold bug but might also be used to
select one from every potion stack via '1!', for example.  (Seems to
be of very limited functionality, but that was more straightforward
than singling out gold's group to behave differently.)

While in there, change how tty uses menuitem_invert_test():  call it
for set-page/set-all/unset-page/unset-all in addition to existing
invert-page/invert-all.  unset-page/unset-all won't actually be
affected unless 'menuinvertmode' option is set to 2.

Closes #697
2022-03-16 17:03:52 -07:00
PatR
5db6dac863 menuinvertmode
Change the 'menuinvertmode' default from 0 to 1 so that it gets more
exercise.  It can be changed back to 0 via option settings but it's
doubtful that anyone will care enough to bother.

Some pickup/take-off actions have been using it to avoid setting
their 'all' choice when bulk toggling for current-page or whole-menu
takes place; 'O' specifies it for its '?' help choice.  This adds
the skipinvert flag to the 'all' choice of #wizidentify.

The comments describing it now state that menuinvertmode applies to
bulk set-on operations as well as to toggle-on/off operations but
that will only be true if/when interfaces call menuitem_invert_test()
for set as well as for invert.  tty is about to start doing that.
2022-03-16 16:19:30 -07:00
nhkeni
7f484815e5 Add streq() and start finding places it fixes warnings.
Some type fixes from Michael Allison.
2022-03-16 18:50:17 -04:00
nhkeni
dc72e07a2b Make readLenType generally available. Fix some warnings around read(2). 2022-03-16 18:41:45 -04:00
nhkeni
a64a666f78 Various type and cast bits. 2022-03-16 18:18:52 -04:00
nhkeni
e51026aee1 LIMIT_TO_RANGE_INT macro and various casts. 2022-03-16 17:59:23 -04:00
nhkeni
81b014977d Some easy loss-of-precision fixes. 2022-03-16 17:49:29 -04:00
nhkeni
16ea5e7fa6 cmdcount_t
Add a type to force g.{command_count,last_command_count,multi} to have the
same type (because cmd.c: g.multi = g.command_count;) and some resulting
cleanup.
2022-03-16 17:33:44 -04:00
nhkeni
ab16cf83b1 Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7 2022-03-16 17:22:43 -04:00
nhkeni
3aed0c61bc xcode cleanup:
don't use git (so tarball distribution should work)
 name the build shell scripts
2022-03-16 17:03:54 -04:00
nhkeni
41203982be Fix xcode recover install 2022-03-16 15:06:55 -04:00
nhkeni
0b4fad3cb7 NetHack.xcodeproj: update handling of Lua 2022-03-16 15:05:19 -04:00
Pasi Kallinen
074476758c Change map terrain changing from macro to function
The function handles setting lava lit, and removing ice melt timers.
2022-03-16 20:59:58 +02:00
Pasi Kallinen
811299edaf Lua: allow calling impossible 2022-03-16 16:58:42 +02:00
Pasi Kallinen
d1ca594d1c Remove melting ice timeouts when terrain changes
If special level lua code creates a melting ice timeout, but
later in the code places stairs, or a trap which might change
the ice to room floor, the timer sanity checking doesn't
like that.
2022-03-16 16:51:53 +02:00
Pasi Kallinen
49b26dbe99 Simplify abscoord code
No need to call get_location_coord, as we're never dealing with
random coordinates or rooms.
2022-03-16 16:46:10 +02:00
Pasi Kallinen
d76cf9377d Unhide monster when rolling boulder explodes 2022-03-16 16:43:42 +02:00
Michael Meyer
c6363d74a7 Fix: levitating/flying monsters moving over liquid
Commit c1a6dd4 was meant to prevent flying, levitating, and clinging
monsters from considering walls of water as acceptable movement
destinations, even outside of the Plane of Water.  However, it was
evaluating the monster's starting position instead of possible places to
move to, and the evaluation was 'backwards' (the equivalent of
IS_WATERWALL, instead of !IS_WATERWALL).

The result was that non-swimming monsters could only move onto any kind
of water or lava square if the position they were moving from was a
WATER square.  Change this so that instead of the starting position,
each potential destination spot's status as a wall of water is evaluated
in turn, and reverse the effect of the test so that it blocks walls of
water instead of allowing them.
2022-03-16 07:39:52 +02:00
Pasi Kallinen
38924002e0 Lua: ice theme room and melting ice
Allow the ice theme room to occasionally have melting ice.
Add nh.abscoord() to convert room-relative to map-absolute coords.
2022-03-15 22:05:36 +02:00
Pasi Kallinen
bdc81ab389 Lua: allow obj chain iteration 2022-03-15 18:24:49 +02:00
Pasi Kallinen
e33dd11e99 Document the lua object class 2022-03-15 14:17:46 +02:00
Pasi Kallinen
957c0fbee0 Lua: location-specific timers
Expose map-location specific timers to lua scripts. For example:

  nh.start_timer_at(x,y, "melt-ice", 10);

Currently only available timer type is "melt-ice".
2022-03-15 13:46:56 +02:00
Pasi Kallinen
006ae67029 Fix autowielding tools taking no time
When applying some tools (whips, polearms, grapples), or rubbing
a lamp, or when fireassist is on and you fire something without
wielded launcher, the automatic wielding should take as much time
as wielding the item normally does.

Fixes #696
2022-03-15 11:34:48 +02:00
copperwater
cc04bf9d8f Fix selection "random" grow direction, and other code cleanup
Noticed that when I set a selection to grow in a random direction, it
instead grew in all directions, which is not what I wanted. Turns out
the -1 random dir ended up being passed straight to the code which
checks bitmasks, without any form of randomizing among directions.

So this adds code to do that, and defines W_RANDOM as -1 rather than
using a magic number. In the process I also noticed that specifying
"random" as the wall for a door in a room made it rerandomize the
direction every iteration of its loop, essentially rolling two rn2(4)s
and only proceeding if they matched. That was pointless so I cleaned it
up a bit.

Also added safety checks in the form of an impossible for des.corridor()
being called with "random" as either walldir, because this is not
implemented currently.

And lastly, I noticed that create_secret_door was entirely unused
(secret door creation is handled in create_door), so I deleted it.

The only behavior change caused by this is that the Valkyrie quest lava
pools will be a little smaller, which is the only place grow is
currently used. If it's desired to keep them the same, that should be
changed to "all".
2022-03-15 07:44:56 +02:00
copperwater
1483778e96 Reduce eucalyptus leaf nutrition to 1
Eucalyptus leaves are famously inedible except by certain animals such
as koalas. I consider it very strange that a single leaf in NetHack
gives you six meatballs' worth of calories.

I considered making it 0 nutrition, but am not sure if a 0-nutrition
comestible would end up violating some assumption that all food is at
least 1 nutrition.
2022-03-15 07:41:53 +02:00
Pasi Kallinen
b271826147 Add test for selection subtraction 2022-03-14 19:06:51 +02:00
copperwater
b4a460f81b Implement selection addition and difference
Selection difference is something I have found myself wanting a lot when
working on levels, and have had to defer to a clunkier xor-then-and
approach. This commit implements the TODO-ed addition and subtraction
operators on two sets.

I don't see how the addition operator would be any different from
logical or, so it just calls l_selection_or rather than implement a new
function.
2022-03-14 18:42:28 +02:00
copperwater
a61a97856b Externify trycall() and replace many docall() calls with it
trycall() is a short docall() wrapper that is a no-op if the item is
already identified or the player has called the object type already. For
some reason, many calls to docall() did those same exact checks
beforehand.

This commit eliminates that redundancy by converting those calls into
trycall(), which is now made extern rather than local to do.c. No
behavior should be changed by this commit; I've checked that none of the
affected places could take a different code path now that the
oc_name_known and oc_uname checks are removed.
2022-03-14 09:48:19 -04:00
Pasi Kallinen
9dd69f4b88 Fix potentially uninitialized variables 2022-03-14 10:06:23 +02:00
nhmall
a61586153f Windows nmake build - separate x86 and x64 objs 2022-03-13 21:17:08 -04:00
PatR
de02301b45 revise a couple of recent changes
include/.gitignore should continue to ignore old files in case
someone checks out an older version, builds, then checks out the
current version without running 'make spotless' first.

sys/unix/Makefile.utl:  tiletxt.o depends on tilemap.c in addition
to tiletxt.c.
2022-03-13 13:58:56 -07:00
Pasi Kallinen
39f3988f76 Lua: object bury method 2022-03-13 18:38:23 +02:00
nhmall
439087ec6d remove a commented out test line from Makefile.utl 2022-03-13 11:37:00 -04:00
nhw_cron
c4593ac861 This is cron-daily v1-Feb-22-2022. 000files updated: Files 2022-03-13 11:26:15 -04:00
nhmall
c7b63d5ef9 follow-up: missed one include/tile.h 2022-03-13 11:24:19 -04:00
nhmall
a7e83696bd update include/.gitinfo 2022-03-13 11:17:58 -04:00
nhmall
2234cc256d some parallel Make glitches noticed
observed: parallel build attempts of makedefs that trampled over
one another.

attempted workaround: Add a dependency as per Pat R's suggestion.

observed: Concurrent header file movement collisions were sometimes
causing file busy errors and build failures.

workaround: Eliminate tile.h header file movement from the
Makefile build so that the collisions won't occur with that
particular file. Leave the header file tile.h in win/share as it
is in the distribution and just adjust the include path in the
rule for the specific files that use it.

observed: tiletxt.c created on-the-fly from Makefile echo statements
sometimes resulted in garbled and duplicate content in it when
parallel makes were involved, and that caused a build failure.

workaround: Instead of creating a tiletxt.c on-the-fly via echo
statements in the Makefile, simplify things and use that
same #include "tilemap.c" approach but make it an actual file
in the distribution. That makes it available for other platforms
too.
2022-03-13 11:06:45 -04:00
nhmall
2bb26da9fa Windows visual studio project updates
hide a couple of warnings in non-nethack code
get rid of an obsolete file reference
2022-03-13 10:20:41 -04:00
Pasi Kallinen
20f214592a Lua: object timers
Expose object timers to lua scripts. For example:

   local o = obj.new("cockatrice egg");
   o:placeobj(5, 5);
   o:start_timer("hatch-egg", 3);

Available methods are:

- obj.has_timer("rot-corpse")
    returns true if object has attached timer, false otherwise.

- obj.peek_timer("hatch-egg")
    returns an integer value, which is the turn when the timer
    attached to the object would trigger. returns 0 if no such timer.

- obj.stop_timer("shrink-glob")
    stops attached timer, or if no timer type is given, stops all
    timers attached to the object.

- obj.start_timer("zombify-mon", 15)
    starts a timer with a trigger time in that many turns in the future.
    replaces any previous timer of the same type.

Valid timers are "rot-organic", "rot-corpse", "revive-mon",
"zombify-mon", "burn-obj", "hatch-egg", "fig-transform",
and "shrink-glob". Also "melt-ice" is recognized, but does nothing
to objects.
2022-03-13 14:50:07 +02:00
nhmall
9e6bddac10 warning fix artifact.c
artifact.c: In function 'dump_artifact_info':
artifact.c:1088:37: warning: '%s' directive writing up to 255 bytes into a region of size 218 [-Wformat-overflow=]
 1088 |             Sprintf(buf, "  %-36.36s%s", artiname(m), buf2);
      |                                     ^~                ~~~~
In file included from ../include/config.h:652,
                 from ../include/hack.h:10,
                 from artifact.c:6:
../include/global.h:255:24: note: 'sprintf' output between 39 and 294 bytes into a destination of size 256
  255 | #define Sprintf (void) sprintf
artifact.c:1088:13: note: in expansion of macro 'Sprintf'
 1088 |             Sprintf(buf, "  %-36.36s%s", artiname(m), buf2);
      |             ^~~~~~~
2022-03-12 21:49:32 -05:00
PatR
77dc522a62 artifact tracking again
Redo the recent artifact creation stuff by replacing several nearly
identical routines with one more general one.  Also adds a tracking
bit for one or two more creation methods.  That changed artiexist[]
from an array of structs holding 8 or less bits to one holding 9, so
bump EDITLEVEL in case the total size changed.
2022-03-12 17:25:54 -08:00
PatR
294365f707 livelog of breaking food conducts
Shorten the livelog messages for food conduct a little by changing a
bunch of "the first time" to just "first time".  Will result in fewer
instances of tty condensing whitespace for a too-wide line written
into a text window.  That includes stripping off indentation, which
messes up the alignment of #chronicle output.

Also, eliminate one redundant livelog printf.  Breaking vegan conduct
by eating wax when poly'd can be folded into same message for eating
leather/bones/dragon hide.  [The breaking vegetarian conduct for those
says "eating meat" which seems wrong but hasn't been changed.]
2022-03-12 17:07:28 -08:00
Pasi Kallinen
4be6fb0df9 Rolling boulder launch coordinates
Allow defining rolling boulder launching location in special level
lua scripts:

 des.trap({ type="rolling boulder", coord={7, 5}, launchfrom={-2, -2} });

launchfrom is relative to the trap coord.
2022-03-12 18:34:44 +02:00
Pasi Kallinen
625571062e Separate function for finding random launch coordinate 2022-03-12 18:04:29 +02:00