Commit Graph
100 Commits
Author SHA1 Message Date
nhmall e70b92e200 paste error in Makefile.nmake 2025-03-19 17:31:19 -04:00
nhmall 1f99638bbf ren nhconst.h -> weight.h
The speed related values were not used, except for NORMAL_SPEED,
which has been moved back to permonst.h
2025-03-19 17:14:07 -04:00
nhmall 526571b1f7 another follow-up for magic number replacement 2025-03-19 14:12:03 -04:00
nhmall e8c401acb3 follow-up: numeric values in comment fix 2025-03-19 13:38:12 -04:00
nhmall a943c4c10b replace some weight-related magic numbers
adds a header file include/nhconst.h  (I'm open to a better name)
2025-03-19 13:29:58 -04:00
nhmall 8c0c33aa1f another follow-up bit 2025-03-17 08:09:00 -04:00
nhmall ed406dafe7 follow-up: store square of dist in arwep table
Also includes some additional unrelated #undef's since one was
being added.
2025-03-17 07:38:37 -04:00
nhmall d53698baea whitespace at end-of-line 2025-03-16 15:39:22 -04:00
nhmall 0bdf9830e6 throw-and-return weapons used by monsters
Resolves #1338
2025-03-16 15:37:49 -04:00
nhmall 53cbccdb86 warning bit from the door fix earlier
mklev.c(97,14): warning C4389: '!=': signed/unsigned mismatch
2025-03-16 08:42:42 -04:00
nhmall e164ce0af4 rings were missed in --dumpweights text 2025-03-16 08:41:08 -04:00
nhmall ef6ca6c5fa follow-up for --dumpweights
Use a string compare for the sort and encode the weight
at the beginning of the string
2025-03-15 23:18:01 -04:00
nhmall b169b79d36 dump monster and obj weights using --dumpweights 2025-03-15 19:55:49 -04:00
nhmall ef4cd7608d follow-up for pull-request #1397
Fix warnings
objnam.c: In function ‘wizterrainwish’:
objnam.c:3536:54: warning: variable ‘didblock’ set but not used [-Wunused-but-set-variable]
 3536 |     boolean madeterrain = FALSE, badterrain = FALSE, didblock, is_dbridge;
      |                                                      ^~~~~~~~
2025-03-14 10:34:22 -04:00
nhmall 57825b170d pull request #1397 by copperwater
Closes #1397
2025-03-14 10:00:35 -04:00
nhmall 9b0724f8f2 update tested versions of Visual Studio 2025-03-13 2025-03-13 12:57:55 -04:00
nhmall dfe2a967fc fix a recent typo 2025-03-13 07:40:20 -04:00
nhmall 8f84f76f09 stop a warning when compiling util/stripbs.c 2025-03-11 10:46:08 -04:00
nhmall 4a67caf3d7 document musl=1 in README-hints 2025-03-11 10:27:18 -04:00
nhmall 8abd9e9564 comment wording bit 2025-03-10 20:29:38 -04:00
nhmall d6829cdcd2 fixes entry for musl libc build, rather than glibc
We've had reports of a couple of issues building against musl libc.

Issues reported:
  - build procedures utilize col for Guidebook-creation, and col
    is deprecated in distros that use musl libc

  - some of the CRASHREPORT code is using library functions that
    are not available in the musl libc environment. The reported
    functions were backtrace() and backtrace_symbols(), which use
    header file /usr/include/execinfo.h.

So we'll try to accommodate this. Since we don't have a means of
autodetecting the musl libc situation during the build (as of yet), the
builder will have to specify 'make musl=1' on the make command line.

Specifying 'musl=1' on the make command line will:
1. ensure that NOCRASHREPORT gets defined in the C preprocessor.
2. set COLCMD to be '../util/stripbs' instead of 'col -bx'.

Related to GitHub #1393
2025-03-10 19:54:12 -04:00
nhmall fbb8ef2fa6 follow-up: set STRIPBS in Makefiles 2025-03-10 17:18:58 -04:00
nhmall bddca2ded5 musl libc build, rather than glibc
We've had reports of a couple of issues building against musl libc.

Issues reported:
  - build procedures utilize cat for Guidebook-creation, and cat
    is deprecated in distros that use musl libc.

  - some of the CRASHREPORT code is using library functions that
    are not available in the musl libc environment. The reported
    functions were backtrace() and backtrace_symbols(), which use
    header file /usr/include/execinfo.h.

So we'll try to accommodate this. Since we don't have a means of
autodetecting the musl libc situation during the build (as of yet), the
builder will have to specify 'make musl=1' on the make command line.

Specifying 'musl=1' on the make command line will:
1. ensure that NOCRASHREPORT gets defined in the C preprocessor.
2. set COLCMD to be '../util/stripbs' instead of 'col -bx'.

Closes #1393
2025-03-10 17:14:24 -04:00
nhmall 3b15e4fff2 a pair of duplicate #include statements in hack.h 2025-03-09 09:51:12 -04:00
nhmall d0d77ed5f4 related comments were not updated with parameters 2025-03-08 12:51:53 -05:00
nhmall ceee6aff31 pointer decl style consistency; use any_types enum 2025-03-06 07:20:16 -05:00
nhmall 78ca37290b cast style tidbit 2025-03-05 10:29:50 -05:00
nhmall fd49242015 botl.c follow-up 2025-03-05 08:55:27 -05:00
nhmall 90d240cbb8 revert assert addition 2025-03-05 08:17:09 -05:00
nhmall 3ef8ae3cc1 Merge branch 'parse_status_hl2' of https://github.com/argrath/NetHack into NetHack-3.7 2025-03-05 08:08:27 -05:00
nhmall 2202b9b8ab Merge branch 'swallowit' of https://github.com/argrath/NetHack into NetHack-3.7 2025-03-05 08:06:38 -05:00
nhmall ebeebcc427 Merge branch 'removemagic' of https://github.com/mkuoppal/NetHack into NetHack-3.7 2025-03-05 07:59:43 -05:00
nhmall 963ee14528 remove references to lev_main.c from comments 2025-02-28 19:20:36 -05:00
nhmall 18063d149f Resolve #1387 on GitHub - Makefile.nmake typo
Merge branch 'fix_makefile' of https://github.com/argrath/NetHack into NetHack-3.7

Resolves #1387
2025-02-28 12:58:51 -05:00
nhmall ce7b7710d8 a fix for issue #1386 - impossible to gen ';' mon
Bug description of #1386 by @copperwater on GitHub:

  "When generating a random monster from a class using des.monster(),
  the G_NOGEN in their statblock is suppressed, but because every monster
  of this class has frequency 0, none of them are actually eligible to get
  picked. mkclass ends up returning a null pointer and create_monster has
  to pick a random monster instead.

  This affects the following levels (all the ones that use random sea monsters):

  Healer quest start
  Healer quest locate
  Plane of Water (difficult to notice, since it has lots of specific sea monsters and only 5 random ones)

  This can be pretty easily viewed by going to the Healer quest start and
  detecting monsters: there is a shark and a giant eel, which are
  specifically defined, but the remaining random sea monster that should
  be there is absent."

Add a tracking array mclass_maxf[MAXMCLASSES] (about 61 entries, the
first not being used), and fill it one time in init_mongen_order() with
the maximum frequency value seen of any monster in that class.

Any mclass_maxf[] entry of zero represents that entire class of monsters
having no positive frequency value.

Detect that in mkclass_aligned(), and use it to work around the situation
to produce the monster being sought by the Lua level description file.
2025-02-28 12:40:34 -05:00
nhmall d56b0a3b7a follow-up bit for Windows console 2025-02-26 23:14:52 -05:00
nhmall 1eaafddca3 fix dolook() on Windows console
usemap boolean wasn't being set to TRUE when it should have been
2025-02-26 23:10:30 -05:00
nhmall 56ebf05324 convert some tabs to spaces in util 2025-02-26 21:51:44 -05:00
nhmall 6ff2bf0993 convert some tabs that crept in to spaces 2025-02-26 21:44:21 -05:00
nhmall 6b2f24a443 Fix out-of-bounds
makemon.c: In function 'init_mongen_order':
makemon.c:1806:25: warning: iteration 383 invokes undefined behavior [-Waggressive-loop-optimizations]
 1806 |         mongen_order[i] = i;
      |         ~~~~~~~~~~~~~~~~^~~
makemon.c:1805:24: note: within this loop
 1805 |     for (i = LOW_PM; i <= NUMMONS; i++)
      |                      ~~^~~~~~~~~~
2025-02-17 07:24:32 -05:00
nhmall 679094ff93 keep tameness at or above its existing level
Resolves #1380
2025-02-16 07:30:22 -05:00
nhmall 1da02b1025 remove a cast that isn't doing anything now 2025-02-16 06:57:53 -05:00
nhmall 8672807a5e cmp_init_mongen_order() qsort comparison function tweaks
The array was ending up ordered the same on different qsort
implementations.

This incorporates the mlet value into the sort value for comparison.
That guarantees that everything stays ordered by mlet, followed by
difficulty (and would even if something ever got misplaced in
monsters.h). It means the "they are equal" zero return for differing
mlet values is not required, and has been removed.

This removes the "they are equal" zero returns for G_NOGEN | G_UNIQ
monsters, so they will still get sorted rather than left at the
whatever array element they happened to be at (which I don't think
should be an issue?).
2025-02-14 19:30:34 -05:00
nhmall f1be2eaffa add --dumpmongen to view mongen_order[] array 2025-02-14 09:38:29 -05:00
nhmall e26102f66d leashed food ration fix
Noticed while testing an earlier fix - after your pet consumes a large mimic
corpse don't have it remain leashed once it begins to mimic something
that isn't leashable
2025-02-13 00:18:39 -05:00
nhmall a68bc3b3fb fix tamed pet issue #1379
fixes #1379
2025-02-12 23:26:03 -05:00
nhmall f8773f65db update tested versions of Visual Studio 2025-02-11 2025-02-11 19:50:08 -05:00
nhmall 907c0fbece follow-up: put back a comment that got removed 2025-02-11 09:29:32 -05:00
nhmall 563340093c stop keeping 5 arrays in sync in dumpenums code 2025-02-11 08:50:30 -05:00
nhmall 1317c850b3 fix output of --dumpenums 2025-02-11 08:02:10 -05:00
nhmall 10e5d2121c fix typo reported in b9ff8068 from Sept 2024 2025-02-09 10:52:21 -05:00
nhmall fe4cb7a626 make rank() static again 2025-02-05 20:03:06 -05:00
nhmall c1516666b3 ebones follow-up fix #1 2025-02-05 17:26:15 -05:00
nhmall c9729bf838 one more follow-up 2025-02-05 08:18:29 -05:00
nhmall a065ced14a follow-up for gw.were_changes 2025-02-05 08:13:35 -05:00
nhmall 0d543a8fae remove a set_uasmon() call from iter_mons() processing
Reported by hackemslashem.
2025-02-05 07:57:25 -05:00
nhmall 88107193db another follow-up, in commented-out code 2025-02-04 15:36:36 -05:00
nhmall 6c0e755573 follow-up for ebones 2025-02-04 15:33:38 -05:00
nhmall 33954f7973 Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7 2025-02-04 15:19:51 -05:00
nhmall c24786430f 'struct former' -> 'struct ebones'
Some variants were already using a similar approach
using a struct called 'ebones', so adopt the same naming
so NetHack-3.7, hardfought, and some variants are using
the same name.

As before there are fields in the struct that are not
currently used by NetHack-3.7, but the intent is that
hardfought save and bones files can be loaded by
NetHack-3.7 without code modification, for debugging
bug reports.

This invalidates existing save and bones files.
2025-02-04 15:16:42 -05:00
nhmall 785f78c39b avoid "You fall down a deep shaft!" if flying down
Fixes #1371
2025-02-03 00:53:06 -05:00
nhmall d65d0062a9 follow-up: evolve placeholder content to match variant
suggestion by paxed

Increments EDITLEVEL again.
2025-02-02 12:53:58 -05:00
nhmall d331029b03 more clobber-detection 2025-02-02 09:08:48 -05:00
nhmall bda3437eab bump EDITLEVEL 2025-02-02 09:00:21 -05:00
nhmall d785f7a649 add two unused fields for hardfought save compatability
There are two hardfought code additions that render save and bones files incompatible
with the upstream NetHack-3.7, and that makes testing with hardfought
save and bones files more challenging than it needs to be, when
investigating and troubleshooting bug reports.

Add some unused fields to advance towards achieving save file parity with
hardfought, which is a significant source of play-testing for NetHack-3.7.

1) the elbereth field addition to u_conduct

