Beispiel #1
0
        /// <summary>
        /// Constructor. Loads data from a theater definition .ini file.
        /// </summary>
        /// <param name="ini">The .ini file to load from.</param>
        /// <param name="key">The value key.</param>
        public DefinitionTheaterWeather(INIFile ini, string key)
        {
            CloudsBase          = ini.GetValue <MinMaxI>("Weather", key + ".Clouds.Base");
            CloudsDensity       = ini.GetValue <MinMaxI>("Weather", key + ".Clouds.Density");
            CloudsPrecipitation = ini.GetValueArray <Precipitation>("Weather", key + ".Clouds.Precipitation");
            if (CloudsPrecipitation.Length == 0)
            {
                CloudsPrecipitation = new Precipitation[] { Precipitation.None }
            }
            ;
            CloudsThickness = ini.GetValue <MinMaxI>("Weather", key + ".Clouds.Thickness");

            DustEnabled = ini.GetValueArray <bool>("Weather", key + ".Dust.Enabled");
            if (DustEnabled.Length == 0)
            {
                DustEnabled = new bool[] { false }
            }
            ;
            DustDensity = ini.GetValue <MinMaxI>("Weather", key + ".Dust.Density");

            FogEnabled = ini.GetValueArray <bool>("Weather", key + ".Fog.Enabled");
            if (FogEnabled.Length == 0)
            {
                DustEnabled = new bool[] { false }
            }
            ;
            FogThickness  = ini.GetValue <MinMaxI>("Weather", key + ".Fog.Thickness");
            FogVisibility = ini.GetValue <MinMaxI>("Weather", key + ".Fog.Visibility");

            QNH        = ini.GetValue <MinMaxI>("Weather", key + ".QNH");
            Turbulence = ini.GetValue <MinMaxI>("Weather", key + ".Turbulence");
            Visibility = ini.GetValue <MinMaxI>("Weather", key + ".Visibility");
        }
    }
}
Beispiel #2
0
        internal DBCommonAirDefenseLevel(INIFile ini, AmountNR airDefenseLevel)
        {
            int i;

            GroupsInArea = new MinMaxI[Toolbox.EnumCount <AirDefenseRange>()];

            if ((airDefenseLevel == AmountNR.None) || (airDefenseLevel == AmountNR.Random))
            {
                EmbeddedChance    = 0;
                EmbeddedUnitCount = new MinMaxI(0, 0);
                for (i = 0; i < Toolbox.EnumCount <AirDefenseRange>(); i++)
                {
                    GroupsInArea[i] = new MinMaxI(0, 0);
                }
                SkillLevel = new DCSSkillLevel[] { DCSSkillLevel.Average };

                return;
            }

            EmbeddedChance    = Toolbox.Clamp(ini.GetValue <int>("AirDefense", $"{airDefenseLevel}.Embedded.Chance"), 0, 100) / 100.0;
            EmbeddedUnitCount = ini.GetValue <MinMaxI>("AirDefense", $"{airDefenseLevel}.Embedded.UnitCount");

            for (i = 0; i < Toolbox.EnumCount <AirDefenseRange>(); i++)
            {
                GroupsInArea[i] = ini.GetValue <MinMaxI>("AirDefense", $"{airDefenseLevel}.GroupsInArea.{(AirDefenseRange)i}");
            }

            SkillLevel = ini.GetValueArray <DCSSkillLevel>("AirDefense", $"{airDefenseLevel}.SkillLevel").Distinct().ToArray();
            if (SkillLevel.Length == 0)
            {
                SkillLevel = new DCSSkillLevel[] { DCSSkillLevel.Average, DCSSkillLevel.Good, DCSSkillLevel.High, DCSSkillLevel.Excellent }
            }
            ;
        }
    }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="ini">.ini file from which to load air defense common settings</param>
        /// <param name="airDefenseLevel">Level of air defense for which this setting applies.</param>
        public DatabaseCommonAirDefenseInfo(INIFile ini, AmountN airDefenseLevel)
        {
            int i;

            GroupsInArea = new MinMaxI[Toolbox.EnumCount <AirDefenseRange>()];

            if (airDefenseLevel == AmountN.None)
            {
                EmbeddedChance    = 0;
                EmbeddedUnitCount = new MinMaxI(0, 0);
                for (i = 0; i < Toolbox.EnumCount <AirDefenseRange>(); i++)
                {
                    GroupsInArea[i] = new MinMaxI(0, 0);
                }

                return;
            }

            EmbeddedChance    = Toolbox.Clamp(ini.GetValue <int>("AirDefense", $"{airDefenseLevel}.Embedded.Chance"), 0, 100) / 100.0;
            EmbeddedUnitCount = ini.GetValue <MinMaxI>("AirDefense", $"{airDefenseLevel}.Embedded.UnitCount");

            for (i = 0; i < Toolbox.EnumCount <AirDefenseRange>(); i++)
            {
                GroupsInArea[i] = ini.GetValue <MinMaxI>("AirDefense", $"{airDefenseLevel}.GroupsInArea.{(AirDefenseRange)i}");
            }
        }
