示例#1
0
        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;
        }
示例#2
0
    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;
    }
示例#3
0
        public bool Start()
        {
            if (config.AttemptToRecconnect)
            {
                recon          = new System.Timers.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.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);
        }