mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-30 22:58:50 +07:00
Ruleset validation for personalities with victory types not present in ruleset
This commit is contained in:
@ -388,7 +388,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
if (victoryTypes.size == 1)
|
||||
return listOf(victoryTypes.first()) // That is the most relevant one
|
||||
val victoryType: List<String> = listOf(nation.preferredVictoryType, getPersonality().preferredVictoryType)
|
||||
.filter { it in gameInfo.gameParameters.victoryTypes }
|
||||
.filter { it in gameInfo.gameParameters.victoryTypes && it in gameInfo.ruleset.victories }
|
||||
return victoryType.ifEmpty { listOf(Constants.neutralVictoryType) }
|
||||
|
||||
}
|
||||
|
@ -105,7 +105,8 @@ object Github {
|
||||
// We DO NOT want to accept "Transfer-Encoding: chunked" here, as we need to know the size for progress tracking
|
||||
// So this attempts to limit the encoding to gzip only
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding
|
||||
// HOWEVER it doesn't seem to work - the server still sends chunked data sometimes :(
|
||||
// HOWEVER it doesn't seem to work - the server still sends chunked data sometimes
|
||||
// which means we don't actually know the total length :(
|
||||
it.setRequestProperty("Accept-Encoding", "gzip")
|
||||
|
||||
val disposition = it.getHeaderField(contentDispositionHeader)
|
||||
@ -115,7 +116,7 @@ object Github {
|
||||
// We could check Content-Type=[application/x-zip-compressed] here, but the ZipFile will catch that anyway. Would save some bandwidth, however.
|
||||
|
||||
contentLength = it.getHeaderField("Content-Length")?.toInt()
|
||||
?: 0
|
||||
?: 0 // repo.length is a total lie
|
||||
} ?: return null
|
||||
|
||||
// Download to temporary zip
|
||||
|
@ -82,6 +82,7 @@ class RulesetValidator(val ruleset: Ruleset) {
|
||||
addTechColumnErrorsRulesetInvariant(lines)
|
||||
addEraErrors(lines, tryFixUnknownUniques)
|
||||
addSpeedErrors(lines)
|
||||
addPersonalityErrors(lines)
|
||||
addBeliefErrors(lines, tryFixUnknownUniques)
|
||||
addNationErrors(lines, tryFixUnknownUniques)
|
||||
addPolicyErrors(lines, tryFixUnknownUniques)
|
||||
@ -408,6 +409,16 @@ class RulesetValidator(val ruleset: Ruleset) {
|
||||
lines.add("Empty turn increment list for game speed ${speed.name}", sourceObject = speed)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addPersonalityErrors(lines: RulesetErrorList) {
|
||||
for (personality in ruleset.personalities.values) {
|
||||
if (personality.preferredVictoryType != Constants.neutralVictoryType
|
||||
&& personality.preferredVictoryType !in ruleset.victories) {
|
||||
lines.add("Preferred victory type ${personality.preferredVictoryType} does not exist in ruleset",
|
||||
RulesetErrorSeverity.Warning, sourceObject = personality,)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addEraErrors(
|
||||
lines: RulesetErrorList,
|
||||
|
Reference in New Issue
Block a user