示例#1
0
        public SimitoneGame() : base()
        {
            GameFacade.Game            = this;
            ImageLoader.PremultiplyPNG = true;
            if (GameFacade.DirectX)
            {
                TimedReferenceController.SetMode(CacheType.PERMANENT);
            }
            Content.RootDirectory = FSOEnvironment.GFXContentDir;

            TargetElapsedTime          = new TimeSpan(10000000 / GlobalSettings.Default.TargetRefreshRate);
            FSOEnvironment.RefreshRate = GlobalSettings.Default.TargetRefreshRate;

            if (!FSOEnvironment.SoftwareKeyboard)
            {
                Graphics.SynchronizeWithVerticalRetrace = true;
                Graphics.PreferredBackBufferWidth       = GlobalSettings.Default.GraphicsWidth;
                Graphics.PreferredBackBufferHeight      = GlobalSettings.Default.GraphicsHeight;
                Graphics.HardwareModeSwitch             = false;
                Graphics.ApplyChanges();
            }

            this.Window.AllowUserResizing  = true;
            this.Window.ClientSizeChanged += new EventHandler <EventArgs>(Window_ClientSizeChanged);

            Thread.CurrentThread.Name = "Game";
        }
示例#2
0
文件: TSOGame.cs 项目: fourks/FreeSO
        public TSOGame() : base()
        {
            GameFacade.Game = this;
            if (GameFacade.DirectX)
            {
                TimedReferenceController.SetMode(CacheType.PERMANENT);
            }
            Content.RootDirectory = FSOEnvironment.GFXContentDir;
            Graphics.SynchronizeWithVerticalRetrace = true;

            Graphics.PreferredBackBufferWidth  = GlobalSettings.Default.GraphicsWidth;
            Graphics.PreferredBackBufferHeight = GlobalSettings.Default.GraphicsHeight;
            TargetElapsedTime          = new TimeSpan(10000000 / GlobalSettings.Default.TargetRefreshRate);
            FSOEnvironment.RefreshRate = GlobalSettings.Default.TargetRefreshRate;

            Graphics.HardwareModeSwitch = false;
            Graphics.ApplyChanges();

            this.Window.AllowUserResizing  = true;
            this.Window.ClientSizeChanged += new EventHandler <EventArgs>(Window_ClientSizeChanged);

            //might want to disable for linux
            Log.UseSensibleDefaults();

            Thread.CurrentThread.Name = "Game";
        }
示例#3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            TimedReferenceController.SetMode(CacheType.PERMANENT);

            try
            {
                var asm  = Assembly.LoadFile(Path.GetFullPath(@"FreeSO.exe"));
                var type = asm.GetType("FSO.Client.FSOProgram");
                FSOProgram          = Activator.CreateInstance(type) as IFSOProgram;
                type                = asm.GetType("FSO.Client.GameStartProxy");
                StartProxy          = Activator.CreateInstance(type) as IGameStartProxy;
                AssemblyUtils.Entry = asm;
            } catch (Exception)
            {
                try
                {
                    var asm  = Assembly.LoadFile(Path.GetFullPath(@"Simitone.exe"));
                    var type = asm.GetType("Simitone.Windows.FSOProgram");
                    FSOProgram = Activator.CreateInstance(type) as IFSOProgram;
                    type       = asm.GetType("Simitone.Windows.GameStartProxy");
                    StartProxy = Activator.CreateInstance(type) as IGameStartProxy;
                }
                catch (Exception e)
                {
                    MessageBox.Show("Failed to find FreeSO or Simitone. Ensure their binary files have the correct name! \r\n" + e.ToString());
                    return;
                }
            }

            if (!FSOProgram.InitWithArguments(args))
            {
                return;
            }
            (new VolcanicStartProxy()).Start();
        }
示例#4
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     TimedReferenceController.SetMode(CacheType.PERMANENT);
     if (!FSO.Client.Program.InitWithArguments(args))
     {
         return;
     }
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     (new VolcanicStartProxy()).Start();
 }
