Commit graph

286 commits

Author SHA1 Message Date
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
3349419ebc Merge the urogue and bugfix branches. 2017-09-15 21:16:28 -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
034331e23c UltraRogue: fix Y2K bug on tombstone.
Years were being displayed as "191XX" instead of "20XX".
2017-09-11 17:46:42 -04:00
John "Elwin" Edwards
6164897cfc UltraRogue: prevent bad array accesses in call().
Marking non-magic items caused segfaults because item_color was set to
NULL.  item_type could also be used as an out-of-bounds index.  These
problems have been fixed by only using these variables when the mark
argument is false, in which case they are properly initialized.

A fall-through case statement was also fixed.
2017-09-10 21:04:22 -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
b521be16e8 UltraRogue: build and install documentation in the Makefile. 2017-09-09 07:25:23 -04:00
John "Elwin" Edwards
3a9054acbf UltraRogue: add install and uninstall targets to the Makefile. 2017-09-05 21:03:26 -04:00
John "Elwin" Edwards
e3c596c443 UltraRogue: begin autoconfiscation.
Build options can now be set with configure.
2017-09-04 21:08:09 -04:00
John "Elwin" Edwards
6c46840eab UltraRogue: add the autosave feature.
UltraRogue now automatically saves the game when SIGHUP or SIGTERM is
received.
2017-09-03 19:58:22 -04:00
John "Elwin" Edwards
8c77aafa62 UltraRogue: compile out wizard mode by default.
Define WIZARD to enable it.  There will be a configure option for this,
once there is a configure script.
2017-03-05 20:14:11 -05:00
John "Elwin" Edwards
9a9c016bae UltraRogue: check the return value from getpwuid().
It is possible for getpwuid() to return NULL.  Such a failure will no
longer cause a segfault.  However, the call to getpwuid() may normally
not be reachable.
2017-03-01 20:40:18 -05:00
John "Elwin" Edwards
ee3408932f UltraRogue: fix the arrow keys.
The startup sequence now calls keypad() to turn on curses recognition
of special keys.
2017-02-28 21:14:53 -05:00
John "Elwin" Edwards
8eebfc0c85 UltraRogue: add logging.
The log file's name is temporarily defined in main.c.
2017-02-26 16:51:29 -05:00
John "Elwin" Edwards
92d1275f42 UltraRogue: flush output when exiting. 2017-02-26 14:58:49 -05:00
John "Elwin" Edwards
bde89e33f7 Merge the UltraRogue branch. 2017-02-19 19:56:43 -05:00
John "Elwin" Edwards
4182f3b4eb Mention UltraRogue in the top-level README. 2017-02-19 19:54:17 -05:00
John "Elwin" Edwards
8690ea40f3 UltraRogue: add location for character files.
When using the -n option, UltraRogue will look for character files in a
single location, similar to save files.

The location is chosen by defining CHRDIR in getplay.c, at least until
UltraRogue gets integrated with the build systems.
2017-02-19 19:47:09 -05:00
John "Elwin" Edwards
d309fcdd46 UltraRogue: make scorefile location configurable. 2017-02-15 20:38:12 -05:00
John "Elwin" Edwards
a8a6e1ce7a UltraRogue: fix a segfault related to restoring monsters.
The functions for restoring saved games failed to properly correct the
t_chasee pointer of monsters chasing the player.  Such monsters would
attempt to chase NULL instead, with predictable results.
2017-02-14 20:42:33 -05:00
John "Elwin" Edwards
fc0b18d304 UltraRogue: restrict changing name and save file.
When the -n option is in use, player name and save file location cannot
be changed.  The score file is also restricted.
2017-02-12 20:16:57 -05:00
John "Elwin" Edwards
67e9cff868 Merge the bugfix branch, which had missed an update. 2017-02-10 09:06:50 -05: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
7b42d453f0 UltraRogue: don't overwrite the savefile name when restoring. 2017-02-09 20:13:25 -05:00
John "Elwin" Edwards
403d9ec171 UltraRogue: add the -n option. 2017-02-09 16:29:45 -05:00
John "Elwin" Edwards
ed27d7a24f UltraRogue: fix crash when restoring.
The r_flags field in struct room was being written as an int and read
as a short.  This caused the restore functions to receive the wrong
data, usually an impossible string length, and abort.

This breaks save compatibility, though the save files had problems
anyway: the r_fires field should have been used, instead of reading and
writing r_flags twice.
2017-02-08 19:50:36 -05:00
John "Elwin" Edwards
b100b40846 UltraRogue: fix various build failures. 2017-01-31 20:33:49 -05:00
John "Elwin" Edwards
11c74c273d Import UltraRogue from the Roguelike Restoration Project (r1490) 2017-01-31 19:56:04 -05:00
John "Elwin" Edwards
c346921c68 Update the fallback install script. 2017-01-31 18:59:38 -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
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
714bad8c3c Rogue V5: fix save/restore making levitation, hallucination permanent.
Like an earlier bug with detecting monsters, the fuses responsible for
ending levitation and hallucination were not recognized by
rs_write_daemons().  They got left out of the savefile, so after
restoring, the effect never wore off.

I think this is the first bugfix I've ever made that reduced the game's
difficulty.
2016-07-20 20:44:41 -04:00
John "Elwin" Edwards
eabbd3e1a1 Added tag rel2016.06 for changeset 182e26224f92 2016-06-01 20:16:23 -04:00
John "Elwin" Edwards
c65d17136d README.txt: additions and clarifications. 2016-05-29 17:05:38 -04: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
c5f4f359ea Rogue V5: don't limit the high score list to 1 on Windows.
The Visual Studio project file failed to define ALLSCORES, causing the
score file to be limited to one entry per UID.  Since the UID is always
set to 42 on Windows, only one entry could ever appear in the list.
2016-05-15 19:04:46 -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
718c807339 Rogue V4, V5: fix messages when viewing the identified items.
The functions for displaying the list of identified items begin by
prompting for the category of item, using msg().  Rogue V4 left this
prompt on the screen after displaying the discovery list.  Rogue V5
erased the message window even if the process of printing the list
created another message which the player had not read.

Messages are now cleared in endline(), which is capable of checking
whether clearing should be done.
2016-04-24 13:33:17 -04:00
John "Elwin" Edwards
de0518b00e Remove old installation instructions. 2016-03-19 16:42:03 -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
2e20820d1b README.txt: remove outdated information. 2016-03-12 14:36:25 -05: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
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
dafa5cc722 XRogue: fix some uses of entire structs instead of their members.
Some calls to runto() were given a pointer to the player struct instead
of to the player's coordinates.  A call to death() was passed a pointer
to a monster instead of the monster's type number.
2016-03-08 20:47:57 -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