Beispiel #4
0
        protected override bool OnLoad(string iniFilePath)
        {
            var ini = new INIFile(iniFilePath);

            BriefingName = new string[2]
            {
                ini.GetValue <string>("ObjectiveTarget", "Briefing.UnitName.Singular"),
                ini.GetValue <string>("ObjectiveTarget", "Briefing.UnitName.Plural")
            };

            UnitFamilies = Toolbox.SetSingleCategoryFamilies(ini.GetValueArray <UnitFamily>("ObjectiveTarget", "Units.Families"));
            if (UnitFamilies.Length == 0)
            {
                BriefingRoom.PrintToLog($"No unit categories for objective target \"{ID}\"", LogMessageErrorLevel.Warning);
                return(false);
            }

            UnitCount = new MinMaxI[Toolbox.EnumCount <Amount>()];
            foreach (Amount amount in Toolbox.GetEnumValues <Amount>())
            {
                UnitCount[(int)amount] = ini.GetValue <MinMaxI>("ObjectiveTarget", $"Units.Count.{amount}");
            }

            ValidSpawnPoints = DatabaseTools.CheckSpawnPoints(ini.GetValueArray <SpawnPointType>("ObjectiveTarget", "ValidSpawnPoints"));

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Constructor. Loads data from a .ini file.
        /// </summary>
        /// <param name="ini">The .ini file to load from.</param>
        /// <param name="section">The .ini section to load from.</param>
        /// <param name="key">The top level .ini key to load from.</param>
        public LibraryCommonSettingsEnemyAirDefense(INIFile ini, string section, string key)
        {
            EmbeddedChance   = HQTools.Clamp(ini.GetValue <int>(section, $"{key}.Embedded.Chance") / 100.0, 0.0, 1.0);
            EmbeddedCount    = ini.GetValue <MinMaxI>(section, $"{key}.Embedded.Count");
            EmbeddedFamilies = ini.GetValueArray <UnitFamily>(section, $"{key}.Embedded.Families");
            EmbeddedFamilies = (from f in EmbeddedFamilies where VALID_EMBEDDED_FAMILIES.Contains(f) select f).ToArray();
            if (EmbeddedFamilies.Length == 0)
            {
                EmbeddedFamilies = new UnitFamily[] { UnitFamily.VehicleAAA }
            }
            ;

            InAreaGroupCount = new MinMaxI[AIR_DEFENSE_RANGE_COUNT];
            InAreaGroupSize  = new MinMaxI[AIR_DEFENSE_RANGE_COUNT];
            InAreaFamilies   = new UnitFamily[AIR_DEFENSE_RANGE_COUNT][];

            for (int i = 0; i < AIR_DEFENSE_RANGE_COUNT; i++)
            {
                string subKey = $"{key}.InArea.{((AirDefenseRange)i).ToString()}";

                InAreaGroupCount[i] = ini.GetValue <MinMaxI>(section, $"{subKey}.GroupCount");
                InAreaGroupSize[i]  = ini.GetValue <MinMaxI>(section, $"{subKey}.GroupSize");
                InAreaFamilies[i]   = ini.GetValueArray <UnitFamily>(section, $"{subKey}.Families");
                InAreaFamilies[i]   = (from f in InAreaFamilies[i] where VALID_INAREA_FAMILIES.Contains(f) select f).ToArray();
                if (InAreaFamilies[i].Length == 0)
                {
                    InAreaFamilies[i] = new UnitFamily[] { UnitFamily.VehicleAAA }
                }
                ;
            }
        }
    }
}
        /// <summary>
        /// Loads data required by this definition.
        /// </summary>
        /// <param name="ini">INI file to load definition from.</param>
        /// <returns>True is successful, false if an error happened.</returns>
        protected override bool OnLoad(INIFile ini)
        {
            int i;

            // [Theater] section
            DCSID               = ini.GetValue <string>("Theater", "DCSID");
            DefaultMapCenter    = ini.GetValue <Coordinates>("Theater", "DefaultMapCenter");
            RequiredModules     = ini.GetValueArray <string>("Theater", "RequiredModules");
            MagneticDeclination = ini.GetValue <float>("Theater", "MagneticDeclination");

            // [Daytime] section
            DayTime = new MinMaxI[12];
            for (i = 0; i < 12; i++)
            {
                DayTime[i] = ini.GetValue <MinMaxI>("Daytime", ((Month)i).ToString());
            }

            // [Temperature] section
            Temperature = new MinMaxI[12];
            for (i = 0; i < 12; i++)
            {
                Temperature[i] = ini.GetValue <MinMaxI>("Temperature", ((Month)i).ToString());
            }

            // [Weather] section
            Weather = new DefinitionTheaterWeather[HQTools.EnumCount <Weather>() - 1]; // -1 because we don't want "Random"
            for (i = 0; i < Weather.Length; i++)
            {
                Weather[i] = new DefinitionTheaterWeather(ini, ((Weather)i).ToString());
            }

            // [Wind] section
            Wind = new DefinitionTheaterWind[HQTools.EnumCount <Wind>() - 1]; // -1 because we don't want "Auto"
            for (i = 0; i < Wind.Length; i++)
            {
                Wind[i] = new DefinitionTheaterWind(ini, ((Wind)i).ToString());
            }

            // [Airbases] section
            Airbases = new DefinitionTheaterAirbase[ini.GetTopLevelKeysInSection("Airbases").Length];
            i        = 0;
            foreach (string k in ini.GetTopLevelKeysInSection("Airbases"))
            {
                Airbases[i] = new DefinitionTheaterAirbase(ini, k); i++;
            }

            // [SpawnPoints] section
            SpawnPoints = new DefinitionTheaterSpawnPoint[ini.GetKeysInSection("SpawnPoints").Length];
            i           = 0;
            foreach (string k in ini.GetKeysInSection("SpawnPoints"))
            {
                SpawnPoints[i] = new DefinitionTheaterSpawnPoint(ini, k); i++;
            }

            ResetUsedSpawnPoints();

            return(true);
        }
