Steam.cs (24923B)
1 // This file is provided under The MIT License as part of Steamworks.NET. 2 // Copyright (c) 2013-2019 Riley Labrecque 3 // Please see the included LICENSE.txt for additional information. 4 5 // This file is automatically generated. 6 // Changes to this file will be reverted when you update Steamworks.NET 7 8 #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH 9 #define DISABLESTEAMWORKS 10 #endif 11 12 #if !DISABLESTEAMWORKS 13 14 using System.Runtime.InteropServices; 15 using IntPtr = System.IntPtr; 16 17 namespace Steamworks { 18 public static class Version { 19 public const string SteamworksNETVersion = "13.0.0"; 20 public const string SteamworksSDKVersion = "1.46"; 21 public const string SteamAPIDLLVersion = "05.25.65.21"; 22 public const int SteamAPIDLLSize = 259360; 23 public const int SteamAPI64DLLSize = 289568; 24 } 25 26 public static class SteamAPI { 27 //----------------------------------------------------------------------------------------------------------------------------------------------------------// 28 // Steam API setup & shutdown 29 // 30 // These functions manage loading, initializing and shutdown of the steamclient.dll 31 // 32 //----------------------------------------------------------------------------------------------------------------------------------------------------------// 33 34 // SteamAPI_Init must be called before using any other API functions. If it fails, an 35 // error message will be output to the debugger (or stderr) with further information. 36 public static bool Init() { 37 InteropHelp.TestIfPlatformSupported(); 38 39 bool ret = NativeMethods.SteamAPI_Init(); 40 41 // Steamworks.NET specific: We initialize the SteamAPI Context like this for now, but we need to do it 42 // every time that Unity reloads binaries, so we also check if the pointers are available and initialized 43 // before each call to any interface functions. That is in InteropHelp.cs 44 if (ret) 45 { 46 ret = CSteamAPIContext.Init(); 47 } 48 49 return ret; 50 } 51 52 public static void Shutdown() { 53 InteropHelp.TestIfPlatformSupported(); 54 NativeMethods.SteamAPI_Shutdown(); 55 } 56 57 // SteamAPI_RestartAppIfNecessary ensures that your executable was launched through Steam. 58 // 59 // Returns true if the current process should terminate. Steam is now re-launching your application. 60 // 61 // Returns false if no action needs to be taken. This means that your executable was started through 62 // the Steam client, or a steam_appid.txt file is present in your game's directory (for development). 63 // Your current process should continue if false is returned. 64 // 65 // NOTE: If you use the Steam DRM wrapper on your primary executable file, this check is unnecessary 66 // since the DRM wrapper will ensure that your application was launched properly through Steam. 67 public static bool RestartAppIfNecessary(AppId_t unOwnAppID) { 68 InteropHelp.TestIfPlatformSupported(); 69 return NativeMethods.SteamAPI_RestartAppIfNecessary(unOwnAppID); 70 } 71 72 // Many Steam API functions allocate a small amount of thread-local memory for parameter storage. 73 // SteamAPI_ReleaseCurrentThreadMemory() will free API memory associated with the calling thread. 74 // This function is also called automatically by SteamAPI_RunCallbacks(), so a single-threaded 75 // program never needs to explicitly call this function. 76 public static void ReleaseCurrentThreadMemory() { 77 InteropHelp.TestIfPlatformSupported(); 78 NativeMethods.SteamAPI_ReleaseCurrentThreadMemory(); 79 } 80 81 82 //----------------------------------------------------------------------------------------------------------------------------------------------------------// 83 // steam callback and call-result helpers 84 // 85 // The following macros and classes are used to register your application for 86 // callbacks and call-results, which are delivered in a predictable manner. 87 // 88 // STEAM_CALLBACK macros are meant for use inside of a C++ class definition. 89 // They map a Steam notification callback directly to a class member function 90 // which is automatically prototyped as "void func( callback_type *pParam )". 91 // 92 // CCallResult is used with specific Steam APIs that return "result handles". 93 // The handle can be passed to a CCallResult object's Set function, along with 94 // an object pointer and member-function pointer. The member function will 95 // be executed once the results of the Steam API call are available. 96 // 97 // CCallback and CCallbackManual classes can be used instead of STEAM_CALLBACK 98 // macros if you require finer control over registration and unregistration. 99 // 100 // Callbacks and call-results are queued automatically and are only 101 // delivered/executed when your application calls SteamAPI_RunCallbacks(). 102 //----------------------------------------------------------------------------------------------------------------------------------------------------------// 103 104 // SteamAPI_RunCallbacks is safe to call from multiple threads simultaneously, 105 // but if you choose to do this, callback code could be executed on any thread. 106 // One alternative is to call SteamAPI_RunCallbacks from the main thread only, 107 // and call SteamAPI_ReleaseCurrentThreadMemory regularly on other threads. 108 public static void RunCallbacks() { 109 InteropHelp.TestIfPlatformSupported(); 110 NativeMethods.SteamAPI_RunCallbacks(); 111 } 112 113 //----------------------------------------------------------------------------------------------------------------------------------------------------------// 114 // steamclient.dll private wrapper functions 115 // 116 // The following functions are part of abstracting API access to the steamclient.dll, but should only be used in very specific cases 117 //----------------------------------------------------------------------------------------------------------------------------------------------------------// 118 119 // SteamAPI_IsSteamRunning() returns true if Steam is currently running 120 public static bool IsSteamRunning() { 121 InteropHelp.TestIfPlatformSupported(); 122 return NativeMethods.SteamAPI_IsSteamRunning(); 123 } 124 125 // returns the HSteamUser of the last user to dispatch a callback 126 public static HSteamUser GetHSteamUserCurrent() { 127 InteropHelp.TestIfPlatformSupported(); 128 return (HSteamUser)NativeMethods.Steam_GetHSteamUserCurrent(); 129 } 130 131 // returns the pipe we are communicating to Steam with 132 public static HSteamPipe GetHSteamPipe() { 133 InteropHelp.TestIfPlatformSupported(); 134 return (HSteamPipe)NativeMethods.SteamAPI_GetHSteamPipe(); 135 } 136 137 public static HSteamUser GetHSteamUser() { 138 InteropHelp.TestIfPlatformSupported(); 139 return (HSteamUser)NativeMethods.SteamAPI_GetHSteamUser(); 140 } 141 } 142 143 public static class GameServer { 144 // Initialize ISteamGameServer interface object, and set server properties which may not be changed. 145 // 146 // After calling this function, you should set any additional server parameters, and then 147 // call ISteamGameServer::LogOnAnonymous() or ISteamGameServer::LogOn() 148 // 149 // - usSteamPort is the local port used to communicate with the steam servers. 150 // - usGamePort is the port that clients will connect to for gameplay. 151 // - usQueryPort is the port that will manage server browser related duties and info 152 // pings from clients. If you pass MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE for usQueryPort, then it 153 // will use "GameSocketShare" mode, which means that the game is responsible for sending and receiving 154 // UDP packets for the master server updater. See references to GameSocketShare in isteamgameserver.h. 155 // - The version string is usually in the form x.x.x.x, and is used by the master server to detect when the 156 // server is out of date. (Only servers with the latest version will be listed.) 157 public static bool Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString) { 158 InteropHelp.TestIfPlatformSupported(); 159 160 bool ret; 161 using (var pchVersionString2 = new InteropHelp.UTF8StringHandle(pchVersionString)) { 162 ret = NativeMethods.SteamGameServer_Init(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString2); 163 } 164 165 // Steamworks.NET specific: We initialize the SteamAPI Context like this for now, but we need to do it 166 // every time that Unity reloads binaries, so we also check if the pointers are available and initialized 167 // before each call to any interface functions. That is in InteropHelp.cs 168 if (ret) { 169 ret = CSteamGameServerAPIContext.Init(); 170 } 171 172 return ret; 173 } 174 175 public static void Shutdown() { 176 InteropHelp.TestIfPlatformSupported(); 177 NativeMethods.SteamGameServer_Shutdown(); 178 CSteamGameServerAPIContext.Clear(); 179 } 180 181 public static void RunCallbacks() { 182 InteropHelp.TestIfPlatformSupported(); 183 NativeMethods.SteamGameServer_RunCallbacks(); 184 } 185 186 // Most Steam API functions allocate some amount of thread-local memory for 187 // parameter storage. Calling SteamGameServer_ReleaseCurrentThreadMemory() 188 // will free all API-related memory associated with the calling thread. 189 // This memory is released automatically by SteamGameServer_RunCallbacks(), 190 // so single-threaded servers do not need to explicitly call this function. 191 public static void ReleaseCurrentThreadMemory() { 192 InteropHelp.TestIfPlatformSupported(); 193 NativeMethods.SteamGameServer_ReleaseCurrentThreadMemory(); 194 } 195 196 public static bool BSecure() { 197 InteropHelp.TestIfPlatformSupported(); 198 return NativeMethods.SteamGameServer_BSecure(); 199 } 200 201 public static CSteamID GetSteamID() { 202 InteropHelp.TestIfPlatformSupported(); 203 return (CSteamID)NativeMethods.SteamGameServer_GetSteamID(); 204 } 205 206 public static HSteamPipe GetHSteamPipe() { 207 InteropHelp.TestIfPlatformSupported(); 208 return (HSteamPipe)NativeMethods.SteamGameServer_GetHSteamPipe(); 209 } 210 211 public static HSteamUser GetHSteamUser() { 212 InteropHelp.TestIfPlatformSupported(); 213 return (HSteamUser)NativeMethods.SteamGameServer_GetHSteamUser(); 214 } 215 } 216 217 public static class SteamEncryptedAppTicket { 218 public static bool BDecryptTicket(byte[] rgubTicketEncrypted, uint cubTicketEncrypted, byte[] rgubTicketDecrypted, ref uint pcubTicketDecrypted, byte[] rgubKey, int cubKey) { 219 InteropHelp.TestIfPlatformSupported(); 220 return NativeMethods.SteamEncryptedAppTicket_BDecryptTicket(rgubTicketEncrypted, cubTicketEncrypted, rgubTicketDecrypted, ref pcubTicketDecrypted, rgubKey, cubKey); 221 } 222 223 public static bool BIsTicketForApp(byte[] rgubTicketDecrypted, uint cubTicketDecrypted, AppId_t nAppID) { 224 InteropHelp.TestIfPlatformSupported(); 225 return NativeMethods.SteamEncryptedAppTicket_BIsTicketForApp(rgubTicketDecrypted, cubTicketDecrypted, nAppID); 226 } 227 228 public static uint GetTicketIssueTime(byte[] rgubTicketDecrypted, uint cubTicketDecrypted) { 229 InteropHelp.TestIfPlatformSupported(); 230 return NativeMethods.SteamEncryptedAppTicket_GetTicketIssueTime(rgubTicketDecrypted, cubTicketDecrypted); 231 } 232 233 public static void GetTicketSteamID(byte[] rgubTicketDecrypted, uint cubTicketDecrypted, out CSteamID psteamID) { 234 InteropHelp.TestIfPlatformSupported(); 235 NativeMethods.SteamEncryptedAppTicket_GetTicketSteamID(rgubTicketDecrypted, cubTicketDecrypted, out psteamID); 236 } 237 238 public static uint GetTicketAppID(byte[] rgubTicketDecrypted, uint cubTicketDecrypted) { 239 InteropHelp.TestIfPlatformSupported(); 240 return NativeMethods.SteamEncryptedAppTicket_GetTicketAppID(rgubTicketDecrypted, cubTicketDecrypted); 241 } 242 243 public static bool BUserOwnsAppInTicket(byte[] rgubTicketDecrypted, uint cubTicketDecrypted, AppId_t nAppID) { 244 InteropHelp.TestIfPlatformSupported(); 245 return NativeMethods.SteamEncryptedAppTicket_BUserOwnsAppInTicket(rgubTicketDecrypted, cubTicketDecrypted, nAppID); 246 } 247 248 public static bool BUserIsVacBanned(byte[] rgubTicketDecrypted, uint cubTicketDecrypted) { 249 InteropHelp.TestIfPlatformSupported(); 250 return NativeMethods.SteamEncryptedAppTicket_BUserIsVacBanned(rgubTicketDecrypted, cubTicketDecrypted); 251 } 252 253 public static byte[] GetUserVariableData(byte[] rgubTicketDecrypted, uint cubTicketDecrypted, out uint pcubUserData) { 254 InteropHelp.TestIfPlatformSupported(); 255 IntPtr punSecretData = NativeMethods.SteamEncryptedAppTicket_GetUserVariableData(rgubTicketDecrypted, cubTicketDecrypted, out pcubUserData); 256 byte[] ret = new byte[pcubUserData]; 257 System.Runtime.InteropServices.Marshal.Copy(punSecretData, ret, 0, (int)pcubUserData); 258 return ret; 259 } 260 261 public static bool BIsTicketSigned(byte[] rgubTicketDecrypted, uint cubTicketDecrypted, byte[] pubRSAKey, uint cubRSAKey) { 262 InteropHelp.TestIfPlatformSupported(); 263 return NativeMethods.SteamEncryptedAppTicket_BIsTicketSigned(rgubTicketDecrypted, cubTicketDecrypted, pubRSAKey, cubRSAKey); 264 } 265 } 266 267 internal static class CSteamAPIContext { 268 internal static void Clear() { 269 m_pSteamClient = IntPtr.Zero; 270 m_pSteamUser = IntPtr.Zero; 271 m_pSteamFriends = IntPtr.Zero; 272 m_pSteamUtils = IntPtr.Zero; 273 m_pSteamMatchmaking = IntPtr.Zero; 274 m_pSteamUserStats = IntPtr.Zero; 275 m_pSteamApps = IntPtr.Zero; 276 m_pSteamMatchmakingServers = IntPtr.Zero; 277 m_pSteamNetworking = IntPtr.Zero; 278 m_pSteamRemoteStorage = IntPtr.Zero; 279 m_pSteamHTTP = IntPtr.Zero; 280 m_pSteamScreenshots = IntPtr.Zero; 281 m_pSteamGameSearch = IntPtr.Zero; 282 m_pSteamMusic = IntPtr.Zero; 283 m_pController = IntPtr.Zero; 284 m_pSteamUGC = IntPtr.Zero; 285 m_pSteamAppList = IntPtr.Zero; 286 m_pSteamMusic = IntPtr.Zero; 287 m_pSteamMusicRemote = IntPtr.Zero; 288 m_pSteamHTMLSurface = IntPtr.Zero; 289 m_pSteamInventory = IntPtr.Zero; 290 m_pSteamVideo = IntPtr.Zero; 291 m_pSteamParentalSettings = IntPtr.Zero; 292 m_pSteamInput = IntPtr.Zero; 293 m_pSteamParties = IntPtr.Zero; 294 m_pSteamRemotePlay = IntPtr.Zero; 295 } 296 297 internal static bool Init() { 298 HSteamUser hSteamUser = SteamAPI.GetHSteamUser(); 299 HSteamPipe hSteamPipe = SteamAPI.GetHSteamPipe(); 300 if (hSteamPipe == (HSteamPipe)0) { return false; } 301 302 using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMCLIENT_INTERFACE_VERSION)) { 303 m_pSteamClient = NativeMethods.SteamInternal_CreateInterface(pchVersionString); 304 } 305 306 if (m_pSteamClient == IntPtr.Zero) { return false; } 307 308 m_pSteamUser = SteamClient.GetISteamUser(hSteamUser, hSteamPipe, Constants.STEAMUSER_INTERFACE_VERSION); 309 if (m_pSteamUser == IntPtr.Zero) { return false; } 310 311 m_pSteamFriends = SteamClient.GetISteamFriends(hSteamUser, hSteamPipe, Constants.STEAMFRIENDS_INTERFACE_VERSION); 312 if (m_pSteamFriends == IntPtr.Zero) { return false; } 313 314 m_pSteamUtils = SteamClient.GetISteamUtils(hSteamPipe, Constants.STEAMUTILS_INTERFACE_VERSION); 315 if (m_pSteamUtils == IntPtr.Zero) { return false; } 316 317 m_pSteamMatchmaking = SteamClient.GetISteamMatchmaking(hSteamUser, hSteamPipe, Constants.STEAMMATCHMAKING_INTERFACE_VERSION); 318 if (m_pSteamMatchmaking == IntPtr.Zero) { return false; } 319 320 m_pSteamMatchmakingServers = SteamClient.GetISteamMatchmakingServers(hSteamUser, hSteamPipe, Constants.STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION); 321 if (m_pSteamMatchmakingServers == IntPtr.Zero) { return false; } 322 323 m_pSteamUserStats = SteamClient.GetISteamUserStats(hSteamUser, hSteamPipe, Constants.STEAMUSERSTATS_INTERFACE_VERSION); 324 if (m_pSteamUserStats == IntPtr.Zero) { return false; } 325 326 m_pSteamApps = SteamClient.GetISteamApps(hSteamUser, hSteamPipe, Constants.STEAMAPPS_INTERFACE_VERSION); 327 if (m_pSteamApps == IntPtr.Zero) { return false; } 328 329 m_pSteamNetworking = SteamClient.GetISteamNetworking(hSteamUser, hSteamPipe, Constants.STEAMNETWORKING_INTERFACE_VERSION); 330 if (m_pSteamNetworking == IntPtr.Zero) { return false; } 331 332 m_pSteamRemoteStorage = SteamClient.GetISteamRemoteStorage(hSteamUser, hSteamPipe, Constants.STEAMREMOTESTORAGE_INTERFACE_VERSION); 333 if (m_pSteamRemoteStorage == IntPtr.Zero) { return false; } 334 335 m_pSteamScreenshots = SteamClient.GetISteamScreenshots(hSteamUser, hSteamPipe, Constants.STEAMSCREENSHOTS_INTERFACE_VERSION); 336 if (m_pSteamScreenshots == IntPtr.Zero) { return false; } 337 338 m_pSteamGameSearch = SteamClient.GetISteamGameSearch(hSteamUser, hSteamPipe, Constants.STEAMGAMESEARCH_INTERFACE_VERSION); 339 if (m_pSteamGameSearch == IntPtr.Zero) { return false; } 340 341 m_pSteamHTTP = SteamClient.GetISteamHTTP(hSteamUser, hSteamPipe, Constants.STEAMHTTP_INTERFACE_VERSION); 342 if (m_pSteamHTTP == IntPtr.Zero) { return false; } 343 344 m_pController = SteamClient.GetISteamController(hSteamUser, hSteamPipe, Constants.STEAMCONTROLLER_INTERFACE_VERSION); 345 if (m_pController == IntPtr.Zero) { return false; } 346 347 m_pSteamUGC = SteamClient.GetISteamUGC(hSteamUser, hSteamPipe, Constants.STEAMUGC_INTERFACE_VERSION); 348 if (m_pSteamUGC == IntPtr.Zero) { return false; } 349 350 m_pSteamAppList = SteamClient.GetISteamAppList(hSteamUser, hSteamPipe, Constants.STEAMAPPLIST_INTERFACE_VERSION); 351 if (m_pSteamAppList == IntPtr.Zero) { return false; } 352 353 m_pSteamMusic = SteamClient.GetISteamMusic(hSteamUser, hSteamPipe, Constants.STEAMMUSIC_INTERFACE_VERSION); 354 if (m_pSteamMusic == IntPtr.Zero) { return false; } 355 356 m_pSteamMusicRemote = SteamClient.GetISteamMusicRemote(hSteamUser, hSteamPipe, Constants.STEAMMUSICREMOTE_INTERFACE_VERSION); 357 if (m_pSteamMusicRemote == IntPtr.Zero) { return false; } 358 359 m_pSteamHTMLSurface = SteamClient.GetISteamHTMLSurface(hSteamUser, hSteamPipe, Constants.STEAMHTMLSURFACE_INTERFACE_VERSION); 360 if (m_pSteamHTMLSurface == IntPtr.Zero) { return false; } 361 362 m_pSteamInventory = SteamClient.GetISteamInventory(hSteamUser, hSteamPipe, Constants.STEAMINVENTORY_INTERFACE_VERSION); 363 if (m_pSteamInventory == IntPtr.Zero) { return false; } 364 365 m_pSteamVideo = SteamClient.GetISteamVideo(hSteamUser, hSteamPipe, Constants.STEAMVIDEO_INTERFACE_VERSION); 366 if (m_pSteamVideo == IntPtr.Zero) { return false; } 367 368 m_pSteamParentalSettings = SteamClient.GetISteamParentalSettings(hSteamUser, hSteamPipe, Constants.STEAMPARENTALSETTINGS_INTERFACE_VERSION); 369 if (m_pSteamParentalSettings == IntPtr.Zero) { return false; } 370 371 m_pSteamInput = SteamClient.GetISteamInput(hSteamUser, hSteamPipe, Constants.STEAMINPUT_INTERFACE_VERSION); 372 if (m_pSteamInput == IntPtr.Zero) { return false; } 373 374 m_pSteamParties = SteamClient.GetISteamParties(hSteamUser, hSteamPipe, Constants.STEAMPARTIES_INTERFACE_VERSION); 375 if (m_pSteamParties == IntPtr.Zero) { return false; } 376 377 m_pSteamRemotePlay = SteamClient.GetISteamRemotePlay(hSteamUser, hSteamPipe, Constants.STEAMREMOTEPLAY_INTERFACE_VERSION); 378 if (m_pSteamRemotePlay == IntPtr.Zero) { return false; } 379 380 return true; 381 } 382 383 internal static IntPtr GetSteamClient() { return m_pSteamClient; } 384 internal static IntPtr GetSteamUser() { return m_pSteamUser; } 385 internal static IntPtr GetSteamFriends() { return m_pSteamFriends; } 386 internal static IntPtr GetSteamUtils() { return m_pSteamUtils; } 387 internal static IntPtr GetSteamMatchmaking() { return m_pSteamMatchmaking; } 388 internal static IntPtr GetSteamUserStats() { return m_pSteamUserStats; } 389 internal static IntPtr GetSteamApps() { return m_pSteamApps; } 390 internal static IntPtr GetSteamMatchmakingServers() { return m_pSteamMatchmakingServers; } 391 internal static IntPtr GetSteamNetworking() { return m_pSteamNetworking; } 392 internal static IntPtr GetSteamRemoteStorage() { return m_pSteamRemoteStorage; } 393 internal static IntPtr GetSteamScreenshots() { return m_pSteamScreenshots; } 394 internal static IntPtr GetSteamGameSearch() { return m_pSteamGameSearch; } 395 internal static IntPtr GetSteamHTTP() { return m_pSteamHTTP; } 396 internal static IntPtr GetSteamController() { return m_pController; } 397 internal static IntPtr GetSteamUGC() { return m_pSteamUGC; } 398 internal static IntPtr GetSteamAppList() { return m_pSteamAppList; } 399 internal static IntPtr GetSteamMusic() { return m_pSteamMusic; } 400 internal static IntPtr GetSteamMusicRemote() { return m_pSteamMusicRemote; } 401 internal static IntPtr GetSteamHTMLSurface() { return m_pSteamHTMLSurface; } 402 internal static IntPtr GetSteamInventory() { return m_pSteamInventory; } 403 internal static IntPtr GetSteamVideo() { return m_pSteamVideo; } 404 internal static IntPtr GetSteamParentalSettings() { return m_pSteamParentalSettings; } 405 internal static IntPtr GetSteamInput() { return m_pSteamInput; } 406 internal static IntPtr GetSteamParties() { return m_pSteamParties; } 407 internal static IntPtr GetSteamRemotePlay() { return m_pSteamRemotePlay; } 408 409 private static IntPtr m_pSteamClient; 410 private static IntPtr m_pSteamUser; 411 private static IntPtr m_pSteamFriends; 412 private static IntPtr m_pSteamUtils; 413 private static IntPtr m_pSteamMatchmaking; 414 private static IntPtr m_pSteamUserStats; 415 private static IntPtr m_pSteamApps; 416 private static IntPtr m_pSteamMatchmakingServers; 417 private static IntPtr m_pSteamNetworking; 418 private static IntPtr m_pSteamRemoteStorage; 419 private static IntPtr m_pSteamScreenshots; 420 private static IntPtr m_pSteamGameSearch; 421 private static IntPtr m_pSteamHTTP; 422 private static IntPtr m_pController; 423 private static IntPtr m_pSteamUGC; 424 private static IntPtr m_pSteamAppList; 425 private static IntPtr m_pSteamMusic; 426 private static IntPtr m_pSteamMusicRemote; 427 private static IntPtr m_pSteamHTMLSurface; 428 private static IntPtr m_pSteamInventory; 429 private static IntPtr m_pSteamVideo; 430 private static IntPtr m_pSteamParentalSettings; 431 private static IntPtr m_pSteamInput; 432 private static IntPtr m_pSteamParties; 433 private static IntPtr m_pSteamRemotePlay; 434 } 435 436 internal static class CSteamGameServerAPIContext { 437 internal static void Clear() { 438 m_pSteamClient = IntPtr.Zero; 439 m_pSteamGameServer = IntPtr.Zero; 440 m_pSteamUtils = IntPtr.Zero; 441 m_pSteamNetworking = IntPtr.Zero; 442 m_pSteamGameServerStats = IntPtr.Zero; 443 m_pSteamHTTP = IntPtr.Zero; 444 m_pSteamInventory = IntPtr.Zero; 445 m_pSteamUGC = IntPtr.Zero; 446 m_pSteamApps = IntPtr.Zero; 447 } 448 449 internal static bool Init() { 450 HSteamUser hSteamUser = GameServer.GetHSteamUser(); 451 HSteamPipe hSteamPipe = GameServer.GetHSteamPipe(); 452 if (hSteamPipe == (HSteamPipe)0) { return false; } 453 454 using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMCLIENT_INTERFACE_VERSION)) { 455 m_pSteamClient = NativeMethods.SteamInternal_CreateInterface(pchVersionString); 456 } 457 if (m_pSteamClient == IntPtr.Zero) { return false; } 458 459 m_pSteamGameServer = SteamGameServerClient.GetISteamGameServer(hSteamUser, hSteamPipe, Constants.STEAMGAMESERVER_INTERFACE_VERSION); 460 if (m_pSteamGameServer == IntPtr.Zero) { return false; } 461 462 m_pSteamUtils = SteamGameServerClient.GetISteamUtils(hSteamPipe, Constants.STEAMUTILS_INTERFACE_VERSION); 463 if (m_pSteamUtils == IntPtr.Zero) { return false; } 464 465 m_pSteamNetworking = SteamGameServerClient.GetISteamNetworking(hSteamUser, hSteamPipe, Constants.STEAMNETWORKING_INTERFACE_VERSION); 466 if (m_pSteamNetworking == IntPtr.Zero) { return false; } 467 468 m_pSteamGameServerStats = SteamGameServerClient.GetISteamGameServerStats(hSteamUser, hSteamPipe, Constants.STEAMGAMESERVERSTATS_INTERFACE_VERSION); 469 if (m_pSteamGameServerStats == IntPtr.Zero) { return false; } 470 471 m_pSteamHTTP = SteamGameServerClient.GetISteamHTTP(hSteamUser, hSteamPipe, Constants.STEAMHTTP_INTERFACE_VERSION); 472 if (m_pSteamHTTP == IntPtr.Zero) { return false; } 473 474 m_pSteamInventory = SteamGameServerClient.GetISteamInventory(hSteamUser, hSteamPipe, Constants.STEAMINVENTORY_INTERFACE_VERSION); 475 if (m_pSteamInventory == IntPtr.Zero) { return false; } 476 477 m_pSteamUGC = SteamGameServerClient.GetISteamUGC(hSteamUser, hSteamPipe, Constants.STEAMUGC_INTERFACE_VERSION); 478 if (m_pSteamUGC == IntPtr.Zero) { return false; } 479 480 m_pSteamApps = SteamGameServerClient.GetISteamApps(hSteamUser, hSteamPipe, Constants.STEAMAPPS_INTERFACE_VERSION); 481 if (m_pSteamApps == IntPtr.Zero) { return false; } 482 483 return true; 484 } 485 486 internal static IntPtr GetSteamClient() { return m_pSteamClient; } 487 internal static IntPtr GetSteamGameServer() { return m_pSteamGameServer; } 488 internal static IntPtr GetSteamUtils() { return m_pSteamUtils; } 489 internal static IntPtr GetSteamNetworking() { return m_pSteamNetworking; } 490 internal static IntPtr GetSteamGameServerStats() { return m_pSteamGameServerStats; } 491 internal static IntPtr GetSteamHTTP() { return m_pSteamHTTP; } 492 internal static IntPtr GetSteamInventory() { return m_pSteamInventory; } 493 internal static IntPtr GetSteamUGC() { return m_pSteamUGC; } 494 internal static IntPtr GetSteamApps() { return m_pSteamApps; } 495 496 private static IntPtr m_pSteamClient; 497 private static IntPtr m_pSteamGameServer; 498 private static IntPtr m_pSteamUtils; 499 private static IntPtr m_pSteamNetworking; 500 private static IntPtr m_pSteamGameServerStats; 501 private static IntPtr m_pSteamHTTP; 502 private static IntPtr m_pSteamInventory; 503 private static IntPtr m_pSteamUGC; 504 private static IntPtr m_pSteamApps; 505 } 506 } 507 508 #endif // !DISABLESTEAMWORKS