Commit graph

248 commits

Author SHA1 Message Date
John "Elwin" Edwards
9ad85754bd Advanced Rogue 5: replace calls to unlink() with md_unlink(). 2015-08-11 16:12:09 -04:00
John "Elwin" Edwards
4381177d66 Advanced Rogue 5: rearrange some of mdport.c.
process.h is now included in the proper place for compiling with MSVC.

md_sleep() has been removed.  If it were used anywhere, it could have
been fixed by replacing _sleep() with Sleep().
2015-08-11 15:29:31 -04:00
John "Elwin" Edwards
47df21eb66 Advanced Rogue 5: add and use md_fdopen().
Portability is improved.
2015-08-11 15:15:09 -04:00
John "Elwin" Edwards
c0f3e1f004 Advanced Rogue 5: initialize some variables. 2015-08-11 13:13:08 -04:00
John "Elwin" Edwards
6fda9fb94b Advanced Rogue 5: don't declare getenv() in rogue.h.
stdlib.h can declare it better.
2015-08-11 12:28:17 -04:00
John "Elwin" Edwards
bd3da25934 Advanced Rogue 7: rearrange messages from potions of food detection.
The message about detecting food now appears before the food symbols
are displayed.  I think this is closer to the original behavior.
2015-08-10 20:39:40 -04:00
John "Elwin" Edwards
1713cb840c Merge a bug fix from the stable branch. 2015-08-07 09:07:14 -04:00
John "Elwin" Edwards
aad9327bd4 srogue: fix an uninitialized variable.
In wanderer(), if rp == hr, the loop could test ch before its value has
been set.  Initializing ch to '-' now causes the loop to repeat until
a location is found.
2015-08-04 11:39:49 -04:00
John "Elwin" Edwards
268b30f851 srogue: provide type definitions if needed.
If not defined in headers, uid_t and gid_t will be defined as
unsigned ints, and pid_t as int.
2015-08-03 21:29:16 -04:00
John "Elwin" Edwards
3b34109c93 srogue: clean up configuration in mdport.c.
curses.h is already included in rogue.h and doesn't need to be included
twice more in mdport.c.

Also set flags for some features when they are present.
2015-08-03 17:16:42 -04:00
John "Elwin" Edwards
00142507db srogue: add and use md_fdopen().
The implementation was copied from rogue4.  Using fdopen() is necessary
because the scorefile needs both encread() and encwrite().  For some
reason I have failed to discover, one of them uses FILE *'s and the
other uses file descriptors.
2015-08-03 09:27:43 -04:00
John "Elwin" Edwards
e857a2cec6 srogue: make checking directories slightly more portable.
MSVC sys/stat.h doesn't define S_ISDIR().
2015-08-03 09:05:15 -04:00
John "Elwin" Edwards
214c2f6608 srogue: remove remnants of deleted savefile checks.
save_file() used fstat() and direct write() as part of the inode check
which was deleted in f11eeafc.  These operations no longer had any
effect.
2015-08-03 07:04:48 -04:00
John "Elwin" Edwards
b1e2b6206d srogue: replace unlink() with md_unlink().
md_unlink_open_file() might be needed eventually.
2015-08-03 06:42:59 -04:00
John "Elwin" Edwards
2c4ad7e941 srogue: another unistd.h which should not be included on Windows. 2015-08-03 06:30:09 -04:00
John "Elwin" Edwards
e79714e88d srogue: don't try to include unistd.h on Windows. 2015-08-02 15:25:24 -04:00
John "Elwin" Edwards
0b952fe136 Merge Super-Rogue fixes into the MSVC testing branch. 2015-08-02 12:25:44 -04:00
John "Elwin" Edwards
de013693fd srogue: prevent overflowing the score file name.
If SCOREFILE is not defined, roguehome() is called to find a directory
for the score file.  It copies up to PATH_MAX-20 bytes from an
environment variable to a static buffer.  Later these are strcpy()'d to
scorefile, which is of size LINLEN.  Unfortunately LINLEN is 80 and
PATH_MAX is at least 256.  On Linux, it happens to be 4096.

