1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 00:40:00 +00:00

fixed CFileMgr somewhat; still issues when loading saves

This commit is contained in:
aap 2019-06-13 01:12:37 +02:00
parent 9703ef9b59
commit 3472a614ae
7 changed files with 22 additions and 21 deletions

View file

@ -23,7 +23,7 @@ CDirectory::ReadDirFile(const char *filename)
fd = CFileMgr::OpenFile(filename, "rb"); fd = CFileMgr::OpenFile(filename, "rb");
while(CFileMgr::Read(fd, (char*)&dirinfo, sizeof(dirinfo))) while(CFileMgr::Read(fd, (char*)&dirinfo, sizeof(dirinfo)))
AddItem(dirinfo); AddItem(dirinfo);
return CFileMgr::CloseFile(fd); CFileMgr::CloseFile(fd);
} }
bool bool

View file

@ -5,6 +5,8 @@
#include "patcher.h" #include "patcher.h"
#include "FileMgr.h" #include "FileMgr.h"
const char *_psGetUserFilesFolder();
/* /*
* Windows FILE is BROKEN for GTA. * Windows FILE is BROKEN for GTA.
* *
@ -49,14 +51,17 @@ found:
return fd; return fd;
} }
static void static int
myfclose(int fd) myfclose(int fd)
{ {
int ret;
assert(fd < NUMFILES); assert(fd < NUMFILES);
if(myfiles[fd].file){ if(myfiles[fd].file){
fclose(myfiles[fd].file); ret = fclose(myfiles[fd].file);
myfiles[fd].file = nil; myfiles[fd].file = nil;
return ret;
} }
return EOF;
} }
static int static int
@ -158,7 +163,8 @@ myfseek(int fd, long offset, int whence)
static int static int
myfeof(int fd) myfeof(int fd)
{ {
return feof(myfiles[fd].file); // return feof(myfiles[fd].file);
return ferror(myfiles[fd].file);
} }
@ -205,7 +211,7 @@ void
CFileMgr::SetDirMyDocuments(void) CFileMgr::SetDirMyDocuments(void)
{ {
SetDir(""); // better start at the root if user directory is relative SetDir(""); // better start at the root if user directory is relative
chdir(GetUserDirectory()); chdir(_psGetUserFilesFolder());
} }
int int
@ -265,10 +271,10 @@ CFileMgr::ReadLine(int fd, char *buf, int len)
return myfgets(buf, len, fd); return myfgets(buf, len, fd);
} }
void int
CFileMgr::CloseFile(int fd) CFileMgr::CloseFile(int fd)
{ {
myfclose(fd); return myfclose(fd);
} }
int int

View file

@ -16,6 +16,6 @@ public:
static int Write(int fd, char *buf, int len); static int Write(int fd, char *buf, int len);
static bool Seek(int fd, int offset, int whence); static bool Seek(int fd, int offset, int whence);
static char *ReadLine(int fd, char *buf, int len); static char *ReadLine(int fd, char *buf, int len);
static void CloseFile(int fd); static int CloseFile(int fd);
static int GetErrorReadWrite(int fd); static int GetErrorReadWrite(int fd);
}; };

View file

@ -72,8 +72,6 @@ extern void **rwengine;
#define SCREEN_FROM_RIGHT(a) Float(SCREEN_WIDTH - SCREEN_STRETCH_X(a)) #define SCREEN_FROM_RIGHT(a) Float(SCREEN_WIDTH - SCREEN_STRETCH_X(a))
#define SCREEN_FROM_BOTTOM(a) Float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a)) #define SCREEN_FROM_BOTTOM(a) Float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a))
char *GetUserDirectory(void);
struct GlobalScene struct GlobalScene
{ {
RpWorld *world; RpWorld *world;

View file

@ -65,3 +65,4 @@ enum Config {
//#define FIX_BUGS //#define FIX_BUGS
//#define NO_CDCHECK //#define NO_CDCHECK
#define NO_MOVIES #define NO_MOVIES
//#define USE_MY_DOCUMENTS

View file

@ -47,17 +47,6 @@ mysrand(unsigned int seed)
myrand_seed = seed; myrand_seed = seed;
} }
// platform stuff
char*
GetUserDirectory(void)
{
static char path[MAX_PATH];
strcpy(path, "userfiles");
mkdir(path);
return path;
}
int (*open_script_orig)(const char *path, const char *mode); int (*open_script_orig)(const char *path, const char *mode);
int int
open_script(const char *path, const char *mode) open_script(const char *path, const char *mode)

View file

@ -191,6 +191,7 @@ void _psCreateFolder(LPCSTR path)
*/ */
const char *_psGetUserFilesFolder() const char *_psGetUserFilesFolder()
{ {
#ifdef USE_MY_DOCUMENTS
HKEY hKey = NULL; HKEY hKey = NULL;
static CHAR szUserFiles[256]; static CHAR szUserFiles[256];
@ -221,6 +222,12 @@ const char *_psGetUserFilesFolder()
strcpy(szUserFiles, "data"); strcpy(szUserFiles, "data");
return szUserFiles; return szUserFiles;
#else
static CHAR szUserFiles[256];
strcpy(szUserFiles, "userfiles");
_psCreateFolder(szUserFiles);
return szUserFiles;
#endif
} }
/* /*