Converting all function definitions to ANSI style accounts for most of
the change. This has exposed other problems, such as daemons not
actually being their stated type, that will require more careful
solutions.
GCC5 enables more warnings by default, including pre-ANSI implicit
function definitions. These two games now build cleanly, but the others
will require more effort.
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.
MSVC complained that they might be used uninitialized. In some cases,
this might have been possible.
XRogue already has initializations for all these variables.
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().
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.
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.
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.
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().
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.
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.
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.
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.
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.
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.