Пример #1
0
        static void Main(string[] args)
        {
            SpaceEngineersGame.SetupBasicGameInfo();
            SpaceEngineersGame.SetupPerGameSettings();

            MyPerGameSettings.SendLogToKeen = DedicatedServer.SendLogToKeen;

            MyPerServerSettings.GameName          = MyPerGameSettings.GameName;
            MyPerServerSettings.GameNameSafe      = MyPerGameSettings.GameNameSafe;
            MyPerServerSettings.GameDSName        = MyPerServerSettings.GameNameSafe + "Dedicated";
            MyPerServerSettings.GameDSDescription = "Your place for space engineering, destruction and exploring.";

            MySessionComponentExtDebug.ForceDisable = true;

            MyPerServerSettings.AppId = 244850;

            ConfigForm <MyObjectBuilder_SessionSettings> .LogoImage      = SpaceEngineersDedicated.Properties.Resources.SpaceEngineersDSLogo;
            ConfigForm <MyObjectBuilder_SessionSettings> .GameAttributes = Game.SpaceEngineers;
            ConfigForm <MyObjectBuilder_SessionSettings> .OnReset        = delegate
            {
                SpaceEngineersGame.SetupBasicGameInfo();
                SpaceEngineersGame.SetupPerGameSettings();
            };
            MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion;

            DedicatedServer.Run <MyObjectBuilder_SessionSettings>(args);
        }
Пример #2
0
    public void Update()
    {
        if (base.networkView.isMine)
        {
            DedicatedServer.CheckPlayer(base.networkView.owner, "NetworkInterpolation @Update");

            this.position = base.transform.position;
            this.rotation = base.transform.rotation;

            if ((double)Mathf.Abs(this.position.x - this.lastPosition.x) > 0.2 || (double)Mathf.Abs(this.position.y - this.lastPosition.y) > 0.2 || (double)Mathf.Abs(this.position.z - this.lastPosition.z) > 0.2)
            {
                this.lastPosition = this.position;
                base.networkView.RPC("tellPosition", RPCMode.Others, new object[] { this.position });
            }

            if (Mathf.Abs(this.rotation.eulerAngles.x - this.lastRotation.eulerAngles.x) > 5f || Mathf.Abs(this.rotation.eulerAngles.y - this.lastRotation.eulerAngles.y) > 5f || Mathf.Abs(this.rotation.eulerAngles.z - this.lastRotation.eulerAngles.z) > 5f)
            {
                this.lastRotation = this.rotation;
                base.networkView.RPC("tellRotation", RPCMode.Others, new object[] { this.rotation });
            }
        }
        else if (base.transform.parent != null && base.transform.parent.name == "models")
        {
            this.lastPosition = base.transform.position;
            this.lastRotation = base.transform.rotation;
            if ((double)Mathf.Abs(this.position.x - this.lastPosition.x) > 0.2 || (double)Mathf.Abs(this.position.y - this.lastPosition.y) > 0.2 || (double)Mathf.Abs(this.position.z - this.lastPosition.z) > 0.2 || Mathf.Abs(this.rotation.eulerAngles.x - this.lastRotation.eulerAngles.x) > 5f || Mathf.Abs(this.rotation.eulerAngles.y - this.lastRotation.eulerAngles.y) > 5f || Mathf.Abs(this.rotation.eulerAngles.z - this.lastRotation.eulerAngles.z) > 5f)
            {
                base.transform.position = Vector3.Lerp(this.lastPosition, this.position, (float)NetworkInterpolation.INTERPOLATION_RATE * Time.deltaTime);
                base.transform.rotation = Quaternion.Lerp(this.lastRotation, this.rotation, (float)NetworkInterpolation.INTERPOLATION_RATE * Time.deltaTime);
            }
        }
    }
Пример #3
0
    public void askAllPlayer(NetworkPlayer player)
    {
        if (!DedicatedServer.CheckPlayer(player, "Player.cs @askAllPlayer"))
        {
            return;
        }

        StartCoroutine("introduceSelf", player);
    }
