X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Ffiles.c;h=220d72cd254e4e9957ef83d5ff325aad2c4b4a83;hb=82abbc606cc5e3d9c26e2ab6d36e093ed86ae1bf;hp=ab39a62c3909ca93a753929c157fa3eb9c6739f4;hpb=0cf993564c26d9f509ca437cca61f18a1b74b014;p=flatwaifu.git diff --git a/src/files.c b/src/files.c index ab39a62..220d72c 100644 --- a/src/files.c +++ b/src/files.c @@ -22,24 +22,16 @@ #include "glob.h" #include -//#include -#include -//#include #include #include -//#include -#include "vga.h" +#include #include "error.h" -#include "sound.h" -//#include "snddrv.h" -#include "memory.h" #include "view.h" #include "items.h" #include "switch.h" #include "files.h" #include "map.h" - char *S_getinfo(void); extern void *snd_drv; @@ -93,15 +85,34 @@ void F_startup(void) { memset(wads,0,sizeof(wads)); } +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; - static char n[]="SAVGAME0.DAT"; short ver; + char *p; for(i=0;i<7;++i) { - n[7]=i+'0';memset(savname[i],0,24);savok[i]=0; - if((h=fopen(n,"rb"))==NULL) continue; //if((h=open(n,O_RDONLY|O_BINARY))==-1) continue; + p = getsavfpname(i,1); + memset(savname[i],0,24);savok[i]=0; + if((h=fopen(p,"rb"))==NULL) continue; //if((h=open(n,O_RDONLY|O_BINARY))==-1) continue; myfread(savname[i],1,24,h);ver=-1;myfread(&ver,1,2,h); fclose(h);savname[i][23]=0;savok[i]=(ver==3)?1:0;//savok[i]=(ver==2)?1:0; } @@ -110,10 +121,9 @@ void F_getsavnames(void) { void F_savegame(int n,char *s) { FILE* h; - static char fn[]="SAVGAME0.DAT"; - - fn[7]=n+'0'; - if((h=fopen(fn,"wb"))==NULL) return; + char *p; + p=getsavfpname(n,0); + if((h=fopen(p,"wb"))==NULL) return; myfwrite(s,1,24,h);myfwrite("\3\0",1,2,h);//myfwrite("\2\0",1,2,h); G_savegame(h); W_savegame(h); @@ -126,16 +136,15 @@ void F_savegame(int n,char *s) { SW_savegame(h); WP_savegame(h); fclose(h); - } void F_loadgame(int n) { FILE* h; - static char fn[]="SAVGAME0.DAT"; short ver; - - fn[7]=n+'0'; - if((h=fopen(fn,"rb"))==NULL) return;//if((h=open(fn,O_BINARY|O_RDONLY))==-1) return; + char *p; + p=getsavfpname(n,1); + + if((h=fopen(p,"rb"))==NULL) return;//if((h=open(fn,O_BINARY|O_RDONLY))==-1) return; fseek(h,24,SEEK_SET);myfread(&ver,1,2,h);if(ver!=3) return;//if(ver!=2) return; G_loadgame(h); W_loadgame(h);