Commit Graph

63 Commits

Author SHA1 Message Date
nhmall
f4a6da2e52 save/restore changes - part 2
This is the second of a series of changes related to save/restore.

    No EDITLEVEL bump has been included, because although the code
    is changed extensively by this, the content of the savefiles have
    not been changed.

    Push the use of the structlevel bwrite() and mread() function use
    out of the core and into sfstruct.c. This is groundwork for upcoming
    changes.

    In the core, replace the bwrite() and mread() calls with the
    use of type-specific savefile output (Sfo) and savefile
    input (Sfi) macros.  The macros are defined in a new header file
    savefile.h, which also contains the prototypes for the sfo_* and
    sfi_* functions that the macros ultimately expand to. The functions
    themselves are in src/sfbase.c.

    On C99, each Sfo or Sfi macro expansion refers directly to the
    corresponding  type-specific sfo_* or sfi_* function.

    If C23 or later is is use, the majority (all but 3 types) of the
    macros refer to a single _Generic output routine sfo(nhfp, dt, tag),
    and a single _Generic input routine sfi(nhfp, dt, tag), which handles
    the dispatch of the type-specific underlying functions. This was
    somewhat experimental, but turned out to be practical because the
    compiler would gripe if the type for a variable was not included in
    the _Generic when passed as an argument, so it could be fixed.

    This alters the savefile verication process by having a common set
    return values for the related functions such as uptodate(),
    check_version(), etc. The new return values return more information
    about savefile incompatibilities, beyond failure/sucess. The
    additional information will be useful for an upcoming addition.
    The expanded return values are:
     SF_UPTODATE                     (0) everything matched and looks good
     SF_OUTDATED                     (1) savefile is outdated
     SF_CRITICAL_BYTE_COUNT_MISMATCH (2) critical size count mismatch
     SF_DM_IL32LLP64_ON_ILP32LL64    (3) Windows x64 savefile on x86
     SF_DM_I32LP64_ON_ILP32LL64      (4) Unix 64 savefile on x86
     SF_DM_ILP32LL64_ON_I32LP64      (5) x86 savefile on Unix 64
     SF_DM_ILP32LL64_ON_IL32LLP64    (6) x86 savefile on Windows x64
     SF_DM_I32LP64_ON_IL32LLP64      (7) Unix 64 savefile on Windows x64
     SF_DM_IL32LLP64_ON_I32LP64      (8) Windows x64 savefile on Unix 64
     SF_DM_MISMATCH                  (9) some other mismatch
    The callers in the core have been adjusted to deal with the expanded
    return values.

    Other miscellaneous inclusions:

       - go.oracle_loc -> svo.oracle_loc.
       - add a bit (1UL << 30) to  called SFCTOOL_BIT as groundwork
         for changes to follow.
2025-05-25 15:03:13 -04:00
PatR
7c40819202 free CRASHREPORT option data
Plug a straightforward memory leak.
2025-04-17 17:00:39 -07:00
nhmall
c7591c0e08 remove redundant zeroing 2024-11-13 17:36:47 -05:00
nhmall
b8083733de some sys.c orphaned pointer prevention 2024-11-13 17:14:47 -05:00
nhmall
5c28b9e987 fix another memory leak
In sys_early_init(), the values for sysopt.gdbpath and
sysopt.greppath were being assigned by calling dupstr()
without ensuring that a value previously assigned by
dupstr() were free()'d.

Also, the sysopt struct definition is changed to sysopt_s,
not because there's anything wrong with the original
    struct sysopt sysopt;
but because I couldn't convince the debugger to use the
correct thing when trying to track down the leak.
2024-11-13 09:07:10 -05:00
Pasi Kallinen
696af89299 Change MSGHANDLER from compile-time to sysconf 2024-10-19 10:47:53 +03:00
PatR
2ab477459f DEBUGFILES setup
Check getenv("DEBUGFILES") unconditionally during startup rather
than waiting until it's needed.

Might prevent the static analyzer from getting so aggravated.
Most likely not though, but should make debugpline() less fragile
if it gets called during a panic or a signal.
2024-06-03 14:16:49 -07:00
nhmall
a7242760f7 consistent cast syntax 2023-11-13 19:28:19 -05:00
nhkeni
8c095b009a Add CRASHREPORT, show contact form on panic/impossible
When calling panic() or impossible(), create the option
of opening a browser window with most of the fields
already populated.  Code for MacOS and linux is included;
other ports are affected by argument change to early_init
which are done but not tested.

