MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / SteamTracker

Method SteamTracker

main/steam_tracker.cpp:45–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43// https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
44
45SteamTracker::SteamTracker() {
46 String path;
47 if (OS::get_singleton()->has_feature("linuxbsd")) {
48 path = OS::get_singleton()->get_executable_path().get_base_dir().path_join("libsteam_api.so");
49 if (!FileAccess::exists(path)) {
50 path = OS::get_singleton()->get_executable_path().get_base_dir().path_join("../lib").path_join("libsteam_api.so");
51 if (!FileAccess::exists(path)) {
52 return;
53 }
54 }
55 } else if (OS::get_singleton()->has_feature("windows")) {
56 if (OS::get_singleton()->has_feature("64")) {
57 path = OS::get_singleton()->get_executable_path().get_base_dir().path_join("steam_api64.dll");
58 } else {
59 path = OS::get_singleton()->get_executable_path().get_base_dir().path_join("steam_api.dll");
60 }
61 if (!FileAccess::exists(path)) {
62 return;
63 }
64 } else if (OS::get_singleton()->has_feature("macos")) {
65 path = OS::get_singleton()->get_executable_path().get_base_dir().path_join("libsteam_api.dylib");
66 if (!FileAccess::exists(path)) {
67 path = OS::get_singleton()->get_executable_path().get_base_dir().path_join("../Frameworks").path_join("libsteam_api.dylib");
68 if (!FileAccess::exists(path)) {
69 return;
70 }
71 }
72 } else {
73 return;
74 }
75
76 Error err = OS::get_singleton()->open_dynamic_library(path, steam_library_handle);
77 if (err != OK) {
78 steam_library_handle = nullptr;
79 return;
80 }
81 print_verbose("Loaded SteamAPI library");
82
83 void *symbol_handle = nullptr;
84 err = OS::get_singleton()->get_dynamic_library_symbol_handle(steam_library_handle, "SteamAPI_InitFlat", symbol_handle, true); // Try new API, 1.59+.
85 if (err != OK) {
86 err = OS::get_singleton()->get_dynamic_library_symbol_handle(steam_library_handle, "SteamAPI_Init", symbol_handle); // Try old API.
87 if (err != OK) {
88 return;
89 }
90 steam_init_function = (SteamAPI_InitFunction)symbol_handle;
91 } else {
92 steam_init_flat_function = (SteamAPI_InitFlatFunction)symbol_handle;
93 }
94
95 err = OS::get_singleton()->get_dynamic_library_symbol_handle(steam_library_handle, "SteamAPI_Shutdown", symbol_handle);
96 if (err != OK) {
97 return;
98 }
99 steam_shutdown_function = (SteamAPI_ShutdownFunction)symbol_handle;
100
101 if (steam_init_flat_function) {
102 char err_msg[1024] = {};

Callers

nothing calls this directly

Calls 6

path_joinMethod · 0.80
get_base_dirMethod · 0.80
has_featureMethod · 0.45
get_executable_pathMethod · 0.45
open_dynamic_libraryMethod · 0.45

Tested by

no test coverage detected