private static int FilterMaps(string[] words, TasClient tas, Spring spring, Ladder ladder, out string[] vals, out int[] indexes) { string[] temp = new string[spring.UnitSync.MapList.Keys.Count]; int cnt = 0; foreach (string s in spring.UnitSync.MapList.Keys) { if (ladder != null) { if (ladder.Maps.Contains(s.ToLower())) temp[cnt++] = s; } else { string[] limit = Program.main.AutoHost.config.LimitMaps; if (limit != null && limit.Length > 0) { bool allowed = false; for (int i = 0; i < limit.Length; ++i) { if (s.ToLower().Contains(limit[i].ToLower())) { allowed = true; break; } } if (allowed) temp[cnt++] = s; } else temp[cnt++] = s; } } return Filter(temp, words, out vals, out indexes); }
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; 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; } int mint, maxt; Battle b = new Battle((ladder == null ? config.Password : "******"), config.HostingPort, config.MaxPlayers, config.MinRank, spring.UnitSync.GetMapInfo(mapname), (ladder != null ? "(ladder " + ladder.Id + ") " : "") + config.GameTitle.Replace("%1", MainConfig.SpringieVersion), spring.UnitSync.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); }
public void Apply(TasClient tas, Ladder ladder) { var b = tas.GetBattle(); if (b == null) return; var d = b.Details; int mint, maxt; if (ladder != null) d = ladder.CheckBattleDetails(d, out mint, out maxt); tas.UpdateBattleDetails(d); if (enableAllUnits) tas.EnableAllUnits(); if (disabledUnits.Length > 0) tas.DisableUnits(UnitInfo.ToStringList(disabledUnits)); foreach (var s in perform) tas.Say(TasClient.SayPlace.Battle, "", s, false); }
public void Apply(TasClient tas, Ladder ladder) { Battle b = tas.GetBattle(); if (b == null) return; BattleDetails d = b.Details; if (startingMetal.HasValue) d.StartingMetal = startingMetal.Value; if (startingEnergy.HasValue) d.StartingEnergy = startingEnergy.Value; if (maxUnits.HasValue) d.MaxUnits = maxUnits.Value; if (startPos.HasValue) d.StartPos = startPos.Value; if (endCondition.HasValue) d.EndCondition = endCondition.Value; if (limitDgun.HasValue) d.LimitDgun = limitDgun.Value; if (diminishingMM.HasValue) d.DiminishingMM = diminishingMM.Value; if (ghostedBuildings.HasValue) d.GhostedBuildings = ghostedBuildings.Value; d.Validate(); int mint, maxt; if (ladder != null) d = ladder.CheckBattleDetails(d, out mint, out maxt); tas.UpdateBattleDetails(d); if (enableAllUnits) tas.EnableAllUnits(); if (disabledUnits.Length > 0) tas.DisableUnits(UnitInfo.ToStringList(disabledUnits)); foreach (string s in perform) tas.Say(TasClient.SayPlace.Battle, "", s, false); }
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; } 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; } int mint, maxt; Battle b = new Battle((ladder == null ? config.Password : "******"), config.HostingPort, config.MaxPlayers, config.MinRank, spring.UnitSync.GetMapInfo(mapname), (ladder != null ? "(ladder " + ladder.Id + ") " : "") + config.GameTitle.Replace("%1", MainConfig.SpringieVersion), spring.UnitSync.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); }