Skip to content

Commit 83b4e37

Browse files
Fixed non-launcher game execution and timing
1 parent 72d4038 commit 83b4e37

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

Changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
* 00a1dda (HEAD -> master, tag: v1.05b, origin/master) Add our Changelog.md output to our project build package
1+
* 72d4038 (HEAD -> master, tag: v1.05b, origin/master) Push git log output into Changelog.md before builds
2+
* 00a1dda Add our Changelog.md output to our project build package
23
* a735a80 Make INI loading smarter when using old configs
34
* 386d3e0 Refactoring of code base and more tuneables Major code cleanup, user tuneable wait times, loosened search timing of launcher process, launcher process is now optional, and pre-launcher event support in URI mode.
45
* ce19cde Remove duplicated README and replace with a file link

OriginSteamOverlayLauncher/Program.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ private static void ProcessLauncher(Settings setHnd)
386386

387387
launcherProc.StartInfo.UseShellExecute = true;
388388
launcherProc.StartInfo.FileName = setHnd.LauncherPath;
389+
launcherProc.StartInfo.WorkingDirectory = Directory.GetParent(setHnd.LauncherPath).ToString();
389390
launcherProc.StartInfo.Arguments = setHnd.LauncherArgs;
390391
Logger("OSOL", "Attempting to start the launcher, cmd: " + setHnd.LauncherPath);
391392
launcherProc.Start();
@@ -423,11 +424,11 @@ private static void ProcessLauncher(Settings setHnd)
423424
Logger("FATAL", "Cannot find main window handle of launcher process at PID [" + launcherProc.Id + "], perhaps the wrong launcher exe?");
424425
return;
425426
}
426-
}// skip over the launcher if we're only launching a game path
427427

428-
// force the launcher window to activate before the game to avoid BPM hooking issues
429-
Thread.Sleep(setHnd.PreGameOverlayWaitTime * 1000); // wait for the BPM overlay notification
430-
BringToFront(launcherProc.MainWindowHandle);
428+
// force the launcher window to activate before the game to avoid BPM hooking issues
429+
Thread.Sleep(setHnd.PreGameOverlayWaitTime * 1000); // wait for the BPM overlay notification
430+
BringToFront(launcherProc.MainWindowHandle);
431+
}// skip over the launcher if we're only launching a game path
431432

432433
/*
433434
* Game Post-Proxy Detection
@@ -437,6 +438,7 @@ private static void ProcessLauncher(Settings setHnd)
437438
{// only run game ourselves if the user asks
438439
gameProc.StartInfo.UseShellExecute = true;
439440
gameProc.StartInfo.FileName = setHnd.GamePath;
441+
gameProc.StartInfo.WorkingDirectory = Directory.GetParent(setHnd.GamePath).ToString();
440442
gameProc.StartInfo.Arguments = setHnd.GameArgs;
441443
Logger("OSOL", "Launching game, cmd: " + setHnd.GamePath + " " + setHnd.GameArgs);
442444
gameProc.Start();
@@ -467,7 +469,7 @@ private static void ProcessLauncher(Settings setHnd)
467469

468470
int g_sanity_counter = 0;
469471
int gamePID = 0;
470-
while (g_sanity_counter <= 300)
472+
while (g_sanity_counter <= 300 && setHnd.LauncherPath != String.Empty)
471473
{// actively attempt to reacquire process, wait up to 5 mins
472474
if (g_sanity_counter == 300)
473475
{
@@ -504,15 +506,17 @@ private static void ProcessLauncher(Settings setHnd)
504506
/*
505507
* Post-Game Cleanup
506508
*/
507-
if (IsRunningPID(launcherProc.Id))
509+
if (setHnd.LauncherPath != String.Empty && IsRunningPID(launcherProc.Id))
508510
{// found the launcher left after the game exited
509511
Thread.Sleep(setHnd.PostGameWaitTime * 1000); // let Origin sync with the cloud
510512
Logger("OSOL", "Game exited, killing launcher instance and cleaning up...");
511513
KillProcTreeByName(launcherName);
512-
513-
// ask a non-async delegate to run a process after the game and launcher exit
514-
ExecuteExternalElevated(setHnd.PostGameExec, setHnd.PostGameExecArgs);
515514
}
515+
else
516+
Logger("OSOL", "Game exited, cleaning up...");
517+
518+
// ask a non-async delegate to run a process after the game and launcher exit
519+
ExecuteExternalElevated(setHnd.PostGameExec, setHnd.PostGameExecArgs);
516520
}
517521
}
518522
}

0 commit comments

Comments
 (0)