This adds an unused placeholder field named 'hf_reserved1', at the appropriate
place in u_conduct to achieve struct field parity with the one in use on
hardfought.

2) hardfought adds a field to struct monst:
    char former_rank[25]; /* for bones' ghost rank in their former life */

Instead of adding that to every monst, this adds a new mextra struct
named 'former', which currently contains the equivalent 25-character
field called 'rank' which can hold the content that was in the
former_rank[25] field. That way, the field will only be added when it
is needed.

A pull request https://github.com/k21971/NetHack37/pull/2 has been
done on hardfought to do it the same way (untested there as of yet).

Even though NetHack-3.7 does not utilize that information presently,
this will be a further step toward allowing hardfought-generated save
and bones files to be used for troubleshooting, without modification,
on a similar architecture running stock NetHack-3.7 code.

That savefile parity won't be achieved until the after the
hardfought pull-request mentioned above (or equivalent) is merged.

As this change will not be compatible with existing save and bones
files, it will be accompanied with an EDITLEVEL increment.
2025-02-02 09:00:05 -05:00
nhmall d74624abbd add mexta field to simplify detection of overwrite
Because this invalidates existing save and bones files,
an increment of EDITLEVEL will accompany this.
2025-02-02 08:30:48 -05:00
nhmall 6431f4727c comment instructions in mextra.h updated 2025-02-01 14:09:58 -05:00
nhmall 7ff7679a76 remove a redundant check for NULL
mksobj is declared to have a NONNULL return:
extern struct obj *mksobj(int, boolean, boolean) NONNULL;

