Commit graph

301 commits

Author SHA1 Message Date
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
de95b19cee Fix another pointer bug related to object stacks. 2018-02-11 15:37:33 -05:00
John "Elwin" Edwards
b855903f99 UltraRogue: clear the next_obj field when removing items from the floor.
The next_obj field is a pointer which the top item in a stack uses to
keep a list of the other items.  When removing an item from the stack,
rem_obj() failed to set next_obj to NULL, which can cause items in
monster inventory to point to items earlier in the inventory list.
That causes infinite co-recursion when saving or restoring.
2018-02-08 20:54:34 -05:00
John "Elwin" Edwards
73a6b21141 Ultra-Rogue: add a NULL check. 2018-02-08 18:56:15 -05:00
John "Elwin" Edwards
5e44d8334d UltraRogue: fix inventory collision after save and restore.
Inventory letters are based on "identifiers" stored in objects' o_ident
field.  Identifiers are allocated by get_ident(), which keeps a list of
objects that have them, to avoid giving the same identifier to multiple
objects.

The list is not stored in the savefile, so after restore, get_ident()
was not aware of existing identifiers.  This resulted in picked-up
objects having the same inventory letters as objects restored from the
file.

The restore code now adds all objects with identifiers to the list.
2018-01-15 20:20:35 -05:00
John "Elwin" Edwards
82dca01969 Rogue V5: fix elemental wands.
Bolts often failed to hit, due to some struct members not being
initialized.

Reported by 'LazyCat' from RogueTemple.
2018-01-12 18:02:39 -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
7fac45d848 UltraRogue: fix changing the score option.
Changing the score file now works again, if use_savedir is not set.  If
it is, an error message is shown.
2017-12-29 17:38:08 -05:00
John "Elwin" Edwards
61e05e655c UltraRogue: ask about unidentified magic items by default. 2017-12-29 14:16:24 -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
a489fa501e UltraRogue: fix options menu.
When displaying options, get_restr() did not position the cursor
correctly, resulting in values being duplicated.
2017-11-26 11:34:45 -05:00
John "Elwin" Edwards
5e60293223 UltraRogue: add a sanity check to do_fuses().
The d_id field, which indicates which fuse function to call, is now
checked to make sure it is not out of range.  do_daemons() already
checks.
2017-11-24 16:22:10 -05:00
John "Elwin" Edwards
1e2f3f5803 UltraRogue: compile out the built-in memory checking.
Functions in memory.c tracked and instrumented memory allocation.  This
mechanism logged information to a text file and also added a 16KB guard
area to every allocation.  Neither of these are desirable in a multi-
user environment, so the whole memory tracking subsystem has been
disabled.

The behavior can be enabled with a configure flag, but it would be a
better idea to use Valgrind to deal with memory bugs.
2017-11-24 13:22:26 -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
79765ae3b2 UltraRogue: don't swap signal handlers.
In md_shellescape(), signal handlers for SIGINT and SIGQUIT were saved
and restored, but exchanged in the process.  This was fixed in the
other games by commit 600873555ec0.

Deleting md_shellescape() might have been a better fix.  It is
apparently unused.
2017-09-29 21:21:50 -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
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