Example #1
0
 void tas_BattleFound(object sender, TasEventArgs e)
 {
   string map = Utils.Glue(e.ServerParams.ToArray(), 10).Split('\t')[0];
   if (!spring.UnitSync.MapList.ContainsKey(map)) {
     if (config.AutoDownloadNewMaps) mapDownloader.DownloadMap(map);
   }
 }
Example #2
0
 public void OnFailure(object sender, TasEventArgs args)
 {
   if (InvokeRequired) Invoke(new TasEvent(OnFailure), sender, args);
   else {
     string mes = "Command failed:";
     tServer.AppendText(mes + Utils.Glue(args.ServerParams.ToArray()) + "\r\n");
   }
 }
Example #3
0
 private void tas_BattleUserIpRecieved(object sender, TasEventArgs e)
 {
   UpdateWithUserIp(e.ServerParams[0], IPAddress.Parse(e.ServerParams[1]));
   BannedUser b;
   if (IsBanned(e.ServerParams[0], out b)) {
     tas.Say(TasClient.SayPlace.Battle, "", e.ServerParams[0] + " (" + b.Name + ") is banned for " + b.Reason, true);
     tas.Kick(e.ServerParams[0]);
   }
 }
Example #4
0
 void mapDownloader_DownloadCompleted(object sender, TasEventArgs e)
 {
   string mes;
   if (e.ServerParams.Count > 1 && e.ServerParams[1] != "") {
     mes = e.ServerParams[0] + " download failed: " + e.ServerParams[1];
   } else {
     mes = e.ServerParams[0] + " download finished!";
     spring.Reload(false, true);
   }
   if (tas.IsConnected) tas.Say(TasClient.SayPlace.Battle, "", mes, true);
 }
Example #5
0
    void tas_BattleUserJoined(object sender, TasEventArgs e)
    {
      string name = e.ServerParams[0];
      string welc = config.Welcome;
      if (welc != "") {
        welc = welc.Replace("%1", name);
        welc = welc.Replace("%2", GetUserLevel(name).ToString());
        welc = welc.Replace("%3", MainConfig.SpringieVersion);
        SayBattle(welc);
      }
      if (config.DisplayMapLink) SayBattle("maplink: " + linker.GetMapBounceLink(tas.GetBattle().Map.Name));

      HandleKickSpecServerLocking();
      HandleAutoLocking();
      HandleMinRankKicking();

     
      if (minCpuSpeed > 0) {
        User u;
        if (tas.GetExistingUser(name, out u)) {
          if (u.cpu != 0 && u.cpu < minCpuSpeed * 1000) {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            SayBattle(name + ", your CPU speed is below minimum set for this server:" + minCpuSpeed + "GHz - sorry");
            ComKick(TasSayEventArgs.Default, new string[] { u.name });
          }
        }
      }
    }
Example #6
0
 private void tas_ConnectionLost(object sender, TasEventArgs e)
 {
   autoHost.Stop();
   recon.Start();
 }
Example #7
0
 void tas_BattleMapChanged(object sender, TasEventArgs e)
 {
   if (config.DisplayMapLink) SayBattle("maplink: " + linker.GetMapBounceLink(tas.GetBattle().Map.Name));
 }
Example #8
0
 private void Tas_ConnectionLost(object sender, TasEventArgs e)
 {
   if (InvokeRequired) Invoke(new TasEvent(Tas_ConnectionLost), sender, e);
   else {
     notifyIcon1.Icon = Resources.err;
     listBoxBattle.Items.Clear();
     listBoxChannel.Items.Clear();
     rehostToolStripMenuItem.Enabled = false;
   }
 }
Example #9
0
 // im connected, let's login
 private void tas_Connected(object sender, TasEventArgs e)
 {
   tas.Login(config.AccountName, config.AccountPassword, MainConfig.SpringieVersion);
 }
Example #10
0
 private void Tas_UserRemoved(object sender, TasEventArgs e)
 {
   if (InvokeRequired) Invoke(new TasEvent(Tas_UserRemoved), sender, e);
   else {
     int i = GetUserIndex(listBoxChannel, e.ServerParams[0]);
     if (i != -1) listBoxChannel.Items.RemoveAt(i);
   }
 }
Example #11
0
    private void tas_BattleUserLeft(object sender, TasEventArgs e)
    {
      CheckForBattleExit();
      HandleKickSpecServerLocking();
      HandleAutoLocking();

      if (spring.IsRunning) spring.SayGame(e.ServerParams[0] + " has left lobby");

      if (e.ServerParams[0] == bossName) {
        SayBattle("boss has left the battle");
        bossName = "";
      }

      if (tas.GetBattle().IsLocked && tas.GetBattle().Users.Count < 2) {
        // player left and only 2 remaining (springie itself + some noob) -> unlock
        tas.ChangeLock(false);
      }
    }
