internal Battle()
 {
     Bots          = new List <BotBattleStatus>();
     Details       = new BattleDetails();
     ModOptions    = new Dictionary <string, string>();
     Rectangles    = new Dictionary <int, BattleRect>();
     DisabledUnits = new List <string>();
     Password      = "******";
     Nat           = NatMode.None;
     Users         = new List <UserBattleStatus>();
 }
        public Battle(string engineVersion, string password, int port, int maxplayers, int rank, Map map, string title, Mod mod, BattleDetails details) : this()
        {
            if (!String.IsNullOrEmpty(password))
            {
                Password = password;
            }
            if (port == 0)
            {
                HostPort = 8452;
            }
            else
            {
                HostPort = port;
            }
            try {
                var ports = IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners().OrderBy(x => x.Port).Select(x => x.Port).ToList();
                if (ports.Contains(HostPort))
                {
                    var blockedPort = HostPort;
                    while (ports.Contains(HostPort))
                    {
                        HostPort++;
                    }
                    Trace.TraceWarning("Host port {0} was used, using backup port {1}", blockedPort, HostPort);
                }
            } catch {}



            EngineVersion = engineVersion;
            MaxPlayers    = maxplayers;
            Rank          = rank;
            this.map      = map;
            MapName       = map.Name;
            MapHash       = map.Checksum;
            Title         = title;
            this.mod      = mod;
            ModName       = mod.Name;
            ModHash       = mod.Checksum;
            if (details != null)
            {
                Details = details;
            }
        }