DEADSOFTWARE

cp866: move to common/
[flatwaifu.git] / src / files.c
index 704ca271b9f3c40f6fae889dec624f7ad6533f64..8189375ee5814b9cba20e68889608cbfdaa85b90 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <assert.h>
-#ifdef UNIX
-#  include <sys/stat.h>
-#endif
 #include "files.h"
-#include "map.h"
-#include "my.h"
-#include "game.h"
-#include "view.h"
-#include "dots.h"
-#include "smoke.h"
-#include "fx.h"
-#include "items.h"
-#include "monster.h"
-#include "player.h"
-#include "switch.h"
-#include "weapons.h"
 #include "error.h"
-#include "cp866.h"
+
+#include "map.h" // MAP_load
 
 #include "common/streams.h"
 #include "common/files.h"
 #include "common/wadres.h"
+#include "common/cp866.h"
 
 int d_start, d_end;
 static int m_start, m_end;
@@ -53,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 {
@@ -159,29 +146,12 @@ void F_randmus (char *s) {
   }
 }
 
-// reads bytes from file until CR
-void F_readstr (FILE* h, char *s, int m) {
-  int i = 0;
-  size_t len = 0;
-  static char c = 0;
-  while (i < m) {
-    c = 13;
-    len = myfreadc(&c, 1, 1, h);
-    if (len == 0 || c == 13 || c == 10) {
-      break;
-    }
-    s[i] = c;
-    i++;
-  }
-  s[i] = 0;
-}
-
 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");
     }