Пример #4
0
 public void Dispose()
 {
     Stop();
     spring.UnsubscribeEvents(this);
     pollTimer.Dispose();
     pollTimer  = null;
     spring     = null;
     ActivePoll = null;
 }
Пример #5
0
        private void SetupSpring()
        {
            spring?.UnsubscribeEvents(this);

            spring = new DedicatedServer(server.SpringPaths);

            spring.DedicatedServerExited += DedicatedServerExited;

            spring.DedicatedServerStarted += DedicatedServerStarted;
            spring.PlayerSaid             += spring_PlayerSaid;
            spring.BattleStarted          += spring_BattleStarted;
        }
Пример #6
0
        /// <summary>
        /// Start server on the current thread.
        /// </summary>
        public void Start()
        {
            IsRunning = true;
            Logger.Write("Starting server.");

            if (MySandboxGame.Log.LogEnabled)
            {
                MySandboxGame.Log.Close();
            }

            DedicatedServer.Run <MyObjectBuilder_SessionSettings>(RunArgs);
        }
Пример #7
0
 public void Dispose()
 {
     spring.UnsubscribeEvents(this);
     if (pollTimer != null)
     {
         pollTimer.Enabled = false;
     }
     pollTimer?.Dispose();
     pollTimer  = null;
     spring     = null;
     ActivePoll = null;
 }
Пример #8
0
        // Host_GetConsoleCommands
        //
        // Add them exactly as if they had been typed at the console
        private void GetConsoleCommands( )
        {
            while (true)
            {
                var cmd = DedicatedServer.ConsoleInput( );

                if (String.IsNullOrEmpty(cmd))
                {
                    break;
                }

                Commands.Buffer.Append(cmd);
            }
        }
            public IEnumerator LoginTestUser()
            {
                var    user            = AccelBytePlugin.GetUser();
                Result userLoginResult = null;

                user.LoginWithDeviceId(result => { userLoginResult = result; });

                while (userLoginResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }

                TestHelper.Assert.IsTrue(!userLoginResult.IsError, "User cannot login.");

                TestVariables.userId = user.Session.UserId;

                TestHelper         testHelper     = new TestHelper();
                Result <TokenData> getAccessToken = null;

                testHelper.GetAccessToken(result => { getAccessToken = result; });

                while (getAccessToken == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getAccessToken.IsError, "Cannot get access token.");

                TestVariables.accessToken = getAccessToken.Value.access_token;

                DedicatedServer server      = AccelByteServerPlugin.GetDedicatedServer();
                Result          loginResult = null;

                server.LoginWithClientCredentials(result => loginResult = result);

                while (loginResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!loginResult.IsError, "Server cannot login.");
            }
Пример #10
0
        public Host(MainWindow window)
        {
            MainWindow = window;
            Cvars      = new Cvars();

            // Factories
            Commands = AddFactory <CommandFactory>( );
            CVars    = AddFactory <ClientVariableFactory>( );

            Commands.Initialise(CVars);

            // Old
            Cache = new Cache( );
            //CommandBuffer = new CommandBuffer( this );
            //Command = new Command( this );
            //CVar.Initialise( Command );
            View            = new View(this);
            ChaseView       = new ChaseView(this);
            GfxWad          = new Wad( );
            Keyboard        = new Keyboard(this);
            Console         = new Con(this);
            Menu            = new Menu(this);
            Programs        = new Programs(this);
            ProgramsBuiltIn = new ProgramsBuiltIn(this);
            Model           = new Mod(this);
            Network         = new Network(this);
            Server          = new server(this);
            Client          = new client(this);
            Video           = new Vid(this);
            DrawingContext  = new Drawer(this);
            Screen          = new Scr(this);
            RenderContext   = new render(this);
            Sound           = new snd(this);
            CDAudio         = new cd_audio(this);
            Hud             = new Hud(this);
            DedicatedServer = new DedicatedServer( );

            WadFiles    = new Dictionary <String, Wad>( );
            WadTextures = new Dictionary <String, String>( );
        }
