only initialize steam if launched from steam

develop
Myk Taylor 2023-06-05 14:18:55 -07:00
parent ecf82471cf
commit 4a2b97105c
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 7 additions and 5 deletions

@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## New Plugins ## New Plugins
## Fixes ## Fixes
- Fix crash for some players when they launch DF outside of the Steam client
## Misc Improvements ## Misc Improvements

@ -52,6 +52,12 @@ static void bind_all(color_ostream& out, DFLibrary* handle) {
} }
bool DFSteam::init(color_ostream& out) { 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) { for (auto& lib_str : STEAM_LIBS) {
if ((g_steam_handle = OpenPlugin(lib_str.c_str()))) if ((g_steam_handle = OpenPlugin(lib_str.c_str())))
break; break;
@ -168,11 +174,6 @@ void DFSteam::launchSteamDFHackIfNecessary(color_ostream& out) {
return; 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"); void* iSteamApps = g_SteamInternal_FindOrCreateUserInterface(g_SteamAPI_GetHSteamUser(), "STEAMAPPS_INTERFACE_VERSION008");
if (!iSteamApps) { if (!iSteamApps) {
DEBUG(dfsteam, out).print("cannot obtain iSteamApps interface\n"); DEBUG(dfsteam, out).print("cannot obtain iSteamApps interface\n");