Commit graph

89 commits

Author SHA1 Message Date
John "Elwin" Edwards
35c5e434e6 Rearrange some Autoconf files.
Autoconf was failing to detect install-sh at the top level and needed
some explicit directions.  It also wants config.guess and config.sub to
be provided too.

A few other macros have also been updated.
2023-09-05 20:05:24 -04:00
John "Elwin" Edwards
8a4bf37667 Naming items should not use up a turn.
This was fixed by adding "after = FALSE;" to the relevant cases in
command().

Rogue V4 and V5 are not affected.
2021-10-31 21:35:53 -04:00
John "Elwin" Edwards
6a654fbe69 Update the Autoconf files.
These are mostly automatic updates for obsolete macros.
2021-05-11 22:30:03 -04:00
John "Elwin" Edwards
06cad9ee1e Fix one more batch of compiler warnings.
A few of these were potential bugs.
2021-05-04 21:03:47 -04:00
John "Elwin" Edwards
d1422feb80 Fix a few more miscellaneous compiler warnings. 2021-05-01 09:51:30 -04:00
John "Elwin" Edwards
3ac49bdaa0 Super-Rogue: fix some out-of-range constants.
Constants K_ARROW etc., for causes of death other than monsters, are in
the 240-255 range.  They were often passed to functions taking char,
which is usually signed, making the values out of range.

The function declarations have been changed to unsigned char, which is
also the type used by the scoreboard code.
2021-04-17 15:41:12 -04:00
John "Elwin" Edwards
6c3cd116ff Fix many compiler warnings.
There should only be two changes in behavior:

arogue7/fight.c, arogue7/fight.c: a to-hit bonus is now correctly
applied to characters who are not monks instead of monks who are not
empty-handed.

urogue/fight.c: fixed an interaction with the "debug" macro that could
cause the wrong message to be displayed.
2021-04-14 18:55:33 -04:00
John "Elwin" Edwards
7d459d7d36 Fix an assortment of compiler warnings.
A few potential bugs were removed in the process.  Much code cleanup
remains to be done.
2019-11-22 21:18:27 -05:00
John "Elwin" Edwards
bb37c1c3f7 Improve the documentation build process.
The choice between troff implementations is now made at configure time,
rather than using shell logic in the Makefile to choose while building.
2017-12-30 14:15:52 -05:00
John "Elwin" Edwards
338214459d Fix a portability issue with md_hasclreol().
Some games' implementation of md_hasclreol() poked around in ncurses
internals, which does not work for some ncurses build configuration.
Most games did not actually call md_hasclreol(), so it was removed.
There is a standard terminfo function which can retrieve the value of
the clr_eol capability, so this was used for rogue5.
2017-12-27 10:26:06 -05:00
John "Elwin" Edwards
359d0987a4 Remove version numbers from docdir paths.
Most Unix systems prefer to omit the versions.
2017-10-16 19:53:38 -04:00
John "Elwin" Edwards
172c83f254 Fix some potential problems detected by clang.
Most of these are unnecessary comparisons and functions returning the
wrong types.
2017-09-23 09:47:00 -04:00
John "Elwin" Edwards
90d5708d84 Fix a few more compiler warnings. 2017-09-18 19:36:14 -04:00
John "Elwin" Edwards
0936c8f216 Excise md_putchar().
The function wrapped the standard putchar(), doing nothing beside
discarding the return value.  That could cause problems with tputs(),
which expects an int to be returned.
2017-09-18 19:11:57 -04:00
John "Elwin" Edwards
ab25967717 Fix potential segfaults at restore related to ctime().
In some games, restore() passes the result of ctime() to mvprintw() or
some other variadic message-formatting function.  If ctime() has not
been declared properly, its return type is inferred to be int instead
of char *.  This does not cause a warning because the compiler does not
know the correct type of variadic arguments.

On platforms where ints and pointers are not the same size, this can,
probably depending on alignment, result in a segfault that is not easy
to trace.

Including time.h fixes the problem.  Some games manually declared
ctime() and avoided the bug.  These declarations have also been
replaced with the include.
2017-09-15 20:51:10 -04:00
John "Elwin" Edwards
c661fd79d4 Use C stdio functions for score files and save files.
Switching from Unix file descriptor operations to C standard FILE*
functions will reduce portability problems.
2017-09-15 19:57:54 -04:00
John "Elwin" Edwards
f8d1f422c8 Remove an extra bracket from some Autoconf macros. 2017-09-10 17:30:13 -04:00
John "Elwin" Edwards
62047972cc Use more portable random seed generation.
The new function md_random_seed() has replaced time() + getpid() and
similar methods.  Putting everything in mdport.c slightly reduces the
warnings and workarounds.
2017-01-28 15:49:41 -05:00
John "Elwin" Edwards
c194ec3dc9 Fix the perpetual haste cheat.
Rogue V3 allowed the player to gain perpetual haste by quaffing a
potion of haste while already hasted.  This is supposed to remove the
haste effect and cause temporary paralysis.

Super-Rogue removed haste correctly, but gave confusing messages.
2017-01-28 11:45:36 -05:00
John "Elwin" Edwards
63b2707739 Enable the logfile on 64-bit Windows.
It seems to work without any problems.

