From 666c9c5b293ce81b2d2f927cf2652ca0a94e1924 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Sat, 25 Mar 2023 19:32:38 +0100 Subject: [PATCH] Omit irrelevant warnings from startup console log (#9032) --- core/src/com/unciv/models/ruleset/Ruleset.kt | 9 +++++++-- core/src/com/unciv/models/ruleset/RulesetValidator.kt | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 51c81879fc..00f84112b9 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -506,8 +506,13 @@ object RulesetCache : HashMap() { debug("Mod loaded successfully: %s", modRuleset.name) if (Log.shouldLog()) { val modLinksErrors = modRuleset.checkModLinks() - if (modLinksErrors.any()) { - debug("checkModLinks errors: %s", modLinksErrors.getErrorText()) + // For extension mods which use references to base ruleset objects, the parameter type + // errors are irrelevant - the checker ran without a base ruleset + val logFilter: (RulesetError) -> Boolean = + if (modRuleset.modOptions.isBaseRuleset) { { it.errorSeverityToReport > RulesetErrorSeverity.WarningOptionsOnly } } + else { { it.errorSeverityToReport > RulesetErrorSeverity.WarningOptionsOnly && !it.text.contains("does not fit parameter type") } } + if (modLinksErrors.any(logFilter)) { + debug("checkModLinks errors: %s", modLinksErrors.getErrorText(logFilter)) } } } catch (ex: Exception) { diff --git a/core/src/com/unciv/models/ruleset/RulesetValidator.kt b/core/src/com/unciv/models/ruleset/RulesetValidator.kt index 61a3c78abb..b41c30fb4a 100644 --- a/core/src/com/unciv/models/ruleset/RulesetValidator.kt +++ b/core/src/com/unciv/models/ruleset/RulesetValidator.kt @@ -572,7 +572,9 @@ class RulesetErrorList : ArrayList() { fun isWarnUser() = getFinalSeverity() >= RulesetErrorSeverity.Warning fun getErrorText(unfiltered: Boolean = false) = - filter { unfiltered || it.errorSeverityToReport != RulesetErrorSeverity.WarningOptionsOnly } + getErrorText { unfiltered || it.errorSeverityToReport != RulesetErrorSeverity.WarningOptionsOnly } + fun getErrorText(filter: (RulesetError)->Boolean) = + filter(filter) .sortedByDescending { it.errorSeverityToReport } .joinToString("\n") { it.errorSeverityToReport.name + ": " + it.text } }