コード例 #1
0
        public void Start(string modname, string mapname)
        {
            Stop();

            config.BattleDetails.Validate();
            if (String.IsNullOrEmpty(modname))
            {
                modname = config.DefaultMod;
            }
            if (String.IsNullOrEmpty(mapname))
            {
                mapname = config.DefaultMap;
            }

            if (!spring.UnitSync.HasMap(mapname))
            {
                mapname = spring.UnitSync.MapList[0];
            }
            if (!spring.UnitSync.HasMod(modname))
            {
                IEnumerator <ModInfo> enu = spring.UnitSync.ModList.Values.GetEnumerator();
                enu.MoveNext();
                modname = enu.Current.Name;
            }

            TasClient.Battle b = new TasClient.Battle(config.Password, config.HostingPort, config.MaxPlayers, config.MinRank, mapname, config.GameTitle.Replace("%1", MainConfig.SpringieVersion), spring.UnitSync.GetModInfo(modname), config.BattleDetails);

            for (int i = 0; i < config.DefaultRectangles.Count; ++i)
            {
                b.Rectangles.Add(i, config.DefaultRectangles[i]);
            }
            tas.OpenBattle(b);
            unsyncKicker = new UnSyncKicker(tas);
        }
コード例 #2
0
        public void RunNub(int num)
        {
            var tas = new TasClient("Nubotron");
            var name = "TestNub" + num;
            var ord = num / 16;
            var batname = "Test " + ord;

            //tas.Input += (sender, args) => { Console.WriteLine(" < {0}", args); };
            //tas.Output += (sender, args) => { Console.WriteLine(" > {0}", args); };

            tas.Connected += (sender, args) => {
                tas.Login(name, "dummy");
            };

            tas.ConnectionLost += (sender, args) => { tas.Connect(GlobalConst.LobbyServerHost, GlobalConst.LobbyServerPort); Console.WriteLine("disconnected"); };


            tas.LoginAccepted += (sender, args) => { Console.WriteLine(name + " accepted"); };
            tas.LoginDenied += (sender, args) => { tas.Register(name, "dummy"); };

            tas.RegistrationAccepted += (sender, args) => { tas.Login(name, "dummy"); };
            tas.RegistrationDenied += (sender, response) => { Console.WriteLine(name + "registration denied"); };

            

            tas.UserAdded += (sender, args) => {
                if (args.Name == name) {
                    tas.JoinChannel("bots");
                    if (num%16 == 0) tas.OpenBattle(new BattleHeader()
                    {
                        Title = batname,
                        MaxPlayers = 16,
                    });
                    else {
                        var bat = tas.ExistingBattles.Values.FirstOrDefault(x => x.Title == batname);
                        if (bat != null) tas.JoinBattle(bat.BattleID);
                    }
                }
            };
            tas.BattleFound += (sender, args) => {
                if (args.Title == batname) {
                    //await Task.Delay(200);
                    tas.JoinBattle(args.BattleID);
                }
            };
            

            tas.Connect(GlobalConst.LobbyServerHost, GlobalConst.LobbyServerPort);
            /*Task.Factory.StartNew(async () =>
            {
                while (true)
                {
                    await Task.Delay(rand.Next(400000));
                    tas.Say(SayPlace.Channel, "zk", sent.GetNext(), false);
                }
            }, TaskCreationOptions.LongRunning);*/
        }
