Commit graph

128 commits

Author SHA1 Message Date
John "Elwin" Edwards
7da765d616 arogue7: make the scorefile location configurable. 2015-05-11 13:36:36 -04:00
John "Elwin" Edwards
3095366864 arogue7: add missing header includes. 2015-05-08 16:45:41 -04:00
John "Elwin" Edwards
cf121ade21 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490) 2015-05-08 15:24:40 -04:00
John "Elwin" Edwards
6af92da76a rogue5: ignore the file name stored in the save file.
state.c had put file_name into the save file.  The saved value was used
to overwrite file_name on restore.  If the save file had been renamed,
unlink(file_name) would then fail, because file_name held the old name.

To avoid breaking savefile compatibility, file_name is still saved, but
it is read back into a temporary buffer and then ignored.

I thought I fixed this already.
2015-01-16 13:42:30 -05:00
John "Elwin" Edwards
832d685d60 rogue4: fix restoring saved games on Windows/MinGW. 2014-05-09 07:52:02 -07:00
John "Elwin" Edwards
be61b1a69e rogue4, arogue5: improve portability.
Most changes merely prevent including header files that don't exist.

All games now build and run on MinGW, though bugs remain.
2014-05-07 14:08:38 -07:00
John "Elwin" Edwards
120beada5a srogue: more compatibility improvements.
Randomness now uses mdport, and xcrypt.c has been replaced with the
rogue5 version.

Super-Rogue now builds on MinGW.
2014-05-03 10:31:30 -07:00
John "Elwin" Edwards
b9cc9cf3a7 srogue: add and use more md_* portable functions.
Privileges and memory usage checks are now more portable.
2014-05-02 15:06:23 -07:00
John "Elwin" Edwards
791df4324f srogue: use functions from mdport.c.
Shell escape, passwd entries, terminal settings, and most signal
handling is now done with the more portable md_* functions.
2014-04-30 14:46:30 -07:00
John "Elwin" Edwards
de1e0f2759 srogue: add a complete mdport.c.
srogue/mdport.c is copied from rogue5/mdport.c, with slight changes.
2014-04-27 08:29:14 -07:00
John "Elwin" Edwards
9dc4559375 rogue5: save the game when SIGHUP is received.
This vital feature was turned off by default, requiring DUMP to be
defined to turn it on.  DUMP has the opposite effect in the other
games.
2014-04-26 08:52:26 -07:00
John "Elwin" Edwards
9a8022c683 Makefiles: don't set defaults for CFLAGS.
CFLAGS is now empty by default.  If its value must be set, it should be
done in the command line for make.
2014-03-29 09:45:33 -07:00
John "Elwin" Edwards
a8b96bbc3e arogue5: make alchemy jugs survive a save and restore.
Alchemy jugs are refilled by the alchemy() fuse, which takes a pointer
to the jug object as an argument.  When written to a save file and read
back out, the pointer is unlikely to point anywhere useful.

Instead, rs_write_daemons() now stores an index into the player's pack
or the list of objects on the floor.  rs_read_daemons() uses this
number to locate the object when restoring.

This change should not cause any new issues with old savefiles, but it
is unable to make a broken alchemy jug work again.
2014-03-28 15:51:43 -07:00
John "Elwin" Edwards
7b0ec1230e arogue5: fix some daemon-related pointer/int casting.
Daemons and fuses take a single argument, nominally an int but either
ignored or unsafely cast to a pointer.  Its type has now been changed
to void*.

The save/restore code no longer tries to store this argument in the
savefile.  For doctor(), this is not a problem, because player is the
only argument it is ever given as a daemon.  However, alchemy() will
fail to do anything when passed NULL.  Fixing this would be complicated
but possible.

Summary: the code is slightly safer, but alchemy jugs are guaranteed to
stop working after save and restore, instead of just extremely likely.
2014-03-28 10:57:03 -07:00
John "Elwin" Edwards
dff96acf36 srogue: remove unnecessary pointer cast.
Casting char* to int before a comparison doesn't alter the result, and
isn't safe if sizeof(char *) != sizeof(int).
2014-03-27 11:09:30 -07:00
John "Elwin" Edwards
67ec840c3c Don't truncate player name in savefile name or log message.
The player name is stored in whoami[], which is length 80 in most games
(1024 in rogue5).  Only the first 10 chars were used to create
file_name, because that buffer is the same length.  Increasing the size
of file_name to 256 permits using all of whoami.

The name is also no longer truncated to 20 chars when writing the log.

All games should now be able to handle 79-character names without
collisions.  Anything more would break save compatibility.
2014-03-23 21:27:14 -07:00
John "Elwin" Edwards
082cd54126 Fix some terribly depressing corruption during restore.
In rogue5/state.c, rs_read_daemons() zeroes out the argument and delay
if the daemon slot is empty.  Unfortunately that code ended up on the
wrong side of the brace that closes the for loop, so instead of running
after each daemon, it got run once after the loop exited, when the
index was of course out of bounds.