Example #12
0
 private void tas_BattleOpened(object sender, TasEventArgs e)
 {
   tas.DisableUnits(UnitInfo.ToStringList(config.DisabledUnits));
 }
Example #13
0
    private void tas_BattleUserStatusChanged(object sender, TasEventArgs e)
    {
      UserBattleStatus u;
      Battle b = tas.GetBattle();

      if (b != null && b.ContainsUser(e.ServerParams[0], out u)) {
        /*if (u.SyncStatus == SyncStatuses.Unsynced) {
          SayBattle("kicking " + u.name + " - has incorrect spring or mod version");
          tas.Kick(u.name);
        }*/

        if (KickSpectators && u.IsSpectator == true && u.name != tas.UserName) {
          SayBattle(config.KickSpectatorText);
          ComKick(TasSayEventArgs.Default, new string[] {u.name});
        }
        HandleAutoLocking();

        int cnt = 0;
        foreach (UserBattleStatus ubs in b.Users) if (!ubs.IsSpectator && ubs.IsReady) cnt++;
        string usname;
        int allyno;
        if (!manager.Enabled) {
          if ((cnt == config.MaxPlayers || (autoLock > 0 && autoLock == cnt)) && AllReadyAndSynced(out usname) && AllUniqueTeams(out usname) && BalancedTeams(out allyno)) {
            SayBattle("server is full, starting");
            Thread.Sleep(1000); // just to make sure that other clients update their game info and balance ends
            ComStart(TasSayEventArgs.Default, new string[] {});
          }
        }
      }
    }
Example #14
0
 void tas_BattleUserIpRecieved(object sender, TasEventArgs e)
 {
   User u;
   if (tas.GetExistingUser(e.ServerParams[0], out u)) {
     SendCommand(gatherScript, "a=joinplayer&name=" + u.name + "&rank=" + u.rank + "&ip=" + e.ServerParams[1], true, true);
   }
  
 }
Example #15
0
 void tas_UserRemoved(object sender, TasEventArgs e)
 {
   SendCommand(gatherScript, "a=removeplayer&name=" + e.ServerParams[0], true, true);
 }
Example #16
0
 void tas_UserStatusChanged(object sender, TasEventArgs e)
 {
   User u;
   if (tas.GetExistingUser(e.ServerParams[0], out u)) {
     SendCommand(gatherScript, "a=addplayer&name=" + u.name + "&rank=" + (u.rank + 1), true, true);
   }
 }
Example #17
0
 private void Tas_Connected(object sender, TasEventArgs e)
 {
   if (InvokeRequired) Invoke(new TasEvent(Tas_Connected), sender, e);
   else {
     tServer.AppendText("Connected to server\r\n");
     notifyIcon1.Icon = Resources.ok;
     rehostToolStripMenuItem.Enabled = true;
   }
 }
Example #18
0
 private void Tas_UserAdded(object sender, TasEventArgs e)
 {
   if (InvokeRequired) Invoke(new TasEvent(Tas_UserAdded), sender, e);
   else {
     string nam = e.ServerParams[0];
     for (int i = 0; i < listBoxChannel.Items.Count; ++i) {
       if (nam.CompareTo(listBoxChannel.Items[i].ToString()) == -1) {
         listBoxChannel.Items.Insert(i, UpdateNameWithCountryAfkAndGame(nam));
         return;
       }
     }
     listBoxChannel.Items.Add(UpdateNameWithCountryAfkAndGame(nam));
   }
 }
Example #19
0
    private void tas_BattleUserJoined(object sender, TasEventArgs e)
    {
      BannedUser b;
      string usname = e.ServerParams[0];

      if (IsBanned(usname, out b)) {
        tas.Say(TasClient.SayPlace.Battle, "", usname + " (" + b.Name + ") is banned for " + b.Reason, true);
        tas.Kick(usname);
      }
    }