Пример #11
0
    public void loadPositionFromSerial(NetworkPlayer player, string serial)
    {
        if (serial != string.Empty)
        {
            string[] strArrays = Packer.unpack(serial, ';');
            Vector3  vector3   = new Vector3(float.Parse(strArrays[0]), float.Parse(strArrays[1]), float.Parse(strArrays[2]));

            DedicatedServer.CheckPlayer(player, "SpawnPlayers.cs @loadPositionFromSerial");

            if (player != Network.player)
            {
                base.networkView.RPC("tellPosition", player, new object[] { vector3, float.Parse(strArrays[3]) });
            }
            else
            {
                this.tellPosition(vector3, float.Parse(strArrays[3]));
            }
        }
        else
        {
            Transform spawnPoint = SpawnPlayers.getSpawnPoint(player, true);
            if (player != Network.player)
            {
                NetworkView networkView = base.networkView;
                object[]    objArray    = new object[] { spawnPoint.position, null };
                Vector3     vector31    = spawnPoint.rotation.eulerAngles;
                objArray[1] = vector31.y + 90f;
                networkView.RPC("tellPosition", player, objArray);
            }
            else
            {
                Vector3 vector32 = spawnPoint.position;
                Vector3 vector33 = spawnPoint.rotation.eulerAngles;
                this.tellPosition(vector32, vector33.y + 90f);
            }
        }
    }
Пример #12
0
        static void Main(string[] args)
        {
            SpaceEngineersGame.SetupPerGameSettings();

            MyPerGameSettings.SendLogToKeen = DedicatedServer.SendLogToKeen;

            MyPerServerSettings.GameName          = MyPerGameSettings.GameName;
            MyPerServerSettings.GameNameSafe      = MyPerGameSettings.GameNameSafe;
            MyPerServerSettings.GameDSName        = MyPerServerSettings.GameNameSafe + "Dedicated";
            MyPerServerSettings.GameDSDescription = "Your place for space engineering, destruction and exploring.";


            MyPerServerSettings.AppId = 244850;

            ConfigForm <MyObjectBuilder_SessionSettings> .LogoImage      = SpaceEngineersDedicated.Properties.Resources.SpaceEngineersDSLogo;
            ConfigForm <MyObjectBuilder_SessionSettings> .GameAttributes = Game.SpaceEngineers;
            ConfigForm <MyObjectBuilder_SessionSettings> .OnReset        = delegate
            {
                SpaceEngineersGame.SetupPerGameSettings();
            };


            DedicatedServer.Run <MyObjectBuilder_SessionSettings>(args);
        }
Пример #13
0
        public void Initialise(QuakeParameters parms)
        {
            Parameters = parms;

            //Command.SetupWrapper( ); // Temporary workaround - change soon!
            Cache.Initialise(1024 * 1024 * 512);   // debug

            Commands.Add("flush", Cache.Flush);

            //CommandBuffer.Initialise( );
            // Command.Initialise( );
            View.Initialise( );
            ChaseView.Initialise( );
            InitialiseVCR(parms);
            MainWindow.Common.Initialise(MainWindow, parms.basedir, parms.argv);
            InitialiseLocal( );

            InitialiseWAD();

            Keyboard.Initialise( );
            Console.Initialise( );
            Menus.Initialise(this);
            Programs.Initialise( );
            ProgramsBuiltIn.Initialise( );
            Model.Initialise(this);
            Network.Initialise( );
            Server.Initialise( );

            //Con.Print("Exe: "__TIME__" "__DATE__"\n");
            //Con.Print("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0));

            RenderContext.InitTextures( );              // needed even for dedicated servers

            if (Client.cls.state != cactive_t.ca_dedicated)
            {
                BasePal = FileSystem.LoadFile("gfx/palette.lmp");
                if (BasePal == null)
                {
                    Utilities.Error("Couldn't load gfx/palette.lmp");
                }
                ColorMap = FileSystem.LoadFile("gfx/colormap.lmp");
                if (ColorMap == null)
                {
                    Utilities.Error("Couldn't load gfx/colormap.lmp");
                }

                // on non win32, mouse comes before video for security reasons
                MainWindow.Input.Initialise(this);
                Video.Initialise(BasePal);
                DrawingContext.Initialise( );
                Screen.Initialise( );
                RenderContext.Initialise( );
                Sound.Initialise( );
                CDAudio.Initialise( );
                Hud.Initialise( );
                Client.Initialise( );
            }
            else
            {
                DedicatedServer.Initialise( );
            }

            Commands.Buffer.Insert("exec quake.rc\n");

            IsInitialised = true;

            Console.DPrint("========Quake Initialized=========\n");
        }