コード例 #3
0
        public void Start(string modname, string mapname)
        {
            Stop();

            lockedByKickSpec = false;
            autoLock         = 0;
            kickSpectators   = config.KickSpectators;
            minCpuSpeed      = config.MinCpuSpeed;
            kickMinRank      = config.KickMinRank;

            config.BattleDetails.Validate();
            if (String.IsNullOrEmpty(modname))
            {
                modname = config.DefaultMod;
            }
            if (String.IsNullOrEmpty(mapname))
            {
                mapname = config.DefaultMap;
            }

            if (!spring.UnitSync.HasMap(mapname))
            {
                IEnumerator <MapInfo> enu = spring.UnitSync.MapList.Values.GetEnumerator();
                enu.MoveNext();
                mapname = enu.Current.Name;
            }
            if (!spring.UnitSync.HasMod(modname))
            {
                IEnumerator <ModInfo> enu = spring.UnitSync.ModList.Values.GetEnumerator();
                enu.MoveNext();
                modname = enu.Current.Name;
            }


            Battle b = new Battle(config.Password, config.HostingPort, config.MaxPlayers, config.MinRank, spring.UnitSync.GetMapInfo(mapname), config.GameTitle.Replace("%1", MainConfig.SpringieVersion), spring.UnitSync.GetModInfo(modname), config.BattleDetails);

            // if hole punching enabled then we use it
            if (config.UseHolePunching)
            {
                b.Nat = Battle.NatMode.HolePunching;
            }
            else if (Program.main.config.GargamelMode && Program.main.Stats != null)
            {
                b.Nat = Battle.NatMode.FixedPorts;
            }
            else
            {
                b.Nat = Battle.NatMode.None;                                                                                                         // else either no nat or fixed ports (for gargamel fake - to get client IPs)
            }
            for (int i = 0; i < config.DefaultRectangles.Count; ++i)
            {
                b.Rectangles.Add(i, config.DefaultRectangles[i]);
            }
            tas.OpenBattle(b);
        }
コード例 #4
0
        public void RunNub(int num)
        {
            var tas     = new TasClient("Nubotron");
            var name    = "TestNub" + num;
            var ord     = num / 16;
            var batname = "Test " + ord;

            //tas.Input += (sender, args) => { Console.WriteLine(" < {0}", args); };
            //tas.Output += (sender, args) => { Console.WriteLine(" > {0}", args); };

            tas.Connected += (sender, args) => {
                tas.Login(name, "dummy");
            };

            tas.ConnectionLost += (sender, args) => { Console.WriteLine("disconnected"); };


            tas.LoginAccepted += (sender, args) => { Console.WriteLine(name + " accepted"); };
            tas.LoginDenied   += (sender, args) => { tas.Register(name, "dummy"); };



            tas.UserAdded += (sender, args) => {
                if (args.Name == name)
                {
                    tas.JoinChannel("bots");
                    if (num % 16 == 0)
                    {
                        tas.OpenBattle(new Battle("91.0", null, 4955, 16, "SmallDivide", "Test " + ord, "Zero-K v1.3.1.15"));
                    }
                    else
                    {
                        var bat = tas.ExistingBattles.Values.FirstOrDefault(x => x.Title == batname);
                        if (bat != null)
                        {
                            tas.JoinBattle(bat.BattleID);
                        }
                    }
                }
            };
            tas.BattleFound += (sender, args) => {
                if (args.Title == batname)
                {
                    //await Task.Delay(200);
                    tas.JoinBattle(args.BattleID);
                }
            };

            tas.Connect(GlobalConst.LobbyServerHost, GlobalConst.LobbyServerPort);
        }
コード例 #5
0
        public void RunNub(int num)
        {
            var tas = new TasClient("Nubotron");
            var name = "TestNub" + num;
            var ord = num / 16;
            var batname = "Test " + ord;

            //tas.Input += (sender, args) => { Console.WriteLine(" < {0}", args); };
            //tas.Output += (sender, args) => { Console.WriteLine(" > {0}", args); };

            tas.Connected += (sender, args) => {
                tas.Login(name, "dummy");
            };

            tas.ConnectionLost += (sender, args) => { Console.WriteLine("disconnected"); };


            tas.LoginAccepted += (sender, args) => { Console.WriteLine(name + " accepted"); };
            tas.LoginDenied += (sender, args) => { tas.Register(name, "dummy"); };

            

            tas.UserAdded += (sender, args) => {
                if (args.Name == name) {
                    tas.JoinChannel("bots");
                    if (num%16 == 0) tas.OpenBattle(new BattleHeader()
                    {
                        Engine = "91.0",
                        Game  = "Zero-K v1.3.1.15",
                        Title = "test" + ord,
                        Map = "SmallDivide",
                        MaxPlayers = 16,
                    });
                    else {
                        var bat = tas.ExistingBattles.Values.FirstOrDefault(x => x.Title == batname);
                        if (bat != null) tas.JoinBattle(bat.BattleID);
                    }
                }
            };
            tas.BattleFound += (sender, args) => {
                if (args.Title == batname) {
                    //await Task.Delay(200);
                    tas.JoinBattle(args.BattleID);
                }
            };

            tas.Connect(GlobalConst.LobbyServerHost, GlobalConst.LobbyServerPort);
        }
