Commit Graph

124 Commits

Author SHA1 Message Date
nhkeni
6bd2172ba7 Lua sandbox
This is enough to prevent abuse by denying access to functions and
    denial of service (RAM and instruction step limits), but not enough
    to allow restricted use of things that require finer control (e.g.
    filesystem access).

    If something goes wrong, the whole thing can be turned off, for
    now, in config.h (see NHL_SANDBOX).

    None of the current functionality requires changes to build systems;
    some of the possible future functionality may require some #defines
    - TBD.  There is lots of dead code (#ifdef notyet) for bits of that
    additional functionality; we can rip it out if we don't want those
    additions or we can complete (parts of) it depending on our needs.

    All current uses of Lua are connected to sandboxes and guarded with
    nhl_pcall (sandbox and lua_pcall wrapper); options and limits can
    be set at the callsites in the passed nhl_sandbox_info.  Some of
    the error handling may be wrong - panic() vs.  impossible() vs
    silence.

    Memory and instruction step limits should be tuned prior to release;
    there's no point tuning them now.
2022-04-29 19:46:33 -04:00
nhmall
a16f17a029 header file ordering change
This is groundwork for some other changes.

Include integer.h ahead of global.h in config.h.
2022-03-11 07:33:28 -05: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
Pasi Kallinen
2e144e814d Change repeat into extended command 2022-01-17 17:13:59 +02:00
Pasi Kallinen
3e620e06eb Define extra sanity checks if not a release 2022-01-02 01:14:16 +02:00
nhmall
9bb96322a8 compile NetHack-3.7 without makedefs-generated .h files
This evolves and hopefully eases the game-build requirements by
removing game-compile dependencies on any header files generated
by the makedefs utility, including:

date.h dependency and its inclusion is removed and comparable functionality
is produced at runtime via new file src/date.c.

pm.h dependency and its inclusion is removed and comparable functionality is
produced by moving the monster definitions from monst.c into new header
file called monsters.h and altering them slightly. The former pm.h header
file #define PM_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.

onames.h dependency and	its inclusion is removed and comparable functionality
is produced by moving the object definitions from objects.c into new header
file called objects.h and altering them slightly. The former onames.h header
file #define values are now replaced with appropriate emitted enum entries
during the compiler preprocessing.

artilist.h has been slightly altered, and the former onames.h artifact-related
header file #define ART_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.

makedefs can still produce date.h (makedefs -v), pm.h (makedefs -p), and
onames.h (makedefs -o) for reference purposes. They won't be used during
the compiler.

The other uses for makedefs remain. They are used to prepare external
file content that the game utilizes, not prerequisite code for the
compile:
    makedefs -d    (database)
    makedefs -r    (rumors)
    makedefs -h    (oracles)
    makedefs -s    (epitaphs, engravings, bogusmons)

date.c

Pull the code for date/time stamping from mdlib.c into date.c.
Set date.o to be dependent on source files, header files, and .o files
so that date.o is rebuilt from date.c when any of those changes, thus
ensuring an accurate date/time stamp. It also includes git sha
functionality formerly done by makedefs writing #define directives
into include/date.h. For unix it passes the git info on
the compile line for date.c (via sys/unix/hints/linux.2020, macOS.2020)

nethack --dumpenums (optional, but on by default)

Allow developer to obtain some internal enum values from NetHack
without having to resort to an external utility such as
makedefs.

Uncomment #define NODUMPENUMS in config.h to disable this.

The updates to sys/windows/Makefile.gcc have not been tested yet.
2021-08-21 07:59:18 -04:00
PatR
ab74ed2c20 SELECTSAVED handling
By default, enable the SELECTSAVED option for everyone instead
of just for Windows or Qt.  And make Qt obey the 'selectsaved'
run-time option.

It can be disabled in config.h if necessary.
2021-01-23 15:02:11 -08:00
PatR
129ff12245 'make depend' fix
The gone but still referenced state of amiconf.h broke 'make depend'.
Fixing that turns it into a comment in the generated dependencies
but that ran into a problem with it being followed by fnamesiz.h
instead of being last in the list containing it.  So in addition to
the depend fix, move #include "fnamesiz.h" from config.h to global.h
in order to have it come before amiconf.h.
2021-01-08 13:33:27 -08:00
Dean Luick
a4e7646f4c Remove src and unix VISION_TABLES
Remove all references to the unused vision tables in the main source
and unix build.  Leave makedefs able to generate the vision tables.
makdefs will be cleaned up in a different commit, once all ports
are clear of dependencies.
2020-12-29 20:38:37 -06:00
PatR
0ec355bdb4 fix github issue #426 - binding special commands
Binding 'repeat' (DOAGAIN, or redo) to a different key than ^A
didn't work as intended because the code that used it was
checking for DOAGAIN (a key value from config.h) instead of
g.Cmd.spkeys[NHKF_DOAGAIN] (the key currently bound to repeat).

Contrary to the github issue, re-bound prefix keys worked ok for
me if followed by a direction.  However, they behaved strangely
if followed by anything else.  If the keystroke was stolen from
some other command and that command hadn't been bound to another
key, following the prefix with a non-direction could end up
executing the command that used to own the key.  For example,
 BIND=d:nopickup
to use 'd' to move without auto-pickup would work if you used
d<direction> but if you used d<something-else> if would execute
the drop command.

The NHKF_REQMENU prefix could be bound to some key other than
'm' but it only worked as intended if the new key was a movement
prefix.

This also makes DOAGAIN be unconditional.  If it is deleted or
commented out in config.h, the default binding will be '\000' so
unusable (freeing up ^A for something), but still be available
to be bound to some key (perhaps even ^A).

This also includes an unrelated change to mdlib.c.  The comments
added to config.h will force a full rebuild.  Changing mdlib.c
now rather than separately will avoid forcing that twice.

Fixes #426
2020-12-25 13:57:05 -08:00
Adam Powers
741e6fd5b7 initial shim graphics 2020-10-04 14:46:31 -04:00
nhmall
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
PatR
827e40705d X11+Qt vs config.h
This lets combined X11 and Qt compile cleanly (when set up with
hints/macosx10.10-qt and built with 'make WANT_WIN_X11=1 USE_XPM=1')
but linking fails at present.  (It can't find X11 library routines
despite specifying the same -L/opt/X11/lib that X11 without Qt uses.
The C++ linker is being used but the code that calls those routines
is compiled as C, not C++ so name mangling shouldn't be an issue.)
2020-07-29 18:23:54 -07:00
nhmall
9b58010880 turn off clang -Wshadow when processing some qt headers
removes recently added win/Qt/qt_undef.h and win/Qt/qt_redef.h
adds win/Qt/qt_pre.h win/Qt/qt_post.h
2020-07-18 08:31:51 -04:00
nhmall
84b598e489 get rid of some shadowed variable warnings with Qt under OSX
In file included from ../win/Qt/qt_bind.cpp:20:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:4:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qglobal.h:1302:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qflags.h:121:41: warning: declaration shadows a
      variable in the global namespace [-Wshadow]
    Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
                                        ^
[…]

../include/flag.h:390:29: note: previous declaration is here
extern NEARDATA struct flag flags;
                            ^
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:36:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qcache.h:191:15: warning: declaration shadows a
      variable in the global namespace [-Wshadow]
        Node *u = n;
              ^
../include/decl.h:219:23: note: previous declaration is here
E NEARDATA struct you u;
                      ^
[…]

In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:45:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qtextlayout.h:47:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qcolor.h:44:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qrgb.h:66:46: warning: declaration shadows a
      variable in the global namespace [-Wshadow]
inline Q_DECL_CONSTEXPR QRgb qRgb(int r, int g, int b)// set RGB value
                                             ^
../include/decl.h:1208:27: note: previous declaration is here
E struct instance_globals g;
                          ^
[…]

In file included from ../win/Qt/qt_glyph.cpp:21:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:48:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qpalette.h:107:49: warning: declaration shadows a
      variable in the global namespace [-Wshadow]
    inline void setCurrentColorGroup(ColorGroup cg) { data.current_group = cg; }
                                                ^
../include/decl.h:1216:30: note: previous declaration is here
E const struct const_globals cg;
                             ^
2020-07-16 22:20:23 -04:00
nhmall
77815e87ee follow-up to patchlevel and build status consolidation
Also remove redundant prototype of has_color in wintty.h now that
it is in extern.h.

has_color() became an actual function when an array of color capabilities
got added to the windowport interface a while back (it checks that array).
2020-07-07 21:00:11 -04:00
nhmall
3cecb97da6 consolidate build status /patchlevel info settings in one place - patchlevel.h 2020-07-06 09:12:22 -04:00
nhmall
e4b18f0545 fix github issue 361 to make user_sounds useful even if MSGTYPE is hidden
fixes #361

Also, experminental introduction of vt_sounddata to enable tty to pass
a sound file index to the terminal side of things where perhaps someone
can add code to something like hterm to take the information relayed by
NetHack to trigger user_sounds locally even if playing on a server.

Compile time option TTY_SOUND_ESCCODES required to build that support in.

It should be independent of TTY_TILE_ESCCODES.
2020-07-02 15:49:45 -04:00
PatR
54bea16f0e Revert "fix issue #351 - summoned critters while Hallu"
This reverts commit e430669f50.
It accidentally included my local config.h settings.
2020-05-30 22:35:35 -07:00
PatR
e430669f50 fix issue #351 - summoned critters while Hallu
If a monster uses the 'summon insects' spell (which will resort to
snakes if all 'a' class critters are genocided or extinct) while the
hero is hallucinating, report the summoning of something unusual
rather than of insects or snakes.  I bypassed "random creature"
direct to "hallucinatory creature" for the something unusual.

Fixes #351
2020-05-30 22:24:21 -07:00
nhmall
e39ec5ce3e rename new header file to fnamesiz.h
Changes to be committed:
renamed:    include/filesize.h -> include/fnamesiz.h
2020-01-29 09:56:43 -05:00
nhmall
209fab138b recover fix
recover had deviated somewhat from NetHack in its
file expectations:
1) A couple of 3.7 fields needed to be accommodated.
2) hard-coded file size values had deviated.