I haven't yet managed to crash or exploit it, but there are surely no
beneficial consequences, so roguehome() has been modified to check the
length, and the string it returns is also checked in main().
2015-08-02 12:14:47 -04:00
John "Elwin" Edwards
dea62ef934 srogue: initialize some pointers.
MSVC complained that they might be used uninitialized.
2015-08-01 21:23:55 -04:00
John "Elwin" Edwards
3c781f89fe srogue: remove md_droppriv() and md_resetpriv().
These partial privilege-dropping functions are no longer needed.
2015-08-01 16:31:03 -04:00
John "Elwin" Edwards
2e4f161e40 srogue: improve privilege handling.
Setgid privileges are now dropped when not required.  restore() is now
less complex.
2015-08-01 16:23:24 -04:00
John "Elwin" Edwards
bc5b26fece srogue: open the score and log files when the program starts.
Super-Rogue can now use the same privilege-dropping scheme as the other
games.
2015-08-01 15:12:11 -04:00
John "Elwin" Edwards
097b315235 rogue4: don't try to close the scorefile if it isn't open.
The MSVC library uses a debug assertion to prevent closing file
descriptors that are negative.  This is always the case with the
scoreboard file descriptor if the scoreboard has been compiled out.
2015-07-31 20:12:33 -04:00
John "Elwin" Edwards
4bd72ac69f rogue4: rearrange some includes.
Using MSVC with pdcurses, curses.h has to be included after windows.h
and before process.h.  This is apparently because bool is now a
built-in type which pdcurses is not allowed to redefine.  But I don't
entirely understand how the headers are interacting, and I don't think
the MSDN page does either.
2015-07-31 20:01:44 -04:00
John "Elwin" Edwards
00d28d536a rogue3: initialize various pointers.
MSVC is afraid they might get used while uninitialized.
2015-07-31 15:34:34 -04:00
John "Elwin" Edwards
2d3d25c5e9 Remove an extra '='.
This is a bug I can't blame on the original authors.
2015-07-23 19:28:12 -04:00
John "Elwin" Edwards
3ebd6da87d arogue7: fix messages from detection potions.
Another fix for overwritten messages, this time for potions of monster
detection and magic detection.

I've made the message appear before the display of information, which
may be closer to the originally intended behavior.
2015-07-02 16:27:39 -04:00
John "Elwin" Edwards
c864015af9 Advanced Rogue family: fix messages from some scrolls.
When scrolls of magic mapping or gold detection were read, their
characteristic messages were displayed before overwriting the whole
screen to show the newly discovered information.  They are now shown
after updating the screen, so they will be visible.
2015-07-02 08:04:16 -04:00
John "Elwin" Edwards
366f2a27a8 arogue7: fix messages from potions of food detection.
Updates to the screen took place in the wrong order, causing messages
and "--More--" prompts to be hidden before they could be seen.

There are probably similar bugs caused by other items.
2015-06-30 15:32:32 -04:00
John "Elwin" Edwards
4c696eef47 arogue7: fix inventory display bug again.
Removing the call to msg() in restore() resulted in msgw remaining as
it was when the game was saved.  This results in another display glitch
like that fixed by r163.  Adding an empty message puts msgw into a
reliable state.
2015-06-30 12:00:02 -04:00
John "Elwin" Edwards
8fed78336a ARogue family: don't hide messages caused by moving to a new level.
new_level() redraws the whole screen, including the message line, so if
msg() has just been called, the message will likely not last long
enough to be noticed.  These cases have been changed so that msg() is
called after new_level().