Remove an unnecessary if block.
2025-01-27 10:12:10 -05:00
nhmall f75e4a13b7 more follow-up for mk_artifact() 2025-01-26 21:38:37 -05:00
nhmall ee0d955050 follow-up: make definition match proto staticfn 2025-01-26 12:25:27 -05:00
nhmall 3cca4f2707 avoid mk_artifact()-related memory leaks
Reported directly to devteam after being discovered in nerfhack.
2025-01-26 11:57:01 -05:00
nhmall ed44da351e more follow-up, less hiding of illegal values
Catch it prior to the rn2() call instead. We need to
be aware of the issue.
2025-01-24 18:26:56 -05:00
nhmall dc938b7acf don't hide the zero value of apport
It was pointed out that it might not be a good idea to hide the illegal value of apport.
2025-01-24 18:24:26 -05:00
nhmall 02102de396 attempt to resolve issue #1368
Resolve #1368
2025-01-24 17:06:17 -05:00
nhmall 349f3871be preproc fix 2025-01-23 19:37:19 -05:00
nhmall 61f969e88b follow-up for put_saddle_on_mon()
Commit 1acc2727 helped ensure that the which_armor(mtmp, W_SADDLE)
test at the top of put_saddle_on_mon() wouldn't lead to an obj
leak.