This tended to manifest, when compiled with -O2, by overwriting hw and
setting it to NULL.  When inventory() next ran, hw would be passed to
wgetch(), which returns ERR when it gets a NULL argument.  This made
md_readchar() think something was wrong and autosave the game.

Upon investigation, rogue3 was found to commit the same mistake.
rogue4 and srogue don't zero the data.  arogue5 already does it
properly.

Someday I am going to run all this through Valgrind.  Someday when I
am a kinder person who will not be driven to invoke hordes of trolls
and centaurs upon the original authors.
2014-01-08 16:44:16 -05:00
John "Elwin" Edwards
46568d24a4 arogue5: fix some save/restore-related crashes.
The save/restore code took the pointer intended as an argument for the
doctor() daemon and wrote it to the savefile as an int.  I don't know
why it took so long to fail horribly.  The problem has been avoided by
replacing the value with &player when restoring.  That seems to be the
only argument ever actually used.

The code also writes only four bytes for an unsigned long; if
sizeof(long) == 8, it casts to unsigned int first.  It failed to do the
cast when reading back, with the result that four bytes were read and
the other half of the number was effectively uninitialized.

It apparently works now, but the save/restore code ought still to be
regarded as decidedly unfortunate.
2014-01-06 15:57:17 -05:00
John "Elwin" Edwards
0f998b01ad rogue4: don't include config.h if it wasn't created. 2013-09-09 07:58:47 -04:00
John "Elwin" Edwards
ea75e2ac0b arogue5: use configure's checks to find term.h.
This should make the build process work on OS X.
2013-09-07 09:43:06 -04:00
John "Elwin" Edwards
720d587422 Rename daemon() to start_daemon().
daemon() conflicted with the standard library function, which is
included by default on OS X.
2013-09-07 08:08:00 -04:00
John "Elwin" Edwards
05b8759305 Update some of the documentation. 2013-09-04 09:01:44 -07:00
John "Elwin" Edwards
6d1d59555c srogue: enable the keypad when restoring.
keypad() was only being called when starting a new game, which meant
the arrow keys did not work when restoring a saved game.
2013-09-03 15:39:04 -07:00
John "Elwin" Edwards
36769ea3e4 Add config.h to the list of headers in the Makefiles.
Some .o files need to be rebuilt if config.h changes.  Adding it to the
list of headers may still fail to solve the problem, because some of
the Makefiles use implicit rules or do not list dependencies properly.
2013-09-03 14:14:48 -07:00
John "Elwin" Edwards
e9c1b3c8b9 srogue: fix backspace key during prompts.
md_readchar() handled the key properly, but get_str(), which is called
when prompting user entry, called wgetch() instead of md_readchar().
2013-09-03 14:02:15 -07:00
John "Elwin" Edwards
138383b394 srogue: add install and uninstall targets to Makefile 2013-09-02 15:47:37 -07:00
John "Elwin" Edwards
35a6ab583c srogue: begin porting to autoconf.
Super-Rogue can now be built with './configure && make', though
'make install' does not work yet, and there may be problems with
portability.
2013-09-01 20:50:52 -07:00
John "Elwin" Edwards
7d4d7dbbe8 srogue: allow wizard mode to be compiled out. 2013-08-31 14:24:31 -07:00
John "Elwin" Edwards
47712fdf5d arogue5: port to autoconf.
'configure' and 'make install' now work.  There may be problems with
hard-to-test features like MAXLOAD.
2013-08-31 09:18:07 -07:00
John "Elwin" Edwards
9d5cb81410 srogue: fix backspace key.
Once the full mdport.c is added to srogue, erasechar() will be replaced
with md_erasechar().
2013-08-28 18:54:35 -07:00
John "Elwin" Edwards
6b4b35ba1e arogue5: fix backspace key. 2013-08-28 08:37:56 -07:00
John "Elwin" Edwards
9506edfdc4 Fix some 'test' failures when running 'make install'.
When shell variables are unexpectedly empty, 'test' gets the wrong
number of arguments and becomes unhappy.  Logical AND should not be
done with 'test EXPR1 -a EXPR2' in such cases, because 'test' logic
does not short-circuit.  Replace with 'test EXPR1 && test EXPR2'.
Shell logic does short-circuit, and if the first test invocation
fails, the second will never occur, and will never encounter missing
arguments.
2013-08-27 22:54:28 -07:00
John "Elwin" Edwards
1f1ae55a26 Make sure file_name contains '/' between SAVEDIR and the file name.
Duplicated slashes are not a problem.  Missing slashes are.
2013-08-27 22:25:40 -07:00
John "Elwin" Edwards
5a25cd89da rogue[345]: fix backspace key in prompts.
md_readchar() mapped KEY_BACKSPACE to CTRL-H, but get_str(), which
handles prompts for strings, only backs up when it receives the erase
character.  The key should be mapped to md_erasechar().