Пример #14
0
        public IEnumerator Setup()
        {
            var user = AccelBytePlugin.GetUser();

            this.server = AccelByteServerPlugin.GetDedicatedServer();

            Result loginResult = null;

            this.server.LoginWithClientCredentials(result => loginResult = result);

            while (loginResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            Result loginWithDevice = null;

            user.LoginWithDeviceId(result => { loginWithDevice = result; });

            while (loginWithDevice == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            this.userId1 = user.Session.UserId;

            Result logoutResult = null;

            user.Logout(result => logoutResult = result);

            while (logoutResult == null)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            var steamTicketBuilder = new StringBuilder();

            if (SteamManager.Initialized)
            {
                var  ticket = new byte[1024];
                uint actualTicketLength;
                SteamUser.GetAuthSessionTicket(ticket, ticket.Length, out actualTicketLength);
                Array.Resize(ref ticket, (int)actualTicketLength);

                foreach (byte b in ticket)
                {
                    steamTicketBuilder.AppendFormat("{0:x2}", b);
                }
            }

            Result steamLoginResult = null;

            user.LoginWithOtherPlatform(
                PlatformType.Steam,
                steamTicketBuilder.ToString(),
                result => steamLoginResult = result);

            while (steamLoginResult == null)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            this.userId2 = user.Session.UserId;

            this.statistic = AccelByteServerPlugin.GetStatistic();

            //Get AccessToken
            Result <TokenData> GetAccessToken = null;

            this.helper.GetAccessToken(result => { GetAccessToken = result; });

            while (GetAccessToken == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            this.helperAccessToken = GetAccessToken.Value.access_token;

            for (int i = 0; i < this.statCodes.Length - 1; i++)
            {
                Debug.Log("Start to create stat! " + this.statCodes[i]);
                Result <StatConfig>        createStatResult = null;
                TestHelper.StatCreateModel createStat       = new TestHelper.StatCreateModel
                {
                    defaultValue  = 0,
                    description   = "Stat for SDK Test",
                    incrementOnly = true,
                    maximum       = 999999,
                    minimum       = 0,
                    name          = this.statCodes[i],
                    setAsGlobal   = false,
                    setBy         = StatisticSetBy.SERVER,
                    statCode      = this.statCodes[i],
                    tags          = new[] { this.tags[i] }
                };

                this.helper.CreateStatConfig(
                    this.helperAccessToken,
                    createStat,
                    result => { createStatResult = result; });

                while (createStatResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }
            }

            Debug.Log("Start to create stat! " + this.statCodes[5]);
            Result <StatConfig> createStat6Result = null;

            TestHelper.StatCreateModel createStat6 = new TestHelper.StatCreateModel
            {
                defaultValue  = 0,
                description   = "Stat for SDK Test",
                incrementOnly = false,
                maximum       = 999999,
                minimum       = 0,
                name          = this.statCodes[5],
                setAsGlobal   = false,
                setBy         = StatisticSetBy.SERVER,
                statCode      = this.statCodes[5],
                tags          = new[] { this.tags[5] }
            };

            this.helper.CreateStatConfig(
                this.helperAccessToken,
                createStat6,
                result => { createStat6Result = result; });

            while (createStat6Result == null)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            foreach (string statCode in this.statCodes)
            {
                Result deleteResult = null;

                this.helper.DeleteStatItem(
                    this.helperAccessToken,
                    this.userId1,
                    statCode,
                    result => deleteResult = result);

                while (deleteResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }

                deleteResult = null;

                this.helper.DeleteStatItem(
                    this.helperAccessToken,
                    this.userId2,
                    statCode,
                    result => deleteResult = result);

                while (deleteResult == null)
                {
                    yield return(new WaitForSeconds(0.1f));
                }
            }
        }
Пример #15
0
 public void Handle(CreateDedicatedServerCommand command)
 {
     var server = new DedicatedServer(ServerId.Create().Value);
 }
Пример #16
0
        public void Initialise(QuakeParameters parms)
        {
            Parameters = parms;

            //Command.SetupWrapper( ); // Temporary workaround - change soon!
            Cache.Initialise(1024 * 1024 * 512);   // debug

            Commands.Add("flush", Cache.Flush);

            //CommandBuffer.Initialise( );
            // Command.Initialise( );
            View.Initialise( );
            ChaseView.Initialise( );
            InitialiseVCR(parms);
            MainWindow.Common.Initialise(MainWindow, parms.basedir, parms.argv);
            InitialiseLocal( );

            // Search wads
            foreach (var wadFile in FileSystem.Search("*.wad"))
            {
                if (wadFile == "radiant.wad")
                {
                    continue;
                }

                if (wadFile == "gfx.wad")
                {
                    continue;
                }

                var data = FileSystem.LoadFile(wadFile);

                if (data == null)
                {
                    continue;
                }

                var wad = new Wad( );
                wad.LoadWadFile(wadFile, data);

                WadFiles.Add(wadFile, wad);

                var textures = wad._Lumps.Values
                               .Select(s => Encoding.ASCII.GetString(s.name).Replace("\0", ""))
                               .ToArray( );

                foreach (var texture in textures)
                {
                    if (!WadTextures.ContainsKey(texture))
                    {
                        WadTextures.Add(texture, wadFile);
                    }
                }
            }

            GfxWad.LoadWadFile("gfx.wad");
            Keyboard.Initialise( );
            Console.Initialise( );
            Menu.Initialise( );
            Programs.Initialise( );
            ProgramsBuiltIn.Initialise( );
            Model.Initialise( );
            Network.Initialise( );
            Server.Initialise( );

            //Con.Print("Exe: "__TIME__" "__DATE__"\n");
            //Con.Print("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0));

            RenderContext.InitTextures( );              // needed even for dedicated servers

            if (Client.cls.state != cactive_t.ca_dedicated)
            {
                BasePal = FileSystem.LoadFile("gfx/palette.lmp");
                if (BasePal == null)
                {
                    Utilities.Error("Couldn't load gfx/palette.lmp");
                }
                ColorMap = FileSystem.LoadFile("gfx/colormap.lmp");
                if (ColorMap == null)
                {
                    Utilities.Error("Couldn't load gfx/colormap.lmp");
                }

                // on non win32, mouse comes before video for security reasons
                MainWindow.Input.Initialise(this);
                Video.Initialise(BasePal);
                DrawingContext.Initialise( );
                Screen.Initialise( );
                RenderContext.Initialise( );
                Sound.Initialise( );
                CDAudio.Initialise( );
                Hud.Initialise( );
                Client.Initialise( );
            }
            else
            {
                DedicatedServer.Initialise( );
            }

            Commands.Buffer.Insert("exec quake.rc\n");

            IsInitialised = true;

            Console.DPrint("========Quake Initialized=========\n");
        }