Beispiel #7
0
     /// <summary>
     /// Constructor.
     /// </summary>
     /// <param name="ini">The .ini file to load airbase data from.</param>
     /// <param name="key">The .ini file key to load from</param>
     public DefinitionObjectiveUnitGroup(INIFile ini, string key)
     {
         Family = ini.GetValueArray <UnitFamily>("UnitGroups", $"{key}.Family");
         if (Family.Length == 0)
         {
             Family = new UnitFamily[] { UnitFamily.HelicopterTransport }
         }
         ;
         Count    = ini.GetValue <MinMaxI>("UnitGroups", $"{key}.Count");
         Flags    = ini.GetValueArray <MissionObjectiveUnitGroupFlags>("UnitGroups", $"{key}.Flags");
         LuaGroup = ini.GetValue <string>("UnitGroups", $"{key}.Lua.Group").Trim();
         LuaUnit  = ini.GetValue <string>("UnitGroups", $"{key}.Lua.Unit").Trim();
     }
 }
Beispiel #8
0
        internal DBCommonCAPLevel(INIFile ini, AmountNR capLevel)
        {
            if ((capLevel == AmountNR.None) || (capLevel == AmountNR.Random))
            {
                SkillLevel = new DCSSkillLevel[] { DCSSkillLevel.Average };
                UnitCount  = new MinMaxI(0, 0);
                return;
            }

            SkillLevel = ini.GetValueArray <DCSSkillLevel>("CAPLevels", $"{capLevel}.SkillLevel").Distinct().ToArray();
            if (SkillLevel.Length == 0)
            {
                SkillLevel = new DCSSkillLevel[] { DCSSkillLevel.Average, DCSSkillLevel.Good, DCSSkillLevel.High, DCSSkillLevel.Excellent }
            }
            ;
            UnitCount = ini.GetValue <MinMaxI>("CAPLevels", $"{capLevel}.UnitCount");
        }
    }