This commit covers off the adjacent can_saddle() test in
put_saddle_on_mon(), because if that failed, it could also lead
to a memory leak of the saddle obj passed by the caller.

- have put_saddle_on_mon() create and use its own saddle obj
  if a NULL saddle obj is passed, instead of having to do that
  in the caller.
- where an existing saddle obj needs to be passed from the caller,
  ensure that the caller has done its own can_saddle(mon) check prior
  to calling put_saddle_on_mon(), so that the can_saddle() test
  in put_saddle_on_mon() won't fail.
- lastly, add an impossible() to put_saddle_on_mon() to catch
  a failure when a saddle obj is passed from the caller and either
  test has failed, just in case. That should not happen with any of
  the existing cases now, but it will provide some bullet-proofing
  for new code, new callers.
2025-01-20 14:37:46 -05:00
nhmall 3a64b404e3 Remove an unused macro that conflicts with pdcursesmod
In file included from ../include/config.h:723:0,
                 from ../include/hack.h:10,
                 from files.c:8:
../include/global.h:519:24: error: expected ')' before '<=' token
 #define unctrl(c) ((c) <= C('z') ? (0x60 | (c)) : (c))
                        ^
../lib/pdcursesmod/curses.h:1686:16: note: in expansion of macro 'unctrl'
 PDCEX  char   *unctrl(chtype);
                ^~~~~~
