Update modernization log: add dates and cleanup whitespace

- Update date from placeholder to 2025-11-07 in MODERNIZATION_LOG.md
- Mark function prototype warnings as fixed in pending issues
- Remove trailing whitespace in daemon.c, rogue.h, state.c
- Clean up formatting in MODERNIZATION_LOG.md
This commit is contained in:
David Silva
2025-11-07 15:36:58 +00:00
parent a0c66a6078
commit f564a46c1c
4 changed files with 151 additions and 177 deletions

View File

@@ -72,7 +72,7 @@ move(oy, ox); /* Use public API instead of internal structure access */
2. Function pointers without proper prototypes 2. Function pointers without proper prototypes
3. Local function declaration conflicting with standard library 3. Local function declaration conflicting with standard library
**Root Cause**: **Root Cause**:
- Pre-C99 code used old-style function declarations - Pre-C99 code used old-style function declarations
- C23 requires proper function prototypes - C23 requires proper function prototypes
- Function pointers need explicit parameter types - Function pointers need explicit parameter types
@@ -126,37 +126,11 @@ move(oy, ox); /* Use public API instead of internal structure access */
## Pending Issues ## Pending Issues
Issues identified but not yet fixed: Issues identified but not yet fixed (low priority - build works correctly):
### 1. Function Prototype Warnings (C23 Compatibility) ### 1. ~~Function Prototype Warnings (C23 Compatibility)~~ ✅ FIXED
**Severity**: Medium (warnings only, build succeeds) **Status**: All function prototype warnings have been resolved in Iteration 2.
**Issue**: Multiple functions declared without prototypes in `extern.h`, causing C23 compatibility warnings.
**Affected Functions**:
- `fatal()` - declared as `void fatal();` but defined as `void fatal(char *s)`
- `my_exit()` - declared as `void my_exit();` but defined as `void my_exit(int st)`
- `set_order()` - declared as `void set_order();` but defined as `void set_order(int *order, int numthings)`
- Function pointer calls in `daemon.c` - `(*dev->d_func)(dev->d_arg)` without prototype
**Impact**:
- Build succeeds but generates warnings
- Will fail to compile with C23 standard
- Function calls may have incorrect argument checking
**Files Affected**:
- `extern.h` - function declarations
- `main.c` - calls to `fatal()` and `my_exit()`
- `daemon.c` - function pointer calls
- `state.c` - call to `new_item()`
- `things.c` - call to `set_order()`
- `rip.c` - call to `my_exit()`
**Solution Approach**:
1. Add proper function prototypes to `extern.h` with correct parameter types
2. Ensure all function definitions match their declarations
3. Fix function pointer type definitions in daemon structures
### 2. Deprecated `register` Keyword ### 2. Deprecated `register` Keyword

View File

