Skip to content

Commit

Permalink
only initialize steam if launched from steam
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Jun 5, 2023
1 parent ecf8247 commit 4a2b971
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## New Plugins

## Fixes
- Fix crash for some players when they launch DF outside of the Steam client

## Misc Improvements

Expand Down
11 changes: 6 additions & 5 deletions library/modules/DFSteam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ static void bind_all(color_ostream& out, DFLibrary* handle) {
}

bool DFSteam::init(color_ostream& out) {
char *steam_client_launch = getenv("SteamClientLaunch");
if (!steam_client_launch || strncmp(steam_client_launch, "1", 2) != 0) {
DEBUG(dfsteam, out).print("not launched from Steam client; not initializing steam\n");
return false;
}

for (auto& lib_str : STEAM_LIBS) {
if ((g_steam_handle = OpenPlugin(lib_str.c_str())))
break;
Expand Down Expand Up @@ -168,11 +174,6 @@ void DFSteam::launchSteamDFHackIfNecessary(color_ostream& out) {
return;
}

if (strncmp(getenv("SteamClientLaunch"), "1", 2)) {
DEBUG(dfsteam, out).print("not launched from Steam client\n");
return;
}

void* iSteamApps = g_SteamInternal_FindOrCreateUserInterface(g_SteamAPI_GetHSteamUser(), "STEAMAPPS_INTERFACE_VERSION008");
if (!iSteamApps) {
DEBUG(dfsteam, out).print("cannot obtain iSteamApps interface\n");
Expand Down

0 comments on commit 4a2b971

Please sign in to comment.