예제 #1
0
		internal static bool Init() {
			HSteamUser hSteamUser = GameServer.GetHSteamUser();
			HSteamPipe hSteamPipe = GameServer.GetHSteamPipe();
			if (hSteamPipe == (HSteamPipe)0) { return false; }

			using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMCLIENT_INTERFACE_VERSION)) {
				m_pSteamClient = NativeMethods.SteamInternal_CreateInterface(pchVersionString);
			}
			if (m_pSteamClient == IntPtr.Zero) { return false; }

			m_pSteamGameServer = SteamGameServerClient.GetISteamGameServer(hSteamUser, hSteamPipe, Constants.STEAMGAMESERVER_INTERFACE_VERSION);
			if (m_pSteamGameServer == IntPtr.Zero) { return false; }

			m_pSteamUtils = SteamGameServerClient.GetISteamUtils(hSteamPipe, Constants.STEAMUTILS_INTERFACE_VERSION);
			if (m_pSteamUtils == IntPtr.Zero) { return false; }

			m_pSteamNetworking = SteamGameServerClient.GetISteamNetworking(hSteamUser, hSteamPipe, Constants.STEAMNETWORKING_INTERFACE_VERSION);
			if (m_pSteamNetworking == IntPtr.Zero) { return false; }

			m_pSteamGameServerStats = SteamGameServerClient.GetISteamGameServerStats(hSteamUser, hSteamPipe, Constants.STEAMGAMESERVERSTATS_INTERFACE_VERSION);
			if (m_pSteamGameServerStats == IntPtr.Zero) { return false; }

			m_pSteamHTTP = SteamGameServerClient.GetISteamHTTP(hSteamUser, hSteamPipe, Constants.STEAMHTTP_INTERFACE_VERSION);
			if (m_pSteamHTTP == IntPtr.Zero) { return false; }

			m_pSteamInventory = SteamGameServerClient.GetISteamInventory(hSteamUser, hSteamPipe, Constants.STEAMINVENTORY_INTERFACE_VERSION);
			if (m_pSteamInventory == IntPtr.Zero) { return false; }

			m_pSteamUGC = SteamGameServerClient.GetISteamUGC(hSteamUser, hSteamPipe, Constants.STEAMUGC_INTERFACE_VERSION);
			if (m_pSteamUGC == IntPtr.Zero) { return false; }

			m_pSteamApps = SteamGameServerClient.GetISteamApps(hSteamUser, hSteamPipe, Constants.STEAMAPPS_INTERFACE_VERSION);
			if (m_pSteamApps == IntPtr.Zero) { return false; }

			using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMNETWORKINGUTILS_INTERFACE_VERSION))
			{
				m_pSteamNetworkingUtils =
					NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pchVersionString) != IntPtr.Zero ?
					NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pchVersionString) :
					NativeMethods.SteamInternal_FindOrCreateGameServerInterface(hSteamUser, pchVersionString);
			}
			if (m_pSteamNetworkingUtils == IntPtr.Zero) { return false; }

			using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMNETWORKINGSOCKETS_INTERFACE_VERSION))
			{
				m_pSteamNetworkingSockets =
					NativeMethods.SteamInternal_FindOrCreateGameServerInterface(hSteamUser, pchVersionString);
			}
			if (m_pSteamNetworkingSockets == IntPtr.Zero) { return false; }

			using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMNETWORKINGMESSAGES_VERSION))
			{
				m_pSteamNetworkingMessages =
					NativeMethods.SteamInternal_FindOrCreateGameServerInterface(hSteamUser, pchVersionString);
			}
			if (m_pSteamNetworkingMessages == IntPtr.Zero) { return false; }

			return true;
		}
        internal static bool Init()
        {
            HSteamUser hSteamUser = GameServer.GetHSteamUser();
            HSteamPipe hSteamPipe = GameServer.GetHSteamPipe();

            if (hSteamPipe == (HSteamPipe)0)
            {
                return(false);
            }
            using (InteropHelp.UTF8StringHandle ver = new InteropHelp.UTF8StringHandle("SteamClient020"))
            {
                m_pSteamClient = NativeMethods.SteamInternal_CreateInterface(ver);
            }
            if (m_pSteamClient == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamGameServer = SteamGameServerClient.GetISteamGameServer(hSteamUser, hSteamPipe, "SteamGameServer013");
            if (m_pSteamGameServer == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamUtils = SteamGameServerClient.GetISteamUtils(hSteamPipe, "SteamUtils009");
            if (m_pSteamUtils == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamNetworking = SteamGameServerClient.GetISteamNetworking(hSteamUser, hSteamPipe, "SteamNetworking006");
            if (m_pSteamNetworking == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamGameServerStats = SteamGameServerClient.GetISteamGameServerStats(hSteamUser, hSteamPipe, "SteamGameServerStats001");
            if (m_pSteamGameServerStats == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamHTTP = SteamGameServerClient.GetISteamHTTP(hSteamUser, hSteamPipe, "STEAMHTTP_INTERFACE_VERSION003");
            if (m_pSteamHTTP == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamInventory = SteamGameServerClient.GetISteamInventory(hSteamUser, hSteamPipe, "STEAMINVENTORY_INTERFACE_V003");
            if (m_pSteamInventory == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamUGC = SteamGameServerClient.GetISteamUGC(hSteamUser, hSteamPipe, "STEAMUGC_INTERFACE_VERSION014");
            if (m_pSteamUGC == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamApps = SteamGameServerClient.GetISteamApps(hSteamUser, hSteamPipe, "STEAMAPPS_INTERFACE_VERSION008");
            if (m_pSteamApps == IntPtr.Zero)
            {
                return(false);
            }
            using (InteropHelp.UTF8StringHandle pszVersion = new InteropHelp.UTF8StringHandle("SteamNetworkingUtils003"))
            {
                m_pSteamNetworkingUtils = ((NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pszVersion) != IntPtr.Zero) ? NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pszVersion) : NativeMethods.SteamInternal_FindOrCreateGameServerInterface(hSteamUser, pszVersion));
            }
            if (m_pSteamNetworkingUtils == IntPtr.Zero)
            {
                return(false);
            }
            using (InteropHelp.UTF8StringHandle pszVersion2 = new InteropHelp.UTF8StringHandle("SteamNetworkingSockets008"))
            {
                m_pSteamNetworkingSockets = NativeMethods.SteamInternal_FindOrCreateGameServerInterface(hSteamUser, pszVersion2);
            }
            if (m_pSteamNetworkingSockets == IntPtr.Zero)
            {
                return(false);
            }
            return(true);
        }