示例#5
0
        public int Run()
        {
            LOG.Info("Starting server");
            TimedReferenceController.SetMode(CacheType.PERMANENT);

            if (Config.Services == null)
            {
                LOG.Warn("No services found in the configuration file, exiting");
                return(1);
            }

            if (!Directory.Exists(Config.GameLocation))
            {
                LOG.Fatal("The directory specified as gameLocation in config.json does not exist");
                return(1);
            }

            Directory.CreateDirectory(Config.SimNFS);
            Directory.CreateDirectory(Path.Combine(Config.SimNFS, "Lots/"));
            Directory.CreateDirectory(Path.Combine(Config.SimNFS, "Objects/"));

            Content.Model.AbstractTextureRef.ImageFetchFunction = Utils.SoftwareImageLoader.SoftImageFetch;

            //TODO: Some content preloading
            LOG.Info("Scanning content");
            Content.Content.Init(Config.GameLocation, Content.ContentMode.SERVER);
            Kernel.Bind <Content.Content>().ToConstant(Content.Content.Get());
            VMContext.InitVMConfig();
            Kernel.Bind <MemoryCache>().ToConstant(new MemoryCache("fso_server"));

            LOG.Info("Loading domain logic");
            Kernel.Load <ServerDomainModule>();

            Servers     = new List <AbstractServer>();
            CityServers = new List <CityServer>();
            Kernel.Bind <IServerNFSProvider>().ToConstant(new ServerNFSProvider(Config.SimNFS));

            if (Config.Services.UserApi != null &&
                Config.Services.UserApi.Enabled)
            {
                var childKernel = new ChildKernel(
                    Kernel
                    );
                var api = new UserApi(Config, childKernel);
                ActiveUApiServer = api;
                Servers.Add(api);
                api.OnRequestShutdown       += RequestedShutdown;
                api.OnBroadcastMessage      += BroadcastMessage;
                api.OnRequestUserDisconnect += RequestedUserDisconnect;
                api.OnRequestMailNotify     += RequestedMailNotify;
            }

            foreach (var cityServer in Config.Services.Cities)
            {
                /**
                 * Need to create a kernel for each city server as there is some data they do not share
                 */
                var childKernel = new ChildKernel(
                    Kernel,
                    new ShardDataServiceModule(Config.SimNFS),
                    new CityServerModule()
                    );

                var city = childKernel.Get <CityServer>(new ConstructorArgument("config", cityServer));
                CityServers.Add(city);
                Servers.Add(city);
            }

            foreach (var lotServer in Config.Services.Lots)
            {
                if (lotServer.SimNFS == null)
                {
                    lotServer.SimNFS = Config.SimNFS;
                }
                var childKernel = new ChildKernel(
                    Kernel,
                    new LotServerModule()
                    );

                Servers.Add(
                    childKernel.Get <LotServer>(new ConstructorArgument("config", lotServer))
                    );
            }

            if (Config.Services.Tasks != null &&
                Config.Services.Tasks.Enabled)
            {
                var childKernel = new ChildKernel(
                    Kernel,
                    new TaskEngineModule()
                    );

                childKernel.Bind <TaskServerConfiguration>().ToConstant(Config.Services.Tasks);
                childKernel.Bind <TaskTuning>().ToConstant(Config.Services.Tasks.Tuning);

                var tasks = childKernel.Get <TaskServer>(new ConstructorArgument("config", Config.Services.Tasks));
                Servers.Add(tasks);
                ActiveTaskServer = tasks;
                Server.Servers.Tasks.Domain.ShutdownTask.ShutdownHook = RequestedShutdown;
            }

            foreach (var server in Servers)
            {
                server.OnInternalShutdown += ServerInternalShutdown;
            }

            Running = true;

            AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;
            AppDomain.CurrentDomain.ProcessExit  += CurrentDomain_ProcessExit;

            /*
             * NetworkDebugger debugInterface = null;
             *
             * if (Options.Debug)
             * {
             *  debugInterface = new NetworkDebugger(Kernel);
             *  foreach (AbstractServer server in Servers)
             *  {
             *      server.AttachDebugger(debugInterface);
             *  }
             * }
             */

            LOG.Info("Starting services");
            foreach (AbstractServer server in Servers)
            {
                server.Start();
            }

            HostPool.Start();

            //Hacky reference to maek sure the assembly is included
            FSO.Common.DatabaseService.Model.LoadAvatarByIDRequest x;

            /*if (debugInterface != null)
             * {
             *  Application.EnableVisualStyles();
             *  Application.Run(debugInterface);
             * }
             * else*/
            {
                while (Running)
                {
                    Thread.Sleep(1000);
                    lock (Servers)
                    {
                        if (Servers.Count == 0)
                        {
                            LOG.Info("All servers shut down, shutting down program...");

                            Kernel.Get <IGluonHostPool>().Stop();

                            /*var domain = AppDomain.CreateDomain("RebootApp");
                             *
                             * var assembly = "FSO.Server.Updater, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                             * var type = "FSO.Server.Updater.Program";
                             *
                             * var updater = typeof(FSO.Server.Updater.Program);
                             *
                             * domain.CreateInstance(assembly, type);
                             * AppDomain.Unload(AppDomain.CurrentDomain);*/
                            return(2 + (int)ShutdownMode);
                        }
                    }
                }
            }
            return(1);
        }
