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(); }
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(); }
/// <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); }
/// <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); }
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); } }
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); }
public void ChangeMap(MapInfo nmap) { if (battle != null) { mapToChangeTo = nmap; UpdateBattleInfo(lockToChangeTo, nmap); } }
/// <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); }
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); } }
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)); }
/// <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); }
/// <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); }