예제 #1
0
 public Battle(string password, int port, int maxplayers, int rank, MapInfo map, string title, ModInfo mod, BattleDetails details)
 {
   if (!String.IsNullOrEmpty(password)) this.Password = password; else this.Password = "******";
   if (port == 0) this.HostPort = 8452; else this.HostPort = port;
   this.MaxPlayers = maxplayers;
   this.Rank = rank;
   this.Map = map;
   this.Title = title;
   this.Mod = mod;
   if (details != null) this.Details = details; else details = new BattleDetails();
   details.Validate();
 }
예제 #2
0
		public Battle(string password, int port, int maxplayers, int rank, MapInfo map, string title, ModInfo mod, BattleDetails details)
		{
			if (!String.IsNullOrEmpty(password)) Password = password;
			else Password = "******";
			if (port == 0) HostPort = 8452;
			else HostPort = port;
			MaxPlayers = maxplayers;
			Rank = rank;
			Map = map;
			Title = title;
			Mod = mod;
			if (details != null) Details = details;
			else details = new BattleDetails();
		}
예제 #3
0
		/// <summary>
		/// Gets map list from unit sync, does not make full reinit by default
		/// </summary>
		/// <returns></returns>
		private void LoadMapList()
		{
			string opath = Directory.GetCurrentDirectory();
			Directory.SetCurrentDirectory(path);

			int mapCount = GetMapCount();
			mapList.Clear();
			for (int i = 0; i < mapCount; ++i) {
				var mi = new MapInfo(this, GetMapName(i), i);
				mapList[mi.Name] = mi;
				mi.ArchiveName = RequestMapArchive(mi.Name);
			}
			Directory.SetCurrentDirectory(opath);
		}
예제 #4
0
		/// <summary>
		/// Loads new map information
		/// </summary>
		/// <param name="mi"></param>
		internal void LoadMapInfo(MapInfo mi)
		{
			string opath = Directory.GetCurrentDirectory();
			Directory.SetCurrentDirectory(path);

			mi.Checksum = (int)GetMapChecksum(mi.MapId);

			Directory.SetCurrentDirectory(opath);
		}
예제 #5
0
		private void UpdateBattleInfo(bool lck, MapInfo mapname)
		{
			if (battle != null) {
				lockToChangeTo = lck;
				con.SendCommand(0, "UPDATEBATTLEINFO", battle.CountSpectators(), (lck ? 1 : 0), mapname.Checksum, mapname.Name);
			}
		}
예제 #6
0
		public void OpenBattle(Battle nbattle)
		{
			LeaveBattle(); // leave current battle
			battleID = -1;
			battle = (Battle) nbattle.Clone();

			var objList = new List<object>();
			objList.Add(0); // type = normal
			objList.Add((int) battle.Nat);
			objList.Add(battle.Password);
			objList.Add(battle.HostPort);
			objList.Add(battle.MaxPlayers);
			;
			//battle.Details.AddToParamList(objList);
			objList.Add(battle.Mod.Checksum);
			objList.Add(battle.Rank);
			objList.Add(battle.Map.Checksum);
			objList.Add(battle.Map.Name);
			objList.Add('\t' + battle.Title);
			objList.Add('\t' + battle.Mod.Name);

			mapToChangeTo = battle.Map;
			lockToChangeTo = false;

			con.SendCommand(0, "OPENBATTLE", objList.ToArray());

			lastSpectatorCount = -1;

			// send predefined starting rectangles
			foreach (var v in battle.Rectangles) con.SendCommand(0, "ADDSTARTRECT", v.Key, v.Value.Left, v.Value.Top, v.Value.Right, v.Value.Bottom);
		}
예제 #7
0
		public void ChangeMap(MapInfo nmap)
		{
			if (battle != null) {
				mapToChangeTo = nmap;
				UpdateBattleInfo(lockToChangeTo, nmap);
			}
		}
예제 #8
0
    /// <summary>
    /// Loads new map information
    /// </summary>
    /// <param name="mi"></param>
    internal void LoadMapInfo(MapInfo mi)
    {
      string opath = Directory.GetCurrentDirectory();
      Directory.SetCurrentDirectory(path);
      int i = mi.MapId;

      ReInit(true);

      GetMapCount();
      //if (mi.Name != GetMapName(i)) throw new Exception("Map " + mi.Name + " modified without reload");

      uint result = 0;
      int acount = GetMapArchiveCount(mi.Name);
      for (int x = 0; x < acount; ++x) {
        result += GetArchiveChecksum(GetMapArchiveName(x));
      }
      mi.Checksum = (int)result;

      Directory.SetCurrentDirectory(opath);
    }
예제 #9
0
    public void OpenBattle(Battle nbattle)
    {
      LeaveBattle(); // leave current battle
      battleID = -1;
      this.battle = (Battle)nbattle.Clone();

      List<Object> objList = new List<object>();
      objList.Add(0); // type = normal
      objList.Add(Program.main.config.GargamelMode ? 2 : 0); // nat - fixed ports for gargamel otherwise 0
      objList.Add(battle.Password);
      objList.Add(battle.HostPort);
      objList.Add(battle.MaxPlayers); ;
      battle.Details.AddToParamList(objList);
      objList.Add(battle.Mod.Checksum);
      objList.Add(battle.Rank);
      objList.Add(battle.Map.Checksum);
      objList.Add(battle.Map.Name);
      objList.Add('\t' + battle.Title);
      objList.Add('\t' + battle.Mod.Name);

      mapToChangeTo = battle.Map;
      lockToChangeTo = false;
      
      con.SendCommand(0, "OPENBATTLE", objList.ToArray());

      lastSpectatorCount = -1;

      // send predefined starting rectangles
      foreach (KeyValuePair<int, BattleRect> v in battle.Rectangles) {
        con.SendCommand(0, "ADDSTARTRECT", v.Key, v.Value.Left, v.Value.Top, v.Value.Right, v.Value.Bottom);
      }

    }
예제 #10
0
 public void OpenBattle(string password, int port, int maxplayers, int rank, MapInfo map, string title, ModInfo mod, BattleDetails details)
 {
   OpenBattle(new Battle(password, port, maxplayers, rank, map, title, mod, details));
 }
예제 #11
0
		/// <summary>
		/// Loads new map information
		/// </summary>

		internal  void LoadMapInfo(MapInfo mi, int mapId)
		{
			string opath = Directory.GetCurrentDirectory();
			Directory.SetCurrentDirectory(path);
			ReInit(true);
      
			mi.Checksum = (int)GetMapChecksum(mapId);

			Directory.SetCurrentDirectory(opath);
		}
예제 #12
0
		/// <summary>
		/// Gets map list from unit sync, does not make full reinit by default
		/// </summary>
		/// <returns></returns>
		private void LoadMapList()
		{
			string opath = Directory.GetCurrentDirectory();
			Directory.SetCurrentDirectory(path);

			int mapCount = GetMapCount();
			mapList.Clear();
			for (int i = 0; i < mapCount; ++i) {
				var mi = new MapInfo(GetMapName(i));
				LoadMapInfo(mi, i);
				mapList[mi.Name] = mi;
			}
			Directory.SetCurrentDirectory(opath);
		}