Commit graph

303 commits

Author SHA1 Message Date
John "Elwin" Edwards
37cc3eeaba arogue7, xrogue: fix command repetition.
In both games, command() loops and calls the action function twice for
each command: once to schedule it by setting player.t_action and
player.t_no_move, and again, to actually do it, once player.t_no_move
has been reduced to 0.  Each loop decremented count, so repeated
commands were only repeated half the number of times the player typed.

count is now decremented only when ch has been set to the repeated
command.
2015-05-28 11:08:03 -04:00
John "Elwin" Edwards
4e5f4c52d3 arogue7, xrogue: rename daemon() to start_daemon().
This prevents conflict with the BSD/OSX daemon() system function.
2015-05-28 10:21:43 -04:00
John "Elwin" Edwards
b369d09125 arogue7: fix the backspace key in prompts.
md_readchar() now translates KEY_BACKSPACE to the erase character.

XRogue seems to work already.
2015-05-28 09:41:29 -04:00
John "Elwin" Edwards
d793ca961f arogue7, xrogue: add support for keypad 5.
Keypad 5 is now equivalent to the '.' key.

XRogue does not include md_readchar() and its ability to work around
deficiencies in the terminfo entry. So the key will not be recognized
in screen/tmux or anywhere else without the kb2 capability.  Adding
md_readchar() would be more complex than it was for Super-Rogue, since
XRogue already does KEY_* interpretation in command().
2015-05-27 17:29:32 -04:00
John "Elwin" Edwards
94b05cac99 arogue7: ask about unidentified objects by default.
The 'askme' option is on in some games and off in others, probably due
to authorial preference.  I am going to be consistent and turn it on in
all of them.
2015-05-21 09:02:15 -04:00
John "Elwin" Edwards
053a248658 arogue7, xrogue: put newlines at the end of startup messages. 2015-05-20 15:15:29 -04:00
John "Elwin" Edwards
faa24df096 xrogue: add an exit prompt.
This gives the player a chance to see the high score list when playing
via dgamelaunch.
2015-05-20 12:51:16 -04:00
John "Elwin" Edwards
e3620a3781 Advanced Rogue family: fix the "score" option.
Changing the score file (when permitted) now works again, closing the
old score file and opening the new one.
2015-05-20 08:42:17 -04:00
John "Elwin" Edwards
ea4244de91 arogue7, xrogue: prevent potential NULL dereferencing.
It is possible for getpwuid() to fail and return NULL.  Various md_get*
functions now check for this.
2015-05-18 10:53:22 -04:00
John "Elwin" Edwards
3554339257 Advanced Rogue family: overhaul privilege handling.
Advanced Rogue 5 and 7, and XRogue, now open the scorefile and logfile
at startup and then drop any set[ug]id privileges if the savedir is not
being used.
2015-05-16 13:39:26 -04:00
John "Elwin" Edwards
1a5e14ad9b Merge arogue7 and xrogue trees. 2015-05-12 21:39:39 -04:00
John "Elwin" Edwards
3bcf8ac2c1 arogue7: prevent segfaults when backstabbing while empty-handed.
The calculation of the backstabbing multiplier checked the current
weapon's properties without making sure the current weapon pointer was
not NULL.
2015-05-12 18:57:30 -04:00
John "Elwin" Edwards
e8f5429554 arogue7: call nonl() during initialization. 2015-05-12 10:28:05 -04:00
John "Elwin" Edwards
e4d23af7c5 arogue7: record completed games in a logfile. 2015-05-12 09:55:05 -04:00
John "Elwin" Edwards
b6ab08176a arogue7: prevent changing protected options.
When using the savedir, whoami, file_name, and score_file cannot be
changed.
2015-05-11 19:41:46 -04:00
John "Elwin" Edwards
7824f79164 arogue7: implement the -n option. 2015-05-11 16:46:00 -04:00
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
fe8a158d6a xrogue: call nonl() during initialization.
This prevents some confusion between CR and LF characters.
2015-05-05 20:54:33 -04:00
John "Elwin" Edwards
fb870fdb4e xrogue: don't segfault when backstabbing while empty-handed.
The code for backstabbing checked the weapon's properties without
making sure it was not NULL.
2015-05-05 12:12:20 -04:00
John "Elwin" Edwards
85a0b26fa3 xrogue: compile out wizard mode by default. 2015-05-05 12:07:12 -04:00
John "Elwin" Edwards
9c0cafd74d xrogue: record the result of each game in a logfile. 2015-05-05 11:24:02 -04:00
John "Elwin" Edwards
283506baf9 xrogue: restrict changes to the save file location.
When using the -n option, disallow changing file_name or whoami via
options or dialogs.
2015-05-02 07:31:14 -04:00
John "Elwin" Edwards
e35502804b xrogue: initial support for the -n option.
The scorefile location is also configurable now.
2015-04-22 16:03:00 -04:00
John "Elwin" Edwards
dec970210b xrogue: add missing includes.
This prevents some warnings.
2015-04-21 10:34:01 -04:00
John "Elwin" Edwards
02cec53f85 xrogue: fix definition of struct delayed_action.
Arrays of struct delayed_action were declared before the definition.
Also, daemon.c and state.c defined it differently.  The state.c
definition, in which d_arg is a union, is now used everywhere.

This is the least bad option, but fuses and daemons are still a
disheartening morass that undoubtedly shelters more bugs.
2015-04-21 10:11:02 -04:00
John "Elwin" Edwards
034d8d6484 Import XRogue 8.0 from the Roguelike Restoration Project (r1490) 2015-04-21 08:55:20 -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