To enable, define CRASHREPORT in config.h and set
CRASHREPORTURL in sysconf to (for the moment at least)
http[s]://www.nethack.org/common/contactcr.html

Adds --grep-defined option to makedefs for Makefiles.

Adds "bid" (binary identifier), an MD4 of the main nethack
binary.  This is ONLY for helping (in the future) contact.html
to set the "NetHack from" field automatically for our own
binaries.  This can be faked, but the user can lie so nothing
lost.  There's nothing magic about MD4; other ports can use
anything that prodcues a long apparently random string we can
match against.

- new option --bidshow for us to get the MD4 of a
  released binary so I can add it to the website.
  Only available in wizard mode and not in nethack.6.
- typo macos -> macosx in hints file

No support for packaging builds as I'm not sure what that
would look like.

Adds a javascript helper for MacOS.
Adds a lua helper for linux (and builds and installs
 nhlua).
2023-09-06 12:27:13 -04:00
PatR
3278d7e0c1 control of command-line usage entry in '?' menu
Instead of using a compile-time macro to suppress inclusion of the
menu entry to show UNIX command-line usage in the help menu, use a
sysconf setting instead.

Default is HIDEUSAGE=0, to include the entry for command-line usage.
Set HIDEUSAGE=1 to exclude that.  Does not affect 'nethack --usage'
if player actually has access to the command-line.
2022-11-18 17:54:17 -08:00
Pasi Kallinen
1e90f89203 Chronicle of major events, and livelog
Log game events, such as entering a new dungeon level, breaking
a conduct, or killing a unique monster, in a new "Major events"
chronicle. The entries record the turn when the event happened.
The log can be viewed with #chronicle -command, and the entries
also show up in the end-of-game dump, if that is available.

This feature is on by default, but can be disabled by
defining NO_CHRONICLE compile-time option.

This also contains "live logging", writing the events as they
happen into a single livelog-file. This is mostly useful for
public servers. The livelog is off by default, and must be
compiled in with LIVELOG, and then turned on in sysconf.

Mostly this a version of livelogging from the Hardfought server,
with some changes.
2022-02-09 22:49:25 +02:00
nhmall
f963c5aca7 switch source tree from k&r to c99 2021-01-26 21:06:16 -05:00
nhmall
48fa4fa5dd more warning bits 2020-10-10 16:28:17 -04:00
nhmall
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
nhmall
98976b3141 Merge branch 'NetHack-3.6' 2019-12-18 07:38:59 -05:00
nhmall
5f0d06fb80 update and simplify the windows portable_device_paths sysconf option
Requires a sysconf file in the windows executable directory in order to work
2019-12-17 23:16:44 -05:00
nhmall
5d4208cd15 Merge branch 'NetHack-3.6' 2019-12-17 12:01:49 -05:00
nhmall
51b02a7584 correct revision of one file on the commit 2019-12-17 01:07:53 -05:00
nhmall
ac6e13fd7a allow run-from-removable-device configuration on Windows
Allow a way to configure NetHack to run entirely from a USB stick
or other removable device in a way that allows everything to
reside entirely on the USB stick, and nothing on the computer's
hard drive. That could be done in versions prior to 3.6.3.

Sample:

i: is a USB stick

i:\nhdist contains the NetHack Windows distribution and a sysconf
file dropped into that distribution with the following entry in it:
	portable_device_top = nethack

No device is included in the portable_device_top entry, the device
is always the device that the nethack exe resides on. If you try
to specify a device in the portable_device_top path, the device
portion will be ignored.

portable_device_top specifies the folder on the device that is writable
by NetHack and as such it cannot be the same folder that the executable
resides in.

i:\nhdist\nethack --showpaths
Variable playground locations:
    [hackdir   ]="i:\nethack\"
    [leveldir  ]="i:\nethack\"
    [savedir   ]="i:\nethack\"
    [bonesdir  ]="i:\nethack\"
    [datadir   ]="i:\nhdist\"
    [scoredir  ]="i:\nethack\"
    [lockdir   ]="i:\nethack\"
    [sysconfdir]="i:\nhdist\"
    [configdir ]="i:\nethack\"
    [troubledir]="i:\nethack\"
NetHack's system configuration file (in sysconfdir):
    "i:\nhdist\sysconf"
The loadable symbols file (in sysconfdir):
    "i:\nhdist\symbols"
Basic data files (in datadir) are collected inside:
    "i:\nhdist\nhdat363"
No end-of-game disclosure file (disabled).
Writable folder for portable device config (sysconf portable_device_top):
    "i:\nethack\"
Your personal configuration file (in configdir):
    "i:\nethack\.nethackrc"