Example #20
0
    private void tas_BattleUserJoined(object sender, TasEventArgs e)
    {
      string name = e.ServerParams[0];
      string welc = config.Welcome;
      if (welc != "") {
        welc = welc.Replace("%1", name);
        welc = welc.Replace("%2", GetUserLevel(name).ToString());
        welc = welc.Replace("%3", MainConfig.SpringieVersion);
        SayBattle(welc, false);
      }
      if (Program.main.config.AllowInGameJoin && spring.IsRunning) {
        SayBattle("GAME IS CURRENTLY IN PROGRESS, PLEASE WAIT TILL IT ENDS!", false);
        SayBattle("If you say !notify, I will PM you when game ends.", false);
      }
      if (config.DisplayMapLink) SayBattle("maplink: " + linker.GetMapBounceLink(tas.GetBattle().Map.Name), false);

      HandleKickSpecServerLocking();
      HandleAutoLocking();
      HandleMinRankKicking();

      if (minCpuSpeed > 0) {
        User u;
        if (tas.GetExistingUser(name, out u)) {
          if (u.cpu != 0 && u.cpu < minCpuSpeed*1000) {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            SayBattle(name + ", your CPU speed is below minimum set for this server:" + minCpuSpeed + "GHz - sorry");
            ComKick(TasSayEventArgs.Default, new string[] {u.name});
          }
        }
      }
    }
Example #21
0
    void tas_LoginAccepted(object sender, TasEventArgs e)
    {
      Account a = accounts.Find(delegate(Account acc) { return acc.UserName == UserName; });
      if (a != null) {
        password = a.Password;
      }

      if (password == "") {
        password = SendCommand(gatherScript, "a=register&name=" + UserName, false, false);
        if (password != "") {
          if (password.StartsWith("FAILED")) {
            MessageBox.Show("You need correct password to submit stats with account " + UserName + ", stats won't work - " + password, "Stats registration failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
          } else {
            accounts.Add(new Account(UserName, password));
            SaveAccounts();
          }
        } else MessageBox.Show("Error registering to stats server - stats server probably down. Statistics wont work until next Springie start", "Stats registration failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
      }
    }
Example #22
0
 private void Tas_BattleUserLeft(object sender, TasEventArgs e)
 {
   if (InvokeRequired) Invoke(new TasEvent(Tas_BattleUserLeft), sender, e);
   else {
     UpdateStatusInfo();
     int i = GetUserIndex(listBoxBattle, e.ServerParams[0]);
     if (i != -1) listBoxBattle.Items.RemoveAt(i);
   }
 }
Example #23
0
 private void tas_BattleLockChanged(object sender, TasEventArgs e)
 {
   SayBattle("game " + (tas.GetBattle().IsLocked ? "locked" : "unlocked"), false);
 }
Example #24
0
 void tas_LoginDenied(object sender, TasEventArgs e)
 {
   Program.formMain.GetNewLogPass();
 }
Example #25
0
 private void tas_BattleMapChanged(object sender, TasEventArgs e)
 {
   if (config.DisplayMapLink) SayBattle("maplink: " + linker.GetMapBounceLink(tas.GetBattle().Map.Name));
   foreach (UserBattleStatus p in tas.GetBattle().Users) {
     //ring all people that host changed the map
     tas.Ring(p.name);
   }
   Battle b = tas.GetBattle();
   string mapName = b.Map.ArchiveName.ToLower();
   if (MapBoxes.ContainsKey(mapName)) {
     for (int i = 0; i < b.Rectangles.Count; ++i) tas.RemoveBattleRectangle(i);
     Dictionary<int, BattleRect> dict = MapBoxes[mapName];
     foreach (KeyValuePair<int, BattleRect> v in dict) tas.AddBattleRectangle(v.Key, v.Value);
   }
 }
Example #26
0
 private void tas_MyStatusChangedToInGame(object sender, TasEventArgs e)
 {
   spring.StartGame(tas.GetBattle());
 }
Example #27
0
 private void tas_UserStatusChanged(object sender, TasEventArgs e)
 {
   if (spring.IsRunning) {
     Battle b = tas.GetBattle();
     if (e.ServerParams[0] != tas.UserName && b.ContainsUser(e.ServerParams[0])) CheckForBattleExit();
   }
 }
Example #28
0
 private void tas_LoginDenied(object sender, TasEventArgs e)
 {
   //MessageBox.Show(e.ServerParams[0], "Login failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
   Program.formMain.GetNewLogPass();
 }
Example #29
0
		/// <summary>
		/// purpose of this event handler is to redirect "fail" events to failure event too
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		private void RaiseFailure(object sender, TasEventArgs args)
		{
			if (Failure != null) Failure(this, args);
		}
Example #30
0
 // login accepted - join channels
 private void tas_LoginAccepted(object sender, TasEventArgs e)
 {
   for (int i = 0; i < config.JoinChannels.Length; ++i) tas.JoinChannel(config.JoinChannels[i]);
   autoHost.Start(null, null);
 }