UOOutlands / Razor

Razor is a free tool designed to help with simple tasks while playing Ultima Online.
http://www.uor-razor.com
GNU General Public License v3.0
9 stars 6 forks source link

[BUG/FEATURE] Fix Sysmessage Log Behavior / Add Override for `insysmsg` `waitforsysmsg` consumption #51

Closed ncskrypt closed 2 years ago

ncskrypt commented 3 years ago

Fix Sysmessage Log Behavior

Currently Razor clear ALL PRIOR messages in log INCLUDING UNMATCHED entries.

Additionally, the message log is trimmed down to 15 anytime it exceeds 25+ messages.

Relevant Code that handles this: https://github.com/UOOutlands/Razor/blob/14e5096e251e7d8fd9f7fb003818ff9df09b8cb6/Razor/Core/SystemMessages.cs#L30

public static void Add(string text) {
  if (string.IsNullOrEmpty(text)) { return; }

  Messages.Add(text);

  if (Messages.Count >= 25) {
    Messages.RemoveRange(0, 10);
  }
}

https://github.com/UOOutlands/Razor/blob/14e5096e251e7d8fd9f7fb003818ff9df09b8cb6/Razor/Core/SystemMessages.cs#L45

public static bool Exists(string text) {
  if (string.IsNullOrEmpty(text)) { return false; }

  for (int i = Messages.Count - 1; i >= 0; i--) {
    if (Messages[i].IndexOf(text, StringComparison.OrdinalIgnoreCase) != -1) {
      Messages.RemoveRange(0, i + 1);
      return true;
    }
  }

  return false;
}
ncskrypt commented 3 years ago

Issue with the code pushed recently for this enhancement.

It is only removing the first occurrence. It should remove all occurrences of that exact same message.

image image