Commit graph

78 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
2a9d279baa Advanced Rogue 5, 7: fix some trading post messages.
When attempting to buy an unaffordable object, messages were often of
the form "You can't afford that a scroll of hold monster !", because
the object description (stored in curpurch) was the same text used in
inventory displays.

This has been worked around by inspecting the contents of curpurch and
using different message templates.
2021-10-24 20:26:21 -04:00
John "Elwin" Edwards
b6067e102e Advanced Rogue 7: fix a crash when casting magic missile.
do_zap() dereferenced a struct object pointer while ignoring the result
of a NULL check.  XRogue had the same problem, though triggering it was
unlikely, since XRogue does not include a magic missile spell.

Reported by John Harris of @Play.
2021-10-21 21:00:15 -04:00
John "Elwin" Edwards
fb0ef69143 Advanced Rogue 7: fix a string literal overwrite.
pick_spell() attempted to capitalize type by overwriting the first
character, changing it back later.  All calls of pick_spell passed a
string literal as type, and string literals should be considered
immutable.

This has been fixed by using a separate variable for the capitalized
first character.  XRogue already has a similar fix.

Reported by John Harris of @Play.
2021-10-19 20:39:00 -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
3dfd8fd09b Advanced Rogue family: fix some potential buffer overflows.
Some code for determining the score file location assumed that PATH_MAX
would be less than 1024, which cannot be guaranteed.

Advanced Rogue 5 and 7, and XRogue, have had the buffers for the file
name enlarged.  UltraRogue never called the functions, so the code has
been deleted instead.
2021-05-03 19:05:37 -04:00
John "Elwin" Edwards
2b6d8bcb77 Advanced Rogue 7: ignore file locations in the save file when restoring.
The variables file_name, score_file, and home are no longer overwritten
with the values stored in the save file.  Those values could be
inaccurate if the files have been moved or configuration has changed.
2021-05-02 21:54:11 -04:00
John "Elwin" Edwards
d1422feb80 Fix a few more miscellaneous compiler warnings. 2021-05-01 09:51:30 -04:00
John "Elwin" Edwards
ca9e48d5f6 Fix some warnings related to format strings. 2021-04-30 20:48:30 -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
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
614dcfffd2 Fix more header-related warnings.
This fixes all current default warnings with GCC7 on Linux.  That does
not mean the code is anywhere close to clean.
2017-09-22 16:24:40 -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
7eeb9ddcb6 Add some braces to a loop in parse_opts().
A for loop had no braces around its body, which was a single if-else
statement.  In Advanced Rogue 5, another statement had been added,
accidentally removing the if-else from the loop.  This could have
resulted in an out-of-bounds access to the options array.

In the other games, the added braces are only for clarity.
2017-02-10 09:02:58 -05: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
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
2d4a66298a Fix some functions not returning the right type. 2016-03-19 16:18:58 -04: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
758c6b1bf0 arogue7, xrogue: improve the handling of the arguments to fuses.
fuse() now expects a pointer as the argument to a fuse function.  If
this is one of the functions that takes int, fuse() follows the pointer
and stores that value in the f_list slot, in the integer field of the
argument union.  When the fuse goes off, do_fuses() recognizes the
function and passes it the integer field instead of the pointer.

This has the disadvantage of hard-coding the functions that require int
in daemon.c, but since the int is copied into f_list, it no longer has
to be in static or global memory, which simplifies several files.
2016-03-11 17:40:00 -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
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
35bea2ba0d Use uniform return types for functions related to options.
Functions for printing options now return void.  Functions for setting
options now return int.  Argument types still vary, though converting
all the option pointers to void* would be possible.
2016-03-06 14:45:18 -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
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
e8e6e604c3 Advanced Rogue 7: convert to ANSI-style function declarations.
Almost 1500 lines of compiler warnings remain, and the GCC developers
are already working on a new version with even more warnings turned on
by default.
2016-02-19 21:02:28 -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
e1d228b946 Merge the MSVC branch. 2015-11-27 08:59:24 -05:00
John "Elwin" Edwards
231295a1ab Advanced Rogue 7: rename magic users to magicians.
Class names with spaces in them confuse anything that parses the
logfile.  The documentation does refer mostly to magicians.
2015-08-22 10:55:53 -04: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
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
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
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