コード例 #6
0
        public void OpenBattleRoom(string modname, string mapname, bool now = true)
        {
            if (!now && spring.IsRunning)
            {
                spring.WaitForExit();
            }
            Stop();

            bossName      = "";
            lastMapChange = DateTime.Now;

            if (String.IsNullOrEmpty(modname))
            {
                modname = config.Mod;
            }
            if (String.IsNullOrEmpty(mapname))
            {
                mapname = config.Map;
            }

            string title = config.Title.Replace("%1", MainConfig.SpringieVersion);

            string password = null;

            if (!string.IsNullOrEmpty(config.BattlePassword))
            {
                password = config.BattlePassword;
            }

            int    maxPlayers = config.MaxPlayers;
            string engine     = springPaths.SpringVersion;

            if (SpawnConfig != null)
            {
                modname = SpawnConfig.Mod;
                if (SpawnConfig.MaxPlayers > 0)
                {
                    maxPlayers = SpawnConfig.MaxPlayers;
                }
                if (!String.IsNullOrEmpty(SpawnConfig.Map))
                {
                    mapname = SpawnConfig.Map;
                }
                title = SpawnConfig.Title;
                if (!String.IsNullOrEmpty(SpawnConfig.Password))
                {
                    password = SpawnConfig.Password;
                }
                if (!String.IsNullOrEmpty(SpawnConfig.Engine))
                {
                    engine = SpawnConfig.Engine;
                }
                {
                    //Something needs to go here to properly tell Springie to use a specific engine version,
                    //attempted code below may or may not be responsible for recent springie drops, so commenting.

                    //the below may be causing a rehost
                    //requestedEngineChange = SpawnConfig.Engine;

                    //alternate attempt

                    /*
                     * Program.main.Downloader.GetAndSwitchEngine(SpawnConfig.Engine);
                     * config.SpringVersion = SpawnConfig.Engine;
                     * springPaths.SetEnginePath(Program.main.paths.GetEngineFolderByVersion(SpawnConfig.Engine));
                     */
                }
            }

            //title = title + string.Format(" [engine{0}]", springPaths.SpringVersion);

            // no mod was provided, auto update is on, check if newer version exists, if it does use that instead of config one
            if (string.IsNullOrEmpty(modname) && !String.IsNullOrEmpty(config.AutoUpdateRapidTag))
            {
                var ver = Program.main.Downloader.PackageDownloader.GetByTag(config.AutoUpdateRapidTag);

                if (ver != null && cache.GetResourceDataByInternalName(ver.InternalName) != null)
                {
                    modname = config.AutoUpdateRapidTag;
                }
            }

            PackageDownloader.Version version = Program.main.Downloader.PackageDownloader.GetByTag(modname);
            if (version != null && version.InternalName != null)
            {
                modname = version.InternalName;
            }

            hostedMod = new Mod()
            {
                Name = modname
            };
            cache.GetMod(modname, (m) => { hostedMod = m; }, (m) => {});
            if (hostedMod.IsMission && !String.IsNullOrEmpty(hostedMod.MissionMap))
            {
                mapname = hostedMod.MissionMap;
            }

            //Map mapi = null;
            //cache.GetMap(mapname, (m, x, y, z) => { mapi = m; }, (e) => { }, springPaths.SpringVersion);
            //int mint, maxt;
            if (!springPaths.HasEngineVersion(engine))
            {
                Program.main.Downloader.GetAndSwitchEngine(engine, springPaths);
            }
            else
            {
                springPaths.SetEnginePath(springPaths.GetEngineFolderByVersion(engine));
            }

            var b = new Battle(engine, password, hostingPort, maxPlayers, mapname, title, modname);

            b.Ip = Program.main.Config.IpOverride;
            tas.OpenBattle(b);
        }
