Commit Graph

280 Commits

Author SHA1 Message Date
Pasi Kallinen
32f2fdb135 Remove leftover level compiler header 2019-11-07 19:40:41 +02:00
nhmall
bcb627100b Merge branch 'paxed-lua-merged3' into paxed-lua-v2-merged 2019-11-06 12:56:21 -05:00
Pasi Kallinen
9cd9280276 Lua: remove dgn_comp, use lua instead 2019-11-06 18:45:10 +02:00
Pasi Kallinen
fd55d9118e Use lua for special level files
Game is playable, and should compile on linux and Windows.
Assumes you have a lua 5.3 library available.

Removes level compiler and associated files.
Replaces special level des-files with lua scripts.
Exposes some NetHack internals to lua:
 - des-table with commands to create special levels
 - nh-table with NetHack core commands
 - nhc-table with some constants
 - u-table with some player-specific data (u-struct)
 - selection userdata

Adds some rudimentary tests.

Adds new extended command #wizloadlua to run a specific script,
and #wizloaddes to run a specific level-creation script.

nhlib.lua is loaded for every lua script.

Download and untar lua:
  mkdir lib
  cd lib
  curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz
  tar zxf lua-5.3.5.tar.gz

Then make nethack normally.
2019-11-06 18:43:20 +02:00
nhmall
3ccc6e5308 Merge branch 'NetHack-3.6' 2019-10-17 20:52:10 -04:00
PatR
e4f3559acc curses on unix - terminal reset needed after abort
Noticed while investigating the message loop.  If I had level files
from an interrupted game and was asked "Destroy old game?" when
starting a new one, answering 'n' left the terminal in an unusable
state.  Executing 'stty sane' (invisibly since input echo was off)
repaired things but the user shouldn't have to do that.

Change unixtty.c's error() to shut down windowing if that has been
initialized.  This might need some tweaking for tty, which will now
clear the screen before showing the startup error message.  Other
systems besides unix use unixtty.c so are affected, but I think the
change doesn't introduce anything that should cause trouble (aside
from the potential screen erasure).
2019-10-09 13:18:34 -07:00
nhmall
fe1b2d6e82 Merge branch 'NetHack-3.6' 2019-10-06 09:16:23 -04:00
PatR
0d76f68f2c tty xputc()
Another part of github issue 227.  Casting a function pointer when
passing it to another function is iffy when lying about the return
type.  tputs() expects a routine which returns int, so give it one.
Other xputc() usage is equivalent to putchar(), so define xputc()
with the same function signature as that has.

The tputs() declarations in system.h should probably be changed
(third argument is a function which takes an int rather than
unspecified parameters) but I've left them alone.  I made that change
to tputs() in sys/share/tclib.c though.

NT and MSDOS changes are untested.  tclib.c compiles ok with clang-
as-gcc on OSX but hasn't been tested with the port that uses it (VMS).
2019-10-05 16:49:34 -07:00
nhmall
8c20c52ecf remove STATIC_DCL, STATIC_OVL, STATIC_VAR, STATIC_PTR from sys/share 2019-07-14 17:28:48 -04:00
nhmall
efbe179f64 fix the msdos build for NetHack-3.7 2019-07-02 22:05:36 -04:00
nhmall
7054e06e42 NetHack minor release checklist items - savefiles
Make some progress on a couple of next minor release checklist
items, hopefully without introducing too many new bugs. This
is just the initial commit, and work continues.

Checklist items:

Savefiles compatible between Windows versions, whether 64-bit
or 32-bit in little-endian field format.

Selection of file formats:
 historical (structlevel saves),
 lendian (little-endian, fieldlevel saves),
 and just for proof-of-concept, ascii fieldlevel saves
 (the ascii is huge! 10x bigger than little-endian).

For the fieldlevel save, all complex data structures recursively
get broken down until until it is one of the simple types that
can't be broken down any further, and that gets when it gets
written to the output file.

New files needed for this build:

hand-coded:
include/sfprocs.h
src/sfbase.c      - really a dispatcher to one of the
                    output/input format routines.
src/sflendian.c   - little-endian output writer/reader.
src/sfascii.c     - ascii text output writer/reader.

auto-coded (generated):
include/sfproto.h
src/sfdata.c

This is just one approach. I'm sure there are countless others
and they have different pros and cons.

