Example #1
0
    public static IEnumerator StartServer(bool doLoad, string saveFileOverride, bool allowOutOfDateSaves)
    {
        float timeScale = UnityEngine.Time.timeScale;

        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = 0f;
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if ((bool)SingletonComponent <WorldSetup> .Instance)
        {
            yield return(SingletonComponent <WorldSetup> .Instance.StartCoroutine(SingletonComponent <WorldSetup> .Instance.InitCoroutine()));
        }
        if ((bool)SingletonComponent <DynamicNavMesh> .Instance && SingletonComponent <DynamicNavMesh> .Instance.enabled && !AiManager.nav_disable)
        {
            yield return(SingletonComponent <DynamicNavMesh> .Instance.StartCoroutine(SingletonComponent <DynamicNavMesh> .Instance.UpdateNavMeshAndWait()));
        }
        if ((bool)SingletonComponent <AiManager> .Instance && SingletonComponent <AiManager> .Instance.enabled)
        {
            SingletonComponent <AiManager> .Instance.Initialize();

            if (!AiManager.nav_disable && AI.npc_enable && TerrainMeta.Path != null)
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (monument.HasNavmesh)
                    {
                        yield return(monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                    }
                }
                if ((bool)TerrainMeta.Path && (bool)TerrainMeta.Path.DungeonRoot)
                {
                    DungeonNavmesh dungeonNavmesh = TerrainMeta.Path.DungeonRoot.AddComponent <DungeonNavmesh>();
                    dungeonNavmesh.NavMeshCollectGeometry = NavMeshCollectGeometry.PhysicsColliders;
                    dungeonNavmesh.LayerMask = 65537;
                    yield return(dungeonNavmesh.StartCoroutine(dungeonNavmesh.UpdateNavMeshAndWait()));
                }
                else
                {
                    Debug.LogError("Failed to find DungeonRoot, NOT generating Dungeon navmesh");
                }
            }
        }
        GameObject gameObject = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab");

        Object.DontDestroyOnLoad(gameObject);
        ServerMgr serverMgr = gameObject.GetComponent <ServerMgr>();

        serverMgr.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves);
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        BaseGameMode.CreateGameMode();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        serverMgr.OpenConnection();
        CompanionServer.Server.Initialize();
        using (BenchmarkTimer.New("Boombox.LoadStations"))
        {
            BoomBox.LoadStations();
        }
        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = timeScale;
        }
        WriteToLog("Server startup complete");
    }
Example #2
0
    private IEnumerator Start()
    {
        WriteToLog("Bootstrap Startup");
        BenchmarkTimer.Enabled = Facepunch.Utility.CommandLine.Full.Contains("+autobench");
        BenchmarkTimer timer = BenchmarkTimer.New("bootstrap");

        if (!UnityEngine.Application.isEditor)
        {
            ExceptionReporter.InitializeFromUrl("https://*****:*****@sentry.io/51080");
            ExceptionReporter.Disabled = !Facepunch.Utility.CommandLine.Full.Contains("-official") && !Facepunch.Utility.CommandLine.Full.Contains("-server.official") && !Facepunch.Utility.CommandLine.Full.Contains("+official") && !Facepunch.Utility.CommandLine.Full.Contains("+server.official");
            BuildInfo current = BuildInfo.Current;
            if (current.Scm.Branch != null && current.Scm.Branch.StartsWith("main"))
            {
                ExceptionReporter.InitializeFromUrl("https://*****:*****@sentry.io/1836389");
                ExceptionReporter.Disabled = false;
            }
        }
        if (AssetBundleBackend.Enabled)
        {
            AssetBundleBackend newBackend = new AssetBundleBackend();
            using (BenchmarkTimer.New("bootstrap;bundles"))
            {
                yield return(StartCoroutine(LoadingUpdate("Opening Bundles")));

                newBackend.Load("Bundles/Bundles");
                FileSystem.Backend = newBackend;
            }
            if (FileSystem.Backend.isError)
            {
                ThrowError(FileSystem.Backend.loadingError);
                yield break;
            }
            using (BenchmarkTimer.New("bootstrap;bundlesindex"))
            {
                newBackend.BuildFileIndex();
            }
        }
        if (FileSystem.Backend.isError)
        {
            ThrowError(FileSystem.Backend.loadingError);
            yield break;
        }
        if (!UnityEngine.Application.isEditor)
        {
            WriteToLog(SystemInfoGeneralText.currentInfo);
        }
        UnityEngine.Texture.SetGlobalAnisotropicFilteringLimits(1, 16);
        if (isErrored)
        {
            yield break;
        }
        using (BenchmarkTimer.New("bootstrap;gamemanifest"))
        {
            yield return(StartCoroutine(LoadingUpdate("Loading Game Manifest")));

            GameManifest.Load();
            yield return(StartCoroutine(LoadingUpdate("DONE!")));
        }
        using (BenchmarkTimer.New("bootstrap;selfcheck"))
        {
            yield return(StartCoroutine(LoadingUpdate("Running Self Check")));

            SelfCheck.Run();
        }
        if (isErrored)
        {
            yield break;
        }
        yield return(StartCoroutine(LoadingUpdate("Bootstrap Tier0")));

        using (BenchmarkTimer.New("bootstrap;tier0"))
        {
            Init_Tier0();
        }
        using (BenchmarkTimer.New("bootstrap;commandlinevalues"))
        {
            ConsoleSystem.UpdateValuesFromCommandLine();
        }
        yield return(StartCoroutine(LoadingUpdate("Bootstrap Systems")));

        using (BenchmarkTimer.New("bootstrap;init_systems"))
        {
            Init_Systems();
        }
        yield return(StartCoroutine(LoadingUpdate("Bootstrap Config")));

        using (BenchmarkTimer.New("bootstrap;init_config"))
        {
            Init_Config();
        }
        if (!isErrored)
        {
            yield return(StartCoroutine(LoadingUpdate("Loading Items")));

            using (BenchmarkTimer.New("bootstrap;itemmanager"))
            {
                ItemManager.Initialize();
            }
            if (!isErrored)
            {
                yield return(StartCoroutine(DedicatedServerStartup()));

                timer?.Dispose();
                GameManager.Destroy(base.gameObject);
            }
        }
    }