コード例 #7
0
        public void Start(string modname, string mapname)
        {
            Stop();

            manager          = new AutoManager(this, tas, spring);
            lockedByKickSpec = false;
            autoLock         = 0;
            kickSpectators   = config.KickSpectators;
            minCpuSpeed      = config.MinCpuSpeed;
            kickMinRank      = config.KickMinRank;

            if (config.LadderId > 0)
            {
                ladder = new Ladder(config.LadderId);
            }
            else
            {
                ladder = null;
            }

            if (String.IsNullOrEmpty(modname))
            {
                modname = config.DefaultMod;
            }
            if (String.IsNullOrEmpty(mapname))
            {
                mapname = config.DefaultMap;
            }

            if (!spring.UnitSyncWrapper.HasMap(mapname))
            {
                IEnumerator <MapInfo> enu = spring.UnitSyncWrapper.MapList.Values.GetEnumerator();
                enu.MoveNext();
                mapname = enu.Current.Name;
            }
            if (!string.IsNullOrEmpty(config.AutoUpdateMod))
            {
                string latest = spring.UnitSyncWrapper.GetNewestModVersion(config.AutoUpdateMod);
                if (latest != null)
                {
                    modname = latest;
                }
            }

            if (!spring.UnitSyncWrapper.HasMod(modname))
            {
                IEnumerator <ModInfo> enu = spring.UnitSyncWrapper.ModList.Values.GetEnumerator();
                enu.MoveNext();
                modname = enu.Current.Name;
            }

            int mint, maxt;
            var b = new Battle((ladder == null ? config.Password : "******"), config.HostingPort, config.MaxPlayers, config.MinRank, spring.UnitSyncWrapper.GetMapInfo(mapname), (ladder != null ? "(ladder " + ladder.Id + ") " : "") + config.GameTitle.Replace("%1", MainConfig.SpringieVersion), spring.UnitSyncWrapper.GetModInfo(modname), (ladder != null ? ladder.CheckBattleDetails(config.BattleDetails, out mint, out maxt) : config.BattleDetails));

            // if hole punching enabled then we use it
            if (config.UseHolePunching)
            {
                b.Nat = Battle.NatMode.HolePunching;
            }
            else if (Program.main.config.GargamelMode && Program.main.Stats != null)
            {
                b.Nat = Battle.NatMode.FixedPorts;
            }
            else
            {
                b.Nat = Battle.NatMode.None;  // else either no nat or fixed ports (for gargamel fake - to get client IPs)
            }
            for (int i = 0; i < config.DefaultRectangles.Count; ++i)
            {
                b.Rectangles.Add(i, config.DefaultRectangles[i]);
            }
            tas.OpenBattle(b);
        }