For producing the auto-coded files a utility called
universal-ctags, that is actively maintained and evolving,
was used to do all the heavy-lifting of parsing the
NetHack C sources to tabulate the data fields, and store
them in an intermediate file called util/nethack.tags
(not required for building NetHack if you already have a
generated include/sfproto.h and src/sfdata.c)

util/readtags (also not required for building NetHack
itself) will decipher the nethack.tags file and produce
the functions that can deal with the NetHack struct data
fields.

You can obtain the source for universal-ctags by cloning it
from here:
https://github.com/universal-ctags/ctags.git

The combination universal-ctags + util/readtags has been
tried and tested under both Windows and Linux, so it is
not tied to a particular platform.

Note: util/readtags will work only with universal-ctags
output, so other ctags are unlikely to work as-is.
Universal-ctags can be build from source very easily
under Linux, or under Windows using visual studio.
2019-06-23 00:11:46 -04:00
Pasi Kallinen
217671e00f Remove built-in speaker support
The changes to amiga, mac and msdos builds are untested.
2019-05-11 11:10:00 +03:00
nhmall
7e79bb2169 Merge branch 'NetHack-3.6.2' 2019-03-08 10:38:18 -05:00
PatR
62507fa40f sys/share/*_yacc.c update
For the pre-generated yacc sources, revert to the version of byacc
used for 3.6.1 and 3.6.0 to avoid unnecessary changes for 3.6.2.
2019-03-06 11:43:27 -08:00
nhmall
b367b4e868 Merge branch 'NetHack-3.6.2' 2019-01-29 17:23:22 -05:00
nhmall
97fdc3f3e4 build bits - mostly for Windows
Allow sys/share/random.c to be included in the build
always, even if USE_ISAAC64 is defined, by making most
of its contents conditional in that case.

That avoids Makefile tinkering when going back and
forth between USE_ISAAC64 and not during testing.
2019-01-29 11:31:41 -05:00
nhmall
befa1d94e9 Merge branch 'NetHack-3.6.2' 2019-01-25 21:08:03 -05:00
PatR
d63c9d866c band-aid for #H4041 - build warning: has_colors()
Since no one has come up with a better fix for has_colors() being
implicitly declared, add a hack for suppressing a compiler complaint
about has_colors() on linux and/or sco unix that use sufficiently old
<curses.h>.

Report was right after release of 3.6.0 but my fix at the time broke
compile when using more recent <curses.h>.
2019-01-24 15:25:50 -08:00
nhmall
f0defb1111 Merge branch 'NetHack-3.6.2' 2019-01-01 19:51:41 -05:00
nhw_cron
94aecd5ca0 This is cron-daily v1-Dec-30-2019. levcomp updated: sys/share/lev_comp.h sys/share/lev_yacc.c 2019-01-01 17:19:21 -05:00
nhw_cron
a2649ae879 This is cron-daily v1-Dec-30-2019. dgncomp updated: sys/share/dgn_comp.h sys/share/dgn_yacc.c 2019-01-01 17:19:11 -05: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
64be5fd35a lock -> g.lock 2018-12-25 13:05:43 -08:00
Bart House
c67f7e5122 globals from files.c moved to instance globals. 2018-12-25 12:56:27 -08:00
Bart House
16db7498d0 UNIX, VMS, DEF_PAGER, MICRO and MFLOPPY globals moved to g. 2018-12-25 09:34:24 -08:00
Bart House
9069615861 Global changes for qt, qt4, amiga, x11 and curses. 2018-12-24 21:28:44 -08:00
Bart House
e5e906dc3b Changes needed in various ports due to globals changes. 2018-12-24 14:47:51 -08:00
Bart House
9567526586 Changed references from hname to g.hname. 2018-12-22 14:51:26 -08:00
Bart House
c9565d4ef6 Change references from hackpid to g.hackpid in various ports. 2018-12-22 14:43:50 -08:00
Bart House
cb42021389 Last big push for moving globals to instance_globals. 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
nhmall
a2296d043f eliminate sys/share/pcsys.c from Windows build
Windows build was actually only using a single function
in there, so just add a similar function to sys/winnt/winnt.c
and eliminate the need for including sys/share/pcsys.c in
the build.
2018-12-19 06:43:00 -05:00
nhmall
ac1f5feb2c update .gitattributes for recent changes 2018-12-18 17:09:52 -05:00
Patric Mueller
7d15535923 Fix always trapped castle chest 2018-12-15 22:40:30 +01:00
nhmall
16cda0882c fix up PDCurses cursor placement for prompts 2018-12-14 23:08:41 -05:00
nhmall
5f21dd1308 fix apparent copy and paste error 2018-12-10 18:01:43 -05:00
nhmall
8d516d4358 clean up Windows exit routines 2018-12-08 22:34:50 -05:00
nhmall
a9342107c8 relocate safeproc.c from sys/share to win/share 2018-12-08 20:09:58 -05:00
nhmall
dc1e2da359 Windows startup modifications
Changes to be committed:
	modified:   include/winprocs.h
	modified:   src/options.c
	modified:   sys/share/pcmain.c
	new file:   sys/share/safeproc.c
	modified:   sys/winnt/Makefile.msc
	modified:   sys/winnt/stubs.c
	new file:   sys/winnt/windmain.c
	modified:   sys/winnt/winnt.c
	modified:   win/win32/vs2017/NetHack.vcxproj
	modified:   win/win32/vs2017/NetHackW.vcxproj
	modified:   win/win32/winhack.c

Because multiple window ports are supported on Windows
now, even in the same executable and selectable via
config file in some cases, some adjustments became
necessary. There will likely be some further refining
of this over the next day or two.

List of changes:

Move Windows startup from sys/share/pcmain.c and
into its own sys/winnt/windmain.c so that it can
be modified to fix some current breakage, and
allow altering the order of some things.

There is startup processing code that is common to
all of the Windows WindowPorts, but that startup
processing code needs to have no dependency on
any one of those WindowPorts.

Yet, during startup processing, some of the initialization
routines can end up calling NetHack functions that
expect an active Window port underneath, and if there
isn't one, routines like pline, impossible, panic can
end up invoking null function pointers.

Place a new file sys/share/safeproc.c, in which a complete
window port is available for early startup processing
purposes. It's WindowPort name field is set to
"safe-startup" just for reference.  The prototypes in
include/winprocs.h require that SAFEPROCS be

Usage:

 windowprocs = get_safe_procs(0);
initializes a set of winprocs function pointers that ensure
none of the function pointers are left null, but that's all it does.

 windowprocs = get_safe_procs(1);
initializes a set of winprocs functions pointers that ensure
none of the function pointers are left null, but also
provides some basic output and input functionality using nothing
other than C stdio routines (no platform or OS specific code).

The conditional code related to WIN32 has been removed from
sys/share/pcmain.c

The code common to all of the Windows WindowPorts calls
get_safe_procs() almost immediately to ensure that
there is a set of WindowPort winprocs available.
2018-12-08 17:56:20 -05:00
nhmall
4a4b3fb8f1 add a macro to ease conditional testing based on active window port
Add WINDOWPORT macro

example:
if (WINDOWPORT("tty"))
	pline("Look at me, I'm on tty at the moment!");
2018-12-02 09:56:44 -05:00
nhmall
802c22ed98 more gcc work for Windows
tty builds and executes
curses builds but crashes

gui - not even trying right now
2018-11-30 20:17:42 -05:00
nhmall
3634d16582 fix nethackw start without arguments
The Windows graphical version in NetHackW.exe is meant to lock
itself to its own windowtype and ignore the OPTIONS=windowtype
setting in the config file, but the code to perform the lock
only did so if (argc > 1).
2018-11-28 23:29:28 -05:00
PatR
b1f1594fbd updated sys/share/lev_comp.h, lev_{lex,yacc}.c
dgn_comp isn't affected.
2018-11-27 18:42:47 -08:00
nhmall
cb43061076 curses changes to existing files 2018-11-16 20:51:22 -05:00
nhmall
96ec49213f Add some windows command line option hooks 2018-11-16 19:32:00 -05:00
Bart House
8944235282 Enforced the inclusion of windows headers before nethack headers.
Moved the code page 437 mapping table to winnt.c so that it could be
used in window and console clients.
Added check that fonts support unicode values we use from code page 437.
Use unicode to draw text if font supports it otherwise use ASCII.
2018-11-12 01:58:56 -08:00
nhmall
a0b53ee391 merge 2018-11-11 10:29:52 -05:00
Bart House
0a3f6d17df Removed the defining of WIN32CONNDEBUG for NethackW.
Defined NOTTYGRAPHICS for NethackW.
2018-11-10 20:25:49 -05:00
nhmall
59019910b5 heed OPTIONS=symset:default in config file in windows and msdos 2018-09-10 15:27:05 -04:00