mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-22 19:19:59 +00:00
fixed CFileMgr somewhat; still issues when loading saves
This commit is contained in:
parent
9703ef9b59
commit
3472a614ae
|
@ -23,7 +23,7 @@ CDirectory::ReadDirFile(const char *filename)
|
|||
fd = CFileMgr::OpenFile(filename, "rb");
|
||||
while(CFileMgr::Read(fd, (char*)&dirinfo, sizeof(dirinfo)))
|
||||
AddItem(dirinfo);
|
||||
return CFileMgr::CloseFile(fd);
|
||||
CFileMgr::CloseFile(fd);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "patcher.h"
|
||||
#include "FileMgr.h"
|
||||
|
||||
const char *_psGetUserFilesFolder();
|
||||
|
||||
/*
|
||||
* Windows FILE is BROKEN for GTA.
|
||||
*
|
||||
|
@ -49,14 +51,17 @@ found:
|
|||
return fd;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
myfclose(int fd)
|
||||
{
|
||||
int ret;
|
||||
assert(fd < NUMFILES);
|
||||
if(myfiles[fd].file){
|
||||
fclose(myfiles[fd].file);
|
||||
ret = fclose(myfiles[fd].file);
|
||||
myfiles[fd].file = nil;
|
||||
return ret;
|
||||
}
|
||||
return EOF;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -158,7 +163,8 @@ myfseek(int fd, long offset, int whence)
|
|||
static int
|
||||
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)
|
||||
{
|
||||
SetDir(""); // better start at the root if user directory is relative
|
||||
chdir(GetUserDirectory());
|
||||
chdir(_psGetUserFilesFolder());
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -265,10 +271,10 @@ CFileMgr::ReadLine(int fd, char *buf, int len)
|
|||
return myfgets(buf, len, fd);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
CFileMgr::CloseFile(int fd)
|
||||
{
|
||||
myfclose(fd);
|
||||
return myfclose(fd);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -16,6 +16,6 @@ public:
|
|||
static int Write(int fd, char *buf, int len);
|
||||
static bool Seek(int fd, int offset, int whence);
|
||||
static char *ReadLine(int fd, char *buf, int len);
|
||||
static void CloseFile(int fd);
|
||||
static int CloseFile(int fd);
|
||||
static int GetErrorReadWrite(int fd);
|
||||
};
|
||||
|
|
|
@ -72,8 +72,6 @@ extern void **rwengine;
|
|||
#define SCREEN_FROM_RIGHT(a) Float(SCREEN_WIDTH - SCREEN_STRETCH_X(a))
|
||||
#define SCREEN_FROM_BOTTOM(a) Float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a))
|
||||
|
||||
char *GetUserDirectory(void);
|
||||
|
||||
struct GlobalScene
|
||||
{
|
||||
RpWorld *world;
|
||||
|
|
|
@ -65,3 +65,4 @@ enum Config {
|
|||
//#define FIX_BUGS
|
||||
//#define NO_CDCHECK
|
||||
#define NO_MOVIES
|
||||
//#define USE_MY_DOCUMENTS
|
||||
|
|
11
src/re3.cpp
11
src/re3.cpp
|
@ -47,17 +47,6 @@ mysrand(unsigned int 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(const char *path, const char *mode)
|
||||
|
|
|
@ -191,6 +191,7 @@ void _psCreateFolder(LPCSTR path)
|
|||
*/
|
||||
const char *_psGetUserFilesFolder()
|
||||
{
|
||||
#ifdef USE_MY_DOCUMENTS
|
||||
HKEY hKey = NULL;
|
||||
|
||||
static CHAR szUserFiles[256];
|
||||
|
@ -221,6 +222,12 @@ const char *_psGetUserFilesFolder()
|
|||
|
||||
strcpy(szUserFiles, "data");
|
||||
return szUserFiles;
|
||||
#else
|
||||
static CHAR szUserFiles[256];
|
||||
strcpy(szUserFiles, "userfiles");
|
||||
_psCreateFolder(szUserFiles);
|
||||
return szUserFiles;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue