Skip to content

Add some debug logging to the code that outputs CCU effects #2621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ImperatorToCK3/Outputter/CulturesOutputter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ private static void OutputCCUParameters(string outputModPath, ModFilesystem ck3M
Logger.Warn("Could not find ccu_scripted_effects.txt in the CK3 mod. Aborting the outputting of CCU parameters.");
return;
}

Logger.Debug($"Found ccu_scripted_effects.txt at {scriptedEffectsPath}");

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

string fileText = File.ReadAllText(scriptedEffectsPath, Encoding.UTF8);
Expand Down Expand Up @@ -400,13 +401,13 @@ private static void AddChildrenToNode(Node node, string filePath, string fileNam
private static void AddChildrenToNodeAfterLastChildContainingText(Node node, string filePath, string fileName, string[] childrenStrings, string precedingChildText) {
List<Child> allChildren = node.AllChildren;

Child? predecingChild = allChildren.LastOrNull(c => CKPrinter.api.prettyPrintStatement.Invoke(c.node.ToRaw).Contains(precedingChildText));
if (predecingChild is null) {
Child? precedingChild = allChildren.LastOrNull(c => CKPrinter.api.prettyPrintStatement.Invoke(c.node.ToRaw).Contains(precedingChildText));
if (!precedingChild.HasValue) {
Logger.Warn($"Failed to find the preceding child containing the text '{precedingChildText}'!");
return;
}

int indexToUse = allChildren.IndexOf(predecingChild.Value) + 1;
int indexToUse = allChildren.IndexOf(precedingChild.Value) + 1;

foreach (var childStr in childrenStrings) {
var statements = CKParser.parseString(childStr, fileName).GetResult();
Expand All @@ -428,6 +429,7 @@ private static void OutputCCUErrorSuppression(string outputModPath, ModFilesyste
"Some harmless errors related to converter-added language parameters may appear in error.log.");
return;
}
Logger.Debug($"Found ccu_error_suppression.txt at {errorSuppressionPath}");

// In the file, find the last line that contains: "if = { limit = { var:temp = flag:heritage_family_",
// and output the same line for each heritage family parameter.
Expand Down
Loading