@@ -22,7 +22,7 @@
struct delayed_action d_list[MAXDAEMONS] = { struct delayed_action d_list[MAXDAEMONS] = {
_X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_,
_X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_,
}; };
/* /*

View File

@@ -12,7 +12,7 @@
#include "extern.h" #include "extern.h"
#undef lines #undef lines
#define NOOP(x) (x += 0) #define NOOP(x) (x += 0)
#define CCHAR(x) ( (char) (x & A_CHARTEXT) ) #define CCHAR(x) ( (char) (x & A_CHARTEXT) )
@@ -681,7 +681,7 @@ bool dropcheck(THING *obj);
bool fallpos(coord *pos, coord *newpos); bool fallpos(coord *pos, coord *newpos);
bool find_floor(struct room *rp, coord *cp, int limit, bool monst); bool find_floor(struct room *rp, coord *cp, int limit, bool monst);
bool is_magic(THING *obj); bool is_magic(THING *obj);
bool is_symlink(char *sp); bool is_symlink(char *sp);
bool levit_check(); bool levit_check();
bool pack_room(bool from_floor, THING *obj); bool pack_room(bool from_floor, THING *obj);
bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl); bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl);

288
state.c
View File

@@ -92,7 +92,7 @@ rs_read(FILE *inf, void *ptr, size_t size)
if (encread(ptr, size, inf) != size) if (encread(ptr, size, inf) != size)
read_error = 1; read_error = 1;
return(READSTAT); return(READSTAT);
} }
@@ -113,7 +113,7 @@ rs_write_int(FILE *savef, int c)
bytes[0] = buf[3]; bytes[0] = buf[3];
buf = bytes; buf = bytes;
} }
rs_write(savef, buf, 4); rs_write(savef, buf, 4);
return(WRITESTAT); return(WRITESTAT);
@@ -125,7 +125,7 @@ rs_read_int(FILE *inf, int *i)
unsigned char bytes[4]; unsigned char bytes[4];
int input = 0; int input = 0;
unsigned char *buf = (unsigned char *)&input; unsigned char *buf = (unsigned char *)&input;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -139,7 +139,7 @@ rs_read_int(FILE *inf, int *i)
bytes[0] = buf[3]; bytes[0] = buf[3];
buf = bytes; buf = bytes;
} }
*i = *((int *) buf); *i = *((int *) buf);
return(READSTAT); return(READSTAT);
@@ -183,17 +183,17 @@ int
rs_read_chars(FILE *inf, char *i, int count) rs_read_chars(FILE *inf, char *i, int count)
{ {
int value = 0; int value = 0;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
rs_read_int(inf, &value); rs_read_int(inf, &value);
if (value != count) if (value != count)
format_error = TRUE; format_error = TRUE;
rs_read(inf, i, count); rs_read(inf, i, count);
return(READSTAT); return(READSTAT);
} }
@@ -218,7 +218,7 @@ int
rs_read_ints(FILE *inf, int *i, int count) rs_read_ints(FILE *inf, int *i, int count)
{ {
int n, value; int n, value;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -230,7 +230,7 @@ rs_read_ints(FILE *inf, int *i, int count)
for(n = 0; n < count; n++) for(n = 0; n < count; n++)
if (rs_read_int(inf, &i[n]) != 0) if (rs_read_int(inf, &i[n]) != 0)
break; break;
return(READSTAT); return(READSTAT);
} }
@@ -238,7 +238,7 @@ int
rs_write_boolean(FILE *savef, int c) rs_write_boolean(FILE *savef, int c)
{ {
unsigned char buf = (c == 0) ? 0 : 1; unsigned char buf = (c == 0) ? 0 : 1;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
@@ -251,14 +251,14 @@ int
rs_read_boolean(FILE *inf, bool *i) rs_read_boolean(FILE *inf, bool *i)
{ {
unsigned char buf = 0; unsigned char buf = 0;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
rs_read(inf, &buf, 1); rs_read(inf, &buf, 1);
*i = (buf != 0); *i = (buf != 0);
return(READSTAT); return(READSTAT);
} }
@@ -283,7 +283,7 @@ int
rs_read_booleans(FILE *inf, bool *i, int count) rs_read_booleans(FILE *inf, bool *i, int count)
{ {
int n = 0, value = 0; int n = 0, value = 0;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -295,7 +295,7 @@ rs_read_booleans(FILE *inf, bool *i, int count)
for(n = 0; n < count; n++) for(n = 0; n < count; n++)
if (rs_read_boolean(inf, &i[n]) != 0) if (rs_read_boolean(inf, &i[n]) != 0)
break; break;
return(READSTAT); return(READSTAT);
} }
@@ -326,7 +326,7 @@ rs_read_short(FILE *inf, short *i)
unsigned char bytes[2]; unsigned char bytes[2];
short input; short input;
unsigned char *buf = (unsigned char *)&input; unsigned char *buf = (unsigned char *)&input;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -338,11 +338,11 @@ rs_read_short(FILE *inf, short *i)
bytes[0] = buf[1]; bytes[0] = buf[1];
buf = bytes; buf = bytes;
} }
*i = *((short *) buf); *i = *((short *) buf);
return(READSTAT); return(READSTAT);
} }
int int
rs_write_shorts(FILE *savef, short *c, int count) rs_write_shorts(FILE *savef, short *c, int count)
@@ -356,7 +356,7 @@ rs_write_shorts(FILE *savef, short *c, int count)
for(n = 0; n < count; n++) for(n = 0; n < count; n++)
if (rs_write_short(savef, c[n]) != 0) if (rs_write_short(savef, c[n]) != 0)
break; break;
return(WRITESTAT); return(WRITESTAT);
} }
@@ -377,7 +377,7 @@ rs_read_shorts(FILE *inf, short *i, int count)
for(n = 0; n < value; n++) for(n = 0; n < value; n++)
if (rs_read_short(inf, &i[n]) != 0) if (rs_read_short(inf, &i[n]) != 0)
break; break;
return(READSTAT); return(READSTAT);
} }
@@ -408,7 +408,7 @@ rs_read_ushort(FILE *inf, unsigned short *i)
unsigned char bytes[2]; unsigned char bytes[2];
unsigned short input; unsigned short input;
unsigned char *buf = (unsigned char *)&input; unsigned char *buf = (unsigned char *)&input;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -420,11 +420,11 @@ rs_read_ushort(FILE *inf, unsigned short *i)
bytes[0] = buf[1]; bytes[0] = buf[1];
buf = bytes; buf = bytes;
} }
*i = *((unsigned short *) buf); *i = *((unsigned short *) buf);
return(READSTAT); return(READSTAT);
} }
int int
rs_write_uint(FILE *savef, unsigned int c) rs_write_uint(FILE *savef, unsigned int c)
@@ -443,7 +443,7 @@ rs_write_uint(FILE *savef, unsigned int c)
bytes[0] = buf[3]; bytes[0] = buf[3];
buf = bytes; buf = bytes;
} }
rs_write(savef, buf, 4); rs_write(savef, buf, 4);
return(WRITESTAT); return(WRITESTAT);
@@ -455,7 +455,7 @@ rs_read_uint(FILE *inf, unsigned int *i)
unsigned char bytes[4]; unsigned char bytes[4];
int input; int input;
unsigned char *buf = (unsigned char *)&input; unsigned char *buf = (unsigned char *)&input;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -469,7 +469,7 @@ rs_read_uint(FILE *inf, unsigned int *i)
bytes[0] = buf[3]; bytes[0] = buf[3];
buf = bytes; buf = bytes;
} }
*i = *((unsigned int *) buf); *i = *((unsigned int *) buf);
return(READSTAT); return(READSTAT);
@@ -486,7 +486,7 @@ rs_write_marker(FILE *savef, int id)
return(WRITESTAT); return(WRITESTAT);
} }
int int
rs_read_marker(FILE *inf, int id) rs_read_marker(FILE *inf, int id)
{ {
int nid; int nid;
@@ -497,7 +497,7 @@ rs_read_marker(FILE *inf, int id)
if (rs_read_int(inf, &nid) == 0) if (rs_read_int(inf, &nid) == 0)
if (id != nid) if (id != nid)
format_error = 1; format_error = 1;
return(READSTAT); return(READSTAT);
} }
@@ -517,7 +517,7 @@ rs_write_string(FILE *savef, char *s)
rs_write_int(savef, len); rs_write_int(savef, len);
rs_write_chars(savef, s, len); rs_write_chars(savef, s, len);
return(WRITESTAT); return(WRITESTAT);
} }
@@ -535,7 +535,7 @@ rs_read_string(FILE *inf, char *s, int max)
format_error = TRUE; format_error = TRUE;
rs_read_chars(inf, s, len); rs_read_chars(inf, s, len);
return(READSTAT); return(READSTAT);
} }
@@ -553,10 +553,10 @@ rs_read_new_string(FILE *inf, char **s)
if (len == 0) if (len == 0)
buf = NULL; buf = NULL;
else else
{ {
buf = malloc(len); buf = malloc(len);
if (buf == NULL) if (buf == NULL)
read_error = TRUE; read_error = TRUE;
} }
@@ -580,7 +580,7 @@ rs_write_strings(FILE *savef, char *s[], int count)
for(n = 0; n < count; n++) for(n = 0; n < count; n++)
if (rs_write_string(savef, s[n]) != 0) if (rs_write_string(savef, s[n]) != 0)
break; break;
return(WRITESTAT); return(WRITESTAT);
} }
@@ -589,7 +589,7 @@ rs_read_strings(FILE *inf, char **s, int count, int max)
{ {
int n = 0; int n = 0;
int value = 0; int value = 0;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -601,7 +601,7 @@ rs_read_strings(FILE *inf, char **s, int count, int max)
for(n = 0; n < count; n++) for(n = 0; n < count; n++)
if (rs_read_string(inf, s[n], max) != 0) if (rs_read_string(inf, s[n], max) != 0)
break; break;
return(READSTAT); return(READSTAT);
} }
@@ -610,7 +610,7 @@ rs_read_new_strings(FILE *inf, char **s, int count)
{ {
int n = 0; int n = 0;
int value = 0; int value = 0;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -622,7 +622,7 @@ rs_read_new_strings(FILE *inf, char **s, int count)
for(n = 0; n < count; n++) for(n = 0; n < count; n++)
if (rs_read_new_string(inf, &s[n]) != 0) if (rs_read_new_string(inf, &s[n]) != 0)
break; break;
return(READSTAT); return(READSTAT);
} }
@@ -691,7 +691,7 @@ rs_write_coord(FILE *savef, coord c)
rs_write_int(savef, c.x); rs_write_int(savef, c.x);
rs_write_int(savef, c.y); rs_write_int(savef, c.y);
return(WRITESTAT); return(WRITESTAT);
} }
@@ -706,7 +706,7 @@ rs_read_coord(FILE *inf, coord *c)
rs_read_int(inf,&in.x); rs_read_int(inf,&in.x);
rs_read_int(inf,&in.y); rs_read_int(inf,&in.y);
if (READSTAT == 0) if (READSTAT == 0)
{ {
c->x = in.x; c->x = in.x;
c->y = in.y; c->y = in.y;
@@ -742,7 +742,7 @@ int
rs_read_window(FILE *inf, WINDOW *win) rs_read_window(FILE *inf, WINDOW *win)
{ {
int row,col,maxlines,maxcols,value,width,height; int row,col,maxlines,maxcols,value,width,height;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -763,7 +763,7 @@ rs_read_window(FILE *inf, WINDOW *win)
if ((row < height) && (col < width)) if ((row < height) && (col < width))
mvwaddch(win,row,col,value); mvwaddch(win,row,col,value);
} }
return(READSTAT); return(READSTAT);
} }
@@ -777,7 +777,7 @@ get_list_item(THING *l, int i)
for(count = 0; l != NULL; count++, l = l->l_next) for(count = 0; l != NULL; count++, l = l->l_next)
if (count == i) if (count == i)
return(l); return(l);
return(NULL); return(NULL);
} }
@@ -789,7 +789,7 @@ find_list_ptr(THING *l, void *ptr)
for(count = 0; l != NULL; count++, l = l->l_next) for(count = 0; l != NULL; count++, l = l->l_next)
if (l == ptr) if (l == ptr)
return(count); return(count);
return(-1); return(-1);
} }
@@ -797,10 +797,10 @@ int
list_size(THING *l) list_size(THING *l)
{ {
int count; int count;
for(count = 0; l != NULL; count++, l = l->l_next) for(count = 0; l != NULL; count++, l = l->l_next)
; ;
return(count); return(count);
} }
@@ -987,10 +987,10 @@ rs_write_sticks(FILE *savef)
rs_write_string_index(savef, metal, cNMETAL, ws_made[i]); rs_write_string_index(savef, metal, cNMETAL, ws_made[i]);
} }
} }
return(WRITESTAT); return(WRITESTAT);
} }
int int
rs_read_sticks(FILE *inf) rs_read_sticks(FILE *inf)
{ {
@@ -1000,7 +1000,7 @@ rs_read_sticks(FILE *inf)
return(READSTAT); return(READSTAT);
for(i = 0; i < MAXSTICKS; i++) for(i = 0; i < MAXSTICKS; i++)
{ {
rs_read_int(inf,&list); rs_read_int(inf,&list);
if (list == 0) if (list == 0)
@@ -1008,7 +1008,7 @@ rs_read_sticks(FILE *inf)
rs_read_string_index(inf, wood, cNWOOD, &ws_made[i]); rs_read_string_index(inf, wood, cNWOOD, &ws_made[i]);
ws_type[i] = "staff"; ws_type[i] = "staff";
} }
else else
{ {
rs_read_string_index(inf, metal, cNMETAL, &ws_made[i]); rs_read_string_index(inf, metal, cNMETAL, &ws_made[i]);
ws_type[i] = "wand"; ws_type[i] = "wand";
@@ -1023,13 +1023,13 @@ rs_write_daemons(FILE *savef, struct delayed_action *d_list, int count)
{ {
int i = 0; int i = 0;
int func = 0; int func = 0;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
rs_write_marker(savef, RSID_DAEMONS); rs_write_marker(savef, RSID_DAEMONS);
rs_write_int(savef, count); rs_write_int(savef, count);
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
{ {
if (d_list[i].d_func == rollwand) if (d_list[i].d_func == rollwand)
@@ -1060,9 +1060,9 @@ rs_write_daemons(FILE *savef, struct delayed_action *d_list, int count)
rs_write_int(savef, d_list[i].d_arg); rs_write_int(savef, d_list[i].d_arg);
rs_write_int(savef, d_list[i].d_time); rs_write_int(savef, d_list[i].d_time);
} }
return(WRITESTAT); return(WRITESTAT);
} }
int int
rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count) rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count)
@@ -1070,7 +1070,7 @@ rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count)
int i = 0; int i = 0;
int func = 0; int func = 0;
int value = 0; int value = 0;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -1087,7 +1087,7 @@ rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count)
rs_read_int(inf, &func); rs_read_int(inf, &func);
rs_read_int(inf, &d_list[i].d_arg); rs_read_int(inf, &d_list[i].d_arg);
rs_read_int(inf, &d_list[i].d_time); rs_read_int(inf, &d_list[i].d_time);
switch(func) switch(func)
{ {
case 1: d_list[i].d_func = rollwand; case 1: d_list[i].d_func = rollwand;
@@ -1119,15 +1119,15 @@ rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count)
d_list[i].d_arg = 0; d_list[i].d_arg = 0;
d_list[i].d_time = 0; d_list[i].d_time = 0;
} }
return(READSTAT); return(READSTAT);
} }
int int
rs_write_obj_info(FILE *savef, struct obj_info *i, int count) rs_write_obj_info(FILE *savef, struct obj_info *i, int count)
{ {
int n; int n;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
@@ -1142,7 +1142,7 @@ rs_write_obj_info(FILE *savef, struct obj_info *i, int count)
rs_write_string(savef,i[n].oi_guess); rs_write_string(savef,i[n].oi_guess);
rs_write_boolean(savef,i[n].oi_know); rs_write_boolean(savef,i[n].oi_know);
} }
return(WRITESTAT); return(WRITESTAT);
} }
@@ -1170,7 +1170,7 @@ rs_read_obj_info(FILE *inf, struct obj_info *mi, int count)
rs_read_new_string(inf,&mi[n].oi_guess); rs_read_new_string(inf,&mi[n].oi_guess);
rs_read_boolean(inf,&mi[n].oi_know); rs_read_boolean(inf,&mi[n].oi_know);
} }
return(READSTAT); return(READSTAT);
} }
@@ -1198,7 +1198,7 @@ rs_write_room(FILE *savef, struct room *r)
rs_write_coord(savef, r->r_exit[9]); rs_write_coord(savef, r->r_exit[9]);
rs_write_coord(savef, r->r_exit[10]); rs_write_coord(savef, r->r_exit[10]);
rs_write_coord(savef, r->r_exit[11]); rs_write_coord(savef, r->r_exit[11]);
return(WRITESTAT); return(WRITESTAT);
} }
@@ -1239,10 +1239,10 @@ rs_write_rooms(FILE *savef, struct room r[], int count)
return(WRITESTAT); return(WRITESTAT);
rs_write_int(savef, count); rs_write_int(savef, count);
for(n = 0; n < count; n++) for(n = 0; n < count; n++)
rs_write_room(savef, &r[n]); rs_write_room(savef, &r[n]);
return(WRITESTAT); return(WRITESTAT);
} }
@@ -1269,7 +1269,7 @@ int
rs_write_room_reference(FILE *savef, struct room *rp) rs_write_room_reference(FILE *savef, struct room *rp)
{ {
int i, room = -1; int i, room = -1;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
@@ -1286,14 +1286,14 @@ int
rs_read_room_reference(FILE *inf, struct room **rp) rs_read_room_reference(FILE *inf, struct room **rp)
{ {
int i; int i;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
rs_read_int(inf, &i); rs_read_int(inf, &i);
*rp = &rooms[i]; *rp = &rooms[i];
return(READSTAT); return(READSTAT);
} }
@@ -1301,7 +1301,7 @@ int
rs_write_monsters(FILE *savef, struct monster *m, int count) rs_write_monsters(FILE *savef, struct monster *m, int count)
{ {
int n; int n;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
@@ -1310,7 +1310,7 @@ rs_write_monsters(FILE *savef, struct monster *m, int count)
for(n=0;n<count;n++) for(n=0;n<count;n++)
rs_write_stats(savef, &m[n].m_stats); rs_write_stats(savef, &m[n].m_stats);
return(WRITESTAT); return(WRITESTAT);
} }
@@ -1331,7 +1331,7 @@ rs_read_monsters(FILE *inf, struct monster *m, int count)
for(n = 0; n < count; n++) for(n = 0; n < count; n++)
rs_read_stats(inf, &m[n].m_stats); rs_read_stats(inf, &m[n].m_stats);
return(READSTAT); return(READSTAT);
} }
@@ -1342,8 +1342,8 @@ rs_write_object(FILE *savef, THING *o)
return(WRITESTAT); return(WRITESTAT);
rs_write_marker(savef, RSID_OBJECT); rs_write_marker(savef, RSID_OBJECT);
rs_write_int(savef, o->_o._o_type); rs_write_int(savef, o->_o._o_type);
rs_write_coord(savef, o->_o._o_pos); rs_write_coord(savef, o->_o._o_pos);
rs_write_int(savef, o->_o._o_launch); rs_write_int(savef, o->_o._o_launch);
rs_write_char(savef, o->_o._o_packch); rs_write_char(savef, o->_o._o_packch);
rs_write_chars(savef, o->_o._o_damage, sizeof(o->_o._o_damage)); rs_write_chars(savef, o->_o._o_damage, sizeof(o->_o._o_damage));
@@ -1380,7 +1380,7 @@ rs_read_object(FILE *inf, THING *o)
rs_read_int(inf, &o->_o._o_flags); rs_read_int(inf, &o->_o._o_flags);
rs_read_int(inf, &o->_o._o_group); rs_read_int(inf, &o->_o._o_group);
rs_read_new_string(inf, &o->_o._o_label); rs_read_new_string(inf, &o->_o._o_label);
return(READSTAT); return(READSTAT);
} }
@@ -1395,7 +1395,7 @@ rs_write_object_list(FILE *savef, THING *l)
for( ;l != NULL; l = l->l_next) for( ;l != NULL; l = l->l_next)
rs_write_object(savef, l); rs_write_object(savef, l);
return(WRITESTAT); return(WRITESTAT);
} }
@@ -1411,7 +1411,7 @@ rs_read_object_list(FILE *inf, THING **list)
rs_read_marker(inf, RSID_OBJECTLIST); rs_read_marker(inf, RSID_OBJECTLIST);
rs_read_int(inf, &cnt); rs_read_int(inf, &cnt);
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
{ {
l = new_item(); l = new_item();
@@ -1429,10 +1429,10 @@ rs_read_object_list(FILE *inf, THING **list)
previous = l; previous = l;
} }
if (l != NULL) if (l != NULL)
l->l_next = NULL; l->l_next = NULL;
*list = head; *list = head;
return(READSTAT); return(READSTAT);
@@ -1442,7 +1442,7 @@ int
rs_write_object_reference(FILE *savef, THING *list, THING *item) rs_write_object_reference(FILE *savef, THING *list, THING *item)
{ {
int i; int i;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
@@ -1457,14 +1457,14 @@ int
rs_read_object_reference(FILE *inf, THING *list, THING **item) rs_read_object_reference(FILE *inf, THING *list, THING **item)
{ {
int i; int i;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
rs_read_int(inf, &i); rs_read_int(inf, &i);
*item = get_list_item(list,i); *item = get_list_item(list,i);
return(READSTAT); return(READSTAT);
} }
@@ -1472,11 +1472,11 @@ int
find_room_coord(struct room *rmlist, coord *c, int n) find_room_coord(struct room *rmlist, coord *c, int n)
{ {
int i = 0; int i = 0;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
if(&rmlist[i].r_gold == c) if(&rmlist[i].r_gold == c)
return(i); return(i);
return(-1); return(-1);
} }
@@ -1524,7 +1524,7 @@ int
rs_write_thing(FILE *savef, THING *t) rs_write_thing(FILE *savef, THING *t)
{ {
int i = -1; int i = -1;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
@@ -1535,7 +1535,7 @@ rs_write_thing(FILE *savef, THING *t)
rs_write_int(savef, 0); rs_write_int(savef, 0);
return(WRITESTAT); return(WRITESTAT);
} }
rs_write_int(savef, 1); rs_write_int(savef, 1);
rs_write_coord(savef, t->_t._t_pos); rs_write_coord(savef, t->_t._t_pos);
rs_write_boolean(savef, t->_t._t_turn); rs_write_boolean(savef, t->_t._t_turn);
@@ -1543,7 +1543,7 @@ rs_write_thing(FILE *savef, THING *t)
rs_write_char(savef, t->_t._t_disguise); rs_write_char(savef, t->_t._t_disguise);
rs_write_char(savef, t->_t._t_oldch); rs_write_char(savef, t->_t._t_oldch);
/* /*
t_dest can be: t_dest can be:
0,0: NULL 0,0: NULL
0,1: location of hero 0,1: location of hero
@@ -1551,7 +1551,7 @@ rs_write_thing(FILE *savef, THING *t)
2,i: location of an object 2,i: location of an object
3,i: location of gold in a room 3,i: location of gold in a room
We need to remember what we are chasing rather than We need to remember what we are chasing rather than
the current location of what we are chasing. the current location of what we are chasing.
*/ */
@@ -1563,7 +1563,7 @@ rs_write_thing(FILE *savef, THING *t)
else if (t->t_dest != NULL) else if (t->t_dest != NULL)
{ {
i = find_thing_coord(mlist, t->t_dest); i = find_thing_coord(mlist, t->t_dest);
if (i >=0 ) if (i >=0 )
{ {
rs_write_int(savef,1); rs_write_int(savef,1);
@@ -1572,7 +1572,7 @@ rs_write_thing(FILE *savef, THING *t)
else else
{ {
i = find_object_coord(lvl_obj, t->t_dest); i = find_object_coord(lvl_obj, t->t_dest);
if (i >= 0) if (i >= 0)
{ {
rs_write_int(savef,2); rs_write_int(savef,2);
@@ -1581,13 +1581,13 @@ rs_write_thing(FILE *savef, THING *t)
else else
{ {
i = find_room_coord(rooms, t->t_dest, MAXROOMS); i = find_room_coord(rooms, t->t_dest, MAXROOMS);
if (i >= 0) if (i >= 0)
{ {
rs_write_int(savef,3); rs_write_int(savef,3);
rs_write_int(savef,i); rs_write_int(savef,i);
} }
else else
{ {
rs_write_int(savef, 0); rs_write_int(savef, 0);
rs_write_int(savef,1); /* chase the hero anyway */ rs_write_int(savef,1); /* chase the hero anyway */
@@ -1600,12 +1600,12 @@ rs_write_thing(FILE *savef, THING *t)
rs_write_int(savef,0); rs_write_int(savef,0);
rs_write_int(savef,0); rs_write_int(savef,0);
} }
rs_write_short(savef, t->_t._t_flags); rs_write_short(savef, t->_t._t_flags);
rs_write_stats(savef, &t->_t._t_stats); rs_write_stats(savef, &t->_t._t_stats);
rs_write_room_reference(savef, t->_t._t_room); rs_write_room_reference(savef, t->_t._t_room);
rs_write_object_list(savef, t->_t._t_pack); rs_write_object_list(savef, t->_t._t_pack);
return(WRITESTAT); return(WRITESTAT);
} }
@@ -1630,8 +1630,8 @@ rs_read_thing(FILE *inf, THING *t)
rs_read_char(inf,&t->_t._t_type); rs_read_char(inf,&t->_t._t_type);
rs_read_char(inf,&t->_t._t_disguise); rs_read_char(inf,&t->_t._t_disguise);
rs_read_char(inf,&t->_t._t_oldch); rs_read_char(inf,&t->_t._t_oldch);
/* /*
t_dest can be (listid,index): t_dest can be (listid,index):
0,0: NULL 0,0: NULL
0,1: location of hero 0,1: location of hero
@@ -1639,10 +1639,10 @@ rs_read_thing(FILE *inf, THING *t)
2,i: location of an object 2,i: location of an object
3,i: location of gold in a room 3,i: location of gold in a room
We need to remember what we are chasing rather than We need to remember what we are chasing rather than
the current location of what we are chasing. the current location of what we are chasing.
*/ */
rs_read_int(inf, &listid); rs_read_int(inf, &listid);
rs_read_int(inf, &index); rs_read_int(inf, &index);
t->_t._t_reserved = -1; t->_t._t_reserved = -1;
@@ -1677,12 +1677,12 @@ rs_read_thing(FILE *inf, THING *t)
} }
else else
t->_t._t_dest = NULL; t->_t._t_dest = NULL;
rs_read_short(inf,&t->_t._t_flags); rs_read_short(inf,&t->_t._t_flags);
rs_read_stats(inf,&t->_t._t_stats); rs_read_stats(inf,&t->_t._t_stats);
rs_read_room_reference(inf, &t->_t._t_room); rs_read_room_reference(inf, &t->_t._t_room);
rs_read_object_list(inf,&t->_t._t_pack); rs_read_object_list(inf,&t->_t._t_pack);
return(READSTAT); return(READSTAT);
} }
@@ -1708,7 +1708,7 @@ int
rs_write_thing_list(FILE *savef, THING *l) rs_write_thing_list(FILE *savef, THING *l)
{ {
int cnt = 0; int cnt = 0;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
@@ -1725,7 +1725,7 @@ rs_write_thing_list(FILE *savef, THING *l)
rs_write_thing(savef, l); rs_write_thing(savef, l);
l = l->l_next; l = l->l_next;
} }
return(WRITESTAT); return(WRITESTAT);
} }
@@ -1742,12 +1742,12 @@ rs_read_thing_list(FILE *inf, THING **list)
rs_read_int(inf, &cnt); rs_read_int(inf, &cnt);
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
{ {
l = new_item(); l = new_item();
l->l_prev = previous; l->l_prev = previous;
if (previous != NULL) if (previous != NULL)
previous->l_next = l; previous->l_next = l;
@@ -1758,12 +1758,12 @@ rs_read_thing_list(FILE *inf, THING **list)
previous = l; previous = l;
} }
if (l != NULL) if (l != NULL)
l->l_next = NULL; l->l_next = NULL;
*list = head; *list = head;
return(READSTAT); return(READSTAT);
} }
@@ -1800,7 +1800,7 @@ int
rs_read_thing_reference(FILE *inf, THING *list, THING **item) rs_read_thing_reference(FILE *inf, THING *list, THING **item)
{ {
int i; int i;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
@@ -1842,15 +1842,15 @@ rs_read_thing_references(FILE *inf, THING *list, THING *items[], int count)
return(WRITESTAT); return(WRITESTAT);
} }
int int
rs_write_places(FILE *savef, PLACE *places, int count) rs_write_places(FILE *savef, PLACE *places, int count)
{ {
int i = 0; int i = 0;
if (write_error) if (write_error)
return(WRITESTAT); return(WRITESTAT);
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
{ {
rs_write_char(savef, places[i].p_ch); rs_write_char(savef, places[i].p_ch);
rs_write_char(savef, places[i].p_flags); rs_write_char(savef, places[i].p_flags);
@@ -1860,15 +1860,15 @@ rs_write_places(FILE *savef, PLACE *places, int count)
return(WRITESTAT); return(WRITESTAT);
} }
int int
rs_read_places(FILE *inf, PLACE *places, int count) rs_read_places(FILE *inf, PLACE *places, int count)
{ {
int i = 0; int i = 0;
if (read_error || format_error) if (read_error || format_error)
return(READSTAT); return(READSTAT);
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
{ {
rs_read_char(inf,&places[i].p_ch); rs_read_char(inf,&places[i].p_ch);
rs_read_char(inf,&places[i].p_flags); rs_read_char(inf,&places[i].p_flags);
@@ -1963,34 +1963,34 @@ rs_save_file(FILE *savef)
rs_write_coord(savef, oldpos); rs_write_coord(savef, oldpos);
rs_write_coord(savef, stairs); rs_write_coord(savef, stairs);
rs_write_thing(savef, &player); rs_write_thing(savef, &player);
rs_write_object_reference(savef, player.t_pack, cur_armor); rs_write_object_reference(savef, player.t_pack, cur_armor);
rs_write_object_reference(savef, player.t_pack, cur_ring[0]); rs_write_object_reference(savef, player.t_pack, cur_ring[0]);
rs_write_object_reference(savef, player.t_pack, cur_ring[1]); rs_write_object_reference(savef, player.t_pack, cur_ring[1]);
rs_write_object_reference(savef, player.t_pack, cur_weapon); rs_write_object_reference(savef, player.t_pack, cur_weapon);
rs_write_object_reference(savef, player.t_pack, l_last_pick); rs_write_object_reference(savef, player.t_pack, l_last_pick);
rs_write_object_reference(savef, player.t_pack, last_pick); rs_write_object_reference(savef, player.t_pack, last_pick);
rs_write_object_list(savef, lvl_obj); rs_write_object_list(savef, lvl_obj);
rs_write_thing_list(savef, mlist); rs_write_thing_list(savef, mlist);
rs_write_places(savef,places,MAXLINES*MAXCOLS); rs_write_places(savef,places,MAXLINES*MAXCOLS);
rs_write_stats(savef,&max_stats); rs_write_stats(savef,&max_stats);
rs_write_rooms(savef, rooms, MAXROOMS); rs_write_rooms(savef, rooms, MAXROOMS);
rs_write_room_reference(savef, oldrp); rs_write_room_reference(savef, oldrp);
rs_write_rooms(savef, passages, MAXPASS); rs_write_rooms(savef, passages, MAXPASS);
rs_write_monsters(savef,monsters,26); rs_write_monsters(savef,monsters,26);
rs_write_obj_info(savef, things, NUMTHINGS); rs_write_obj_info(savef, things, NUMTHINGS);
rs_write_obj_info(savef, arm_info, MAXARMORS); rs_write_obj_info(savef, arm_info, MAXARMORS);
rs_write_obj_info(savef, pot_info, MAXPOTIONS); rs_write_obj_info(savef, pot_info, MAXPOTIONS);
rs_write_obj_info(savef, ring_info, MAXRINGS); rs_write_obj_info(savef, ring_info, MAXRINGS);
rs_write_obj_info(savef, scr_info, MAXSCROLLS); rs_write_obj_info(savef, scr_info, MAXSCROLLS);
rs_write_obj_info(savef, weap_info, MAXWEAPONS+1); rs_write_obj_info(savef, weap_info, MAXWEAPONS+1);
rs_write_obj_info(savef, ws_info, MAXSTICKS); rs_write_obj_info(savef, ws_info, MAXSTICKS);
rs_write_daemons(savef, &d_list[0], 20); /* 5.4-daemon.c */ rs_write_daemons(savef, &d_list[0], 20); /* 5.4-daemon.c */
#ifdef MASTER #ifdef MASTER
rs_write_int(savef,total); /* 5.4-list.c */ rs_write_int(savef,total); /* 5.4-list.c */
@@ -2093,7 +2093,7 @@ rs_restore_file(FILE *inf)
rs_read_coord(inf, &oldpos); rs_read_coord(inf, &oldpos);
rs_read_coord(inf, &stairs); rs_read_coord(inf, &stairs);
rs_read_thing(inf, &player); rs_read_thing(inf, &player);
rs_read_object_reference(inf, player.t_pack, &cur_armor); rs_read_object_reference(inf, player.t_pack, &cur_armor);
rs_read_object_reference(inf, player.t_pack, &cur_ring[0]); rs_read_object_reference(inf, player.t_pack, &cur_ring[0]);
rs_read_object_reference(inf, player.t_pack, &cur_ring[1]); rs_read_object_reference(inf, player.t_pack, &cur_ring[1]);
@@ -2101,8 +2101,8 @@ rs_restore_file(FILE *inf)
rs_read_object_reference(inf, player.t_pack, &l_last_pick); rs_read_object_reference(inf, player.t_pack, &l_last_pick);
rs_read_object_reference(inf, player.t_pack, &last_pick); rs_read_object_reference(inf, player.t_pack, &last_pick);
rs_read_object_list(inf, &lvl_obj); rs_read_object_list(inf, &lvl_obj);
rs_read_thing_list(inf, &mlist); rs_read_thing_list(inf, &mlist);
rs_fix_thing(&player); rs_fix_thing(&player);
rs_fix_thing_list(mlist); rs_fix_thing_list(mlist);
@@ -2113,21 +2113,21 @@ rs_restore_file(FILE *inf)
rs_read_room_reference(inf, &oldrp); rs_read_room_reference(inf, &oldrp);
rs_read_rooms(inf, passages, MAXPASS); rs_read_rooms(inf, passages, MAXPASS);
rs_read_monsters(inf,monsters,26); rs_read_monsters(inf,monsters,26);
rs_read_obj_info(inf, things, NUMTHINGS); rs_read_obj_info(inf, things, NUMTHINGS);
rs_read_obj_info(inf, arm_info, MAXARMORS); rs_read_obj_info(inf, arm_info, MAXARMORS);
rs_read_obj_info(inf, pot_info, MAXPOTIONS); rs_read_obj_info(inf, pot_info, MAXPOTIONS);
rs_read_obj_info(inf, ring_info, MAXRINGS); rs_read_obj_info(inf, ring_info, MAXRINGS);
rs_read_obj_info(inf, scr_info, MAXSCROLLS); rs_read_obj_info(inf, scr_info, MAXSCROLLS);
rs_read_obj_info(inf, weap_info, MAXWEAPONS+1); rs_read_obj_info(inf, weap_info, MAXWEAPONS+1);
rs_read_obj_info(inf, ws_info, MAXSTICKS); rs_read_obj_info(inf, ws_info, MAXSTICKS);
rs_read_daemons(inf, d_list, 20); /* 5.4-daemon.c */ rs_read_daemons(inf, d_list, 20); /* 5.4-daemon.c */
rs_read_int(inf,&dummyint); /* total */ /* 5.4-list.c */ rs_read_int(inf,&dummyint); /* total */ /* 5.4-list.c */
rs_read_int(inf,&between); /* 5.4-daemons.c */ rs_read_int(inf,&between); /* 5.4-daemons.c */
rs_read_coord(inf, &nh); /* 5.4-move.c */ rs_read_coord(inf, &nh); /* 5.4-move.c */
rs_read_int(inf,&group); /* 5.4-weapons.c */ rs_read_int(inf,&group); /* 5.4-weapons.c */
rs_read_window(inf,stdscr); rs_read_window(inf,stdscr);
return(READSTAT); return(READSTAT);