コード例 #8
0
        public void RunNub(int num)
        {
            var tas = new TasClient("Nubotron");

            var maps = AutoRegistrator.RegistratorRes.campaignMaps.Split('\n');
            var name = "TestNub" + num;
            var ord  = num / 16;

            //tas.Input += (sender, args) => { Console.WriteLine(" < {0}", args); };
            //tas.Output += (sender, args) => { Console.WriteLine(" > {0}", args); };

            tas.Connected += (sender, args) =>
            {
                tas.Login(name, "dummy");
            };

            tas.ConnectionLost += (sender, args) => { tas.Connect(GlobalConst.LobbyServerHost, GlobalConst.LobbyServerPort); Console.WriteLine("disconnected"); };


            tas.LoginAccepted += (sender, args) => { Console.WriteLine(name + " accepted"); };
            tas.LoginDenied   += (sender, args) => { tas.Register(name, "dummy"); };

            tas.RegistrationAccepted += (sender, args) => { tas.Login(name, "dummy"); };
            tas.RegistrationDenied   += (sender, response) => { Console.WriteLine(name + "registration denied"); };



            tas.Connect(GlobalConst.LobbyServerHost, GlobalConst.LobbyServerPort);

            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    await Task.Delay(rand.Next(10000));
                    if (tas.IsLoggedIn)
                    {
                        await tas.LeaveBattle();
                        if (tas.ExistingBattles.Count < 20)
                        {
                            await tas.OpenBattle(new BattleHeader()
                            {
                                Title      = "" + name,
                                MaxPlayers = 16,
                                Mode       = AutohostMode.None,
                                Engine     = tas.ServerWelcome.Engine,
                                Game       = tas.ServerWelcome.Game,
                                Map        = maps[rand.Next(maps.Length)],
                            });
                        }
                        else
                        {
                            var bats = tas.ExistingBattles.Values.ToList();
                            if (bats.Count > 0)
                            {
                                var bat = bats[rand.Next(bats.Count)];
                                if (bat != null)
                                {
                                    tas.JoinBattle(bat.BattleID);
                                }
                            }
                        }
                    }
                }
            }, TaskCreationOptions.LongRunning);


            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    await Task.Delay(rand.Next(50000));
                    if (tas.IsLoggedIn)
                    {
                        tas.Say(SayPlace.Channel, "zk", sent.GetNext(), false);
                    }
                }
            }, TaskCreationOptions.LongRunning);

            Task.Factory.StartNew(async() =>
            {
                bool cycler = false;
                while (true)
                {
                    await Task.Delay(rand.Next(5000));
                    if (tas.IsLoggedIn)
                    {
                        await tas.ChangeMyUserStatus(cycler, cycler);
                        //await tas.ChangeMyBattleStatus(cycler, SyncStatuses.Synced, 1);
                        cycler = !cycler;
                    }
                }
            }, TaskCreationOptions.LongRunning);
        }
コード例 #9
0
        public void Start(string modname, string mapname, bool now = true)
        {
            if (!now && spring.IsRunning)
            {
                spring.WaitForExit();
            }
            Stop();

            lastMapChange = DateTime.Now;

            if (String.IsNullOrEmpty(modname))
            {
                modname = config.Mod;
            }
            if (String.IsNullOrEmpty(mapname))
            {
                mapname = config.Map;
            }

            string title    = config.Title.Replace("%1", MainConfig.SpringieVersion);
            string password = "******";

            if (!string.IsNullOrEmpty(config.BattlePassword))
            {
                password = config.BattlePassword;
            }

            if (SpawnConfig != null)
            {
                modname = SpawnConfig.Mod;
                mapname = SpawnConfig.Map;
                title   = SpawnConfig.Title;
                if (!String.IsNullOrEmpty(SpawnConfig.Password))
                {
                    password = SpawnConfig.Password;
                }
                if (!String.IsNullOrEmpty(SpawnConfig.Engine))
                {
                    //Something needs to go here to properly tell Springie to use a specific engine version,
                    //attempted code below may or may not be responsible for recent springie drops, so commenting.

                    //the below may be causing a rehost
                    //requestedEngineChange = SpawnConfig.Engine;

                    //alternate attempt

                    /*
                     * Program.main.Downloader.GetAndSwitchEngine(SpawnConfig.Engine);
                     * config.SpringVersion = SpawnConfig.Engine;
                     * springPaths.SetEnginePath(Program.main.paths.GetEngineFolderByVersion(SpawnConfig.Engine));
                     */
                }
            }

            //title = title + string.Format(" [engine{0}]", springPaths.SpringVersion);

            // no mod was provided, auto update is on, check if newer version exists, if it does use that instead of config one
            if (string.IsNullOrEmpty(modname) && !String.IsNullOrEmpty(config.AutoUpdateRapidTag))
            {
                var ver = Program.main.Downloader.PackageDownloader.GetByTag(config.AutoUpdateRapidTag);

                if (ver != null && cache.GetResourceDataByInternalName(ver.InternalName) != null)
                {
                    modname = config.AutoUpdateRapidTag;
                }
            }

            PackageDownloader.Version version = Program.main.Downloader.PackageDownloader.GetByTag(modname);
            if (version != null && cache.GetResourceDataByInternalName(version.InternalName) != null)
            {
                modname = version.InternalName;
            }

            hostedMod = new Mod();
            cache.GetMod(modname, (m) => { hostedMod = m; }, (m) => { }, springPaths.SpringVersion);
            if (hostedMod.IsMission && !String.IsNullOrEmpty(hostedMod.MissionMap))
            {
                mapname = hostedMod.MissionMap;
            }

            Map mapi = null;

            cache.GetMap(mapname, (m, x, y, z) => { mapi = m; }, (e) => { }, springPaths.SpringVersion);
            //int mint, maxt;
            var b = new Battle(springPaths.SpringVersion, password, hostingPort, config.MaxPlayers, 0, mapi, title, hostedMod, new BattleDetails());

            // if hole punching enabled then we use it
            if (Program.main.Config.UseHolePunching)
            {
                b.Nat = Battle.NatMode.HolePunching;
            }
            else if (Program.main.Config.GargamelMode)
            {
                b.Nat = Battle.NatMode.FixedPorts;
            }
            else
            {
                b.Nat = Battle.NatMode.None;  // else either no nat or fixed ports (for gargamel fake - to get client IPs)
            }
            tas.OpenBattle(b);
            tas.SetScriptTag("GAME/hosttype=SPRINGIE");
        }