The file sizes are now in an added header file named "filesize.h",
which is included at the bottom of config.h.

There will likely be another commit to write the filename size ahead
of the file name so that the precise number of characters can be read,
but since that will break existing saves, it can go in along with another
save-breaking commit.

This commit doesn't not alter savefiles written by nethack so does not
require an editlevel bump. It does alter the read-in expectation in
recover to match the game and this get recover working again.
2020-01-29 09:15:55 -05:00
nhmall
d2d40289e6 update and/or clarify some version references 2019-12-01 19:07:28 -05:00
Bart House
5870cb6a92 Revert "Added experimental feature NEW_KEYBOARD_HIT."
This reverts commit bc65112ce0.
2019-07-14 21:28:55 -07:00
Bart House
bc65112ce0 Added experimental feature NEW_KEYBOARD_HIT. 2019-07-09 22:30:34 -07:00
nhmall
fd585a58c2 add some debugging BREADCRUMBS to identify caller of some functions
Only takes effect if a developer uncomments BREADCRUMBS in config.h
2019-06-03 18:37:45 -04:00
PatR
d1ce0aac89 fixes github issue #190 - EDIT_GETLIN for curses
Fixes #190

Add EDIT_GETLIN support for curses.  It remains disabled by default.
2019-05-18 23:52:04 -07: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
nhmall
66b874dce3 Revert "Added PLAYAGAIN experimental support definition."
This reverts commit ea8cf6613a.
2018-11-23 22:17:33 -05:00
nhmall
c5b283a839 Revert "Added decl_early_init() which is called when PLAYAGAIN is supported."
This reverts commit acbe4d9242.
2018-11-23 22:17:24 -05:00
nhmall
93ebcf0071 Revert "check."
This reverts commit 7814d9097a.
2018-11-23 22:17:16 -05:00
nhmall
4590c9c0dd Revert "Instance variable work check-point."
This reverts commit 8e316df117.
2018-11-23 22:17:12 -05:00
Bart House
8e316df117 Instance variable work check-point. 2018-11-23 15:22:53 -08:00
Bart House
7814d9097a check. 2018-11-23 15:22:52 -08:00
Bart House
acbe4d9242 Added decl_early_init() which is called when PLAYAGAIN is supported.
decl_early_init() is called when we are starting a game.  On first
start, it validates that global state is in the expected state.
When called on subsequent starts, it initializes global state to
expected state.
2018-11-23 15:22:51 -08:00
Bart House
ea8cf6613a Added PLAYAGAIN experimental support definition. 2018-11-23 15:22:51 -08:00
Pasi Kallinen
3517277467 Add some commented out flags to linux hints file 2018-11-23 19:26:13 +02:00
nhmall
cb43061076 curses changes to existing files 2018-11-16 20:51:22 -05:00
nhmall
2b66b5ecd1 bump version ID values 2018-05-16 23:06:44 -04:00
keni
d8c49ec9d1 Add updated copyright lines, part 1. 2018-04-25 15:00:13 -04:00
Pasi Kallinen
94ad7512a6 Compile-time option to allow some prompts remember the input
Define EDIT_GETLIN to make the tty, X11, and Qt4 windowports to
remember the input strings for wishing and annotation.
2018-03-26 23:04:53 +03:00
nhmall
25d17eb62c fix some typos mentioned downstream 2018-02-19 21:32:54 -05:00
Pasi Kallinen
69f7a78dba Hilite Status: Improved
Allow defining multiple stops per field. Add hitpointbar.
2017-09-26 10:04:25 +03:00
Pasi Kallinen
9c118b5b6b Secure config errors
If user can make NETHACKOPTIONS point to a file, that user could then
get the file contents via the extended config file error reporting.
Add CONFIG_ERROR_SECURE compile-time option to make that case output
only the first error, no line number or error context.
2017-09-10 21:05:51 +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
PatR
c3ef98c4d1 REPRODUCIBLE_BUILD
Take the 4-5 line Debian patch and turn it into six dozen lines of
new code.  The submitted patch introduces use of several C library
routines that aren't presently in use, so would need testing by all
functional or nearly-functional ports to verify that it wouldn't
break anything.  It also switched the formatted build date+time
from localtime to UTC.  This makes the code conditional so it can
be ignored by anybody and avoid the risk of breakage.  And a lot of
the increase in size is comments attempting to explain what the new
conditional is for:  when REPRODUCIBLE_BUILD is defined, makedefs
will use getenv("SOURCE_DATE_EPOCH") (whose value is an integer
representing seconds since 1-Jan-1970) instead of current date+time
when generating date.h.  The purpose is to be able to rebuild at a
later date and produce an identical program, which doesn't happen
when compile time gets incorporated into the binary.

