Skip to content

Commit

Permalink
Fix #148: fix AGMEMO system that broke in last release
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyOThan committed Sep 23, 2024
1 parent 16985e7 commit 596456b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Discord support server: https://discord.gg/vBDzZAq3AF.

Please always post your [KSP.log file](https://gist.github.com/JonnyOThan/04c2074b56f78e56d115621effee30f9) when reporting issues.

## Unreleased

### Bug Fixes

- Fixed AGMEMO system (did I even test this?)

## 1.0.1 - 2024-09-13

### New Features
Expand Down
6 changes: 3 additions & 3 deletions RasterPropMonitor/Core/RasterPropMonitorComputer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ public void Start()
string[] descriptionStrings = vesselDescription.UnMangleConfigText().Split(JUtil.LineSeparator, StringSplitOptions.None);
for (int i = 0; i < descriptionStrings.Length; i++)
{
var matches = x_agmemoRegex.Matches(descriptionStrings[i]);
if (matches.Count == 2 && uint.TryParse(matches[0].Value, out uint groupID) && groupID < actionGroupMemo.Length)
var match = x_agmemoRegex.Match(descriptionStrings[i]);
if (match.Success && match.Groups.Count == 3 && uint.TryParse(match.Groups[1].Value, out uint groupID) && groupID < actionGroupMemo.Length)
{
descriptionStrings[i] = string.Empty;
actionGroupMemo[groupID] = matches[1].Value;
actionGroupMemo[groupID] = match.Groups[2].Value;
}
}

Expand Down
11 changes: 9 additions & 2 deletions RasterPropMonitor/Core/UtilityFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1357,12 +1357,19 @@ public static string EnforceSlashes(this string input)

public static string UnMangleConfigText(this string input)
{
return input.Replace("<=", "{").Replace("=>", "}").Replace("$$$", Environment.NewLine);
return input
.Replace("<=", "{")
.Replace("=>", "}")
.Replace("$$$", Environment.NewLine);
}

public static string MangleConfigText(this string input)
{
return input.Replace("{", "<=").Replace("}", "=>").Replace(Environment.NewLine, "$$$");
return input
.Replace("{", "<=")
.Replace("}", "=>")
.Replace("\n", "$$$")
.Replace("\r", string.Empty);
}

public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
Expand Down

0 comments on commit 596456b

Please sign in to comment.