示例#1
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();
        }
示例#2
0
        public void CleanupLastWorld()
        {
            if (vm == null)
            {
                return;
            }

            //clear our cache too, if the setting lets us do that
            TimedReferenceController.Clear();
            TimedReferenceController.Clear();

            vm.Context.Ambience.Kill();
            foreach (var ent in vm.Entities)
            { //stop object sounds
                var threads = ent.SoundThreads;
                for (int i = 0; i < threads.Count; i++)
                {
                    threads[i].Sound.RemoveOwner(ent.ObjectID);
                }
                threads.Clear();
            }
            vm.CloseNet(VMCloseNetReason.LeaveLot);
            GameFacade.Scenes.Remove(World);
            World.Dispose();
            vm.SuppressBHAVChanges();
            vm     = null;
            World  = null;
            Driver = null;
        }
示例#3
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";
        }
示例#4
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";
        }
示例#5
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();
 }
示例#6
0
文件: SPR2.cs 项目: fourks/FreeSO
        private Texture2D GetZTexture(GraphicsDevice device, bool onlyThis)
        {
            Texture2D result = null;

            if (ContainsNothing || ContainsNoZ)
            {
                return(null);
            }
            if (!ZCache.TryGetTarget(out result) || ((CachableTexture2D)result).BeingDisposed || result.IsDisposed)
            {
                DecodeIfRequired(true);
                if (this.Width == 0 || this.Height == 0)
                {
                    ContainsNothing = true;
                    return(null);
                }
                if (ZBufferData == null)
                {
                    ContainsNoZ = true;
                    return(null);
                }
                result = new CachableTexture2D(device, this.Width, this.Height, false, SurfaceFormat.Alpha8);
                result.SetData <byte>(this.ZBufferData);
                ZCache = new WeakReference <Texture2D>(result);
                if (TimedReferenceController.CurrentType == CacheType.PERMANENT)
                {
                    PermaRefZ = result;
                }
                if (!IffFile.RETAIN_CHUNK_DATA)
                {
                    ZBufferData = null;
                    if (onlyThis)
                    {
                        PixelData = null;
                    }
                }
            }
            if (TimedReferenceController.CurrentType != CacheType.PERMANENT)
            {
                TimedReferenceController.KeepAlive(result, KeepAliveType.ACCESS);
            }
            return(result);
        }
示例#7
0
        private Texture2D GetTexture(GraphicsDevice device, bool onlyThis)
        {
            if (ContainsNothing)
            {
                return(null);
            }
            Texture2D result = null;

            if (!PixelCache.TryGetTarget(out result) || ((CachableTexture2D)result).BeingDisposed || result.IsDisposed)
            {
                DecodeIfRequired(false);
                if (this.Width == 0 || this.Height == 0)
                {
                    ContainsNothing = true;
                    return(null);
                }
                var mip = FSOEnvironment.Enable3D && (FSOEnvironment.EnableNPOTMip || (Width == 128 && Height == 64));
                result = new CachableTexture2D(device, this.Width, this.Height, mip, SurfaceFormat.Color);
                if (mip)
                {
                    TextureUtils.UploadWithMips(result, device, this.PixelData);
                }
                else
                {
                    result.SetData <Color>(this.PixelData);
                }
                PixelCache = new WeakReference <Texture2D>(result);
                if (TimedReferenceController.CurrentType == CacheType.PERMANENT)
                {
                    PermaRefP = result;
                }
                if (!IffFile.RETAIN_CHUNK_DATA)
                {
                    PixelData = null;
                    //if (onlyThis && !FSOEnvironment.Enable3D) ZBufferData = null;
                }
            }
            if (TimedReferenceController.CurrentType != CacheType.PERMANENT)
            {
                TimedReferenceController.KeepAlive(result, KeepAliveType.ACCESS);
            }
            return(result);
        }