2025-01-19 22:36:38 -05:00
nhmall 8de3aa564f update tested versions of Visual Studio 2025-01-19 2025-01-19 22:02:43 -05:00
nhmall 9da836fb4a more follow-up: Qt build fix 2025-01-19 21:55:36 -05:00
nhmall d992155f1f follow-up for tradstdc.h
remove a duplicate comment
2025-01-19 21:20:52 -05:00
nhmall 3221665f5a updates to tradstdc.h
Define a macro NH_C to provide a shorter & simpler way to test for
which C standard the build is being carried out under (c99 or c23).

 NH_C > 202300L     Being compiled under C23 or greater
 NH_C > 199900L     Being compiled under C99 or greater
 NH_C > 198900L     Being compiled under C89 or greater,
                    or C std could not be determined.

While NetHack only requires c99, we've been taking advantage
of some c23 features (attributes), if they are available,
to allow the use of ATTRNORETURN/NORETURN and FALLTHROUGH on
compilers other than gcc.

Also add some comment documentation to tradstdc.h about NetHack's
use of c99.

The sys/unix/Makefile.top change overcomes a warning in the
Makefile-generated nhlua.h. That warning arises under some compilers
that rely on attribute [[noreturn]] ahead of a declaration
(NetHack macro ATTRNORETURN), rather than the trailing gcc
__attribute((noreturn)) (NetHack macro NORETURN). The sed command
is modified to include ATTRNORETURN at the start of the declaration
in addition to the NORETURN at the end of the declaration, in the
generated file. That's the same combination that's used for the
declaration of other functions that don't return.
2025-01-19 20:51:46 -05:00
nhmall fc7fdd7f08 get rid of a compiler gripe 2025-01-17 14:26:03 -05:00
nhmall d2aff9a9b2 remove some xchar vestiges 2025-01-14 12:13:39 -05:00
nhmall b2f4b687c1 yet another coordxy bit 2025-01-14 11:33:30 -05:00
nhmall a513b41748 more coordxy consistency, mklev.c 2025-01-14 11:17:41 -05:00
nhmall 2354fef2d6 be more consistent with coordxy in mkmap.c
Also closes #1365
2025-01-14 10:32:36 -05:00
nhmall 1b8bc6fc29 finished CI testing; put things back 2025-01-13 13:12:40 -05:00
nhmall ea647f3adb test custom warning filter in CI 2025-01-13 12:52:32 -05:00
nhmall 3c224fc49d update azure-pipelines.yml 2025-01-13 12:31:57 -05:00
nhmall fd919c1560 Revert "Revert "Revert "eliminate a couple of build warnings (noticed with clang)"""
This reverts commit 6dad19a4f6.
2025-01-13 12:13:06 -05:00
nhmall 92340296ad azure-pipelines warning filter take 2 2025-01-13 12:01:16 -05:00
nhmall 6dad19a4f6 Revert "Revert "eliminate a couple of build warnings (noticed with clang)""
This reverts commit 1a8395002f.
2025-01-13 11:48:46 -05:00
nhmall 1a8395002f Revert "eliminate a couple of build warnings (noticed with clang)"
This reverts commit 7e8a04b35a.
2025-01-13 11:47:57 -05:00
nhmall 0a401253ce test CI warnings 2025-01-13 11:47:00 -05:00
nhmall 7e8a04b35a eliminate a couple of build warnings (noticed with clang)
2025-01-12T19:08:53.4759829Z ../win/curses/cursinvt.c:191:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
2025-01-12T19:08:53.4760198Z   191 |     case KEY_RIGHT:
2025-01-12T19:08:53.4767986Z       |     ^
2025-01-12T19:08:53.4967354Z ../win/curses/cursinvt.c:191:5: note: insert '__attribute__((fallthrough));' to silence this warning
2025-01-12T19:08:53.4967860Z   191 |     case KEY_RIGHT:
2025-01-12T19:08:53.4968026Z       |     ^
2025-01-12T19:08:53.4968219Z       |     __attribute__((fallthrough));
2025-01-12T19:08:53.4968404Z ../win/curses/cursinvt.c:191:5: note: insert 'break;' to avoid fall-through
2025-01-12T19:08:53.4968583Z   191 |     case KEY_RIGHT:
2025-01-12T19:08:53.4968709Z       |     ^
2025-01-12T19:08:53.4968820Z       |     break;
2025-01-12T19:08:53.5099063Z 1 warning generated.

