X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fmap.c;h=d09022738cc1b2dc8dfcb4e076acec08581e885e;hb=HEAD;hp=1bdb4d3c145c643f19ac9ca207b9012c6fe95230;hpb=6b61ca69e4085875215d30ef75df7703edb0ddd2;p=flatwaifu.git diff --git a/src/map.c b/src/map.c index 1bdb4d3..d70a4fb 100644 --- a/src/map.c +++ b/src/map.c @@ -25,18 +25,15 @@ #include "view.h" #include "music.h" -#include "files.h" #include "render.h" -#include #include #include -#include "my.h" #include "error.h" -#include "cp866.h" #include "common/streams.h" #include "common/files.h" +#include "common/cp866.h" enum { MB_COMMENT = -1, MB_END = 0, @@ -65,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); @@ -78,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) { @@ -174,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: @@ -220,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: @@ -242,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) { @@ -273,10 +270,11 @@ static int W_load (Reader *h) { return 0; } -int MAP_load (Reader *r) { - assert(r != NULL); +int MAP_load (Stream *r) { int ok = 0; + long off; map_header_t hdr; + assert(r != NULL); W_init(); // reset all game data stream_read(hdr.id, 8, 1, r); hdr.ver = stream_read16(r); @@ -286,7 +284,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; + off = stream_getpos(r) + blk.sz; switch (blk.t) { case MB_MUSIC: ok = G_load(r); @@ -313,22 +311,12 @@ 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"); + abort(); ok = 0; } return ok; } - -void F_loadmap (char n[8]) { - FILE_Reader rd; - int r = F_getresid(n); - FILE *h = wadh[wad[r].f]; - fseek(h, wad[r].o, SEEK_SET); - FILE_AssignReader(&rd, h); - if (!MAP_load(&rd.base)) { - ERR_fatal("Failed to load map"); - } -}