public AutoHost(TasClient tas, Spring spring, AutoHostConfig conf) { if (conf == null) LoadConfig(); else config = conf; SaveConfig(); this.tas = tas; this.spring = spring; tas.Said += new EventHandler<TasSayEventArgs>(tas_Said); pollTimer = new Timer(PollTimeout * 1000); pollTimer.Enabled = false; pollTimer.AutoReset = false; pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed); spring.SpringExited += new EventHandler(spring_SpringExited); spring.GameOver += new EventHandler<SpringLogEventArgs>(spring_GameOver); tas.BattleUserLeft += new EventHandler<TasEventArgs>(tas_BattleUserLeft); tas.UserRemoved += new EventHandler<TasEventArgs>(tas_UserRemoved); tas.UserStatusChanged += new EventHandler<TasEventArgs>(tas_UserStatusChanged); tas.BattleUserJoined += new EventHandler<TasEventArgs>(tas_BattleUserJoined); tas.BattleMapChanged += new EventHandler<TasEventArgs>(tas_BattleMapChanged); tas.BattleUserStatusChanged += new EventHandler<TasEventArgs>(tas_BattleUserStatusChanged); tas.BattleLockChanged += new EventHandler<TasEventArgs>(tas_BattleLockChanged); mapLinker = new MapLinker(spring); mapDownloader = new MapDownloader(spring); mapDownloader.DownloadCompleted += new EventHandler<TasEventArgs>(mapDownloader_DownloadCompleted); mapDownloader.DownloadProgressChanged += new EventHandler<TasEventArgs>(mapDownloader_DownloadProgressChanged); tas.BattleFound += new EventHandler<TasEventArgs>(tas_BattleFound); }
internal static int FilterMaps(string[] words, TasClient tas, Spring spring, 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) { temp[cnt++] = s; } return Filter(temp, words, out vals, out indexes); }
public AutoManager(AutoHost ah, TasClient tas, Spring spring) { this.ah = ah; this.tas = tas; this.spring = spring; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); }
internal static int FilterUsers(string[] words, TasClient tas, Spring spring, out string[] vals, out int[] indexes) { TasClient.Battle b = tas.GetBattle(); string[] temp = new string[b.Users.Count]; int i = 0; foreach (TasClient.UserBattleStatus u in b.Users) { temp[i++] = u.name; } return Filter(temp, words, out vals, out indexes); }
/************************************************************************/ /* PUBLIC METHODS */ /************************************************************************/ /// <summary> /// Initializes auto downloader /// </summary> public AutoUpdater(Spring spring, TasClient tas) { this.spring = spring; this.tas = tas; timer = new Timer(); timer.Interval = updateCheckInterval*1000*60; timer.AutoReset = true; timer.Elapsed += timer_Elapsed; timer.Start(); spring.SpringExited += spring_SpringExited; }
/************************************************************************/ /* PUBLIC METHODS */ /************************************************************************/ /// <summary> /// Initializes auto downloader /// </summary> public AutoUpdater(Spring spring, TasClient tas) { this.spring = spring; this.tas = tas; timer = new System.Timers.Timer(); timer.Interval = updateCheckInterval * 1000 * 60; timer.AutoReset = true; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); spring.SpringExited += new EventHandler(spring_SpringExited); }
public AbstractPoll(TasClient tas, Spring spring, AutoHost ah) { this.tas = tas; this.spring = spring; this.ah = ah; string[] usrs; int[] indexes; AutoHost.FilterUsers(new string[0], tas, spring, out usrs, out indexes); foreach (string s in usrs) { if (s != tas.UserName) { users.Add(s); votes.Add(0); } } initialUserCount = users.Count; }
public AbstractPoll(TasClient tas, Spring spring, AutoHost ah) { this.tas = tas; this.spring = spring; this.ah = ah; initialUserCount = 0; var b = tas.GetBattle(); if (b != null) { foreach (var us in b.Users) { if (us.name != tas.UserName) { users.Add(us.name); votes.Add(0); if (!us.IsSpectator) initialUserCount++; } } } }
private static void SpringOutputReader(object param) { Spring s = (Spring)param; do { string l; try { l = s.process.StandardOutput.ReadLine(); } catch { return; } if (l == null || !s.IsRunning || l.Length == 0) { return; } s.ProcessLogLine(l); } while (true); }
public Stats(TasClient tas, Spring spring) { this.tas = tas; this.spring = spring; LoadAccounts(); tas.LoginAccepted += new EventHandler<TasEventArgs>(tas_LoginAccepted); if (Program.main.config.GargamelMode) { tas.UserRemoved += new EventHandler<TasEventArgs>(tas_UserRemoved); tas.BattleUserIpRecieved += new EventHandler<TasEventArgs>(tas_BattleUserIpRecieved); tas.UserStatusChanged += new EventHandler<TasEventArgs>(tas_UserStatusChanged); } spring.SpringStarted += new EventHandler(spring_SpringStarted); spring.PlayerJoined += new EventHandler<SpringLogEventArgs>(spring_PlayerJoined); spring.PlayerLeft += new EventHandler<SpringLogEventArgs>(spring_PlayerLeft); spring.PlayerLost += new EventHandler<SpringLogEventArgs>(spring_PlayerLost); spring.PlayerDisconnected += new EventHandler<SpringLogEventArgs>(spring_PlayerDisconnected); spring.GameOver += new EventHandler<SpringLogEventArgs>(spring_GameOver); }
public Stats(TasClient tas, Spring spring) { this.tas = tas; this.spring = spring; LoadAccounts(); tas.LoginAccepted += tas_LoginAccepted; if (Program.main.config.GargamelMode) { tas.UserRemoved += tas_UserRemoved; tas.BattleUserIpRecieved += tas_BattleUserIpRecieved; tas.UserStatusChanged += tas_UserStatusChanged; } spring.SpringStarted += spring_SpringStarted; spring.PlayerJoined += spring_PlayerJoined; spring.PlayerLeft += spring_PlayerLeft; spring.PlayerLost += spring_PlayerLost; spring.PlayerDisconnected += spring_PlayerDisconnected; spring.GameOver += spring_GameOver; }
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 AutoHost(TasClient tas, Spring spring, AutoHostConfig conf) { banList = new BanList(this, tas); if (conf == null) LoadConfig(); else config = conf; SaveConfig(); this.tas = tas; this.spring = spring; tas.Said += new EventHandler<TasSayEventArgs>(tas_Said); pollTimer = new System.Timers.Timer(PollTimeout * 1000); pollTimer.Enabled = false; pollTimer.AutoReset = false; pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed); spring.SpringExited += new EventHandler(spring_SpringExited); spring.GameOver += new EventHandler<SpringLogEventArgs>(spring_GameOver); tas.BattleUserLeft += new EventHandler<TasEventArgs>(tas_BattleUserLeft); tas.UserStatusChanged += new EventHandler<TasEventArgs>(tas_UserStatusChanged); tas.BattleUserJoined += new EventHandler<TasEventArgs>(tas_BattleUserJoined); tas.BattleMapChanged += new EventHandler<TasEventArgs>(tas_BattleMapChanged); tas.BattleUserStatusChanged += new EventHandler<TasEventArgs>(tas_BattleUserStatusChanged); tas.BattleLockChanged += new EventHandler<TasEventArgs>(tas_BattleLockChanged); tas.BattleOpened += new EventHandler<TasEventArgs>(tas_BattleOpened); linker = new UnknownFilesLinker(spring); fileDownloader = new FileDownloader(spring); fileDownloader.DownloadCompleted += new EventHandler<FileDownloader.DownloadEventArgs>(fileDownloader_DownloadCompleted); //fileDownloader.DownloadProgressChanged += new EventHandler<TasEventArgs>(fileDownloader_DownloadProgressChanged); tas.BattleFound += new EventHandler<TasEventArgs>(tas_BattleFound); }
public static void Respond(TasClient tas, Spring spring, TasSayEventArgs e, string text) { TasClient.SayPlace p = TasClient.SayPlace.User; bool emote = false; if (e.Place == TasSayEventArgs.Places.Battle) { p = TasClient.SayPlace.Battle; emote = true; } if (e.Place == TasSayEventArgs.Places.Game && spring.IsRunning) spring.SayGame(text); else tas.Say(p, e.UserName, text, emote); }
internal static int FilterMaps(string[] words, TasClient tas, Spring spring, out string[] vals, out int[] indexes) { return Filter(spring.UnitSync.MapList.ToArray(), words, out vals, out indexes); }
public VoteMap(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { }
public bool Start() { if (config.AttemptToRecconnect) { recon = new Timer(config.AttemptReconnectInterval*1000); recon.Elapsed += recon_Elapsed; } recon.Enabled = false; spring = new Spring(); tas = new TasClient(); tas.ConnectionLost += tas_ConnectionLost; tas.Connected += tas_Connected; tas.LoginDenied += tas_LoginDenied; tas.LoginAccepted += tas_LoginAccepted; tas.Said += tas_Said; tas.MyStatusChangedToInGame += tas_MyStatusChangedToInGame; tas.ChannelUserAdded += tas_ChannelUserAdded; spring.SpringExited += spring_SpringExited; spring.SpringStarted += spring_SpringStarted; spring.PlayerSaid += spring_PlayerSaid; autoHost = new AutoHost(tas, spring, null); if (config.PlanetWarsEnabled) InitializePlanetWarsServer(); autoUpdater = new AutoUpdater(spring, tas); if (config.StatsEnabledReal) stats = new Stats(tas, spring); try { tas.Connect(config.ServerHost, config.ServerPort); } catch { recon.Start(); } return true; }
public VoteForceStart(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { }
public VotePlanet(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { this.tas = tas; this.spring = spring; this.ah = ah; var pw = Program.main.PlanetWars; var fact = pw.GetOffensiveFaction(); faction = fact.Name; users.Clear(); votes.Clear(); initialUserCount = 0; var b = tas.GetBattle(); if (b != null) { foreach (var us in b.Users) { if (us.name != tas.UserName && !us.IsSpectator && pw.GetPlayerInfo(us.name).FactionName == faction) { users.Add(us.name); votes.Add(0); initialUserCount++; } } } }
internal static int FilterMods(string[] words, TasClient tas, Spring spring, out string[] vals, out int[] indexes) { var temp = new string[spring.UnitSyncWrapper.ModList.Keys.Count]; int cnt = 0; foreach (var s in spring.UnitSyncWrapper.ModList.Keys) { var limit = Program.main.AutoHost.config.LimitMods; 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 bool Start() { if (config.AttemptToRecconnect) { recon = new Timer(config.AttemptReconnectInterval*1000); recon.Elapsed += new ElapsedEventHandler(recon_Elapsed); } recon.Enabled = false; try { spring = new Spring(config.SpringPath); } catch { MessageBox.Show("Spring not found in " + config.SpringPath, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); OpenFileDialog od = new OpenFileDialog(); od.FileName = Spring.ExecutableName; od.DefaultExt = Path.GetExtension(Spring.ExecutableName); od.InitialDirectory = config.SpringPath; od.Title = "Please select your spring installation"; od.RestoreDirectory = true; od.CheckFileExists = true; od.CheckPathExists = true; od.AddExtension = true; od.Filter = "Executable (*.exe)|*.exe"; DialogResult dr = od.ShowDialog(); if (dr == DialogResult.OK) { config.SpringPath = Path.GetDirectoryName(od.FileName); SaveConfig(); try { spring = new Spring(config.SpringPath); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error while checking spring, exiting"); Application.Exit(); return false; } } else { MessageBox.Show("Spring not found, exiting"); Application.Exit(); return false; } } tas = new TasClient(); tas.ConnectionLost += new EventHandler<TasEventArgs>(tas_ConnectionLost); tas.Connected += new EventHandler<TasEventArgs>(tas_Connected); tas.LoginDenied += new EventHandler<TasEventArgs>(tas_LoginDenied); tas.LoginAccepted += new EventHandler<TasEventArgs>(tas_LoginAccepted); tas.Said += new EventHandler<TasSayEventArgs>(tas_Said); tas.MyStatusChangedToInGame += new EventHandler<TasEventArgs>(tas_MyStatusChangedToInGame); spring.SpringExited += new EventHandler(spring_SpringExited); spring.SpringStarted += new EventHandler(spring_SpringStarted); spring.PlayerSaid += new EventHandler<SpringLogEventArgs>(spring_PlayerSaid); autoHost = new AutoHost(tas, spring, null); autoUpdater = new AutoUpdater(spring, tas); if (config.StatsEnabled) stats = new Stats(tas, spring); try { tas.Connect(config.ServerHost, config.ServerPort); } catch { recon.Start(); } return true; }
internal static int FilterUsers(string[] words, TasClient tas, Spring spring, out string[] vals, out int[] indexes) { var b = tas.GetBattle(); var temp = new string[b.Users.Count]; int i = 0; foreach (var u in b.Users) temp[i++] = u.name; return Filter(temp, words, out vals, out indexes); }
/************************************************************************/ /* PUBLIC METHODS */ /************************************************************************/ /// <summary> /// Initializes map downloader /// </summary> /// <param name="spring">spring instance to use</param> public MapDownloader(Spring spring) { this.spring = spring; wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted); wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged); }
/************************************************************************/ /* PUBLIC METHODS */ /************************************************************************/ /// <summary> /// Initializes Mod downloader /// </summary> public FileDownloader(Spring spring) { this.spring = spring; }
/************************************************************************/ /* PUBLIC METHODS */ /************************************************************************/ #region Constructors public UnknownFilesLinker(Spring spring) { this.spring = spring; timerDelResults.Elapsed += timerDelResults_Elapsed; timerDelResults.Enabled = true; }
public VoteKickSpec(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { }
public AutoHost(TasClient tas, Spring spring, AutoHostConfig conf) { banList = new BanList(this, tas); if (conf == null) LoadConfig(); else config = conf; SaveConfig(); this.tas = tas; this.spring = spring; tas.Said += tas_Said; pollTimer = new Timer(PollTimeout*1000); pollTimer.Enabled = false; pollTimer.AutoReset = false; pollTimer.Elapsed += pollTimer_Elapsed; spring.SpringExited += spring_SpringExited; spring.GameOver += spring_GameOver; spring.NotifyModsChanged += spring_NotifyModsChanged; tas.BattleUserLeft += tas_BattleUserLeft; tas.UserStatusChanged += tas_UserStatusChanged; tas.BattleUserJoined += tas_BattleUserJoined; tas.BattleMapChanged += tas_BattleMapChanged; tas.BattleUserStatusChanged += tas_BattleUserStatusChanged; tas.BattleLockChanged += tas_BattleLockChanged; tas.BattleOpened += tas_BattleOpened; linkProvider = new ResourceLinkProvider(); spring.UnitSyncWrapper.Downloader.LinksRecieved += linkProvider.Downloader_LinksRecieved; }
/************************************************************************/ /* PUBLIC METHODS */ /************************************************************************/ public UnknownFilesLinker(Spring spring) { this.spring = spring; timerDelResults.Elapsed += new ElapsedEventHandler(timerDelResults_Elapsed); timerDelResults.Enabled = true; }
public VoteSetOptions(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) {}
public static void SayBattle(TasClient tas, Spring spring, string text, bool ingame) { tas.Say(TasClient.SayPlace.Battle, "", text, true); if (spring.IsRunning && ingame) spring.SayGame(text); }
//new const double ratio = 0.50; public VoteTempAdmin(TasClient tas, Spring spring, AutoHost ah) : base(tas, spring, ah) { }