Commit graph

11 commits

Author SHA1 Message Date
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
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
2d4a66298a Fix some functions not returning the right type. 2016-03-19 16:18:58 -04:00
John "Elwin" Edwards
f38b2223c8 Advanced Rogue 5: convert to ANSI function declarations.
This still leaves over a thousand lines of warning messages, mostly
related to the return types of daemons and fuses.
2016-02-07 14:39:21 -05:00
John "Elwin" Edwards
a8b96bbc3e arogue5: make alchemy jugs survive a save and restore.
Alchemy jugs are refilled by the alchemy() fuse, which takes a pointer
to the jug object as an argument.  When written to a save file and read
back out, the pointer is unlikely to point anywhere useful.

Instead, rs_write_daemons() now stores an index into the player's pack
or the list of objects on the floor.  rs_read_daemons() uses this
number to locate the object when restoring.

This change should not cause any new issues with old savefiles, but it
is unable to make a broken alchemy jug work again.
2014-03-28 15:51:43 -07:00
John "Elwin" Edwards
7b0ec1230e arogue5: fix some daemon-related pointer/int casting.
Daemons and fuses take a single argument, nominally an int but either
ignored or unsafely cast to a pointer.  Its type has now been changed
to void*.

The save/restore code no longer tries to store this argument in the
savefile.  For doctor(), this is not a problem, because player is the
only argument it is ever given as a daemon.  However, alchemy() will
fail to do anything when passed NULL.  Fixing this would be complicated
but possible.

Summary: the code is slightly safer, but alchemy jugs are guaranteed to
stop working after save and restore, instead of just extremely likely.
2014-03-28 10:57:03 -07:00
John "Elwin" Edwards
46568d24a4 arogue5: fix some save/restore-related crashes.
The save/restore code took the pointer intended as an argument for the
doctor() daemon and wrote it to the savefile as an int.  I don't know
why it took so long to fail horribly.  The problem has been avoided by
replacing the value with &player when restoring.  That seems to be the
only argument ever actually used.

The code also writes only four bytes for an unsigned long; if
sizeof(long) == 8, it casts to unsigned int first.  It failed to do the
cast when reading back, with the result that four bytes were read and
the other half of the number was effectively uninitialized.

It apparently works now, but the save/restore code ought still to be
regarded as decidedly unfortunate.
2014-01-06 15:57:17 -05:00
John "Elwin" Edwards
e375c8bd05 Properly handle invalid room references in savefiles.
In all games, rs_write_room_reference() stored -1 for a nonexistent
room, but rs_read_room_reference() did not check for out-of-bounds
values, leading to pointers to rooms[-1], which sometimes caused
crashes.  rs_read_room_reference() has now been modified to use NULL
instead.

Some of the games required further changes to replace NULL with the
pointer to the actual room.  Others are capable of handling NULL for
objects not in any room.
2013-08-08 12:41:35 -07:00
John "Elwin" Edwards
5fe41fbc3a arogue5: fix the crash when checking prices in shops.
A buffer called curpurch, which stores a description of an item in a
trading post which the player might be interested in, was only 15
bytes.  It was overflowing into oldrp, a room pointer, leading to
segfaults.  The size of curpurch has been increased to LINELEN*2,
which matches the size of prbuf, which is returned by inv_name and
then strcpy()'d to curpurch.  As long as nothing overflows prbuf it
should be safe now.

NOTE that this breaks savefile compatibility.
2012-09-05 10:14:34 -07:00
John "Elwin" Edwards
f0527564ea arogue5: add missing header files. 2012-08-11 17:19:03 +00:00
John "Elwin" Edwards
14fad3b319 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490) 2012-08-09 22:58:48 +00:00