protected void ParseSettings()
{
Match Match;
int dummy;
// Stats Enabled
Match = Regex.Match(FileContents, @"stats_enable = (?<value>[0-1])");
if (!Int32.TryParse(Match.Groups["value"].Value, out dummy))
throw new Exception("The config key \"stats_enable\" was not formated correctly.");
StatsEnabled = (dummy == 1);
// Debug Enabled
Match = Regex.Match(FileContents, @"debug_enable = (?<value>[0-1])");
if (!Int32.TryParse(Match.Groups["value"].Value, out dummy))
throw new Exception("The config key \"debug_enable\" was not formated correctly.");
DebugEnabled = (dummy == 1);
// Snapshot logging
Match = Regex.Match(FileContents, "snapshot_logging = (?<value>[0-2])");
if (!Int32.TryParse(Match.Groups["value"].Value, out SnapshotLogging))
throw new Exception("The config key \"snapshot_logging\" was not formated correctly.");
// Snapshot prefix
Match = Regex.Match(FileContents, @"snapshot_prefix = '(?<value>[A-Za-z0-9_]+)?'");
if (!Match.Success)
throw new Exception("The config key \"snapshot_prefix\" was not formated correctly.");
SnapshotPrefix = Match.Groups["value"].Value;
// Medal Data
Match = Regex.Match(FileContents, @"medals_custom_data = '(?<value>[A-Za-z0-9_]*)'");
if (!Match.Success)
throw new Exception("The config key \"medals_custom_data\" was not formated correctly.");
MedalDataProfile = Match.Groups["value"].Value;
// Xpack Medal Enabled Mods
Match = Regex.Match(FileContents, @"medals_xpack_mods = \[(?<value>[A-Za-z0-9_/\s',]*)\]");
if (!Match.Success)
throw new Exception("The config key \"medals_xpack_mods\" was not formated correctly.");
// Extract medals mods
string[] values = Match.Groups["value"].Value.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
foreach (string mod in values)
{
XpackMedalMods.Add(mod.Trim('\'').Replace("mods/", "").ToLowerInvariant());
}
// ASP Address
Match = Regex.Match(FileContents, @"http_backend_addr = '(?<value>.*)'");
if (!Match.Success)
throw new Exception("The config key \"http_backend_addr\" was not formated correctly.");
AspAddress = IPAddress.Parse(Match.Groups["value"].Value);
// ASP Port
Match = Regex.Match(FileContents, @"http_backend_port = (?<value>[0-9]+)");
if (!Match.Success || !Int32.TryParse(Match.Groups["value"].Value, out AspPort))
throw new Exception("The config key \"http_backend_port\" was not formated correctly.");
// ASP Callback
Match = Regex.Match(FileContents, @"http_backend_asp = '(?<value>.*)'");
if (!Match.Success)
throw new Exception("The config key \"http_backend_asp\" was not formated correctly.");
AspFile = Match.Groups["value"].Value;
// Central ASP Address
Match = Regex.Match(FileContents, @"http_central_addr = '(?<value>.*)'");
if (!Match.Success)
throw new Exception("The config key \"http_central_addr\" was not formated correctly.");
CentralAspAddress = IPAddress.Parse(Match.Groups["value"].Value);
// Central ASP Port
Match = Regex.Match(FileContents, @"http_central_port = (?<value>[0-9]+)");
if (!Match.Success || !Int32.TryParse(Match.Groups["value"].Value, out CentralAspPort))
throw new Exception("The config key \"http_central_port\" was not formated correctly.");
// Central Callback
Match = Regex.Match(FileContents, @"http_central_asp = '(?<value>.*)'");
if (!Match.Success)
throw new Exception("The config key \"http_central_asp\" was not formated correctly.");
CentralAspFile = Match.Groups["value"].Value;
// Central Database Enabled
Match = Regex.Match(FileContents, @"http_central_enable = (?<value>[0-2])");
if (!Int32.TryParse(Match.Groups["value"].Value, out CentralStatsMode))
throw new Exception("The config key \"http_central_enable\" was not formated correctly.");
// CLAN MANAGER
Match = Regex.Match(FileContents, @"enableClanManager = (?<value>[0-1])");
if (!Int32.TryParse(Match.Groups["value"].Value, out dummy))
throw new Exception("The config key \"enableClanManager\" was not formated correctly.");
ClanManager.Enabled = (dummy == 1);
// Server Mode
Match = Regex.Match(FileContents, @"serverMode = (?<value>[0-4])");
if (!Int32.TryParse(Match.Groups["value"].Value, out ClanManager.ServerMode))
throw new Exception("The config key \"serverMode\" was not formated correctly.");
// Clan manager array values
// Clan Tag
Match = Regex.Match(FileContents, @"'clantag',[\s|\t]+'(?<value>[A-Za-z0-9_=-\|\s\[\]]*)'");
if (!Match.Success)
throw new Exception("The config key \"criteria_data => clantag\" was not formated correctly.");
ClanManager.ClanTagRequirement = Match.Groups["value"].Value;
// Score
Match = Regex.Match(FileContents, @"'score',[\s|\t]+(?<value>[0-9]+)");
if (!Match.Success)
throw new Exception("The config key \"criteria_data => score\" was not formated correctly.");
ClanManager.ScoreRequirement = Int32.Parse(Match.Groups["value"].Value);
// time
Match = Regex.Match(FileContents, @"'time',[\s|\t]+(?<value>[0-9]+)");
if (!Match.Success)
throw new Exception("The config key \"criteria_data => time\" was not formated correctly.");
ClanManager.TimeRequirement = Int32.Parse(Match.Groups["value"].Value);
// K/D Ratio
Match = Regex.Match(FileContents, @"'kdratio',[\s|\t]+(?<value>[0-9.]+)");
if (!Match.Success)
throw new Exception("The config key \"criteria_data => kdratio\" was not formated correctly.");
ClanManager.KDRatioRequirement = Decimal.Parse(Match.Groups["value"].Value);
// Banned
Match = Regex.Match(FileContents, @"'banned',[\s|\t]+(?<value>[0-9]+)");
if (!Match.Success)
throw new Exception("The config key \"criteria_data => banned\" was not formated correctly.");
ClanManager.MaxBanCount = Int32.Parse(Match.Groups["value"].Value);
// Country
Match = Regex.Match(FileContents, @"'country',[\s|\t]+'(?<value>[A_Za-z]*)'");
if (!Match.Success)
throw new Exception("The config key \"criteria_data => country\" was not formated correctly.");
ClanManager.CountryRequirement = Match.Groups["value"].Value;
// Rank
Match = Regex.Match(FileContents, @"'rank',[\s|\t]+(?<value>[0-9]+)");
if (!Int32.TryParse(Match.Groups["value"].Value, out ClanManager.RankRequirement))
throw new Exception("The config key \"criteria_data => rank\" was not formated correctly.");
}