mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 09:18:43 +07:00
Mod CI - Load vanilla ruleset into cache before validation
This commit is contained in:
@ -26,7 +26,7 @@ object RulesetCache : HashMap<String, Ruleset>() {
|
||||
fun loadRulesets(consoleMode: Boolean = false, noMods: Boolean = false): List<String> {
|
||||
val newRulesets = HashMap<String, Ruleset>()
|
||||
|
||||
for (ruleset in BaseRuleset.values()) {
|
||||
for (ruleset in BaseRuleset.entries) {
|
||||
val fileName = "jsons/${ruleset.fullName}"
|
||||
val fileHandle =
|
||||
if (consoleMode) FileHandle(fileName)
|
||||
@ -99,9 +99,9 @@ object RulesetCache : HashMap<String, Ruleset>() {
|
||||
return baseRulesets.sortedWith(
|
||||
compareBy(
|
||||
{ ruleset ->
|
||||
BaseRuleset.values()
|
||||
BaseRuleset.entries
|
||||
.firstOrNull { br -> br.fullName == ruleset }?.ordinal
|
||||
?: BaseRuleset.values().size
|
||||
?: BaseRuleset.entries.size
|
||||
},
|
||||
{ it }
|
||||
)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.unciv.app.desktop
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import com.badlogic.gdx.graphics.glutils.HdpiMode
|
||||
@ -11,6 +10,7 @@ import com.unciv.logic.files.UncivFiles
|
||||
import com.unciv.models.metadata.GameSettings.ScreenSize
|
||||
import com.unciv.models.metadata.GameSettings.WindowState
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
import com.unciv.models.ruleset.validation.RulesetErrorSeverity
|
||||
import com.unciv.models.ruleset.validation.RulesetValidator
|
||||
import com.unciv.ui.components.fonts.Fonts
|
||||
@ -31,9 +31,11 @@ internal object DesktopLauncher {
|
||||
ruleset.folderLocation = FileHandle(".")
|
||||
val jsonsFolder = FileHandle("jsons")
|
||||
if (jsonsFolder.exists()) {
|
||||
// Load vanilla ruleset from the JAR, in case the mod requires parts of it
|
||||
RulesetCache.loadRulesets(consoleMode = true, noMods = true)
|
||||
// Load the actual ruleset here
|
||||
ruleset.load(jsonsFolder)
|
||||
}
|
||||
ruleset.load(FileHandle("jsons"))
|
||||
val errors = RulesetValidator(ruleset).getErrorList(true)
|
||||
println(errors.getErrorText(true))
|
||||
exitProcess(if (errors.any { it.errorSeverityToReport == RulesetErrorSeverity.Error }) 1 else 0)
|
||||
|
Reference in New Issue
Block a user