private void FindBtn_Click(object sender, EventArgs e) { HeadersVw.ClearItems(); _game.GenerateMessageHashes(); IEnumerable <ASClass> messages = _game.GetMessages(Hash); if (messages == null) { MessageBox.Show("Cannot find any Outgoing/Incoming messages that are associated with this hash.", "Tanji ~ Alert!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); HashTxt.Select(); HashTxt.SelectAll(); return; } foreach (ASClass msgClass in messages) { ushort header = _game.GetMessageHeader(msgClass); bool isOutgoing = _game.IsMessageOutgoing(msgClass); string messageName = msgClass.Instance.Name.Name; string type = "Outgoing"; if (!isOutgoing) { type = "Incoming"; messageName += (", " + _game.GetIncomingMessageParser( msgClass).Instance.Name.Name); } ListViewItem item = HeadersVw.AddFocusedItem(type, header, messageName); item.Tag = msgClass; // Display the message/class information? GG m8? } }
public void Find(string hash) { Hash = hash; HeadersVw.ClearItems(); IEnumerable <ASClass> messages = _game.GetMessages(HashTxt.Text); if (messages == null) { return; } foreach (ASClass messageClass in messages) { ushort header = _game.GetMessageHeader(messageClass); bool isOutgoing = _game.IsMessageOutgoing(messageClass); string messageName = messageClass.Instance.Name.Name; string type = "Outgoing"; if (!isOutgoing) { type = "Incoming"; messageName += (", " + _game.GetIncomingMessageParser( messageClass).Instance.Name.Name); } HeadersVw.AddFocusedItem(type, header, messageName); } }
static string UpdateHeaders(string headersPath, HGame current, HGame previous, bool isUpdatingOutgoing) { IReadOnlyDictionary <ushort, ASClass> curMsgClasses = (isUpdatingOutgoing ? current.OutgoingMessages : current.IncomingMessages); IReadOnlyDictionary <ushort, ASClass> preMsgClasses = (isUpdatingOutgoing ? previous.OutgoingMessages : previous.IncomingMessages); string value = File.ReadAllText(headersPath); MatchEvaluator replacer = delegate(Match match) { bool isOut = isUpdatingOutgoing; string endValue = match.Groups["end"].Value; string headerValue = match.Groups["header"].Value; ushort preHeader = 0; if (!ushort.TryParse(headerValue, out preHeader) || !preMsgClasses.ContainsKey(preHeader)) { if (headerValue != "0000") { return($"-1{endValue} //Invalid Header '{headerValue}'"); } else { return("-1" + endValue); } } ASClass msgClass = preMsgClasses[preHeader]; string hash = previous.GetMessageHash(msgClass); bool isDead = false; string result = string.Empty; IReadOnlyList <ASClass> curSimilars = current.GetMessages(hash); if (curSimilars == null) { return($"-1{endValue} //No Matches {msgClass.Instance.QualifiedName.Name}[{headerValue}]"); } else { ASClass curMsgClass = curSimilars[0]; isDead = !current.IsMessageReferenced(curMsgClass); if (curSimilars.Count == 1) { ushort curHeader = current.GetMessageHeader(curMsgClass); result = $"{curHeader}{endValue} //{headerValue}"; } else { result = $"-1{endValue} //Duplicate Matches {msgClass.Instance.QualifiedName.Name}[{headerValue}] | {hash}"; } } if (isDead) { result += " | Dead Message(0 References)"; } return(result); }; value = Regex.Replace(value, "( |)//(.*?)\r\n", "\r\n", RegexOptions.Singleline).Trim(); if (value.Contains("-1")) { value = Regex.Replace(value, @"-\b1\b", "0000", RegexOptions.Multiline); } value = Regex.Replace(value, @"(\b(?<header>\d{1,4})\b)(?<end>[^\r|$]*)", replacer, RegexOptions.Multiline); return(value); }