This fixes Red Hat Bugzilla #847852.
2013-08-27 09:25:30 -07:00
John "Elwin" Edwards
fef5939ab1 Don't set DESTDIR via configure.
DESTDIR ought to be set via option passed to 'make install'.
2013-08-26 19:58:44 -07:00
John "Elwin" Edwards
4e5449535a rogue3: set missing Makefile variables.
Some variables had been overlooked, which caused the documentation to
be installed in the wrong places.
2013-08-25 21:31:22 -07:00
John "Elwin" Edwards
41aaefc7b9 rogue3: add install and uninstall targets to Makefile. 2013-08-25 19:52:23 -07:00
John "Elwin" Edwards
bd7cb16026 rogue3: update the installation instructions. 2013-08-24 14:07:16 -07:00
John "Elwin" Edwards
60b7a0d98e rogue3: short bows should not be called int bows.
I thought I fixed this already.
2013-08-24 13:50:15 -07:00
John "Elwin" Edwards
7f1fc97497 rogue3: begin porting to autoconf.
Rogue V3 can now be built with './configure && make'.  This is
preliminary: 'make install' does not work yet.
2013-08-24 13:36:13 -07:00
John "Elwin" Edwards
0e8809de2b Don't set the player's ISRUN flag.
rogue4 and rogue5 set the player's ISRUN flag upon exit from sleep or
holding.  This is apparently supposed to indicate that the player can
move again.  What it actually does is make it harder for monsters to
hit the player, until the flag is reset.

As this behavior makes little sense and seems like a cheat, it has
been deemed a bug and removed.
2013-08-13 09:19:56 -07:00
John "Elwin" Edwards
4aa582dfb6 srogue: add arrow-key support.
This is a first attempt which may not be completely portable.
2013-08-10 17:43:58 -07:00
John "Elwin" Edwards
2d117230ed Refuse to restore if the character is dead.
This prevents recovering from death by killing the game between death
and exit, producing an automatic save.
2013-08-09 09:34:07 -07:00
John "Elwin" Edwards
5a47554e45 rogue4: don't delete the savefile if the terminal is too small.
Let the user resize the terminal and try again.
2013-08-08 14:30:12 -07:00
John "Elwin" Edwards
e375c8bd05 Properly handle invalid room references in savefiles.
In all games, rs_write_room_reference() stored -1 for a nonexistent
room, but rs_read_room_reference() did not check for out-of-bounds
values, leading to pointers to rooms[-1], which sometimes caused
crashes.  rs_read_room_reference() has now been modified to use NULL
instead.

Some of the games required further changes to replace NULL with the
pointer to the actual room.  Others are capable of handling NULL for
objects not in any room.
2013-08-08 12:41:35 -07:00
John "Elwin" Edwards
a210387f8d srogue: don't store machine-dependent metadata in the savefile.
Super-Rogue, like Rogue V4, stored data of machine-dependent length in
the savefile, to prevent cheating.  This made saved games non-portable.
Also deleted was a check that used this data, and prevented restoring
savefiles from backup.

This change BREAKS SAVEFILE COMPATIBILITY, but old files can be
converted by removing the block at offset 0x1e with length
sizeof(ino_t) + sizeof(dev_t) + 2 * sizeof(time_t).  That seems to be
0x14 on i686 and 0x20 on x86_64.
2013-08-06 19:02:58 -07:00
John "Elwin" Edwards
fdc346deb1 rogue4: don't put savefile metadata into the savefile.
The save_file() function in save.c stored the savefile's device number,
inode number, creation time, and modification time in the file.  The
restore() function read them back, and apparently used to compare them
to protect against cheaters.

Unfortunately, the types and sizes of these numbers differ from system
to system, which ruins the Roguelike Restoration Project's fine
portability work.  So they have been removed from the savefile.

This BREAKS SAVEFILE COMPATIBILITY, but old files can be converted by
excising the chunk starting at offset 0x22 with length sizeof(ino_t) +
sizeof(dev_t) + 2 * sizeof(time_t).  That's 0x14 on i686 and 0x20 on
x86_64, at least with current versions of Linux and glibc.
2013-08-05 20:49:41 -07:00
John "Elwin" Edwards
7f094a6b77 Add a top-level README.txt. 2013-07-01 07:58:55 -07:00
John "Elwin" Edwards
b6bcf2e3f4 arogue5: make some prayer-related messages appear properly. 2012-09-09 17:58:38 -07:00
John "Elwin" Edwards
ad5245c5f8 arogue5: fix some more drawing to the wrong window.
The spell-choosing and prayer-choosing routines, when the one-line
inventory option is set, displayed to cw instead of msgw.  This caused
permanent corruption of the message line.
2012-09-09 15:55:51 -07:00