Commit graph

207 commits

Author SHA1 Message Date
John "Elwin" Edwards
d20fe81e22 Update the Visual Studio project files.
These files were produced by Visual Studio 2015 on Windows 8.1.
2015-08-18 13:23:56 -04:00
John "Elwin" Edwards
13f4a96d93 XRogue: fix md_htonl() and md_ntohl().
xcrypt requires them.  The implementations in state.c used htonl() and
ntohl(), which aren't available on Windows.  So the Advanced Rogue 7
versions were copied over.

This implementation could be problematic on other systems where
sizeof(long) == 8.  Maybe someday I can convert everything to C99 and
use stdint.h.
2015-08-13 17:17:40 -04:00
John "Elwin" Edwards
b2ebcf72c9 XRogue: add and use more md_ functions.
Portable md_fileno() and md_unlink() have been added to state.c.
2015-08-13 15:15:21 -04:00
John "Elwin" Edwards
7d750a4410 XRogue: fix some header includes. 2015-08-13 14:57:26 -04:00
John "Elwin" Edwards
50961af028 Permit not defining score and log files. 2015-08-13 07:47:01 -04:00
John "Elwin" Edwards
6813e9c5bf Advanced Rogue 7: add and use more md_ functions.
md_fileno() and md_fdopen() are now included.  I still hope to rewrite
everything to use FILE *'s.
2015-08-13 07:38:57 -04:00
John "Elwin" Edwards
916a683bf6 Advanced Rogue 7: remove some unused md_ functions.
md_hasclreol() and md_sleep() were not actually portable.  If they were
needed in the future, fixing them would be possible.
2015-08-12 17:03:15 -04:00
John "Elwin" Edwards
9c93a66db7 Fix some preprocessor directives.
Include process.h in the right place, and use the correct definition of
PATH_MAX, when compiling on Windows.
2015-08-12 16:56:19 -04:00
John "Elwin" Edwards
295a180ea1 Advanced Rogue 7: initialize multiple variables.
MSVC complained that they might be used uninitialized.  In some cases,
this might have been possible.

XRogue already has initializations for all these variables.
2015-08-12 15:42:02 -04:00
John "Elwin" Edwards
b41fb230b0 Advanced Rogue 5: remove an unneeded fstat() call.
The results of the call are no longer used to check for savefile
copying.
2015-08-11 16:19:04 -04:00
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
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