예제 #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);
            }

            return(true);
        }