mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 11:17:08 -05:00
Merge ba5c527b18
into adfc942fa0
This commit is contained in:
commit
3b22591997
1 changed files with 23 additions and 0 deletions
|
@ -138,11 +138,34 @@ 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() {
|
||||
std::array<WCHAR, MAX_PATH> cwd;
|
||||
|
||||
DWORD size = GetModuleFileNameW(NULL, cwd.data(), cwd.size());
|
||||
if (size == cwd.size()) return;
|
||||
|
||||
int i;
|
||||
for (i = (int)size - 1; i >= 0; i--) {
|
||||
if (cwd[i] == '\\') {
|
||||
cwd[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < 0) return;
|
||||
|
||||
SetCurrentDirectoryW(cwd.data());
|
||||
}
|
||||
|
||||
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!",
|
||||
|
|
Loading…
Reference in a new issue