Steam.cs 24 KB

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