mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 11:34:54 -04:00
Ruleset validation for personalities with victory types not present in ruleset
This commit is contained in:
parent
c4c46eb316
commit
5c7e2c673f
@ -388,7 +388,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
|||||||
if (victoryTypes.size == 1)
|
if (victoryTypes.size == 1)
|
||||||
return listOf(victoryTypes.first()) // That is the most relevant one
|
return listOf(victoryTypes.first()) // That is the most relevant one
|
||||||
val victoryType: List<String> = listOf(nation.preferredVictoryType, getPersonality().preferredVictoryType)
|
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) }
|
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
|
// 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
|
// So this attempts to limit the encoding to gzip only
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding
|
// 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")
|
it.setRequestProperty("Accept-Encoding", "gzip")
|
||||||
|
|
||||||
val disposition = it.getHeaderField(contentDispositionHeader)
|
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.
|
// 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()
|
contentLength = it.getHeaderField("Content-Length")?.toInt()
|
||||||
?: 0
|
?: 0 // repo.length is a total lie
|
||||||
} ?: return null
|
} ?: return null
|
||||||
|
|
||||||
// Download to temporary zip
|
// Download to temporary zip
|
||||||
|
@ -82,6 +82,7 @@ class RulesetValidator(val ruleset: Ruleset) {
|
|||||||
addTechColumnErrorsRulesetInvariant(lines)
|
addTechColumnErrorsRulesetInvariant(lines)
|
||||||
addEraErrors(lines, tryFixUnknownUniques)
|
addEraErrors(lines, tryFixUnknownUniques)
|
||||||
addSpeedErrors(lines)
|
addSpeedErrors(lines)
|
||||||
|
addPersonalityErrors(lines)
|
||||||
addBeliefErrors(lines, tryFixUnknownUniques)
|
addBeliefErrors(lines, tryFixUnknownUniques)
|
||||||
addNationErrors(lines, tryFixUnknownUniques)
|
addNationErrors(lines, tryFixUnknownUniques)
|
||||||
addPolicyErrors(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)
|
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(
|
private fun addEraErrors(
|
||||||
lines: RulesetErrorList,
|
lines: RulesetErrorList,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user