This repository has been archived by the owner. It is now read-only.
Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
268 additions
and 4,811 deletions.
- +98 −4,787 milessdk/include/mss.h
- BIN milessdk/lib/mss32.lib
- +1 −2 src/animation/CutsceneMgr.cpp
- +0 −1 src/control/Script.cpp
- +1 −1 src/core/CdStream.cpp
- +0 −2 src/core/Game.cpp
- +1 −1 src/core/Timer.cpp
- +1 −1 src/core/re3.cpp
- +0 −3 src/rw/TexRead.cpp
- +2 −1 src/save/GenericGameStorage.cpp
- +5 −4 src/save/PCSave.cpp
- +81 −0 src/skel/crossplatform.cpp
- +65 −0 src/skel/crossplatform.h
- +0 −6 src/skel/events.cpp
- +2 −2 src/skel/win/win.cpp
- +11 −0 src/skel/win/win.h
There are no files selected for viewing
Binary file not shown.
| @@ -0,0 +1,81 @@ | |||
| #include "common.h" | |||
| #define USEALTERNATIVEWINFUNCS | |||
| #include "crossplatform.h" | |||
|
|
|||
| // For internal use | |||
| // wMilliseconds is not needed | |||
| void tmToSystemTime(const tm *tm, SYSTEMTIME *out) { | |||
| out->wYear = tm->tm_year + 1900; | |||
| out->wMonth = tm->tm_mon + 1; | |||
| out->wDayOfWeek = tm->tm_wday; | |||
| out->wDay = tm->tm_mday; | |||
| out->wHour = tm->tm_hour; | |||
| out->wMinute = tm->tm_min; | |||
| out->wSecond = tm->tm_sec; | |||
| } | |||
|
|
|||
| void GetLocalTime_CP(SYSTEMTIME *out) { | |||
| time_t timestamp = time(nil); | |||
| tm *localTm = localtime(×tamp); | |||
| tmToSystemTime(localTm, out); | |||
| } | |||
|
|
|||
| #if !defined _WIN32 || defined __MINGW32__ | |||
| HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) { | |||
| char newpathname[32]; | |||
| strncpy(newpathname, pathname, 32); | |||
| char* path = strtok(newpathname, "\\*"); | |||
| strncpy(firstfile->folder, path, sizeof(firstfile->folder)); | |||
|
|
|||
| // Both w/ extension and w/o extension is ok | |||
| if (strlen(path) + 2 != strlen(pathname)) | |||
| strncpy(firstfile->extension, strtok(NULL, "\\*"), sizeof(firstfile->extension)); | |||
| else | |||
| strncpy(firstfile->extension, "", sizeof(firstfile->extension)); | |||
|
|
|||
| HANDLE d; | |||
| if ((d = opendir(path)) == NULL || !FindNextFile(d, firstfile)) | |||
| return NULL; | |||
|
|
|||
| return d; | |||
| } | |||
|
|
|||
| bool FindNextFile(HANDLE d, WIN32_FIND_DATA* finddata) { | |||
| dirent *file; | |||
| static struct stat fileStats; | |||
| static char path[PATH_MAX], relativepath[NAME_MAX + sizeof(finddata->folder) + 1]; | |||
| int extensionLen = strlen(finddata->extension); | |||
| while ((file = readdir(d)) != NULL) { | |||
|
|
|||
| // We only want "DT_REG"ular Files, but reportedly some FS and OSes gives DT_UNKNOWN as type. | |||
| if ((file->d_type == DT_UNKNOWN || file->d_type == DT_REG) && | |||
| (extensionLen == 0 || strncmp(&file->d_name[strlen(file->d_name) - extensionLen], finddata->extension, extensionLen) == 0)) { | |||
|
|
|||
| sprintf(relativepath, "%s/%s", finddata->folder, file->d_name); | |||
| realpath(relativepath, path); | |||
| stat(path, &fileStats); | |||
| strncpy(finddata->cFileName, file->d_name, sizeof(finddata->cFileName)); | |||
| finddata->ftLastWriteTime = fileStats.st_mtime; | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
|
|
|||
| void GetDateFormat(int unused1, int unused2, SYSTEMTIME* in, int unused3, char* out, int size) { | |||
| tm linuxTime; | |||
| linuxTime.tm_year = in->wYear - 1900; | |||
| linuxTime.tm_mon = in->wMonth - 1; | |||
| linuxTime.tm_wday = in->wDayOfWeek; | |||
| linuxTime.tm_mday = in->wDay; | |||
| linuxTime.tm_hour = in->wHour; | |||
| linuxTime.tm_min = in->wMinute; | |||
| linuxTime.tm_sec = in->wSecond; | |||
| strftime(out, size, nl_langinfo(D_FMT), &linuxTime); | |||
| } | |||
|
|
|||
| void FileTimeToSystemTime(time_t* writeTime, SYSTEMTIME* out) { | |||
| tm *ptm = gmtime(writeTime); | |||
| tmToSystemTime(ptm, out); | |||
| } | |||
| #endif | |||
| @@ -0,0 +1,65 @@ | |||
| #include <time.h> | |||
|
|
|||
| #ifndef MAX_PATH | |||
| #if !defined _WIN32 || defined __MINGW32__ | |||
| #define MAX_PATH PATH_MAX | |||
| #else | |||
| #define MAX_PATH 260 | |||
| #endif | |||
| #endif | |||
|
|
|||
| // Mostly wrappers around Windows functions | |||
|
|
|||
| // TODO: Remove USEALTERNATIVEWINFUNCS and don't use it anywhere when re3 becomes fully cross-platform, this is for testing | |||
| // Codes compatible with Windows and Linux | |||
| #if defined USEALTERNATIVEWINFUNCS || !defined _WIN32 || defined __MINGW32__ | |||
| #define DeleteFile unlink | |||
|
|
|||
| // Needed for save games | |||
| struct SYSTEMTIME { | |||
| uint16 wYear; | |||
| uint16 wMonth; | |||
| uint16 wDayOfWeek; | |||
| uint16 wDay; | |||
| uint16 wHour; | |||
| uint16 wMinute; | |||
| uint16 wSecond; | |||
| uint16 wMilliseconds; | |||
| }; | |||
|
|
|||
| #define GetLocalTime GetLocalTime_CP | |||
| #else | |||
| #include <Windows.h> | |||
| #endif | |||
|
|
|||
| void GetLocalTime_CP(SYSTEMTIME* out); | |||
|
|
|||
|
|
|||
| // Only runs on GNU/POSIX/etc. | |||
| #if !defined _WIN32 || defined __MINGW32__ | |||
| #define OutputDebugString(s) re3_debug("[DBG-2]: " s "\n") | |||
|
|
|||
| #include <iostream> | |||
| #include <dirent.h> | |||
| #include <sys/types.h> | |||
| #include <sys/stat.h> | |||
| #include <langinfo.h> | |||
|
|
|||
| typedef DIR* HANDLE; | |||
| #define INVALID_HANDLE_VALUE NULL | |||
| #define FindClose closedir | |||
| #define LOCALE_USER_DEFAULT 0 | |||
| #define DATE_SHORTDATE 0 | |||
|
|
|||
| struct WIN32_FIND_DATA { | |||
| char extension[32]; // for searching | |||
| char folder[32]; // for searching | |||
| char cFileName[256]; // because tSkinInfo has it 256 | |||
| time_t ftLastWriteTime; | |||
| }; | |||
|
|
|||
| HANDLE FindFirstFile(char*, WIN32_FIND_DATA*); | |||
| bool FindNextFile(HANDLE, WIN32_FIND_DATA*); | |||
| void FileTimeToSystemTime(time_t*, SYSTEMTIME*); | |||
| void GetDateFormat(int, int, SYSTEMTIME*, int, char*, int); | |||
| #endif | |||