summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-06-13 01:12:37 +0200
committeraap <aap@papnet.eu>2019-06-13 01:12:37 +0200
commit3472a614ae3b4ecf7f49516a97d387761f0f5820 (patch)
tree27f6bd454211d0ea8c88b34915ee22ef7e9c05a0
parentimplemented CutsceneObject; little fixes (diff)
downloadre3-3472a614ae3b4ecf7f49516a97d387761f0f5820.tar
re3-3472a614ae3b4ecf7f49516a97d387761f0f5820.tar.gz
re3-3472a614ae3b4ecf7f49516a97d387761f0f5820.tar.bz2
re3-3472a614ae3b4ecf7f49516a97d387761f0f5820.tar.lz
re3-3472a614ae3b4ecf7f49516a97d387761f0f5820.tar.xz
re3-3472a614ae3b4ecf7f49516a97d387761f0f5820.tar.zst
re3-3472a614ae3b4ecf7f49516a97d387761f0f5820.zip
Diffstat (limited to '')
-rw-r--r--src/Directory.cpp2
-rw-r--r--src/FileMgr.cpp18
-rw-r--r--src/FileMgr.h2
-rw-r--r--src/common.h2
-rw-r--r--src/config.h1
-rw-r--r--src/re3.cpp11
-rw-r--r--src/skel/win/win.cpp7
7 files changed, 22 insertions, 21 deletions
diff --git a/src/Directory.cpp b/src/Directory.cpp
index 553dd539..3e0d5382 100644
--- a/src/Directory.cpp
+++ b/src/Directory.cpp
@@ -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
diff --git a/src/FileMgr.cpp b/src/FileMgr.cpp
index 3aad9794..02c797ba 100644
--- a/src/FileMgr.cpp
+++ b/src/FileMgr.cpp
@@ -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
diff --git a/src/FileMgr.h b/src/FileMgr.h
index a77ae6fa..f67056f1 100644
--- a/src/FileMgr.h
+++ b/src/FileMgr.h
@@ -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);
};
diff --git a/src/common.h b/src/common.h
index e110e67f..4187e0c3 100644
--- a/src/common.h
+++ b/src/common.h
@@ -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;
diff --git a/src/config.h b/src/config.h
index 8ef51871..71689778 100644
--- a/src/config.h
+++ b/src/config.h
@@ -65,3 +65,4 @@ enum Config {
//#define FIX_BUGS
//#define NO_CDCHECK
#define NO_MOVIES
+//#define USE_MY_DOCUMENTS
diff --git a/src/re3.cpp b/src/re3.cpp
index 55ce5699..905aa992 100644
--- a/src/re3.cpp
+++ b/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)
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index c26855eb..3ca4aa5d 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -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
}
/*