示例#6
0
        static void Main(string[] args)
        {
            FSO.Windows.Program.InitWindows();
            TimedReferenceController.SetMode(CacheType.PERMANENT);

            Console.WriteLine("Loading Config...");
            try
            {
                var configString = File.ReadAllText("facadeconfig.json");
                Config = Newtonsoft.Json.JsonConvert.DeserializeObject <FacadeConfig>(configString);
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not find configuration file 'facadeconfig.json'. Please ensure it is valid and present in the same folder as this executable.");
                return;
            }

            Console.WriteLine("Locating The Sims Online...");
            string baseDir = AppDomain.CurrentDomain.BaseDirectory;

            Directory.SetCurrentDirectory(baseDir);
            //Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

            OperatingSystem os  = Environment.OSVersion;
            PlatformID      pid = os.Platform;

            ILocator gameLocator;
            bool     linux = pid == PlatformID.MacOSX || pid == PlatformID.Unix;

            if (linux && Directory.Exists("/Users"))
            {
                gameLocator = new MacOSLocator();
            }
            else if (linux)
            {
                gameLocator = new LinuxLocator();
            }
            else
            {
                gameLocator = new WindowsLocator();
            }

            bool useDX = true;

            FSOEnvironment.Enable3D    = true;
            GameThread.NoGame          = true;
            GameThread.UpdateExecuting = true;

            var path = gameLocator.FindTheSimsOnline();

            if (path != null)
            {
                FSOEnvironment.ContentDir    = "Content/";
                FSOEnvironment.GFXContentDir = "Content/" + (useDX ? "DX/" : "OGL/");
                FSOEnvironment.Linux         = linux;
                FSOEnvironment.DirectX       = useDX;
                FSOEnvironment.GameThread    = Thread.CurrentThread;

                FSO.HIT.HITVM.Init();
                FSO.HIT.HITVM.Get().SetMasterVolume(FSO.HIT.Model.HITVolumeGroup.AMBIENCE, 0);
                FSO.HIT.HITVM.Get().SetMasterVolume(FSO.HIT.Model.HITVolumeGroup.FX, 0);
                FSO.HIT.HITVM.Get().SetMasterVolume(FSO.HIT.Model.HITVolumeGroup.MUSIC, 0);
                FSO.HIT.HITVM.Get().SetMasterVolume(FSO.HIT.Model.HITVolumeGroup.VOX, 0);
                FSO.Files.Formats.IFF.Chunks.STR.DefaultLangCode = FSO.Files.Formats.IFF.Chunks.STRLangCode.EnglishUS;
            }

            Console.WriteLine("Creating Graphics Device...");
            var gds = new GraphicsDeviceServiceMock();
            var gd  = gds.GraphicsDevice;

            //set up some extra stuff like the content manager
            var services = new GameServiceContainer();
            var content  = new ContentManager(services);

            content.RootDirectory = FSOEnvironment.GFXContentDir;
            services.AddService <IGraphicsDeviceService>(gds);

            var vitaboyEffect = content.Load <Effect>("Effects/Vitaboy");

            FSO.Vitaboy.Avatar.setVitaboyEffect(vitaboyEffect);

            WorldConfig.Current = new WorldConfig()
            {
                LightingMode    = 3,
                SmoothZoom      = true,
                SurroundingLots = 0
            };
            DGRP3DMesh.Sync = true;

            Console.WriteLine("Looks like that worked. Loading FSO Content!");
            VMContext.InitVMConfig(false);
            Content.Init(path, gd);
            WorldContent.Init(services, content.RootDirectory);
            VMAmbientSound.ForceDisable = true;
            Layer = new _3DLayer();
            Layer.Initialize(gd);
            GD = gd;

            Console.WriteLine("Starting Worker Loop!");
            WorkerLoop();

            Console.WriteLine("Exiting.");
            GameThread.Killed = true;
            GameThread.OnKilled.Set();
            gds.Release();
        }
