mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 09:55:34 -05:00
using std::array
This commit is contained in:
parent
e222313f22
commit
ba5c527b18
1 changed files with 11 additions and 6 deletions
|
@ -142,16 +142,21 @@ unsigned int gdTimestamp = 0;
|
|||
// 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--) {
|
||||
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';
|
||||
cwd[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetCurrentDirectoryW(cwd);
|
||||
if (i < 0) return;
|
||||
|
||||
SetCurrentDirectoryW(cwd.data());
|
||||
}
|
||||
|
||||
int WINAPI gdMainHook(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) {
|
||||
|
|
Loading…
Reference in a new issue