Without that sysconf file in the NetHack distribution folder on the
USB stick with the 'portable_device_top = '  entry, the paths
return to the default locations for 3.6.3 on Windows:

i:\nhdist\nethack --showpaths
Variable playground locations:
    [hackdir   ]="C:\Users\JaneDoe\NetHack\3.6\"
    [leveldir  ]="C:\Users\JaneDoe\AppData\Local\NetHack\3.6\"
    [savedir   ]="C:\Users\JaneDoe\AppData\Local\NetHack\3.6\"
    [bonesdir  ]="C:\ProgramData\NetHack\3.6\"
    [datadir   ]="i:\nhdist\"
    [scoredir  ]="C:\ProgramData\NetHack\3.6\"
    [lockdir   ]="C:\ProgramData\NetHack\3.6\"
    [sysconfdir]="C:\ProgramData\NetHack\3.6\"
    [configdir ]="C:\Users\JaneDoe\NetHack\"
    [troubledir]="C:\Users\JaneDoe\NetHack\3.6\"
NetHack's system configuration file (in sysconfdir):
    "C:\ProgramData\NetHack\3.6\sysconf"
The loadable symbols file (in sysconfdir):
    "C:\ProgramData\NetHack\3.6\symbols"
Basic data files (in datadir) are collected inside:
    "i:\nhdist\nhdat363"
No end-of-game disclosure file (disabled).
Your personal configuration file (in configdir):
    "C:\Users\JaneDoe\NetHack\.nethackrc"
2019-12-17 00:41:55 -05:00
nhmall
a512567103 Merge branch 'NetHack-3.6' 2019-12-06 16:48:00 -05:00
PatR
afb4a67f0e PANICTRACE memory leak
Changing from BETA to RELEASED resulted in turning off PANICTRACE
and that exposed a minor memory leak.  Only applies to program exit
so doesn't impact play.
2019-12-06 12:59:18 -08:00
nhmall
e6bafb3f90 default to little-endian in 3.7 2019-11-09 13:52:36 -05:00
nhmall
34d38dcf82 Merge branch 'NetHack-3.6' 2019-10-28 00:45:56 -04:00
nhmall
a399151d01 some symbol tweaks
A few symbol-related modifications:

- fulfill a request from a blind player to allow them to
  specify a unique/recognizable character for all pets and/or
  the player in the config file for use when using a screen
  reader (S_player_override, S_pet_override). Requires sysconf
  setting ACCESSIBILITY to be set to have an effect, although
  they can still be specified in the config file.

- Config file SYMBOLS entries were not working properly on
  the rogue level. Allow ROGUESYMBOLS as well as SYMBOLS to be
  specified in the config file independently.

- When values are moved into showsyms[], the overriding SYMBOLS
  or ROGUESYMBOLS entry from the config file is used if there is
  one; if there is no overriding value for a particular symbol,
  the loaded symset value is used; if there is no symset entry
  loaded for the symbol then a default symbol is used.
2019-10-27 23:12:11 -04:00
nhmall
145bb3f172 Merge branch 'NetHack-3.6' 2019-05-10 15:01:59 -04:00
nhmall
5f56440956 instead of BETA or not, have devel states of release, wip, beta
Now that development sources are made public prior to
BETA testing, it is useful to have a work-in-progress
state prior to BETA.
2019-05-10 14:59:03 -04:00
nhmall
cbcb1ea7eb Merge branch 'NetHack-3.6.2' 2019-01-10 09:42:38 -05:00
PatR
b1782b813f SEDUCE=0
When SEDUCE is disabled, instead of swapping attacks in mons[] once,
do it on the fly in getmattk() whenever needed.  That allows mons[]
to become readonly, although this doesn't declare it 'const' because
doing so will require a zillion 'struct permonst *' updates to match.

This seemed trickier than it should be, but that turned out to be
because the old behavior was broken.  Setting SEDUCE=0 in sysconf or
user's own configuration file resulted in all succubus and incubus
attacks being described as monster smiles engagingly or seductively
rather than hitting (while dishing out physical damage).  I didn't
try rebuilding 3.4.3 to see whether this was already broken before
being migrated to SYSCF.
2019-01-10 03:10:35 -08:00
Bart House
ed096f74c3 shk followmsg moved to instance globals. early_init introduced. 2018-12-25 17:46:52 -08:00
Bart House
769ad91cc3 mthrowu, nhlan, options, regions, rip and role globals moved to g. 2018-12-25 16:26:27 -08:00
Bart House
07b01da147 Correct for rebasing mistakes. 2018-12-19 20:01:56 -08:00
Bart House
912886a73f First set of changes to move globals to instance_globals. 2018-12-19 20:00:35 -08:00
Pasi Kallinen
1eca824321 Add sysconf BONES_POOLS to allow more bones-files per level
Reduce the chance of a player playing on a public server encountering
their own bones, by implementing separate bones pools. The pool a player
belongs to is determined at game start, and only bones in that pool
are used. The sysconf BONES_POOLS allows the sysadmin to define how
many pools there are.
2017-08-20 23:04:59 +03:00
Pasi Kallinen
7d8b4d4f97 Add end-of-game dumplogs
This is based on the "new" dumplog patch for 3.6.0, by Maxime Bacoux.