If a fall through a trapdoor is fatal, "You fall into a trap!" is no
longer printed, but the tombstone should make things clear.
2015-06-29 20:37:32 -04:00
John "Elwin" Edwards
419a920e1d arogue7, xrogue: fix uninitialized variables when restoring.
The save and restore code assumed sizeof(long) == 4, which is not the
case on x64.  Reading only 4 bytes from the savefile left the others
uninitialized, which led to problems like billions of experience points
or gold pieces.
2015-06-26 11:42:02 -04:00
John "Elwin" Edwards
c639303acf arogue7: comment out a problematic message.
This line causes a segfault on x64.  I suspect one of the char*
arguments to msg() is being corrupted.  But gdb doesn't make it easy
to debug variadic functions, and the crash doesn't occur when running
under valgrind.  So the message is being removed until I can discover
the root of the problem.
2015-06-26 11:32:37 -04:00
John "Elwin" Edwards
3c792f4898 Move some autotools files to where configure can find them.
rogue5 uses config.guess and config.sub to find the canonical system
names.  The configure script expects them to be in the same directory
as install-sh.  So they have been relocated to the top level.

This is a quick and dirty fix.  The eventual plan is to relocate them
to /dev/null.

I also suspect they should be used to set HOST, not TARGET.  Rogue is
not a cross-compiler.
2015-06-16 11:44:49 -04:00
John "Elwin" Edwards
79a736fd0b arogue7: fix a display bug when viewing inventory after restoring.
The restore() function displayed a status message via wprintw() instead
of using the msg() functions.  If the inventory was then viewed before
a call to msg(), msgw would obscure the first lines of the inventory
list.

There are surely more bugs related to messages.
2015-06-12 12:09:16 -04:00
John "Elwin" Edwards
5d0e3dd646 Don't swap signal handlers in md_shellescape().
md_shellescape() sets SIGINT and SIGQUIT to be ignored, storing the
previous handlers, and restores them after the shell exits.  But it
mixed up the two handlers.

Since the signals were usually handled by the same function, this fix
doesn't have much effect, but anything that makes signal code less
confusing is a good thing.
2015-06-08 10:01:25 -04:00
John "Elwin" Edwards
6ab6c944fb Only include one copy of the install-sh script. 2015-06-05 18:02:17 -04:00
John "Elwin" Edwards
3a456017a7 arogue7, xrogue: set CFLAGS empty by default in the Makefiles. 2015-06-05 14:06:11 -04:00
John "Elwin" Edwards
ec3e34544a arogue7, xrogue: fix configure's wizardmode and limitscore options.
WIZARD and LIMITSCORE, when set by options to './configure', are no
longer overridden in mach_dep.h.
2015-06-05 13:57:38 -04:00
John "Elwin" Edwards
cfe8f3c281 arogue7, xrogue: add 'install' targets to Makefiles.
'make install' and 'make uninstall' should now work as expected.
2015-06-04 17:08:40 -04:00
John "Elwin" Edwards
321e437f47 Fix a typo in configure.ac.
'test' had been misspelled 'text', and the error had propagated to all
seven games.
2015-06-04 14:48:25 -04:00
John "Elwin" Edwards
d3c281122c arogue7, xrogue: begin using autoconf.
File locations can be customized via './configure'.  'make install'
does not work yet.  Options for wizard mode and load checks may not do
what is intended.

Fun fact: there's an enlightening epigraph in the introduction to the
autoconf manual.
2015-06-04 10:41:39 -04:00
John "Elwin" Edwards
97ef6ee2df arogue7, xrogue: fix save/restore of alchemy jugs.
state.c now saves the fuse that refills alchemy jugs, using the method
of numbering objects previously applied to Advanced Rogue 5.  Alchemy
jugs that are empty when the game is saved will continue to function
after it is restored.

Savefile compatibility should not be affected.
2015-05-29 17:34:04 -04:00
John "Elwin" Edwards
3232b9e4ba Mention arogue7 and xrogue in the README. 2015-05-28 15:39:28 -04:00
John "Elwin" Edwards
f5bd700b2d xrogue: escaping to a shell should not cause a move to the left.
This was due to the classic error of forgetting a break statement.
2015-05-28 13:51:01 -04:00
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