From 36e2bc95d385c79075495d96e066d697727449d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 11 May 2020 20:10:01 +0300 Subject: [PATCH] Fix Windows build and premake --- premake5.lua | 3 ++- src/save/GenericGameStorage.cpp | 1 + src/save/PCSave.cpp | 1 + src/skel/crossplatform.cpp | 5 +++++ src/skel/crossplatform.h | 4 ++-- src/skel/glfw/glfw.cpp | 2 +- src/skel/win/win.cpp | 16 ++++++++-------- 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/premake5.lua b/premake5.lua index dc16e31e..08ace524 100644 --- a/premake5.lua +++ b/premake5.lua @@ -90,7 +90,8 @@ workspace "re3" } debugdir (gamepath) if (exepath) then - debugcommand (gamepath .. exepath) + -- Used VS variable $(TargetFileName) because it doesn't accept premake tokens. Does debugcommand even work outside VS?? + debugcommand (gamepath .. "$(TargetFileName)") dir, file = exepath:match'(.*/)(.*)' debugdir (gamepath .. (dir or "")) end diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index d0cdb358..ba7bd216 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -1,3 +1,4 @@ +#define WITHWINDOWS #include "common.h" #include "crossplatform.h" #include "main.h" diff --git a/src/save/PCSave.cpp b/src/save/PCSave.cpp index 77d1ddce..3dc80f73 100644 --- a/src/save/PCSave.cpp +++ b/src/save/PCSave.cpp @@ -1,3 +1,4 @@ +#define WITHWINDOWS #include "common.h" #include "crossplatform.h" diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index 9971d2ae..40f4f053 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -1,6 +1,9 @@ #include "common.h" #include "crossplatform.h" +// Codes compatible with Windows and Linux +#ifndef _WIN32 + // For internal use // wMilliseconds is not needed void tmToSystemTime(const tm *tm, SYSTEMTIME *out) { @@ -18,6 +21,7 @@ void GetLocalTime_CP(SYSTEMTIME *out) { tm *localTm = localtime(×tamp); tmToSystemTime(localTm, out); } +#endif // Compatible with Linux/POSIX and MinGW on Windows #ifndef _WIN32 @@ -80,6 +84,7 @@ void FileTimeToSystemTime(time_t* writeTime, SYSTEMTIME* out) { } #endif +// Funcs/features from Windows that we need on other platforms #ifndef _WIN32 char *strupr(char *s) { char* tmp = s; diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h index f6a3408b..a21877c1 100644 --- a/src/skel/crossplatform.h +++ b/src/skel/crossplatform.h @@ -82,7 +82,7 @@ RwBool IsForegroundApp(); #endif // Codes compatible with Windows and Linux -#if !defined _WIN32 +#ifndef _WIN32 #define DeleteFile unlink // Needed for save games @@ -103,7 +103,7 @@ void GetLocalTime_CP(SYSTEMTIME* out); #endif // Compatible with Linux/POSIX and MinGW on Windows -#if !defined _WIN32 +#ifndef _WIN32 #include #include #include diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index b30bda7b..4a35adcf 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -66,7 +66,7 @@ static psGlobalType PsGlobal; #define JIF(x) if (FAILED(hr=(x))) \ {debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;} -long _dwMemAvailPhys; +unsigned long _dwMemAvailPhys; RwUInt32 gGameState; #ifdef _WIN32 diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index d20cc0bf..9a885818 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -100,10 +100,10 @@ IVideoWindow *pVW = nil; IMediaSeeking *pMS = nil; DWORD dwDXVersion; -DWORD _dwMemTotalPhys; -DWORD _dwMemAvailPhys; -DWORD _dwMemTotalVirtual; -DWORD _dwMemAvailVirtual; +SIZE_T _dwMemTotalPhys; +SIZE_T _dwMemAvailPhys; +SIZE_T _dwMemTotalVirtual; +SIZE_T _dwMemAvailVirtual; DWORD _dwMemTotalVideo; DWORD _dwMemAvailVideo; DWORD _dwOperatingSystemVersion; @@ -687,10 +687,10 @@ psInitialise(void) _GetVideoMemInfo(&_dwMemTotalVideo, &_dwMemAvailVideo); #ifdef FIX_BUGS - debug("Physical memory size %u\n", _dwMemTotalPhys); - debug("Available physical memory %u\n", _dwMemAvailPhys); - debug("Video memory size %u\n", _dwMemTotalVideo); - debug("Available video memory %u\n", _dwMemAvailVideo); + debug("Physical memory size %lu\n", _dwMemTotalPhys); + debug("Available physical memory %lu\n", _dwMemAvailPhys); + debug("Video memory size %lu\n", _dwMemTotalVideo); + debug("Available video memory %lu\n", _dwMemAvailVideo); #else debug("Physical memory size %d\n", _dwMemTotalPhys); debug("Available physical memory %d\n", _dwMemAvailPhys);