示例#7
0
        static void Main(string[] args)
        {
            FSO.Windows.Program.InitWindows();
            TimedReferenceController.SetMode(CacheType.PERMANENT);

            Console.WriteLine("Loading Config...");
            _config = FacadeConfig.Default;

            Console.WriteLine("Locating The Sims Online...");
            string baseDir = AppDomain.CurrentDomain.BaseDirectory;

            Directory.SetCurrentDirectory(baseDir);
            //Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

            var os    = Environment.OSVersion;
            var pid   = os.Platform;
            var linux = pid == PlatformID.MacOSX || pid == PlatformID.Unix;

            bool useDX = true;

            FSOEnvironment.Enable3D    = false;
            GameThread.NoGame          = true;
            GameThread.UpdateExecuting = true;

            var path = Pathfinder.GamePath;

            if (path != null)
            {
                FSOEnvironment.ContentDir    = "Content/";
                FSOEnvironment.GFXContentDir = "Content/" + (useDX ? "DX/" : "OGL/");
                FSOEnvironment.Linux         = linux;
                FSOEnvironment.DirectX       = useDX;
                FSOEnvironment.GameThread    = Thread.CurrentThread;

                FSO.HIT.HITVM.Init();
                FSO.HIT.HITVM.Get.SetMasterVolume(FSO.HIT.Model.HITVolumeGroup.AMBIENCE, 0);
                FSO.HIT.HITVM.Get.SetMasterVolume(FSO.HIT.Model.HITVolumeGroup.FX, 0);
                FSO.HIT.HITVM.Get.SetMasterVolume(FSO.HIT.Model.HITVolumeGroup.MUSIC, 0);
                FSO.HIT.HITVM.Get.SetMasterVolume(FSO.HIT.Model.HITVolumeGroup.VOX, 0);
                FSO.Files.Formats.IFF.Chunks.STR.DefaultLangCode = FSO.Files.Formats.IFF.Chunks.STRLangCode.EnglishUS;
            }

            Console.WriteLine("Creating Graphics Device...");
            var gds = new GraphicsDeviceServiceMock();
            var gd  = gds.GraphicsDevice;

            //set up some extra stuff like the content manager
            var services = new GameServiceContainer();
            var content  = new ContentManager(services)
            {
                RootDirectory = FSOEnvironment.GFXContentDir
            };

            services.AddService <IGraphicsDeviceService>(gds);

            var vitaboyEffect = content.Load <Effect>("Effects/Vitaboy");

            FSO.Vitaboy.Avatar.setVitaboyEffect(vitaboyEffect);

            WorldConfig.Current = new WorldConfig()
            {
                LightingMode    = 3,
                SmoothZoom      = true,
                SurroundingLots = 0
            };
            DGRP3DMesh.Sync = true;

            Console.WriteLine("Looks like that worked. Loading FSO Content!");
            // VMContext.InitVMConfig(false);
            // Content.Init(path, gd);
            WorldContent.Init(services, content.RootDirectory);
            // VMAmbientSound.ForceDisable = true;
            _layer = new _3DLayer();
            _layer.Initialize(gd);
            _gd = gd;

            Console.WriteLine("Starting Worker Loop!");
            WorkerLoop();

            Console.WriteLine("Exiting.");
            GameThread.Killed = true;
            GameThread.OnKilled.Set();
            gds.Release();
        }