One use of a non-portable function was corrected in the process.
2016-05-17 21:28:34 -04:00
John "Elwin" Edwards
ca1c442db2 Rogue V[345], Super-Rogue: Fix violet fungi/venus flytraps.
Violet fungi (renamed venus flytraps in Rogue V5) do an increasing
amount of damage each time they hit.  If they miss, you still suffer
the same number of HP.  This worked by keeping a counter and printing
new damage strings into monsters[5].m_stats.s_dmg, which is the
"prototype" of that particular monster.

Each individual monster has its own damage string.  Apparently these
were once char *, pointing to the same string as the prototype.  When
the s_dmg member was changed to be an internal char array, changing the
prototype's damage string no longer had any effect on actual monsters.

As a result, flytraps did no damage on a hit, or only one point in V5.
The mechanism for doing damage on a miss continued to work.

This has been fixed by overwriting the individual monster's damage
string instead of the prototype's.  It is now no longer necessary to
reset the damage string when the flytrap is killed.  The method for
resetting it when the hero teleports away had to be modified.  Comments
referencing the long-unused xstr have been removed.
2016-05-01 19:39:56 -04:00
John "Elwin" Edwards
2d4a66298a Fix some functions not returning the right type. 2016-03-19 16:18:58 -04:00
John "Elwin" Edwards
84db7dbc2a Super-Rogue: fix saving and restoring on Windows.
The problem turned out to be that the save file wasn't being deleted
because it was still open.
2016-03-12 14:29:07 -05:00
John "Elwin" Edwards
8df0a6308d Merge the GCC5 and build fix branches.
This fixes all warnings produced by GCC 5, except the ones related to
system functions.  Those could be fixed by including the proper headers,
but it would be better to replace the system-dependent code with
functions from mdport.c.
2016-03-11 19:47:52 -05:00
John "Elwin" Edwards
e30aa0e491 Makefiles: don't rely on built-in implicit rules.
Not all make implementations will use CPPFLAGS when compiling C files.
2016-03-08 19:45:41 -05:00
John "Elwin" Edwards
a6c73eb65a Fix various overlooked causes of warnings.
GCC5 now produces under 300 lines of warnings, but the remaining ones
will require more complex solutions.
2016-03-06 21:02:59 -05:00
John "Elwin" Edwards
fece552183 Don't force the use of GCC.
Due to incomplete autoconfiscation, most of the Makefiles ignored the
C compiler found by 'configure' and always used 'gcc'.
2016-03-06 17:09:17 -05:00
John "Elwin" Edwards
0a354903e0 Daemons and fuses now return void.
Functions for starting and stopping daemons and fuses now expect the
type 'void (*func)()'.  Only a few functions in XRogue needed to be
modified to fit.  Determining the type of the argument is left for a
later date.

Building with GCC5 should now produce less than 200 lines of warnings
per game.
2016-03-05 20:49:37 -05:00
John "Elwin" Edwards
6dfde944f0 Rogue V4, V5: disable a cheat granting permanent monster detection.
In these two games, a potion of monster detection turns on the player's
SEEMONST flag.  A fuse is set to call turn_see() to turn the flag back
off.  But the save and restore functions do not recognize turn_see() and
fail to set the fuse up again.

When restoring, Rogue V4 merely sets the fuse's function to NULL and
leaves it burning.  When it goes off, a segfault results.  Rogue V5
clears all the fuse's fields, and the player retains the ability to see
all monsters on the level.

The save and restore code can now handle the fuse.  The function used is
a new wrapper, turn_see_off(), which should lead to less problems with
daemons being multiple incompatible types.

Also, Rogue V4 and Super-Rogue now properly clear unrecognized daemon
and fuse slots when restoring a saved game.
2016-03-05 12:10:20 -05:00
John "Elwin" Edwards
cfda1f88e8 Super-Rogue: begin fixing restore failures on Windows.
Start to solve the problem by calling md_init() to set _fmode.  Now
reading a savefile only triggers an error handler and causes an abort
instead of a crash.
2016-03-03 21:30:38 -05:00
John "Elwin" Edwards
8bf09d3064 Merge the GCC5 and build fix branches. 2016-03-02 21:28:34 -05:00
John "Elwin" Edwards
f5c2898524 Makefile fixes related to installation.
'make install' and 'make uninstall' should now work correctly, placing
the documentation in the proper places.  Any directories needed will be
created.
2016-02-26 17:30:30 -05:00
John "Elwin" Edwards
c6f7d67623 Generate text documentation from the troff source files.
This is done by make, in the 'docs' target, which is now part of the
normal build process.

Unfortunately, not all the games include troff sources.  Getting decent
HTML output from groff is still a difficult process which will not be
attempted at this time.  There are a few bugs in the 'install' and
'uninstall' rules.

Not to mention that the documentation is sometimes inaccurate.
2016-02-21 20:47:12 -05:00
John "Elwin" Edwards
eab5aa2ec4 Fix curses library detection.
A custom autoconf macro searched for the curses library, and provided an
option to use ncurses instead of a (presumably deficient) curses
implementation.  Unfortunately, some of the Makefiles ignored the
search's results.

Now that this is fixed, building against pdcurses should be easier too.
2016-02-12 15:12:37 -05:00
John "Elwin" Edwards
59f448e92e Super-Rogue: convert to ANSI-style function declarations.
This fixes most of the build warnings.
2016-01-31 13:45:07 -05:00
John "Elwin" Edwards
11f7731a3d Initialize some more pointers for the benefit of MSVC.
There should be no more errors with Visual Studio 2015, in Debug or
Release mode.
2016-01-21 21:10:23 -05:00
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
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