2025-01-12T19:08:53.8002074Z ../win/X11/winX.c:995:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
2025-01-12T19:08:53.8008155Z   995 |     case NHW_TEXT:
2025-01-12T19:08:53.8008513Z       |     ^
2025-01-12T19:08:53.8032511Z ../win/X11/winX.c:995:5: note: insert '__attribute__((fallthrough));' to silence this warning
2025-01-12T19:08:53.8032899Z   995 |     case NHW_TEXT:
2025-01-12T19:08:53.8033057Z       |     ^
2025-01-12T19:08:53.8033219Z       |     __attribute__((fallthrough));
2025-01-12T19:08:53.8033395Z ../win/X11/winX.c:995:5: note: insert 'break;' to avoid fall-through
2025-01-12T19:08:53.8033644Z   995 |     case NHW_TEXT:
2025-01-12T19:08:53.8033783Z       |     ^
2025-01-12T19:08:53.8033912Z       |     break;
2025-01-12T19:08:53.8800783Z 1 warning generated.
2025-01-13 09:36:48 -05:00
nhmall 1bb0f89b82 Merge branch 'check_version' of https://github.com/argrath/NetHack into NetHack-3.7 2025-01-13 08:24:15 -05:00
nhmall 62fe9e83c6 Merge branch 'xytod' of https://github.com/argrath/NetHack into NetHack-3.7 2025-01-13 08:23:52 -05:00
nhmall 8ee014f5d1 update credits 2025-01-12 23:57:56 -05:00
nhmall e08a9671dc another follow-up: another bit is needed
breaks savefiles and bones.
2025-01-12 14:08:15 -05:00
nhmall 25558e1e01 follow-up
Check the correct bits before returning.
2025-01-12 13:58:13 -05:00