X-Git-Url: https://deadsoftware.ru/gitweb?p=flatwaifu.git;a=blobdiff_plain;f=src%2Ffiles.c;h=f8543ff7924cc5189353f19828c5386d81320b07;hp=597d149f4cbad222c65e64b1f0e5dcdfc9d12d59;hb=efb17348438f10c929e2e9807013969f71802661;hpb=2bb81ea2565c3627c954b5c37326db89b0048472 diff --git a/src/files.c b/src/files.c index 597d149..f8543ff 100644 --- a/src/files.c +++ b/src/files.c @@ -39,16 +39,16 @@ #include "switch.h" #include "weapons.h" #include "error.h" +#include "cp866.h" typedef struct { byte n, i, v, d; } dmv; int d_start, d_end; -byte savname[7][24]; -byte savok[7]; mwad_t wad[MAX_WAD]; -map_block_t blk; +char wads[MAX_WADS][__MAX_PATH]; +FILE* wadh[MAX_WADS]; static byte seq[255]; static byte seqn; @@ -61,9 +61,6 @@ static int m_start, m_end; static int s_start, s_end; static int wad_num; -static char wads[MAX_WADS][__MAX_PATH]; -static FILE* wadh[MAX_WADS]; - static char f_drive[__MAX_DRIVE]; static char f_dir[__MAX_DIR]; static char f_name[__MAX_FNAME]; @@ -74,88 +71,7 @@ void F_startup (void) { memset(wads,0,sizeof(wads)); } -static char *getsavfpname (int n, int ro) { - static char fn[]="savgame0.dat"; - fn[7]=n+'0'; -#ifndef WIN32 - static char p[100]; - char *e = getenv("HOME"); - strncpy(p,e,60); - strcat(p,"/.doom2d-rembo"); - if (!ro) mkdir(p, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - strcat(p,"/"); - strcat(p,fn); -#else - strcpy(p,fn); -#endif - return p; -} - -void F_getsavnames (void) { - int i; - FILE *h; - short ver; - char *p; - for (i = 0; i < 7; ++i) { - p = getsavfpname(i, 1); - memset(savname[i], 0, 24); - savok[i] = 0; - h = fopen(p, "rb"); - if (h != NULL) { - ver = -1; - myfread(savname[i], 24, 1, h); - ver = myfread16(h); - savname[i][23] = 0; - savok[i] = (ver == 3) ? 1 : 0; - fclose(h); - } - } -} - -void F_savegame (int n, char *s) { - char *p = getsavfpname(n, 0); - FILE *h = fopen(p, "wb"); - if (h != NULL) { - myfwrite(s, 24, 1, h); // slot name - myfwrite16(3, h); // version - G_savegame(h); - W_savegame(h); - DOT_savegame(h); - SMK_savegame(h); - FX_savegame(h); - IT_savegame(h); - MN_savegame(h); - PL_savegame(h); - SW_savegame(h); - WP_savegame(h); - fclose(h); - } -} - -void F_loadgame (int n) { - short ver; - char *p = getsavfpname(n, 1); - FILE *h = fopen(p, "rb"); - if (h != NULL) { - fseek(h, 24, SEEK_SET); // skip name - ver = myfread16(h); // version - if (ver == 3) { - G_loadgame(h); - W_loadgame(h); - DOT_loadgame(h); - SMK_loadgame(h); - FX_loadgame(h); - IT_loadgame(h); - MN_loadgame(h); - PL_loadgame(h); - SW_loadgame(h); - WP_loadgame(h); - } - fclose(h); - } -} - -void F_addwad (char *fn) { +void F_addwad (const char *fn) { int i; for(i=0;i=m_end) i=m_start+1; - if (strcasecmp(wad[i].n,"MENU") == 0 || - strcasecmp(wad[i].n,"INTERMUS") == 0 || - strcasecmp(wad[i].n,"\x8a\x8e\x8d\x85\x96\x0") == 0) + if (cp866_strcasecmp(wad[i].n,"MENU") == 0 || + cp866_strcasecmp(wad[i].n,"INTERMUS") == 0 || + cp866_strcasecmp(wad[i].n,"\x8a\x8e\x8d\x85\x96\x0") == 0) continue; - if(strncasecmp(wad[i].n,"DMI",3)!=0) break; + if(cp866_strncasecmp(wad[i].n,"DMI",3)!=0) break; } memcpy(s,wad[i].n,8); } @@ -434,44 +353,6 @@ void F_readstrz (FILE* h,char *s,int m) { } */ -void F_loadmap (char n[8]) { - int r, o; - FILE *h; - map_header_t hdr; - W_init(); - r = F_getresid(n); - h = wadh[wad[r].f]; - fseek(h, wad[r].o, SEEK_SET); - myfread(hdr.id, 8, 1, h); - hdr.ver = myfread16(h); - if (memcmp(hdr.id, "Doom2D\x1A", 8) != 0) { - ERR_fatal("%.8s не является уровнем", n); - } - for(;;) { - blk.t = myfread16(h); - blk.st = myfread16(h); - blk.sz = myfread32(h); - if(blk.t == MB_END) { - break; - } - if(blk.t == MB_COMMENT) { - fseek(h, blk.sz, SEEK_CUR); - continue; - } - o = ftell(h) + blk.sz; - if(!G_load(h)) { - if(!W_load(h)) { - if(!IT_load(h)) { - if(!SW_load(h)) { - ERR_fatal("Неизвестный блок %d(%d) в уровне %.8s", blk.t, blk.st, n); - } - } - } - } - fseek(h, o, SEEK_SET); - } -} - /*void F_freemus(void) { int i;