Ejemplo n.º 1
0
        internal static void Initialize(Arguments args)
        {
            Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);

            AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;

            Settings = new Settings(Platform.SupportDir + "settings.yaml", args);
            Settings.Save();

            Log.LogPath = Platform.SupportDir + "Logs" + Path.DirectorySeparatorChar;
            Log.AddChannel("perf", "perf.log");
            Log.AddChannel("debug", "debug.log");
            Log.AddChannel("sync", "syncreport.log");

            FileSystem.Mount(".");             // Needed to access shaders
            Renderer.Initialize(Game.Settings.Graphics.Mode);
            Renderer = new Renderer();

            Console.WriteLine("Available mods:");
            foreach (var mod in Mod.AllMods)
            {
                Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
            }

            Sound.Create(Settings.Sound.Engine);
            InitializeWithMods(Settings.Game.Mods);
        }
Ejemplo n.º 2
0
        internal static void Initialize(Arguments args)
        {
            Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);

            AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;

            Settings = new Settings(Platform.SupportDir + "settings.yaml", args);

            Log.LogPath = Platform.SupportDir + "Logs" + Path.DirectorySeparatorChar;
            Log.AddChannel("perf", "perf.log");
            Log.AddChannel("debug", "debug.log");
            Log.AddChannel("sync", "syncreport.log");
            Log.AddChannel("server", "server.log");
            Log.AddChannel("sound", "sound.log");

            if (Settings.Server.DiscoverNatDevices)
            {
                UPnP.TryNatDiscovery();
            }
            else
            {
                Settings.Server.NatDeviceAvailable = false;
                Settings.Server.AllowPortForward   = false;
            }

            FileSystem.Mount(".");             // Needed to access shaders
            Renderer.Initialize(Game.Settings.Graphics.Mode);
            Renderer = new Renderer();

            Console.WriteLine("Available mods:");
            foreach (var mod in Mod.AllMods)
            {
                Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
            }

            Sound.Create(Settings.Sound.Engine);
            InitializeWithMods(Settings.Game.Mods);

            if (Settings.Server.DiscoverNatDevices)
            {
                RunAfterDelay(Settings.Server.NatDiscoveryTimeout, () =>
                              UPnP.TryStoppingNatDiscovery()
                              );
            }
        }
Ejemplo n.º 3
0
        internal static void Initialize(Arguments args)
        {
            Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);

            AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly;

            InitializeSettings(args);

            Log.AddChannel("perf", "perf.log");
            Log.AddChannel("debug", "debug.log");
            Log.AddChannel("sync", "syncreport.log");
            Log.AddChannel("server", "server.log");
            Log.AddChannel("sound", "sound.log");
            Log.AddChannel("graphics", "graphics.log");
            Log.AddChannel("geoip", "geoip.log");

            if (Settings.Server.DiscoverNatDevices)
            {
                UPnP.TryNatDiscovery();
            }
            else
            {
                Settings.Server.NatDeviceAvailable = false;
                Settings.Server.AllowPortForward   = false;
            }

            try
            {
                GeoIpDatabase = new DatabaseReader("GeoLite2-Country.mmdb");
            }
            catch (Exception e)
            {
                Log.Write("geoip", "DatabaseReader failed: {0}", e);
            }

            GlobalFileSystem.Mount(Platform.GameDir);             // Needed to access shaders
            var renderers = new[] { Settings.Graphics.Renderer, "Sdl2", null };

            foreach (var r in renderers)
            {
                if (r == null)
                {
                    throw new InvalidOperationException("No suitable renderers were found. Check graphics.log for details.");
                }

                Settings.Graphics.Renderer = r;
                try
                {
                    Renderer = new Renderer(Settings.Graphics, Settings.Server);
                    break;
                }
                catch (Exception e)
                {
                    Log.Write("graphics", "{0}", e);
                    Console.WriteLine("Renderer initialization failed. Fallback in place. Check graphics.log for details.");
                }
            }

            try
            {
                Sound.Create(Settings.Sound.Engine);
            }
            catch (Exception e)
            {
                Log.Write("sound", "{0}", e);
                Console.WriteLine("Creating the sound engine failed. Fallback in place. Check sound.log for details.");
                Settings.Sound.Engine = "Null";
                Sound.Create(Settings.Sound.Engine);
            }

            Console.WriteLine("Available mods:");
            foreach (var mod in ModMetadata.AllMods)
            {
                Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
            }

            InitializeMod(Settings.Game.Mod, args);

            if (Settings.Server.DiscoverNatDevices)
            {
                RunAfterDelay(Settings.Server.NatDiscoveryTimeout, UPnP.StoppingNatDiscovery);
            }
        }
Ejemplo n.º 4
0
        internal static void Initialize(Arguments args)
        {
            Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);

            AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;

            Settings = new Settings(Platform.SupportDir + "settings.yaml", args);

            Log.LogPath = Platform.SupportDir + "Logs" + Path.DirectorySeparatorChar;
            Log.AddChannel("perf", "perf.log");
            Log.AddChannel("debug", "debug.log");
            Log.AddChannel("sync", "syncreport.log");
            Log.AddChannel("server", "server.log");
            Log.AddChannel("sound", "sound.log");
            Log.AddChannel("graphics", "graphics.log");

            if (Settings.Server.DiscoverNatDevices)
            {
                UPnP.TryNatDiscovery();
            }
            else
            {
                Settings.Server.NatDeviceAvailable = false;
                Settings.Server.AllowPortForward   = false;
            }

            FileSystem.Mount(".");             // Needed to access shaders
            var renderers = new[] { Settings.Graphics.Renderer, "Sdl2", "Gl", "Cg", null };

            foreach (var r in renderers)
            {
                if (r == null)
                {
                    throw new InvalidOperationException("No suitable renderers were found. Check graphics.log for details.");
                }

                Settings.Graphics.Renderer = r;
                try
                {
                    Renderer.Initialize(Settings.Graphics.Mode);
                    break;
                }
                catch (Exception e)
                {
                    Log.Write("graphics", "{0}", e);
                    Console.WriteLine("Renderer initialization failed. Fallback in place. Check graphics.log for details.");
                }
            }

            Renderer = new Renderer();

            try
            {
                Sound.Create(Settings.Sound.Engine);
            }
            catch (Exception e)
            {
                Log.Write("sound", "{0}", e);
                Console.WriteLine("Creating the sound engine failed. Fallback in place. Check sound.log for details.");
                Settings.Sound.Engine = "Null";
                Sound.Create(Settings.Sound.Engine);
            }

            Console.WriteLine("Available mods:");
            foreach (var mod in Mod.AllMods)
            {
                Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
            }

            InitializeWithMod(Settings.Game.Mod);

            if (Settings.Server.DiscoverNatDevices)
            {
                RunAfterDelay(Settings.Server.NatDiscoveryTimeout, UPnP.TryStoppingNatDiscovery);
            }
        }