コード例 #10
0
        public void RunNub(int num)
        {
            var tas     = new TasClient("Nubotron");
            var name    = "TestNub" + num;
            var ord     = num / 16;
            var batname = "Test " + ord;

            //tas.Input += (sender, args) => { Console.WriteLine(" < {0}", args); };
            //tas.Output += (sender, args) => { Console.WriteLine(" > {0}", args); };

            tas.Connected += (sender, args) => {
                tas.Login(name, "dummy");
            };

            tas.ConnectionLost += (sender, args) => { tas.Connect(GlobalConst.LobbyServerHost, GlobalConst.LobbyServerPort); Console.WriteLine("disconnected"); };


            tas.LoginAccepted += (sender, args) => { Console.WriteLine(name + " accepted"); };
            tas.LoginDenied   += (sender, args) => { tas.Register(name, "dummy"); };

            tas.RegistrationAccepted += (sender, args) => { tas.Login(name, "dummy"); };
            tas.RegistrationDenied   += (sender, response) => { Console.WriteLine(name + "registration denied"); };



            tas.UserAdded += (sender, args) => {
                if (args.Name == name)
                {
                    tas.JoinChannel("bots");
                    if (num % 16 == 0)
                    {
                        tas.OpenBattle(new BattleHeader()
                        {
                            Title      = batname,
                            MaxPlayers = 16,
                        });
                    }
                    else
                    {
                        var bat = tas.ExistingBattles.Values.FirstOrDefault(x => x.Title == batname);
                        if (bat != null)
                        {
                            tas.JoinBattle(bat.BattleID);
                        }
                    }
                }
            };
            tas.BattleFound += (sender, args) => {
                if (args.Title == batname)
                {
                    //await Task.Delay(200);
                    tas.JoinBattle(args.BattleID);
                }
            };


            tas.Connect(GlobalConst.LobbyServerHost, GlobalConst.LobbyServerPort);

            /*Task.Factory.StartNew(async () =>
             * {
             *  while (true)
             *  {
             *      await Task.Delay(rand.Next(400000));
             *      tas.Say(SayPlace.Channel, "zk", sent.GetNext(), false);
             *  }
             * }, TaskCreationOptions.LongRunning);*/
        }