Fixed some bugs (#5178)

* Fixed bug where moving a unit stopped automation

* Fixed bug where chosing an icon last in the religion screen would not enable the 'found religion' button

* Fixed bug where buying units with an increasing cost would deduct the wrong amount

* Fixed bug making it impossible to pick free techs
This commit is contained in:
Xander Lenstra 2021-09-11 22:09:43 +02:00 committed by GitHub
parent db78bcf00d
commit b002e53eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 17 deletions

View File

@ -503,9 +503,25 @@ class CityConstructions {
if (!cityInfo.civInfo.gameInfo.gameParameters.godMode) {
val construction = getConstruction(constructionName)
if (construction is PerpetualConstruction) return false
val constructionCost = (construction as INonPerpetualConstruction).getStatBuyCost(cityInfo, stat)
val constructionCost =
(construction as INonPerpetualConstruction).getStatBuyCost(cityInfo, stat)
if (constructionCost == null) return false // We should never end up here anyway, so things have already gone _way_ wrong
cityInfo.addStat(stat, -1 * constructionCost)
if (cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
.any {
(
construction is BaseUnit && construction.matchesFilter(it.params[0]) ||
construction is Building && construction.matchesFilter(it.params[0])
)
&& cityInfo.matchesFilter(it.params[3])
&& cityInfo.civInfo.getEraNumber() >= cityInfo.civInfo.gameInfo.ruleSet.eras[it.params[4]]!!.eraNumber
&& it.params[2] == stat.name
}
) {
cityInfo.civInfo.boughtConstructionsWithGloballyIncreasingPrice[constructionName] =
(cityInfo.civInfo.boughtConstructionsWithGloballyIncreasingPrice[constructionName] ?: 0) + 1
}
}
if (queuePosition in 0 until constructionQueue.size)

View File

@ -407,8 +407,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
return
val pathToLastReachableTile = distanceToTiles.getPathToTile(lastReachableTile)
if (unit.isFortified() || unit.isSetUpForSiege() || unit.isSleeping() || unit.isAutomated())
unit.action = null // un-fortify/un-setup/un-sleep/un-automate after moving
if (unit.isFortified() || unit.isSetUpForSiege() || unit.isSleeping())
unit.action = null // un-fortify/un-setup/un-sleep after moving
// If this unit is a carrier, keep record of its air payload whereabouts.
val origin = unit.getTile()

View File

@ -403,18 +403,6 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
unit.setupAbilityUses(cityConstructions.cityInfo)
}
if (boughtWith != null && cityConstructions.cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
.any {
matchesFilter(it.params[0])
&& cityConstructions.cityInfo.matchesFilter(it.params[3])
&& cityConstructions.cityInfo.civInfo.getEraNumber() >= ruleset.eras[it.params[4]]!!.eraNumber
&& it.params[2] == boughtWith.name
}
) {
cityConstructions.cityInfo.civInfo.boughtConstructionsWithGloballyIncreasingPrice[name] =
(cityConstructions.cityInfo.civInfo.boughtConstructionsWithGloballyIncreasingPrice[name] ?: 0) + 1
}
if (this.isCivilian()) return true // tiny optimization makes save files a few bytes smaller

View File

@ -94,11 +94,12 @@ class ReligiousBeliefsPickerScreen (
}
previouslySelectedIcon = button
button.disable()
checkAndEnableRightSideButton()
changeDisplayedReligionName(religionName)
this.religionName = religionName
changeReligionNameButton.enable()
checkAndEnableRightSideButton()
}
if (religionName == this.religionName || gameInfo.religions.keys.any { it == religionName }) button.disable()
iconsTable.add(button).pad(5f)

View File

@ -61,7 +61,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
if (freeTechPick) {
val freeTech = selectedTech!!.name
// More evil people fast-clicking to cheat - #4977
if (researchableTechs.contains(freeTech)) return@onClick
if (!researchableTechs.contains(freeTech)) return@onClick
civTech.getFreeTechnology(selectedTech!!.name)
}
else civTech.techsToResearch = tempTechsToResearch