MCPcopy Create free account
hub / github.com/DFHack/dfhack / launchSteamDFHackIfNecessary

Method launchSteamDFHackIfNecessary

library/modules/DFSteam.cpp:240–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238#endif
239
240void 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}

Callers

nothing calls this directly

Calls 3

launchDFHackFunction · 0.85
printMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected