From 65130d9f6581e4bd39ceae50d820c9774e4972a9 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 7 Apr 2021 10:09:53 +0300 Subject: [PATCH] streams: use single stram object for read and write --- src/common/files.c | 96 ++++++++++++-------------------------------- src/common/files.h | 21 +++------- src/common/streams.c | 24 +++++++---- src/common/streams.h | 36 ++++++++--------- src/common/wadres.c | 24 +++++------ src/common/wadres.h | 4 +- src/files.c | 8 ++-- src/map.c | 16 ++++---- src/map.h | 2 +- src/save.c | 68 +++++++++++++++---------------- src/save.h | 4 +- 11 files changed, 126 insertions(+), 177 deletions(-) diff --git a/src/common/files.c b/src/common/files.c index 91789f6..792df2d 100644 --- a/src/common/files.c +++ b/src/common/files.c @@ -4,8 +4,8 @@ #include #include -static long FILE_Reader_GetPos (Reader *r) { - FILE_Reader *rd = (FILE_Reader*)r; +static long FILE_Stream_GetPos (Stream *r) { + FILE_Stream *rd = (FILE_Stream*)r; assert(rd != NULL); assert(rd->fp != NULL); long pos = ftell(rd->fp); @@ -13,8 +13,8 @@ static long FILE_Reader_GetPos (Reader *r) { return pos; } -static void FILE_Reader_SetPos (Reader *r, long pos) { - FILE_Reader *rd = (FILE_Reader*)r; +static void FILE_Stream_SetPos (Stream *r, long pos) { + FILE_Stream *rd = (FILE_Stream*)r; assert(rd != NULL); assert(rd->fp != NULL); assert(pos >= 0); @@ -22,96 +22,50 @@ static void FILE_Reader_SetPos (Reader *r, long pos) { assert(res == 0); // fail } -static void FILE_Reader_Read (Reader *r, void *data, size_t size, size_t n) { - FILE_Reader *rd = (FILE_Reader*)r; +static void FILE_Stream_Read (Stream *r, void *data, size_t size, size_t n) { + FILE_Stream *rd = (FILE_Stream*)r; assert(rd != NULL); assert(rd->fp != NULL); size_t res = fread(data, size, n, rd->fp); assert(res == n); // fail } -void FILE_AssignReader (FILE_Reader *r, FILE *fp) { +static void FILE_Stream_Write (Stream *w, const void *data, size_t size, size_t n) { + FILE_Stream *wr = (FILE_Stream*)w; + assert(wr != NULL); + assert(wr->fp != NULL); + size_t res = fwrite(data, size, n, wr->fp); + assert(res == n); // fail +} + +void FILE_Assign (FILE_Stream *r, FILE *fp) { assert(r != NULL); assert(fp != NULL); - r->base.getpos = FILE_Reader_GetPos; - r->base.setpos = FILE_Reader_SetPos; - r->base.read = FILE_Reader_Read; + r->base.getpos = FILE_Stream_GetPos; + r->base.setpos = FILE_Stream_SetPos; + r->base.read = FILE_Stream_Read; + r->base.write = FILE_Stream_Write; r->fp = fp; } -int FILE_OpenReader (FILE_Reader *r, const char *name) { +int FILE_Open (FILE_Stream *r, const char *name, const char *mode) { assert(r != NULL); assert(name != NULL); - FILE *fp = fopen(name, "rb"); + FILE *fp = fopen(name, mode); if (fp) { - FILE_AssignReader(r, fp); + FILE_Assign(r, fp); } return fp != NULL; } -void FILE_CloseReader (FILE_Reader *r) { +void FILE_Close (FILE_Stream *r) { assert(r != NULL); if (r->fp != NULL) { fclose(r->fp); } r->base.getpos = NULL; r->base.setpos = NULL; - r->base.read = NULL; + r->base.read = NULL; + r->base.write = NULL; r->fp = NULL; } - -static long FILE_Writer_GetPos (Writer *w) { - FILE_Writer *wr = (FILE_Writer*)w; - assert(wr != NULL); - assert(wr->fp != NULL); - long pos = ftell(wr->fp); - assert(pos != -1); // fail - return pos; -} - -static void FILE_Writer_SetPos (Writer *w, long pos) { - FILE_Writer *wr = (FILE_Writer*)w; - assert(wr != NULL); - assert(wr->fp != NULL); - assert(pos >= 0); - int res = fseek(wr->fp, pos, SEEK_SET); - assert(res == 0); // fail -} - -static void FILE_Writer_Write (Writer *w, const void *data, size_t size, size_t n) { - FILE_Writer *wr = (FILE_Writer*)w; - assert(wr != NULL); - assert(wr->fp != NULL); - size_t res = fwrite(data, size, n, wr->fp); - assert(res == n); // fail -} - -void FILE_AssignWriter (FILE_Writer *w, FILE *fp) { - assert(w != NULL); - assert(fp != NULL); - w->base.getpos = FILE_Writer_GetPos; - w->base.setpos = FILE_Writer_SetPos; - w->base.write = FILE_Writer_Write; - w->fp = fp; -} - -int FILE_OpenWriter (FILE_Writer *w, const char *name) { - assert(w != NULL); - assert(name != NULL); - FILE *fp = fopen(name, "wb"); - if (fp) { - FILE_AssignWriter(w, fp); - } - return fp != NULL; -} - -void FILE_CloseWriter (FILE_Writer *w) { - assert(w != NULL); - if (w->fp != NULL) { - fclose(w->fp); - } - w->base.getpos = NULL; - w->base.setpos = NULL; - w->base.write = NULL; - w->fp = NULL; -} diff --git a/src/common/files.h b/src/common/files.h index 9145902..a575ec1 100644 --- a/src/common/files.h +++ b/src/common/files.h @@ -4,22 +4,13 @@ #include #include "streams.h" -typedef struct FILE_Reader { - Reader base; +typedef struct FILE_Stream { + Stream base; FILE *fp; -} FILE_Reader; +} FILE_Stream; -typedef struct FILE_Writer { - Writer base; - FILE *fp; -} FILE_Writer; - -void FILE_AssignReader (FILE_Reader *r, FILE *fp); -int FILE_OpenReader (FILE_Reader *r, const char *name); -void FILE_CloseReader (FILE_Reader *r); - -void FILE_AssignWriter (FILE_Writer *w, FILE *fp); -int FILE_OpenWriter (FILE_Writer *w, const char *name); -void FILE_CloseWriter (FILE_Writer *w); +void FILE_Assign (FILE_Stream *r, FILE *fp); +int FILE_Open (FILE_Stream *r, const char *name, const char *mode); +void FILE_Close (FILE_Stream *r); #endif /* COMMON_FILES_H_INCLUDED */ \ No newline at end of file diff --git a/src/common/streams.c b/src/common/streams.c index 46e756b..76edaab 100644 --- a/src/common/streams.c +++ b/src/common/streams.c @@ -4,42 +4,50 @@ #include #include -void stream_read (void *data, size_t size, size_t n, Reader *r) { +long stream_getpos (Stream *s) { + return s->getpos(s); +} + +void stream_setpos (Stream *s, long pos) { + s->setpos(s, pos); +} + +void stream_read (void *data, size_t size, size_t n, Stream *r) { r->read(r, data, size, n); } -int8_t stream_read8 (Reader *r) { +int8_t stream_read8 (Stream *r) { int8_t x; r->read(r, &x, 1, 1); return x; } -int16_t stream_read16 (Reader *r) { +int16_t stream_read16 (Stream *r) { int16_t x; r->read(r, &x, 2, 1); return short2host(x); } -int32_t stream_read32 (Reader *r) { +int32_t stream_read32 (Stream *r) { int32_t x; r->read(r, &x, 4, 1); return int2host(x); } -void stream_write (const void *data, size_t size, size_t n, Writer *w) { +void stream_write (const void *data, size_t size, size_t n, Stream *w) { w->write(w, data, size, n); } -void stream_write8 (int8_t x, Writer *w) { +void stream_write8 (int8_t x, Stream *w) { w->write(w, &x, 1, 1); } -void stream_write16 (int16_t x, Writer *w) { +void stream_write16 (int16_t x, Stream *w) { int16_t y = short2host(x); w->write(w, &y, 2, 1); } -void stream_write32 (int32_t x, Writer *w) { +void stream_write32 (int32_t x, Stream *w) { int32_t y = int2host(x); w->write(w, &y, 4, 1); } diff --git a/src/common/streams.h b/src/common/streams.h index d82b51a..e40427f 100644 --- a/src/common/streams.h +++ b/src/common/streams.h @@ -4,30 +4,26 @@ #include #include -typedef struct Reader Reader; -typedef struct Writer Writer; -typedef struct Handle Handle; +typedef struct Stream Stream; -struct Reader { - long (*getpos)(Reader *r); - void (*setpos)(Reader *r, long pos); - void (*read)(Reader *r, void *data, size_t size, size_t n); +struct Stream { + long (*getpos)(Stream *r); + void (*setpos)(Stream *r, long pos); + void (*read)(Stream *r, void *data, size_t size, size_t n); + void (*write)(Stream *w, const void *data, size_t size, size_t n); }; -struct Writer { - long (*getpos)(Writer *w); - void (*setpos)(Writer *w, long pos); - void (*write)(Writer *w, const void *data, size_t size, size_t n); -}; +long stream_getpos (Stream *s); +void stream_setpos (Stream *s, long pos); -void stream_read (void *data, size_t size, size_t n, Reader *f); -int8_t stream_read8 (Reader *f); -int16_t stream_read16 (Reader *f); -int32_t stream_read32 (Reader *f); +void stream_read (void *data, size_t size, size_t n, Stream *r); +int8_t stream_read8 (Stream *r); +int16_t stream_read16 (Stream *r); +int32_t stream_read32 (Stream *r); -void stream_write (const void *data, size_t size, size_t n, Writer *w); -void stream_write8 (int8_t x, Writer *w); -void stream_write16 (int16_t x, Writer *w); -void stream_write32 (int32_t x, Writer *w); +void stream_write (const void *data, size_t size, size_t n, Stream *w); +void stream_write8 (int8_t x, Stream *w); +void stream_write16 (int16_t x, Stream *w); +void stream_write32 (int32_t x, Stream *w); #endif /* COMMON_STREAMS_H_INCLUDED */ \ No newline at end of file diff --git a/src/common/wadres.c b/src/common/wadres.c index 99524cc..88583b7 100644 --- a/src/common/wadres.c +++ b/src/common/wadres.c @@ -14,18 +14,18 @@ typedef struct Entry { static int n_wads; static int n_resources; -static Reader *wads[MAX_WADS]; +static Stream *wads[MAX_WADS]; static Entry resources[MAX_RESOURCES]; -static int check_header (Reader *r) { +static int check_header (Stream *r) { assert(r != NULL); char ident[4]; - r->setpos(r, 0); + stream_setpos(r, 0); // !!! stream_read(ident, 4, 1, r); return (memcmp(ident, "IWAD", 4) == 0) || (memcmp(ident, "PWAD", 4) == 0); } -int WADRES_addwad (Reader *r) { +int WADRES_addwad (Stream *r) { assert(r != NULL); if (n_wads < MAX_WADS && check_header(r)) { wads[n_wads] = r; @@ -52,11 +52,11 @@ static int WADRES_addresource (const Entry *e) { return -1; } -static int WADRES_read (Reader *r) { - r->setpos(r, 4); // skip magic +static int WADRES_read (Stream *r) { + stream_setpos(r, 4); // skip magic int32_t n = stream_read32(r); int32_t dir = stream_read32(r); - r->setpos(r, dir); + stream_setpos(r, dir); int ok = 1; for (int32_t i = 0; ok && i < n; ++i) { Entry e; @@ -90,7 +90,7 @@ int WADRES_maxids (void) { return n_resources; } -Reader *WADRES_getbasereader (int id) { +Stream *WADRES_getbasereader (int id) { assert(id >= 0 && id < n_resources); return wads[resources[id].f]; } @@ -112,9 +112,9 @@ void WADRES_getname (int id, char *name) { void WADRES_getdata (int id, void *data) { assert(id >= 0 && id < n_resources); - Reader *r = wads[resources[id].f]; - long pos = r->getpos(r); - r->setpos(r, resources[id].offset); + Stream *r = wads[resources[id].f]; + long pos = stream_getpos(r); + stream_setpos(r, resources[id].offset); stream_read(data, resources[id].size, 1, r); - r->setpos(r, pos); + stream_setpos(r, pos); } diff --git a/src/common/wadres.h b/src/common/wadres.h index 30ee85b..b970dfb 100644 --- a/src/common/wadres.h +++ b/src/common/wadres.h @@ -6,13 +6,13 @@ #define MAX_WADS 20 #define MAX_RESOURCES 2000 -int WADRES_addwad (Reader *r); +int WADRES_addwad (Stream *r); int WADRES_rehash (void); int WADRES_find (const char name[8]); int WADRES_maxids (void); -Reader *WADRES_getbasereader (int id); +Stream *WADRES_getbasereader (int id); long WADRES_getoffset (int id); long WADRES_getsize (int id); void WADRES_getname (int id, char *name); diff --git a/src/files.c b/src/files.c index 1141c3b..deac9e3 100644 --- a/src/files.c +++ b/src/files.c @@ -40,9 +40,9 @@ void F_startup (void) { void F_addwad (const char *fn) { static int i = 0; - static FILE_Reader wadh[MAX_WADS]; + static FILE_Stream wadh[MAX_WADS]; if (i < MAX_WADS) { - if (FILE_OpenReader(&wadh[i], fn)) { + if (FILE_Open(&wadh[i], fn, "rb")) { if (WADRES_addwad(&wadh[i].base)) { i += 1; } else { @@ -149,9 +149,9 @@ void F_randmus (char *s) { void F_loadmap (char n[8]) { int id = F_getresid(n); if (id != -1) { - Reader *r = WADRES_getbasereader(id); + Stream *r = WADRES_getbasereader(id); long offset = WADRES_getoffset(id); - r->setpos(r, offset); + stream_setpos(r, offset); if (!MAP_load(r)) { ERR_fatal("Failed to load map"); } diff --git a/src/map.c b/src/map.c index dc65f0c..a5b5bd8 100644 --- a/src/map.c +++ b/src/map.c @@ -62,7 +62,7 @@ typedef struct old_thing_t { static map_block_t blk; -static int G_load (Reader *h) { +static int G_load (Stream *h) { switch (blk.t) { case MB_MUSIC: stream_read(g_music, 8, 1, h); @@ -75,7 +75,7 @@ static int G_load (Reader *h) { return 0; } -static int IT_load (Reader *h) { +static int IT_load (Stream *h) { int m, i, j; old_thing_t t; switch (blk.t) { @@ -171,7 +171,7 @@ static int IT_load (Reader *h) { return 0; } -static int SW_load (Reader *h) { +static int SW_load (Stream *h) { int i; switch(blk.t) { case MB_SWITCH2: @@ -217,7 +217,7 @@ static void unpack (void *buf, int len, void *obuf) { } } -static int read_array (void *p, Reader *h) { +static int read_array (void *p, Stream *h) { void *buf; switch (blk.st) { case 0: @@ -239,7 +239,7 @@ static int read_array (void *p, Reader *h) { return 1; } -static int W_load (Reader *h) { +static int W_load (Stream *h) { int i; char s[8]; switch (blk.t) { @@ -270,7 +270,7 @@ static int W_load (Reader *h) { return 0; } -int MAP_load (Reader *r) { +int MAP_load (Stream *r) { assert(r != NULL); int ok = 0; map_header_t hdr; @@ -283,7 +283,7 @@ int MAP_load (Reader *r) { blk.t = stream_read16(r); blk.st = stream_read16(r); blk.sz = stream_read32(r); - long off = r->getpos(r) + blk.sz; + long off = stream_getpos(r) + blk.sz; switch (blk.t) { case MB_MUSIC: ok = G_load(r); @@ -310,7 +310,7 @@ int MAP_load (Reader *r) { logo("Unknown block %d(%d)\n", blk.t, blk.st); return 0; // error } - r->setpos(r, off); + stream_setpos(r, off); } } else { logo("Invalid map header\n"); diff --git a/src/map.h b/src/map.h index 4e14706..3b0ff10 100644 --- a/src/map.h +++ b/src/map.h @@ -20,6 +20,6 @@ #include "common/streams.h" -int MAP_load (Reader *r); +int MAP_load (Stream *r); #endif /* MAP_H_INCLUDED */ diff --git a/src/save.c b/src/save.c index c5dcb76..a40160d 100644 --- a/src/save.c +++ b/src/save.c @@ -44,7 +44,7 @@ char savname[SAVE_MAX][SAVE_MAXLEN]; char savok[SAVE_MAX]; -static void DOT_savegame (Writer *h) { +static void DOT_savegame (Stream *h) { int i, n; for (i = n = 0; i < MAXDOT; ++i) { if (dot[i].t) { @@ -68,7 +68,7 @@ static void DOT_savegame (Writer *h) { } } -static void DOT_loadgame (Reader *h) { +static void DOT_loadgame (Stream *h) { int i, n; n = stream_read32(h); for (i = 0; i < n; i++) { @@ -85,7 +85,7 @@ static void DOT_loadgame (Reader *h) { } } -static void FX_savegame (Writer *h) { +static void FX_savegame (Stream *h) { int i, n; for (i = n = 0; i < MAXFX; ++i) { if (fx[i].t) { @@ -105,7 +105,7 @@ static void FX_savegame (Writer *h) { } } -static void FX_loadgame (Reader *h) { +static void FX_loadgame (Stream *h) { int i, n; n = stream_read32(h); for (i = 0; i < n; i++) { @@ -118,7 +118,7 @@ static void FX_loadgame (Reader *h) { } } -static void G_savegame (Writer *h) { +static void G_savegame (Stream *h) { stream_write8(_2pl, h); stream_write8(g_dm, h); stream_write8(g_exit, h); @@ -138,7 +138,7 @@ static void G_savegame (Writer *h) { stream_write(g_music, 8, 1, h); } -static void G_loadgame (Reader *h) { +static void G_loadgame (Stream *h) { _2pl = stream_read8(h); g_dm = stream_read8(h); g_exit = stream_read8(h); @@ -159,7 +159,7 @@ static void G_loadgame (Reader *h) { MUS_load(g_music); } -static void IT_savegame (Writer *h) { +static void IT_savegame (Stream *h) { int i, n; for (n = MAXITEM - 1; n >= 0 && it[n].t == 0; n--) { // empty @@ -181,7 +181,7 @@ static void IT_savegame (Writer *h) { stream_write32(itm_rtime, h); } -static void IT_loadgame (Reader *h) { +static void IT_loadgame (Stream *h) { int i, n; n = stream_read32(h); for (i = 0; i < n; i++) { @@ -199,7 +199,7 @@ static void IT_loadgame (Reader *h) { itm_rtime = stream_read32(h); } -static void MN_savegame (Writer *h) { +static void MN_savegame (Stream *h) { int i, n; for (n = MAXMN - 1; n >= 0 && mn[n].t == 0; n--) { // empty @@ -235,7 +235,7 @@ static void MN_savegame (Writer *h) { stream_write32(gsndt, h); } -static void MN_loadgame (Reader *h) { +static void MN_loadgame (Stream *h) { int i, n, c; n = stream_read32(h); for (i = 0; i < n; i++) { @@ -274,7 +274,7 @@ static void MN_loadgame (Reader *h) { } } -static void PL_save_player (player_t *p, Writer *h) { +static void PL_save_player (player_t *p, Stream *h) { stream_write32(p->o.x, h); stream_write32(p->o.y, h); stream_write32(p->o.xv, h); @@ -318,7 +318,7 @@ static void PL_save_player (player_t *p, Writer *h) { // k* not saved } -static void PL_savegame (Writer *h) { +static void PL_savegame (Stream *h) { PL_save_player(&pl1, h); if (_2pl) { PL_save_player(&pl2, h); @@ -328,7 +328,7 @@ static void PL_savegame (Writer *h) { stream_write8(p_immortal, h); } -static void PL_load_player (player_t *p, Reader *h) { +static void PL_load_player (player_t *p, Stream *h) { p->o.x = stream_read32(h); p->o.y = stream_read32(h); p->o.xv = stream_read32(h); @@ -372,7 +372,7 @@ static void PL_load_player (player_t *p, Reader *h) { // k* not saved } -static void PL_loadgame (Reader *h) { +static void PL_loadgame (Stream *h) { PL_load_player(&pl1, h); if (_2pl) { PL_load_player(&pl2, h); @@ -382,7 +382,7 @@ static void PL_loadgame (Reader *h) { p_immortal = stream_read8(h); } -static void SMK_savegame (Writer *h) { +static void SMK_savegame (Stream *h) { int i, n; for (i = n = 0; i < MAXSMOK; ++i) { if (sm[i].t) { @@ -403,7 +403,7 @@ static void SMK_savegame (Writer *h) { } } -static void SMK_loadgame (Reader *h) { +static void SMK_loadgame (Stream *h) { int i, n; n = stream_read32(h); for (i = 0; i < n; ++i) { @@ -417,7 +417,7 @@ static void SMK_loadgame (Reader *h) { } } -static void SW_savegame (Writer *h) { +static void SW_savegame (Stream *h) { int i, n; for (n = MAXSW - 1; n >= 0 && sw[n].t == 0; n--) { // empty @@ -438,7 +438,7 @@ static void SW_savegame (Writer *h) { stream_write32(sw_secrets, h); } -static void SW_loadgame (Reader *h) { +static void SW_loadgame (Stream *h) { int i, n; n = stream_read32(h); for (i = 0; i < n; i++) { @@ -455,7 +455,7 @@ static void SW_loadgame (Reader *h) { sw_secrets = stream_read32(h); } -static void W_savegame (Writer* h) { +static void W_savegame (Stream* h) { char s[8]; int i; stream_write32(sky_type, h); @@ -474,7 +474,7 @@ static void W_savegame (Writer* h) { stream_write(fldf, FLDW*FLDH, 1, h); } -static void W_loadgame (Reader *h) { +static void W_loadgame (Stream *h) { int i; char s[8]; sky_type = stream_read32(h); @@ -498,7 +498,7 @@ static void W_loadgame (Reader *h) { stream_read(fldf, FLDW*FLDH, 1, h); } -static void WP_savegame (Writer *h) { +static void WP_savegame (Stream *h) { int i, n; for (n = MAXWPN - 1; n >= 0 && wp[n].t == 0; n--) { // empty @@ -521,7 +521,7 @@ static void WP_savegame (Writer *h) { } } -static void WP_loadgame (Reader *h) { +static void WP_loadgame (Stream *h) { int i, n; n = stream_read32(h); for (i = 0; i < n; i++) { @@ -559,7 +559,7 @@ static char *getsavfpname (int n, int ro) { return p; } -void SAVE_save (Writer *w, const char name[24]) { +void SAVE_save (Stream *w, const char name[24]) { assert(w != NULL); stream_write(name, 24, 1, w); // slot name stream_write16(3, w); // version @@ -576,17 +576,17 @@ void SAVE_save (Writer *w, const char name[24]) { } void F_savegame (int n, char *s) { - FILE_Writer wr; + FILE_Stream wr; char *p = getsavfpname(n, 0); - if (FILE_OpenWriter(&wr, p)) { + if (FILE_Open(&wr, p, "wb")) { SAVE_save(&wr.base, s); - FILE_CloseWriter(&wr); + FILE_Close(&wr); } } -void SAVE_load (Reader *h) { +void SAVE_load (Stream *h) { int16_t version; - h->setpos(h, 24); // skip name + stream_setpos(h, 24); // skip name version = stream_read16(h); if (version == 3) { G_loadgame(h); @@ -605,28 +605,28 @@ void SAVE_load (Reader *h) { void F_getsavnames (void) { int i; char *p; - FILE_Reader rd; + FILE_Stream rd; int16_t version; for (i = 0; i < 7; ++i) { p = getsavfpname(i, 1); memset(savname[i], 0, 24); savok[i] = 0; - if (FILE_OpenReader(&rd, p)) { + if (FILE_Open(&rd, p, "rb")) { version = -1; stream_read(savname[i], 24, 1, &rd.base); version = stream_read16(&rd.base); savname[i][23] = 0; savok[i] = version == 3; - FILE_CloseReader(&rd); + FILE_Close(&rd); } } } void F_loadgame (int n) { - FILE_Reader rd; + FILE_Stream rd; char *p = getsavfpname(n, 1); - if (FILE_OpenReader(&rd, p)) { + if (FILE_Open(&rd, p, "rb")) { SAVE_load(&rd.base); - FILE_CloseReader(&rd); + FILE_Close(&rd); } } diff --git a/src/save.h b/src/save.h index b3848ab..5f98bfe 100644 --- a/src/save.h +++ b/src/save.h @@ -30,7 +30,7 @@ void F_getsavnames (void); void F_savegame (int n, char *s); void F_loadgame (int n); -void SAVE_save (Writer *w, const char name[24]); -void SAVE_load (Reader *r); +void SAVE_save (Stream *w, const char name[24]); +void SAVE_load (Stream *r); #endif /* SAVE_H_INCLUDED */ -- 2.29.2