This commit is contained in:
IliasHDZ 2024-08-21 14:31:32 +05:00 committed by GitHub
commit f8a12ae8e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -138,11 +138,29 @@ void* mainTrampolineAddr;
#include "gdTimestampMap.hpp"
unsigned int gdTimestamp = 0;
// In case the game is launched from a different directory through command line
// this function will set the current working directory to the game's directory
// to avoid the game crashing due to not being able to find the resources
static void fixCWD() {
WCHAR cwd[MAX_PATH];
DWORD size = GetModuleFileNameW(NULL, cwd, sizeof(cwd));
if (size == sizeof(cwd)) return;
for (int i = size - 1; i >= 0; i--) {
if (cwd[i] == '\\') {
cwd[i] = '\0';
break;
}
}
SetCurrentDirectoryW(cwd);
}
int WINAPI gdMainHook(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) {
// MessageBoxA(NULL, "Hello from gdMainHook!", "Hi", 0);
updateGeode();
fixCWD();
if (versionToTimestamp(GEODE_STR(GEODE_GD_VERSION)) > gdTimestamp) {
console::messageBox(
"Unable to Load Geode!",