Beispiel #9
0
        /// <summary>
        /// Loads data required by this definition.
        /// </summary>
        /// <param name="ini">The ini file to load from.</param>
        /// <returns>True is successful, false if an error happened.</returns>
        protected override bool OnLoad(INIFile ini)
        {
            // -------------------
            // [Coalition] section
            // -------------------
            DisplayName = ini.GetValue <string>("Coalition", "DisplayName");

            MinMaxI timePeriodInteger = ini.GetValue <MinMaxI>("Coalition", "TimePeriod");

            MinMaxTimePeriod = new TimePeriod[] { (TimePeriod)timePeriodInteger.Min, (TimePeriod)timePeriodInteger.Max };

            NATOCallsigns = ini.GetValue <bool>("Coalition", "NATOCallsigns");
            UnitSystem    = ini.GetValue <UnitSystem>("Coalition", "UnitSystem");
            if (UnitSystem == UnitSystem.ByCoalition)
            {
                UnitSystem = UnitSystem.Metric;
            }
            RequiredModules = ini.GetValueArray <string>("Coalition", "RequiredModules");
            Countries       = ini.GetValueArray <DCSCountry>("Coalition", "Countries").Distinct().ToArray();
            if (Countries.Length == 0)
            {
                MessageBox.Show($"Failed to load coalition definition {ID.ToUpperInvariant()}, no countries assigned to coalition.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false); // No countries, bad coalition
            }

            // ---------------
            // [Units] section
            // ---------------
            Units = ini.GetAllValuesInSectionAsStringArray("Units");

            // ---------------------
            // [LegacyUnits] section
            // ---------------------
            LegacyUnits = ini.GetAllValuesInSectionAsStringArray("LegacyUnits");

            return(true);
        }
Beispiel #10
0
        protected override bool OnLoad(string iniFilePath)
        {
            var ini = new INIFile(iniFilePath);

            BriefingDescription = ini.GetValue <string>("Briefing", "Description");

            CloudsBase      = ini.GetValue <MinMaxI>("Weather", "Clouds.Base");
            CloudsPresets   = ini.GetValueArray <string>("Weather", "Clouds.Presets");
            CloudsThickness = ini.GetValue <MinMaxI>("Weather", "Clouds.Thickness");

            Dust        = ini.GetValue <bool>("Weather", "Dust");
            DustDensity = ini.GetValue <MinMaxI>("Weather", "Dust.Density");

            Fog           = ini.GetValue <bool>("Weather", "Fog");
            FogThickness  = ini.GetValue <MinMaxI>("Weather", "Fog.Thickness");
            FogVisibility = ini.GetValue <MinMaxI>("Weather", "Fog.Visibility");

            BadWeather = ini.GetValue <bool>("Weather", "IsBadWeather");
            QNH        = ini.GetValue <MinMaxI>("Weather", "QNH");
            Turbulence = ini.GetValue <MinMaxI>("Weather", "Turbulence");
            Visibility = ini.GetValue <MinMaxI>("Weather", "Visibility");

            return(true);
        }
Beispiel #11
0
 internal DBCommonWind(INIFile ini, string key)
 {
     Wind       = ini.GetValue <MinMaxI>("Wind", key + ".Wind");
     Turbulence = ini.GetValue <MinMaxI>("Wind", key + ".Turbulence");
 }
 /// <summary>
 /// Constructor. Loads data from a theater definition .ini file.
 /// </summary>
 /// <param name="ini">The .ini file to load from.</param>
 /// <param name="key">The value key.</param>
 public DefinitionTheaterWind(INIFile ini, string key)
 {
     Wind       = ini.GetValue <MinMaxI>("Wind", key + ".Wind");
     Turbulence = ini.GetValue <MinMaxI>("Wind", key + ".Turbulence");
 }
Beispiel #13
0
        /// <summary>
        /// Loads a database entry from an .ini file.
        /// </summary>
        /// <param name="iniFilePath">Path to the .ini file where entry inforation is stored</param>
        /// <returns>True is successful, false if an error happened</returns>

        protected override bool OnLoad(string iniFilePath)
        {
            int i;

            using (INIFile ini = new INIFile(iniFilePath))
            {
                // [Briefing] section
                BriefingNames = ini.GetValueArray <string>("Briefing", "Names");

                // [Theater] section
                DCSID               = ini.GetValue <string>("Theater", "DCSID");
                DefaultMapCenter    = ini.GetValue <Coordinates>("Theater", "DefaultMapCenter");
                MagneticDeclination = ini.GetValue <float>("Theater", "MagneticDeclination");

                // [Daytime] section
                DayTime = new MinMaxI[12];
                for (i = 0; i < 12; i++)
                {
                    MinMaxI?dayTimeValue = ParseMinMaxTime(ini.GetValueArray <string>("Daytime", ((Month)i).ToString()));

                    if (!dayTimeValue.HasValue) // Cast failed
                    {
                        DebugLog.Instance.WriteLine(
                            $"Wrong format for daytime value for month {(Month)i} in theater {ID}, using default value", 0,
                            DebugLogMessageErrorLevel.Warning);
                    }

                    DayTime[i] = dayTimeValue ?? DEFAULT_DAYTIME;
                }

                // [Temperature] section
                Temperature = new MinMaxI[12];
                for (i = 0; i < 12; i++)
                {
                    Temperature[i] = ini.GetValue <MinMaxI>("Temperature", ((Month)i).ToString());
                }

                // [Weather] section
                Weather = new DBEntryTheaterWeather[Toolbox.EnumCount <Weather>() - 1]; // -1 because we don't want "Random"
                for (i = 0; i < Weather.Length; i++)
                {
                    Weather[i] = new DBEntryTheaterWeather(ini, ((Weather)i).ToString());
                }

                // [Wind] section
                Wind = new DBEntryTheaterWind[Toolbox.EnumCount <Wind>() - 1]; // -1 because we don't want "Auto"
                for (i = 0; i < Wind.Length; i++)
                {
                    Wind[i] = new DBEntryTheaterWind(ini, ((Wind)i).ToString());
                }

                // [Airbases] section
                Airbases = new DBEntryTheaterAirbase[ini.GetTopLevelKeysInSection("Airbases").Length];
                i        = 0;
                foreach (string k in ini.GetTopLevelKeysInSection("Airbases"))
                {
                    Airbases[i] = new DBEntryTheaterAirbase(ini, k); i++;
                }

                // [SpawnPoints] section
                List <DBEntryTheaterSpawnPoint> spawnPointsList = new List <DBEntryTheaterSpawnPoint>();
                foreach (string k in ini.GetKeysInSection("SpawnPoints"))
                {
                    DBEntryTheaterSpawnPoint sp = new DBEntryTheaterSpawnPoint();
                    if (sp.Load(ini, k))
                    {
                        spawnPointsList.Add(sp);
                    }
                }
                SpawnPoints = spawnPointsList.ToArray();
            }

            return(true);
        }
Beispiel #14
0
        protected override bool OnLoad(string iniFilePath)
        {
            int i;

            var ini = new INIFile(iniFilePath);

            // [Briefing] section
            BriefingNames = ini.GetValueArray <string>("Briefing", "Names");

            // [Theater] section
            DCSID               = ini.GetValue <string>("Theater", "DCSID");
            DefaultMapCenter    = ini.GetValue <Coordinates>("Theater", "DefaultMapCenter");
            MagneticDeclination = ini.GetValue <double>("Theater", "MagneticDeclination");

            // [Daytime] section
            DayTime = new MinMaxI[12];
            for (i = 0; i < 12; i++)
            {
                MinMaxI?dayTimeValue = ParseMinMaxTime(ini.GetValueArray <string>("Daytime", ((Month)i).ToString()));

                if (!dayTimeValue.HasValue) // Cast failed
                {
                    BriefingRoom.PrintToLog(
                        $"Wrong format for daytime value for month {(Month)i} in theater {ID}, using default value",
                        LogMessageErrorLevel.Warning);
                }

                DayTime[i] = dayTimeValue ?? DEFAULT_DAYTIME;
            }


            // Water Coordinates
            WaterCoordinates = new List <Coordinates>();
            foreach (string key in ini.GetKeysInSection("WaterCoordinates"))
            {
                WaterCoordinates.Add(ini.GetValue <Coordinates>("WaterCoordinates", key));
            }


            List <DBEntryTheaterSpawnPoint> spawnPointsList = new List <DBEntryTheaterSpawnPoint>();

            foreach (string key in ini.GetKeysInSection("SpawnPoints"))
            {
                DBEntryTheaterSpawnPoint sp = new DBEntryTheaterSpawnPoint();
                if (sp.Load(ini, key))
                {
                    spawnPointsList.Add(sp);
                }
            }
            SpawnPoints = spawnPointsList.ToArray();

            WaterExclusionCoordinates = new List <List <Coordinates> >();
            if (ini.GetSections().Contains("waterexclusioncoordinates"))
            {
                // Water Exclusion Coordinates
                var tempList = new List <Coordinates>();
                var groupID  = ini.GetKeysInSection("WaterExclusionCoordinates").First().Split(".")[0];
                foreach (string key in ini.GetKeysInSection("WaterExclusionCoordinates"))
                {
                    var newGroupId = key.Split(".")[0];
                    if (groupID != newGroupId)
                    {
                        groupID = newGroupId;
                        WaterExclusionCoordinates.Add(tempList);
                        tempList = new List <Coordinates>();
                    }
                    tempList.Add(ini.GetValue <Coordinates>("WaterExclusionCoordinates", key));
                }
                WaterExclusionCoordinates.Add(tempList);
            }

            // [Temperature] section
            Temperature = new MinMaxI[12];
            for (i = 0; i < 12; i++)
            {
                Temperature[i] = ini.GetValue <MinMaxI>("Temperature", ((Month)i).ToString());
            }

            return(true);
        }