public static Vector3D POSToVector3D(string pos) { Vector3D result = new Vector3D(); double x = 0.0, y = 0.0, z = 0.0; if (String.IsNullOrWhiteSpace(pos)) { return(result); } var values = Re.GetSubString(pos, @"([\d|\.|,]+)"); if (String.IsNullOrWhiteSpace(values)) { return(result); } var xyz = values.Split(','); if (xyz.Length == 3) { x = double.Parse(xyz[0], CultureInfo.InvariantCulture); y = double.Parse(xyz[1], CultureInfo.InvariantCulture); z = double.Parse(xyz[2], CultureInfo.InvariantCulture); } return(new Vector3D(x, y, z)); }
private void StartNewMission(string logFilePath) { //Check if MissionEnd is sent if (missionHistory != null && missionHistory.Count > 0) { var existing = missionHistory.FirstOrDefault(data => data is MissionLogEventMissionEnd); if (existing == null) { var endMission = new MissionLogEventMissionEnd(new MissionLogEventHeader(String.Format("T:{0} AType:7", lastTick), lastEventTime)); AddHistory(endMission); actionManager.ProcessAction(endMission); } } Log.WriteInfo("New mission started {0}", logFilePath); missionDateTimePrefix = Re.GetSubString(logFilePath, @"missionReport\((.*)?\)\[0\]\.txt"); if (String.IsNullOrWhiteSpace(missionDateTimePrefix)) { return; } server.ResetMission(); server.CurrentMissionId = GuidUtility.Create(GuidUtility.IsoOidNamespace, String.Concat(server.ServerId, "_", missionDateTimePrefix)).ToString(); MissionStartDateTime = Util.ParseDate(missionDateTimePrefix).ToUniversalTime(); }
private string GetString(string name) { if (String.IsNullOrWhiteSpace(name) || String.IsNullOrWhiteSpace(configContent)) return String.Empty; else return Re.GetSubString(configContent, String.Concat(name, reParameter)).With(x => x.Trim()); }
private string GetString(string name) { if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(this.configContent)) { return(string.Empty); } else { return(Re.GetSubString(this.configContent, string.Concat(name, RE_PARAMETER)).With(x => x.Trim())); } }
private void SetValue(string section, string name, string value) { var sectionContent = Re.GetSubString(configContent, String.Format(reSection,section)); if (String.IsNullOrWhiteSpace(sectionContent)) return; var replacement = Regex.Replace(sectionContent, String.Concat(@"[\s|\t]*",name, reParameter), Environment.NewLine); replacement = String.Concat(replacement, String.Format("{2}\t{0} = {1}", name, value, Environment.NewLine)); configContent = configContent.Replace(sectionContent, replacement); Util.Try(() => File.WriteAllText(configFilePath, configContent)); }
private void SetValue(string section, string name, string value) { var sectionContent = Re.GetSubString(this.configContent, string.Format(RE_SECTION, section)); if (string.IsNullOrWhiteSpace(sectionContent)) { return; } var replacement = Regex.Replace(sectionContent, string.Concat(@"[\s|\t]*", name, RE_PARAMETER), Environment.NewLine); replacement = string.Concat(replacement, string.Format("{2}\t{0} = {1}", name, value, Environment.NewLine)); this.configContent = this.configContent.Replace(sectionContent, replacement); Util.Try(() => File.WriteAllText(this.configFilePath, this.configContent)); }
public void Login() { while (true) { var result = Rcon.GetConsole(); var newName = Re.GetSubString(result, @"Server name '(.*?)'"); if (!String.IsNullOrWhiteSpace(newName)) { Name = newName; break; } else { Thread.Sleep(1000); } } }
public static int[] SequenceToIntArray(string seq) { var result = new int[] {}; if (String.IsNullOrWhiteSpace(seq)) { return(result); } var values = Re.GetSubString(seq, @"([\d|\.|,]+)"); if (String.IsNullOrWhiteSpace(values)) { return(result); } return(values.Split(',') .Select(x => { int i = 0; int.TryParse(x, out i); return i; }) .ToArray()); }
public void ReadMissionHistory(string firstMissionLogFile = null) { //missionReport(2015-02-25_11-43-53)[0].txt if (firstMissionLogFile == null) { firstMissionLogFile = Util.GetNewestFilePath(MissionLogFolder, "missionReport(*)[0].txt"); if (String.IsNullOrWhiteSpace(firstMissionLogFile)) { Log.WriteError("Mission log not found in {0}", MissionLogFolder); return; } } else { firstMissionLogFile = this.With(x => Re.GetSubString(firstMissionLogFile, @"(missionReport\([\d+|\-|_]+\))\[\d+\].txt")) .With(x => String.Concat(x, "[0].txt")); } if (String.IsNullOrWhiteSpace(firstMissionLogFile)) { Log.WriteError("Malformed log filename {0}", firstMissionLogFile); return; } Log.WriteInfo("Reading events history from {0}", firstMissionLogFile); StartNewMission(firstMissionLogFile); if (MissionStartDateTime.Equals(default(DateTime))) { return; } var missionFiles = Util.GetFilesSortedByTime(MissionLogFolder, String.Format("missionReport({0})[*].txt", missionDateTimePrefix), true); var readException = Util.Try(() => { foreach (var file in missionFiles) { var fileInfo = new FileInfo(file); if (fileInfo.Length > 0 && !String.IsNullOrWhiteSpace(file)) { if (tracker != null) { tracker.AddFileOffset(file, fileInfo.Length); } var lines = File.ReadAllLines(file); if (lines != null) { foreach (var line in lines) { var data = MissionLogDataBuilder.GetData(line, MissionStartDateTime, GetCurrentEventNumber(), server); if (data is MissionLogEventHeader) { var header = data as MissionLogEventHeader; header.MissionFile = Path.GetFileName(file); AddHistory(data); } } } } } }); }