diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 1998-08-22 08:56:02 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 1998-08-22 08:56:02 +0000 |
commit | 6910826c1b27cf6a9d4cb8400743d571d3c9a27b (patch) | |
tree | 9562c830236235b683790903daad5db093658719 /games/rogue/save.c | |
parent | 92cf145f2c1e59139400da3a8db7b06cc24b7b54 (diff) |
More largely NetBSD-inspired code cleanup
Diffstat (limited to 'games/rogue/save.c')
-rw-r--r-- | games/rogue/save.c | 96 |
1 files changed, 43 insertions, 53 deletions
diff --git a/games/rogue/save.c b/games/rogue/save.c index 73008b3987c..b75aa7c37ab 100644 --- a/games/rogue/save.c +++ b/games/rogue/save.c @@ -1,3 +1,4 @@ +/* $OpenBSD: save.c,v 1.4 1998/08/22 08:55:46 pjanzen Exp $ */ /* $NetBSD: save.c,v 1.3 1995/04/22 10:28:21 cgd Exp $ */ /* @@ -40,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: save.c,v 1.3 1995/04/22 10:28:21 cgd Exp $"; +static char rcsid[] = "$OpenBSD: save.c,v 1.4 1998/08/22 08:55:46 pjanzen Exp $"; #endif #endif /* not lint */ @@ -52,7 +53,7 @@ static char rcsid[] = "$NetBSD: save.c,v 1.3 1995/04/22 10:28:21 cgd Exp $"; * 1.) No portion of this notice shall be removed. * 2.) Credit shall not be taken for the creation of this source. * 3.) This code is not to be traded, sold, or used for personal - * gain or profit. + * gain or profit. * */ @@ -62,29 +63,7 @@ static char rcsid[] = "$NetBSD: save.c,v 1.3 1995/04/22 10:28:21 cgd Exp $"; short write_failed = 0; char *save_file = (char *) 0; -extern boolean detect_monster; -extern short cur_level, max_level; -extern char hunger_str[]; -extern char login_name[]; -extern short party_room; -extern short foods; -extern boolean is_wood[]; -extern short cur_room; -extern boolean being_held; -extern short bear_trap; -extern short halluc; -extern short blind; -extern short confused; -extern short levitate; -extern short haste_self; -extern boolean see_invisible; -extern boolean detect_monster; -extern boolean wizard; -extern boolean score_only; -extern short m_moves; - -extern boolean msg_cleared; - +void save_game() { char fname[64]; @@ -98,8 +77,9 @@ save_game() save_into_file(fname); } +void save_into_file(sfile) -char *sfile; + char *sfile; { FILE *fp; int file_id; @@ -108,7 +88,7 @@ char *sfile; struct rogue_time rt_buf; if (sfile[0] == '~') { - if (hptr = md_getenv("HOME")) { + if ((hptr = md_getenv("HOME"))) { if (strlen(hptr) + strlen(sfile+1) < sizeof(name_buffer)) { (void) strcpy(name_buffer, hptr); (void) strcat(name_buffer, sfile+1); @@ -172,8 +152,9 @@ char *sfile; } } +void restore(fname) -char *fname; + char *fname; { FILE *fp; struct rogue_time saved_time, mod_time; @@ -252,23 +233,25 @@ char *fname; fclose(fp); } +void write_pack(pack, fp) -object *pack; -FILE *fp; + object *pack; + FILE *fp; { object t; - while (pack = pack->next_object) { + while ((pack = pack->next_object)) { r_write(fp, (char *) pack, sizeof(object)); } t.ichar = t.what_is = 0; r_write(fp, (char *) &t, sizeof(object)); } +void read_pack(pack, fp, is_rogue) -object *pack; -FILE *fp; -boolean is_rogue; + object *pack; + FILE *fp; + boolean is_rogue; { object read_obj, *new_obj; @@ -295,9 +278,10 @@ boolean is_rogue; } } +void rw_dungeon(fp, rw) -FILE *fp; -boolean rw; + FILE *fp; + boolean rw; { short i, j; char buf[DCOLS]; @@ -319,11 +303,12 @@ boolean rw; } } +void rw_id(id_table, fp, n, wr) -struct id id_table[]; -FILE *fp; -int n; -boolean wr; + struct id id_table[]; + FILE *fp; + int n; + boolean wr; { short i; @@ -342,9 +327,10 @@ boolean wr; } } +void write_string(s, fp) -char *s; -FILE *fp; + char *s; + FILE *fp; { short n; @@ -354,9 +340,10 @@ FILE *fp; r_write(fp, s, n); } +void read_string(s, fp) -char *s; -FILE *fp; + char *s; + FILE *fp; { short n; @@ -365,9 +352,10 @@ FILE *fp; xxxx(s, n); } +void rw_rooms(fp, rw) -FILE *fp; -boolean rw; + FILE *fp; + boolean rw; { short i; @@ -377,20 +365,22 @@ boolean rw; } } +void r_read(fp, buf, n) -FILE *fp; -char *buf; -int n; + FILE *fp; + char *buf; + int n; { if (fread(buf, sizeof(char), n, fp) != n) { clean_up("read() failed, don't know why"); } } +void r_write(fp, buf, n) -FILE *fp; -char *buf; -int n; + FILE *fp; + char *buf; + int n; { if (!write_failed) { if (fwrite(buf, sizeof(char), n, fp) != n) { @@ -403,7 +393,7 @@ int n; boolean has_been_touched(saved_time, mod_time) -struct rogue_time *saved_time, *mod_time; + struct rogue_time *saved_time, *mod_time; { if (saved_time->year < mod_time->year) { return(1); |