X-Git-Url: https://deadsoftware.ru/gitweb?p=flatwaifu.git;a=blobdiff_plain;f=src%2Ffiles.c;h=d78389ff4da1ea5d7038d5eb93ace9be11695d39;hp=1b470913c6c4aaf56958889ddfe5c55f43dc730e;hb=ef16dea09f87b15fc6d58fae0aa0832e0648c00e;hpb=02f89a09888d2aab62c7bd92b8d3ac33fcd0c0ab diff --git a/src/files.c b/src/files.c index 1b47091..d78389f 100644 --- a/src/files.c +++ b/src/files.c @@ -1,24 +1,19 @@ -/* - Copyright (C) Prikol Software 1996-1997 - Copyright (C) Aleksey Volynskov 1996-1997 - Copyright (C) 2011 - - This file is part of the Doom2D:Rembo project. - - Doom2D:Rembo is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - Doom2D:Rembo is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see or - write to the Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ +/* Copyright (C) 1996-1997 Aleksey Volynskov + * Copyright (C) 2011 Rambo + * Copyright (C) 2020 SovietPony + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "glob.h" #include @@ -46,10 +41,9 @@ typedef struct { } 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; @@ -62,9 +56,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]; @@ -75,87 +66,6 @@ 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 (const char *fn) { int i; @@ -351,21 +261,24 @@ void F_getresname (char n[8], int r) { } // get sprite id -int F_getsprid (const char n[4], int s, int d) { +int F_getsprid (const char n[4], int s, int d, char *dir) { int i; - byte a,b; - - s+='A';d+='0'; - for(i=s_start+1;i