Mercurial > hg > early-roguelike
diff xrogue/state.c @ 220:f54901b9c39b
XRogue: convert to ANSI-style function declarations.
author | John "Elwin" Edwards |
---|---|
date | Wed, 02 Mar 2016 21:13:26 -0500 |
parents | 3def5e487faa |
children | 7c1cb43f346e |
line wrap: on
line diff
--- a/xrogue/state.c Fri Feb 19 21:02:28 2016 -0500 +++ b/xrogue/state.c Wed Mar 02 21:13:26 2016 -0500 @@ -97,6 +97,14 @@ int save_debug = FALSE; #define DBG(x) {if (save_debug) rsPrintf x;} +bool rs_read_new_string(int inf, char **s); +int find_list_ptr(struct linked_list *l, void *ptr); +bool rs_write_coord_list(FILE *savef, struct linked_list *l); +bool rs_read_coord_list(int inf, struct linked_list **list); +int list_size(struct linked_list *l); +bool rs_write_object_list(FILE *savef, struct linked_list *l); +bool rs_read_object_list(int inf, struct linked_list **list); + int rsPrintf(char *fmt, ...) { @@ -128,6 +136,7 @@ return(NULL); } +bool rs_write(FILE *savef, void *ptr, size_t size) { size_t i = 0; @@ -143,6 +152,7 @@ int end_of_file = FALSE; +bool rs_read(int inf, void *ptr, size_t size) { int actual; @@ -165,6 +175,7 @@ int big_endian = 0; +bool rs_write_uint(FILE *savef, unsigned int c) { char bytes[4]; @@ -184,6 +195,7 @@ return(WRITESTAT); } +bool rs_write_int(FILE *savef, int c) { char bytes[4]; @@ -203,6 +215,7 @@ return(WRITESTAT); } +bool rs_write_ulong(FILE *savef, unsigned long c) { unsigned int c2; @@ -229,6 +242,7 @@ return(WRITESTAT); } +bool rs_write_long(FILE *savef, long c) { int c2; @@ -255,6 +269,7 @@ return(WRITESTAT); } +bool rs_write_boolean(FILE *savef, bool c) { char buf; @@ -269,6 +284,7 @@ return(WRITESTAT); } +bool rs_read_int(int inf, int *i) { char bytes[4]; @@ -291,6 +307,7 @@ return(READSTAT); } +bool rs_read_uint(int inf, unsigned int *i) { char bytes[4]; @@ -313,6 +330,7 @@ return(READSTAT); } +bool rs_read_ulong(int inf, unsigned long *i) { char bytes[4]; @@ -337,6 +355,7 @@ return(READSTAT); } +bool rs_read_long(int inf, long *i) { char bytes[4]; @@ -361,6 +380,7 @@ return(READSTAT); } +bool rs_read_boolean(int inf, bool *i) { char buf; @@ -372,6 +392,7 @@ return(READSTAT); } +bool rs_write_ints(FILE *savef, int *c, int count) { int n=0; @@ -384,6 +405,7 @@ return(WRITESTAT); } +bool rs_write_short(FILE *savef, short c) { char bytes[2]; @@ -401,6 +423,7 @@ return(WRITESTAT); } +bool rs_read_short(int inf, short *s) { char bytes[2]; @@ -421,6 +444,7 @@ } +bool rs_write_shorts(FILE *savef, short *c, int count) { int n=0; @@ -433,6 +457,7 @@ return(WRITESTAT); } +bool rs_write_longs(FILE *savef, long *c, int count) { int n=0; @@ -445,6 +470,7 @@ return(WRITESTAT); } +bool rs_write_ulongs(FILE *savef, unsigned long *c, int count) { int n=0; @@ -457,6 +483,7 @@ return(WRITESTAT); } +bool rs_write_booleans(FILE *savef, bool *c, int count) { int n=0; @@ -469,6 +496,7 @@ return(WRITESTAT); } +bool rs_read_ints(int inf, int *i, int count) { int n=0,value=0; @@ -487,6 +515,7 @@ return(READSTAT); } +bool rs_read_shorts(int inf, short *i, int count) { int n=0,value=0; @@ -505,6 +534,7 @@ return(READSTAT); } +bool rs_read_longs(int inf, long *i, int count) { int n=0,value=0; @@ -523,6 +553,7 @@ return(READSTAT); } +bool rs_read_ulongs(int inf, unsigned long *i, int count) { int n=0,value=0; @@ -541,6 +572,7 @@ return(READSTAT); } +bool rs_read_booleans(int inf, bool *i, int count) { int n=0,value=0; @@ -559,6 +591,7 @@ return(READSTAT); } +bool rs_write_levtype(FILE *savef, LEVTYPE c) { int lt; @@ -578,6 +611,7 @@ return(WRITESTAT); } +bool rs_read_levtype(int inf, LEVTYPE *l) { int lt; @@ -597,6 +631,7 @@ return(READSTAT); } +bool rs_write_char(FILE *savef, char c) { rs_write(savef, &c, 1); @@ -605,6 +640,7 @@ return(WRITESTAT); } +bool rs_read_char(int inf, char *c) { rs_read(inf, c, 1); @@ -612,6 +648,7 @@ return(READSTAT); } +bool rs_write_uchar(FILE *savef, unsigned char c) { rs_write(savef, &c, 1); @@ -620,6 +657,7 @@ return(WRITESTAT); } +bool rs_read_uchar(int inf, unsigned char *c) { rs_read(inf, c, 1); @@ -627,6 +665,7 @@ return(READSTAT); } +bool rs_write_string(FILE *savef, char *s) { int len = 0; @@ -639,6 +678,7 @@ return(WRITESTAT); } +bool rs_read_string_index(int inf, struct words master[], int maxindex, char **str) { int i; @@ -660,6 +700,7 @@ return(READSTAT); } +bool rs_write_string_index(FILE *savef, struct words master[], int maxindex, char *str) { int i; @@ -677,6 +718,7 @@ return(WRITESTAT); } +bool rs_read_scrolls(int inf) { int i; @@ -691,6 +733,7 @@ return(READSTAT); } +bool rs_write_scrolls(FILE *savef) { int i; @@ -701,9 +744,10 @@ rs_write_boolean(savef,s_know[i]); rs_write_string(savef,s_guess[i]); } - return(READSTAT); + return(WRITESTAT); } +bool rs_read_potions(int inf) { int i; @@ -718,6 +762,7 @@ return(READSTAT); } +bool rs_write_potions(FILE *savef) { int i; @@ -732,6 +777,7 @@ return(WRITESTAT); } +bool rs_read_rings(int inf) { int i; @@ -746,6 +792,7 @@ return(READSTAT); } +bool rs_write_rings(FILE *savef) { int i; @@ -760,6 +807,7 @@ return(WRITESTAT); } +bool rs_read_misc(int inf) { int i; @@ -773,6 +821,7 @@ return(READSTAT); } +bool rs_write_misc(FILE *savef) { int i; @@ -786,6 +835,7 @@ return(WRITESTAT); } +bool rs_write_sticks(FILE *savef) { int i; @@ -809,6 +859,7 @@ return(WRITESTAT); } +bool rs_read_sticks(int inf) { int i = 0, list = 0; @@ -833,6 +884,7 @@ return(READSTAT); } +bool rs_read_string(int inf, char *s, int max) { int len = 0; @@ -852,6 +904,7 @@ return(READSTAT); } +bool rs_read_new_string(int inf, char **s) { int len=0; @@ -878,6 +931,7 @@ return(READSTAT); } +bool rs_write_strings(FILE *savef, char *s[], int count) { int len = 0; @@ -896,6 +950,7 @@ return(WRITESTAT); } +bool rs_write_words(FILE *savef, struct words *w, int count) { int n = 0; @@ -911,6 +966,7 @@ return(WRITESTAT); } +bool rs_read_words(int inf, struct words *w, int count) { int n = 0; @@ -933,6 +989,7 @@ return(READSTAT); } +bool rs_read_new_strings(int inf, char **s, int count) { int len = 0; @@ -966,6 +1023,7 @@ return(READSTAT); } +bool rs_write_coord(FILE *savef, coord *c) { DBG(("X =")); @@ -976,6 +1034,7 @@ return(WRITESTAT); } +bool rs_read_coord(int inf, coord *c) { rs_read_int(inf,&c->x); @@ -1047,6 +1106,7 @@ return tobj; } +bool rs_write_daemons(FILE *savef, struct delayed_action *d_list,int count) { int i = 0; @@ -1173,6 +1233,7 @@ return(WRITESTAT); } +bool rs_read_daemons(int inf, struct delayed_action *d_list, int count) { int i = 0; @@ -1344,6 +1405,7 @@ return(READSTAT); } +bool rs_write_rooms(FILE *savef, struct room r[], int count) { int n = 0,i = -1; @@ -1376,6 +1438,7 @@ return(WRITESTAT); } +bool rs_read_rooms(int inf, struct room *r, int count) { int value = 0, n = 0, i = 0, index = 0, id = 0; @@ -1436,6 +1499,7 @@ return(READSTAT); } +bool rs_write_object(FILE *savef, struct object *o) { rs_write_int(savef, RSXR_OBJECT); @@ -1487,6 +1551,7 @@ return(WRITESTAT); } +bool rs_read_object(int inf, struct object *o) { int id; @@ -1523,6 +1588,7 @@ return(READSTAT); } +bool rs_write_stats(FILE *savef, struct stats *s) { DBG(("Stats\n")); @@ -1546,6 +1612,7 @@ return(WRITESTAT); } +bool rs_read_stats(int inf, struct stats *s) { int id; @@ -1580,6 +1647,7 @@ return(READSTAT); } +bool rs_write_mstats(FILE *savef, struct mstats *s) { DBG(("M-Stats\n")); @@ -1598,6 +1666,7 @@ return(WRITESTAT); } +bool rs_read_mstats(int inf, struct mstats *s) { int id; @@ -1634,6 +1703,7 @@ return(READSTAT); } +bool rs_write_init_weps(FILE *savef, struct init_weps *w, int count) { int i; @@ -1656,6 +1726,7 @@ return(WRITESTAT); } +bool rs_read_init_weps(int inf, struct init_weps *w,int count) { int id,value,i; @@ -1684,6 +1755,7 @@ return(READSTAT); } +bool rs_write_init_armor(FILE *savef, struct init_armor *a, int count) { int i; @@ -1701,6 +1773,7 @@ return(WRITESTAT); } +bool rs_read_init_armor(int inf, struct init_armor *a,int count) { int id,value,i; @@ -1720,6 +1793,7 @@ return(READSTAT); } +bool rs_write_spells(FILE *savef, struct spells *s, int count) { int i; @@ -1736,6 +1810,7 @@ return(WRITESTAT); } +bool rs_read_spells(int inf, struct spells *s,int count) { int id,value,i; @@ -1753,6 +1828,7 @@ return(READSTAT); } +bool rs_write_item_list(FILE *savef, struct item_list *i) { DBG(("Item List\n")); @@ -1761,6 +1837,8 @@ rs_write(savef, i->item_desc, sizeof(i->item_desc)); return(WRITESTAT); } + +bool rs_read_item_list(int inf, struct item_list *i) { int id; @@ -1772,6 +1850,7 @@ return(READSTAT); } +bool rs_write_h_list(FILE *savef, struct h_list *h) { DBG(("H List\n")); @@ -1781,6 +1860,7 @@ return(WRITESTAT); } +bool rs_read_h_list(int inf, struct h_list *h) { int id; @@ -1792,6 +1872,7 @@ return(READSTAT); } +bool rs_write_death_types(FILE *savef, struct death_type *d,int count) { int i; @@ -1807,6 +1888,8 @@ } return(WRITESTAT); } + +bool rs_read_death_types(int inf, struct death_type *d, int count) { int id,value,i; @@ -1828,6 +1911,7 @@ return(READSTAT); } +bool rs_write_character_types(FILE *savef, struct character_types *c, int count) { int i; @@ -1851,6 +1935,7 @@ return(WRITESTAT); } +bool rs_read_character_types(int inf, struct character_types *c,int count) { int id,value,i; @@ -1880,6 +1965,7 @@ return(READSTAT); } +bool rs_write_traps(FILE *savef, struct trap *trap,int count) { int n; @@ -1895,8 +1981,10 @@ rs_write_coord(savef, &trap[n].tr_pos); rs_write_long(savef, trap[n].tr_flags); } + return(WRITESTAT); } +bool rs_read_traps(int inf, struct trap *trap, int count) { int id = 0, value = 0, n = 0; @@ -1937,6 +2025,7 @@ return(READSTAT); } +bool rs_write_monsters(FILE * savef, struct monster * m, int count) { int n; @@ -1965,6 +2054,7 @@ return(WRITESTAT); } +bool rs_read_monsters(int inf, struct monster *m, int count) { int id = 0, value = 0, n = 0; @@ -2024,6 +2114,7 @@ /*****************************************************************************/ +bool rs_write_coord_list(FILE *savef, struct linked_list *l) { DBG(("Coordinate List\n")); @@ -2039,6 +2130,7 @@ return(WRITESTAT); } +bool rs_read_coord_list(int inf, struct linked_list **list) { int id; @@ -2082,6 +2174,7 @@ return(READSTAT); } +bool rs_write_object_list(FILE *savef, struct linked_list *l) { DBG(("Object List\n")); @@ -2097,6 +2190,7 @@ return(WRITESTAT); } +bool rs_read_object_list(int inf, struct linked_list **list) { int id; @@ -2175,6 +2269,7 @@ return(-1); } +bool rs_write_thing(FILE *savef, struct thing *t) { int i = -1; @@ -2285,6 +2380,7 @@ return(WRITESTAT); } +void rs_fix_thing(struct thing *t) { struct linked_list *item; @@ -2302,6 +2398,7 @@ } } +bool rs_read_thing(int inf, struct thing *t) { int id; @@ -2413,6 +2510,7 @@ } +bool rs_write_monster_list(FILE *savef, struct linked_list *l) { int cnt = 0; @@ -2435,8 +2533,8 @@ return(WRITESTAT); } -rs_fix_monster_list(list) -struct linked_list *list; +void +rs_fix_monster_list(struct linked_list *list) { struct linked_list *item; @@ -2444,6 +2542,7 @@ rs_fix_thing(THINGPTR(item)); } +bool rs_read_monster_list(int inf, struct linked_list **list) { int id; @@ -2485,6 +2584,7 @@ return(READSTAT); } +bool rs_write_magic_items(FILE *savef, struct magic_item *i, int count) { int n; @@ -2505,6 +2605,7 @@ return(WRITESTAT); } +bool rs_read_magic_items(int inf, struct magic_item *mi, int count) { int id; @@ -2546,6 +2647,7 @@ return(READSTAT); } +bool rs_write_window(FILE *savef, WINDOW *win) { int row,col,height,width; @@ -2558,8 +2660,11 @@ for(row=0;row<height;row++) for(col=0;col<width;col++) rs_write_int(savef, mvwinch(win,row,col)); + + return(WRITESTAT); } +bool rs_read_window(int inf, WINDOW *win) { int row,col,maxlines,maxcols,value,width,height; @@ -2588,6 +2693,7 @@ return(READSTAT); } +bool rs_save_file(FILE *savef) { int i, weapon, armor, ring, misc, room = -1; @@ -2743,6 +2849,7 @@ return(WRITESTAT); } +bool rs_restore_file(int inf) { int weapon, armor, ring, misc, room = -1,i,checkpoint; @@ -2904,6 +3011,7 @@ return(READSTAT); } +void rs_write_scorefile(FILE *savef, struct sc_ent *entries, int count) { int i; @@ -2923,6 +3031,7 @@ } } +int rs_read_scorefile(FILE *savef, struct sc_ent *entries, int count) { int i,available = 0; @@ -2954,6 +3063,7 @@ +void rs_print_thing(FILE *outf, struct thing *thing, char *prefix, int list, int index) { int i; @@ -2995,6 +3105,7 @@ fprintf(outf,"%st_reserved : %d\n",prefix,thing->t_reserved); } +void rs_print_game_state(FILE *outf) { fprintf(outf, "Player\n"); @@ -3025,8 +3136,7 @@ ****/ int -md_rand(range) -register int range; +md_rand(int range) { #ifdef _WIN32 return(range <= 0 ? 0 : rand() % range); @@ -3036,8 +3146,7 @@ } int -md_srand(seed) -register int seed; +md_srand(int seed) { #ifdef _WIN32 srand(seed); @@ -3047,7 +3156,7 @@ } void -md_flushinp() +md_flushinp(void) { /* ioctl(0,TIOCFLUSH) */ /* ioctl(_tty_ch,TCFLSH,0) */ @@ -3055,7 +3164,7 @@ } int -md_getuid() +md_getuid(void) { #ifdef _WIN32 return(42); @@ -3065,7 +3174,7 @@ } long -md_memused() +md_memused(void) { #ifdef _WIN32 MEMORYSTATUS stat; @@ -3079,7 +3188,7 @@ } char * -md_getusername() +md_getusername(void) { static char login[80]; char *l = NULL; @@ -3114,7 +3223,7 @@ } char * -md_gethomedir() +md_gethomedir(void) { static char homedir[PATH_MAX]; char *h = NULL; @@ -3181,7 +3290,7 @@ } char * -md_getroguedir() +md_getroguedir(void) { static char path[1024]; char *end,*home; @@ -3218,7 +3327,7 @@ } char * -md_getshell() +md_getshell(void) { static char shell[PATH_MAX]; char *s = NULL; @@ -3246,7 +3355,7 @@