Define DUMPLOG to enable. By default only enabled for the TTY linux.
2017-02-19 15:33:27 +02:00
Pasi Kallinen
942ee14d0f Move generic usernames to sysconf 2016-06-13 11:01:05 +03:00
Pasi Kallinen
fe006b9c0a Add CHECK_PLNAME to sysconf
Setting CHECK_PLNAME to 1 makes WIZARDS, EXPLORERS, and SHELLERS
check the player name instead of the user's login name.

This is mostly useful for public servers which have external
login system and don't create user accounts for players.
2016-02-05 20:39:17 +02:00
PatR
3edfcffccc SYSCF WIZARDS
Preformat SYSCF entry 'WIZARDS' so that it can be displayed during panic
feedback without allocating memory for the formatted list at that time.
It also gets displayed for help's "support information" ('?k').

For panic(), push "it may be possible to rebuild" to a second line since
the formatted usernames might make the line long.
2015-11-22 17:23:11 -08:00
PatR
010859bcca SYSCF tiny memory leak
Free sysopt.shellers and sysopt.explorers when releasing the memory used
for other sysopt fields.

Also some formatting stuff since sys.c was previously untouched.
2015-11-09 17:21:20 -08:00
Sean Hunt
1c081b1647 Remove stale version control lines. 2015-05-25 09:21:31 +09:00
Sean Hunt
97d6fade74 Reformat all C files.
I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
2015-05-09 13:43:16 -04:00
karnov
2a907f894e Version number increment 2015-05-06 22:04:27 -04:00
Pasi Kallinen
eb77c57a6c Allow disabling savefile UID checking in sysconf 2015-04-11 21:07:57 +03:00
Pasi Kallinen
ca80675d59 Allow admin to disable explore mode
Some public servers want to disable explore mode, so
make it configurable in sysconf.
2015-03-31 18:14:16 +03:00
PatR
562fa952ce allow DEBUGFILES to be overridden via getenv()
If getenv("DEBUGFILES") yields a value then it takes precedence over
sysconf.DEBUGFILES or sys.c's #define DEBUGFILES.  (It probably should
only be controlled via environment since it is not a system-wide
attribute, but I haven't taken out the SYSCF handling for it.)
2015-03-16 15:54:10 -07:00
PatR
a983a58b6a free 'sysopt' strings upon termination 2015-03-16 02:03:40 -07:00
PatR
14525ed0c6 DEBUG/debugpline() fixup
* Replace variadic debugpline() with fixed argument debugpline0(str),
   debugpline1(fmt,arg), and so on so that C99 support isn't required;
 * showdebug() becomes a function rather than a macro and handles a
   bit more;
 * two debugpline() calls in light.c have been changed to impossible();
 * DEBUGFILES macro (in sys.c) can substitute for SYSCF's DEBUGFILES
   setting in !SYSCF configuration (I hope that's temporary).
2015-03-15 18:02:26 -07:00
Pasi Kallinen
a335f8306f Add MAX_STATUENAME_RANK sysconf setting
MAX_STATUENAME_RANK tells how many score file entries to use
for random statue names.
2015-03-11 19:59:52 +02:00
Sean Hunt
6e9fa71b05 Make SEDUCE unconditional. 2015-02-27 19:33:48 -05:00
Pasi Kallinen
612852f7de Apply paxed's DEBUG patch to remove DEBUG/D_DEBUG.
Move debugging output into couple preprocessor defines, which
    are no-op without DEBUG.  To show debugging output from a
    certain source files, use sysconf:

    DEBUGFILES=dungeon.c questpgr.c

    Also fix couple debug lines which did not compile.

This also includes fixes due to Derek Ray to depugpline to work better
on other platforms.
2015-02-27 19:33:45 -05:00
Sean Hunt
4f59f5c6fd Make WIZARD unconditional. 2015-02-27 19:33:22 -05:00