| 238 | #endif |
| 239 | |
| 240 | void DFSteam::launchSteamDFHackIfNecessary(color_ostream& out) { |
| 241 | if (!g_steam_initialized || |
| 242 | !g_SteamAPI_GetHSteamUser || |
| 243 | !g_SteamInternal_FindOrCreateUserInterface || |
| 244 | !g_SteamAPI_ISteamApps_BIsAppInstalled) { |
| 245 | DEBUG(dfsteam, out).print("required Steam API calls are unavailable\n"); |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | const std::string & cmdline = df::global::game->command_line.original; |
| 250 | if (cmdline.find("--nosteam-dfhack") != std::string::npos) { |
| 251 | WARN(dfsteam, out).print("--nosteam-dfhack specified on commandline; not launching DFHack coprocess\n"); |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | void* iSteamApps = g_SteamInternal_FindOrCreateUserInterface(g_SteamAPI_GetHSteamUser(), "STEAMAPPS_INTERFACE_VERSION008"); |
| 256 | if (!iSteamApps) { |
| 257 | DEBUG(dfsteam, out).print("cannot obtain iSteamApps interface\n"); |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | bool isDFHackInstalled = g_SteamAPI_ISteamApps_BIsAppInstalled(iSteamApps, DFHACK_STEAM_APPID); |
| 262 | if (!isDFHackInstalled) { |
| 263 | DEBUG(dfsteam, out).print("player has not installed DFHack through Steam\n"); |
| 264 | return; |
| 265 | } |
| 266 | |
| 267 | bool ret = launchDFHack(out); |
| 268 | DEBUG(dfsteam, out).print("launching DFHack via Steam: {}\n", ret ? "successful" : "unsuccessful"); |
| 269 | } |
nothing calls this directly
no test coverage detected