I've added some sanity checking to try to make sure the getenv()
value obtained isn't bogus.  And the version string put into date.h
will be slightly different, allowing someone who sees date.h or 'v'
output to tell whether SOURCE_DATE_EPOCH was involved:  showing
"<port> NetHack <version> last revision <date>" instead of the
usual "... last build <date>".

To test, checkout a new branch for building, make any local edits
to unixconf.h and config.h, including enabling REPRODUCIBLE_BUILD,
git add+commit them, then use
  SOURCE_DATE_EPOCH=`git log -1 --pretty=%ct` make install
Other ports will need a bit more work to set up the environment,
but can still use git to track file dates and supply the latest.
Building with alternate configurations could be accomplished by
using tags instead of 'log -1' or by using distinct build branches
where nothing is commited/merged/rebased after completed build.

Unresolved issue:  BUILD_DATE, VERSION_ID, and COPYRIGHT_BANNER_C
contain formatted date+time but omit timezone.  SOURCE_DATE_EPOCH
is assumed to be UTC but the formatted values don't say so, so it
might appear to be incorrect when compared with local time.  We
definitely don't want to start mucking about with timezones within
nethack, so I think we just live with this.  It's not an issue for
default configruation where REPRODUCIBLE_BUILD is left disabled.
2016-03-31 17:56:11 -07:00
Pasi Kallinen
65d780dc3d Add compile-time option MSGHANDLER
This was a feature request from a blind player; he wanted to
play a sound whenever a pline message was given.
2016-01-10 13:08:20 +02:00
Pasi Kallinen
e7d65a44cd TTY: Add compile-time option for tile data hinting
Several people have asked if 3.6.0 supports playing with tiles on
a public server. Because there's no way for the user's end to know
what that white @ is, this adds special console escape codes for
tile hinting.

The idea was originally a patch called TelnetTiles by Justin Hiltscher,
but this expanded version comes via NAO, where it's been in use for years.

This is basically an interim hack, which should go away when/if
we support actual client-server model.
2016-01-10 10:53:15 +02:00
Pasi Kallinen
34b45a2c10 Add an alternative paniclog format as compile-time option 2016-01-04 18:05:16 +02:00