示例#8
0
        public void CleanupLastWorld()
        {
            if (vm == null)
            {
                return;
            }

            //clear our cache too, if the setting lets us do that
            DiscordRpcEngine.SendFSOPresence(gizmo.CurrentAvatar.Value.Avatar_Name, null, 0, 0, 0, 0, gizmo.CurrentAvatar.Value.Avatar_PrivacyMode > 0);
            TimedReferenceController.Clear();
            TimedReferenceController.Clear();

            if (ZoomLevel < 4)
            {
                ZoomLevel = 5;
            }
            vm.Context.Ambience.Kill();
            foreach (var ent in vm.Entities)   //stop object sounds
            {
                var threads = ent.SoundThreads;
                for (int i = 0; i < threads.Count; i++)
                {
                    threads[i].Sound.RemoveOwner(ent.ObjectID);
                }
                threads.Clear();
            }
            vm.CloseNet(VMCloseNetReason.LeaveLot);
            Driver.OnClientCommand -= VMSendCommand;
            GameFacade.Scenes.Remove(World);
            World.Dispose();
            LotControl.Dispose();
            this.Remove(LotControl);
            ucp.SetPanel(-1);
            ucp.SetInLot(false);
            vm.SuppressBHAVChanges();
            vm         = null;
            World      = null;
            Driver     = null;
            LotControl = null;
            CityRenderer.DisposeOnLot();
        }
示例#9
0
        public void CleanupLastWorld()
        {
            if (vm == null)
            {
                return;
            }

            //clear our cache too, if the setting lets us do that
            TimedReferenceController.Clear();
            TimedReferenceController.Clear();
            VM.ClearAssembled();

            vm.Context.Ambience.Kill();
            foreach (var ent in vm.Entities)
            { //stop object sounds
                var threads = ent.SoundThreads;
                for (int i = 0; i < threads.Count; i++)
                {
                    threads[i].Sound.RemoveOwner(ent.ObjectID);
                }
                threads.Clear();
            }
            vm.CloseNet(VMCloseNetReason.LeaveLot);
            //Driver.OnClientCommand -= VMSendCommand;
            GameFacade.Scenes.Remove(World);
            World.Dispose();
            LotControl.Dispose();
            this.Remove(LotControl);
            ucp.SetPanel(-1);
            ucp.SetInLot(false);
            vm.SuppressBHAVChanges();
            vm         = null;
            World      = null;
            Driver     = null;
            LotControl = null;

            SandServer?.Shutdown();
            SandCli?.Disconnect();
            SandServer = null;
            SandCli    = null;
        }
示例#10
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);
        }
示例#11
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();
        }
示例#12
0
文件: SPR2.cs 项目: thertzelle/FreeSO
        private Texture2D GetZTexture(GraphicsDevice device, bool onlyThis)
        {
            Texture2D result = null;

            if (ContainsNothing || ContainsNoZ)
            {
                return(null);
            }
            if (!ZCache.TryGetTarget(out result) || ((CachableTexture2D)result).BeingDisposed || result.IsDisposed)
            {
                DecodeIfRequired(true);
                if (this.Width == 0 || this.Height == 0)
                {
                    ContainsNothing = true;
                    return(null);
                }
                if (ZBufferData == null)
                {
                    ContainsNoZ = true;
                    return(null);
                }
                if (FSOEnvironment.TexCompress)
                {
                    result = new CachableTexture2D(device, ((Width + 3) / 4) * 4, ((Height + 3) / 4) * 4, false, SurfaceFormat.Alpha8);
                    var tempZ = new byte[result.Width * result.Height];
                    var dind  = 0;
                    var sind  = 0;
                    for (int i = 0; i < Height; i++)
                    {
                        Array.Copy(ZBufferData, sind, tempZ, dind, Width);
                        sind += Width;
                        dind += result.Width;
                    }

                    result.SetData <byte>(tempZ);
                }
                else
                {
                    result = new CachableTexture2D(device, this.Width, this.Height, false, SurfaceFormat.Alpha8);
                    result.SetData <byte>(this.ZBufferData);
                }
                ZCache = new WeakReference <Texture2D>(result);
                if (TimedReferenceController.CurrentType == CacheType.PERMANENT)
                {
                    PermaRefZ = result;
                }
                if (!IffFile.RETAIN_CHUNK_DATA)
                {
                    //if (!FSOEnvironment.Enable3D) ZBufferData = null; disabled right now til we get a clean way of getting this post-world-texture for ultra lighting
                    if (onlyThis)
                    {
                        PixelData = null;
                    }
                }
            }
            if (TimedReferenceController.CurrentType != CacheType.PERMANENT)
            {
                TimedReferenceController.KeepAlive(result, KeepAliveType.ACCESS);
            }
            return(result);
        }
示例#13
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();
        }