mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Fix crash caused by cascaded ruins unit gifts (#4133)
* Fix d1f6c5ac breaking builds * Fix d1f6c5ac breaking builds - patch1 * Fix silent crash when ancient ruins cascade gifted units
This commit is contained in:
parent
d1f6c5ac0a
commit
07a43f3f1a
@ -2882,7 +2882,7 @@ Professional Army = Profesionální armáda
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = Kompletní Čest
|
Honor Complete = Kompletní Čest
|
||||||
Honor = Čest
|
Honor = Čest
|
||||||
+[amount]% Strength vs [param] = +[amount]% síly proti [unitType]
|
+[amount]% Strength vs [param] = +[amount]% síly proti [param]
|
||||||
Notified of new Barbarian encampments = Upozornění na nový Barbarský tábor
|
Notified of new Barbarian encampments = Upozornění na nový Barbarský tábor
|
||||||
|
|
||||||
Organized Religion = Organizovaná víra
|
Organized Religion = Organizovaná víra
|
||||||
|
@ -4101,7 +4101,7 @@ Gold cost of upgrading [unitType] units reduced by [amount]% =
|
|||||||
# Requires translation!
|
# Requires translation!
|
||||||
Honor Complete =
|
Honor Complete =
|
||||||
Honor = Eer
|
Honor = Eer
|
||||||
+[amount]% Strength vs [param] = +[amount]% Kracht vs [unitType]
|
+[amount]% Strength vs [param] = +[amount]% Kracht vs [param]
|
||||||
# Requires translation!
|
# Requires translation!
|
||||||
Notified of new Barbarian encampments =
|
Notified of new Barbarian encampments =
|
||||||
|
|
||||||
|
@ -2859,7 +2859,7 @@ Professional Army = Berufsarmee
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = Ehre vollständig
|
Honor Complete = Ehre vollständig
|
||||||
Honor = Ehre
|
Honor = Ehre
|
||||||
+[amount]% Strength vs [param] = +[amount]% Stärke gegen [unitType]
|
+[amount]% Strength vs [param] = +[amount]% Stärke gegen [param]
|
||||||
Notified of new Barbarian encampments = Benachrichtigungen über neue Barbarenlager
|
Notified of new Barbarian encampments = Benachrichtigungen über neue Barbarenlager
|
||||||
|
|
||||||
Organized Religion = Organisierte Religion
|
Organized Religion = Organisierte Religion
|
||||||
|
@ -2885,7 +2885,7 @@ Professional Army = Prajurit Profesional
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = Kehormatan Lengkap
|
Honor Complete = Kehormatan Lengkap
|
||||||
Honor = Kehormatan
|
Honor = Kehormatan
|
||||||
+[amount]% Strength vs [param] = +[amount]% Kekuatan vs [unitType]
|
+[amount]% Strength vs [param] = +[amount]% Kekuatan vs [param]
|
||||||
Notified of new Barbarian encampments = Diberi tahu ketika muncul perkemahan orang Barbar baru
|
Notified of new Barbarian encampments = Diberi tahu ketika muncul perkemahan orang Barbar baru
|
||||||
|
|
||||||
Organized Religion = Agama Terorganisasi
|
Organized Religion = Agama Terorganisasi
|
||||||
|
@ -2859,7 +2859,7 @@ Professional Army = Esercito professionale
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = Onore Completo
|
Honor Complete = Onore Completo
|
||||||
Honor = Onore
|
Honor = Onore
|
||||||
+[amount]% Strength vs [param] = +[amount]% Strength contro [unitType]
|
+[amount]% Strength vs [param] = +[amount]% Strength contro [param]
|
||||||
Notified of new Barbarian encampments = Sarai notificato dei nuovi accampamenti barbari
|
Notified of new Barbarian encampments = Sarai notificato dei nuovi accampamenti barbari
|
||||||
|
|
||||||
Organized Religion = Religione Organizzata
|
Organized Religion = Religione Organizzata
|
||||||
|
@ -2914,7 +2914,7 @@ Professional Army = 軍隊の常備
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = 名誉コンプリート
|
Honor Complete = 名誉コンプリート
|
||||||
Honor = 名誉
|
Honor = 名誉
|
||||||
+[amount]% Strength vs [param] = [unitType]に対して戦闘力+[amount]%
|
+[amount]% Strength vs [param] = [param]に対して戦闘力+[amount]%
|
||||||
Notified of new Barbarian encampments = 新たな蛮族の野営地が出現すると通知
|
Notified of new Barbarian encampments = 新たな蛮族の野営地が出現すると通知
|
||||||
|
|
||||||
Organized Religion = 宗教の組織化
|
Organized Religion = 宗教の組織化
|
||||||
|
@ -2954,7 +2954,7 @@ Professional Army = Armia Zawodowa
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = Ukończony Honor
|
Honor Complete = Ukończony Honor
|
||||||
Honor = Honor
|
Honor = Honor
|
||||||
+[amount]% Strength vs [param] = +[amount]% Siły w wlace z [unitType]
|
+[amount]% Strength vs [param] = +[amount]% Siły w wlace z [param]
|
||||||
Notified of new Barbarian encampments = Powiadomiono o nowych obozach Barbarzyńców
|
Notified of new Barbarian encampments = Powiadomiono o nowych obozach Barbarzyńców
|
||||||
|
|
||||||
Organized Religion = Hierarchia Kościelna
|
Organized Religion = Hierarchia Kościelna
|
||||||
|
@ -2902,7 +2902,7 @@ Professional Army = Профессиональная армия
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = Честь завершена
|
Honor Complete = Честь завершена
|
||||||
Honor = Честь
|
Honor = Честь
|
||||||
+[amount]% Strength vs [param] = +[amount]% Силы против [unitType]
|
+[amount]% Strength vs [param] = +[amount]% Силы против [param]
|
||||||
Notified of new Barbarian encampments = Вы будете получать извещение всякий раз, когда варвары будут ставить новый лагерь
|
Notified of new Barbarian encampments = Вы будете получать извещение всякий раз, когда варвары будут ставить новый лагерь
|
||||||
|
|
||||||
Organized Religion = Организованная религия
|
Organized Religion = Организованная религия
|
||||||
|
@ -2897,7 +2897,7 @@ Professional Army = 职业军队
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = 完整的荣誉政策
|
Honor Complete = 完整的荣誉政策
|
||||||
Honor = 荣誉政策
|
Honor = 荣誉政策
|
||||||
+[amount]% Strength vs [param] = 对战[unitType]时+[amount]%战斗力
|
+[amount]% Strength vs [param] = 对战[param]时+[amount]%战斗力
|
||||||
Notified of new Barbarian encampments = 新的蛮族营地出现时将会通知
|
Notified of new Barbarian encampments = 新的蛮族营地出现时将会通知
|
||||||
|
|
||||||
Organized Religion = 教会组织
|
Organized Religion = 教会组织
|
||||||
|
@ -2859,7 +2859,7 @@ Professional Army = Ejercito Profesional
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = Honor Completado
|
Honor Complete = Honor Completado
|
||||||
Honor = Honor
|
Honor = Honor
|
||||||
+[amount]% Strength vs [param] = +[amount]% de Fuerza vs [unitType]
|
+[amount]% Strength vs [param] = +[amount]% de Fuerza vs [param]
|
||||||
Notified of new Barbarian encampments = Notificado de nuevos campamentos Bárbaros
|
Notified of new Barbarian encampments = Notificado de nuevos campamentos Bárbaros
|
||||||
|
|
||||||
Organized Religion = Religión Organizada
|
Organized Religion = Religión Organizada
|
||||||
|
@ -2885,7 +2885,7 @@ Professional Army = Professionell Armé
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = Heder Fullbordat
|
Honor Complete = Heder Fullbordat
|
||||||
Honor = Heder
|
Honor = Heder
|
||||||
+[amount]% Strength vs [param] = +[amount]% Styrka mot [unitType]
|
+[amount]% Strength vs [param] = +[amount]% Styrka mot [param]
|
||||||
Notified of new Barbarian encampments = Uppmärksammas på nya Barbarläger
|
Notified of new Barbarian encampments = Uppmärksammas på nya Barbarläger
|
||||||
|
|
||||||
Organized Religion = Organiserad Religion
|
Organized Religion = Organiserad Religion
|
||||||
|
@ -2917,7 +2917,7 @@ Professional Army = 職業軍隊
|
|||||||
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
Gold cost of upgrading [unitType] units reduced by [amount]% =
|
||||||
Honor Complete = 完整的榮譽政策
|
Honor Complete = 完整的榮譽政策
|
||||||
Honor = 榮譽政策
|
Honor = 榮譽政策
|
||||||
+[amount]% Strength vs [param] = 對戰[unitType]時+[amount]%戰鬥力
|
+[amount]% Strength vs [param] = 對戰[param]時+[amount]%戰鬥力
|
||||||
Notified of new Barbarian encampments = 新的蠻族營地出現時將會通知
|
Notified of new Barbarian encampments = 新的蠻族營地出現時將會通知
|
||||||
|
|
||||||
Organized Religion = 教會組織
|
Organized Religion = 教會組織
|
||||||
|
@ -607,6 +607,11 @@ class CivilizationInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Tries to place the a [unitName] unit into the [TileInfo] closest to the given the [position]
|
||||||
|
* @param location where to try to place the unit
|
||||||
|
* @param unitName name of the [BaseUnit] to create and place
|
||||||
|
* @return created [MapUnit] or null if no suitable location was found
|
||||||
|
* */
|
||||||
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit? {
|
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit? {
|
||||||
return gameInfo.tileMap.placeUnitNearTile(location, unitName, this)
|
return gameInfo.tileMap.placeUnitNearTile(location, unitName, this)
|
||||||
}
|
}
|
||||||
|
@ -596,14 +596,15 @@ class MapUnit {
|
|||||||
fun removeFromTile() = currentTile.removeUnit(this)
|
fun removeFromTile() = currentTile.removeUnit(this)
|
||||||
|
|
||||||
fun moveThroughTile(tile: TileInfo) {
|
fun moveThroughTile(tile: TileInfo) {
|
||||||
|
// addPromotion requires currentTile to be valid because it accesses ruleset through it
|
||||||
|
// getAncientRuinBonus, if it places a new unit, does too
|
||||||
|
currentTile = tile
|
||||||
|
|
||||||
if (tile.improvement == Constants.ancientRuins && civInfo.isMajorCiv())
|
if (tile.improvement == Constants.ancientRuins && civInfo.isMajorCiv())
|
||||||
getAncientRuinBonus(tile)
|
getAncientRuinBonus(tile)
|
||||||
if (tile.improvement == Constants.barbarianEncampment && !civInfo.isBarbarian())
|
if (tile.improvement == Constants.barbarianEncampment && !civInfo.isBarbarian())
|
||||||
clearEncampment(tile)
|
clearEncampment(tile)
|
||||||
|
|
||||||
// addPromotion requires currentTile to be valid because it accesses ruleset through it
|
|
||||||
currentTile = tile
|
|
||||||
|
|
||||||
if (!hasUnique("All healing effects doubled") && type.isLandUnit() && type.isMilitary()) {
|
if (!hasUnique("All healing effects doubled") && type.isLandUnit() && type.isMilitary()) {
|
||||||
val gainDoubleHealPromotion = tile.neighbors
|
val gainDoubleHealPromotion = tile.neighbors
|
||||||
.any { it.hasUnique("Grants Rejuvenation (all healing effects doubled) to adjacent military land units for the rest of the game") }
|
.any { it.hasUnique("Grants Rejuvenation (all healing effects doubled) to adjacent military land units for the rest of the game") }
|
||||||
@ -676,6 +677,17 @@ class MapUnit {
|
|||||||
tile.improvement = null
|
tile.improvement = null
|
||||||
val tileBasedRandom = Random(tile.position.toString().hashCode())
|
val tileBasedRandom = Random(tile.position.toString().hashCode())
|
||||||
val actions: ArrayList<() -> Unit> = ArrayList()
|
val actions: ArrayList<() -> Unit> = ArrayList()
|
||||||
|
|
||||||
|
fun goldBonus() {
|
||||||
|
val amount = listOf(25, 60, 100).random(tileBasedRandom)
|
||||||
|
civInfo.addGold(amount)
|
||||||
|
civInfo.addNotification(
|
||||||
|
"We have found a stash of [$amount] gold in the ruins!",
|
||||||
|
tile.position,
|
||||||
|
NotificationIcon.Gold
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (civInfo.cities.isNotEmpty()) actions.add {
|
if (civInfo.cities.isNotEmpty()) actions.add {
|
||||||
val city = civInfo.cities.random(tileBasedRandom)
|
val city = civInfo.cities.random(tileBasedRandom)
|
||||||
city.population.population++
|
city.population.population++
|
||||||
@ -687,6 +699,7 @@ class MapUnit {
|
|||||||
NotificationIcon.Growth
|
NotificationIcon.Growth
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val researchableAncientEraTechs = tile.tileMap.gameInfo.ruleSet.technologies.values
|
val researchableAncientEraTechs = tile.tileMap.gameInfo.ruleSet.technologies.values
|
||||||
.filter {
|
.filter {
|
||||||
!civInfo.tech.isResearched(it.name)
|
!civInfo.tech.isResearched(it.name)
|
||||||
@ -705,14 +718,19 @@ class MapUnit {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val possibleUnits = (
|
||||||
val possibleUnits = listOf(Constants.settler, Constants.worker, "Warrior")
|
//City-States and OCC don't get settler from ruins
|
||||||
.filter { civInfo.gameInfo.ruleSet.units.containsKey(it) }
|
listOf(Constants.settler).filterNot { civInfo.isCityState() || civInfo.isOneCityChallenger() }
|
||||||
|
+ listOf(Constants.worker, "Warrior")
|
||||||
|
).filter { civInfo.gameInfo.ruleSet.units.containsKey(it) }
|
||||||
if (possibleUnits.isNotEmpty())
|
if (possibleUnits.isNotEmpty())
|
||||||
actions.add {
|
actions.add {
|
||||||
val chosenUnit = possibleUnits.random(tileBasedRandom)
|
val chosenUnit = possibleUnits.random(tileBasedRandom)
|
||||||
if (!(civInfo.isCityState() || civInfo.isOneCityChallenger()) || chosenUnit != Constants.settler) { //City-States and OCC don't get settler from ruins
|
// placeUnitNearTile _can_ fail, and since this code can run behind a try with empty
|
||||||
civInfo.placeUnitNearTile(tile.position, chosenUnit)
|
// catch inside nested thread switches - petter play it safe
|
||||||
|
if (civInfo.placeUnitNearTile(tile.position, chosenUnit) == null) {
|
||||||
|
goldBonus()
|
||||||
|
} else {
|
||||||
civInfo.addNotification(
|
civInfo.addNotification(
|
||||||
"A [$chosenUnit] has joined us!",
|
"A [$chosenUnit] has joined us!",
|
||||||
tile.position,
|
tile.position,
|
||||||
@ -731,15 +749,7 @@ class MapUnit {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.add {
|
actions.add { goldBonus() }
|
||||||
val amount = listOf(25, 60, 100).random(tileBasedRandom)
|
|
||||||
civInfo.addGold(amount)
|
|
||||||
civInfo.addNotification(
|
|
||||||
"We have found a stash of [$amount] gold in the ruins!",
|
|
||||||
tile.position,
|
|
||||||
NotificationIcon.Gold
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
actions.add {
|
actions.add {
|
||||||
civInfo.policies.addCulture(20)
|
civInfo.policies.addCulture(20)
|
||||||
|
@ -157,7 +157,9 @@ class TileMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Tries to place the [unitName] into the [TileInfo] closest to the given the [position]
|
/** Tries to place the [unitName] into the [TileInfo] closest to the given [position]
|
||||||
|
* @param position where to try to place the unit (or close - max 10 tiles distance)
|
||||||
|
* @param unitName name of the [BaseUnit] to create and place
|
||||||
* @param civInfo civilization to assign unit to
|
* @param civInfo civilization to assign unit to
|
||||||
* @return created [MapUnit] or null if no suitable location was found
|
* @return created [MapUnit] or null if no suitable location was found
|
||||||
* */
|
* */
|
||||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.files.FileHandle
|
import com.badlogic.gdx.files.FileHandle
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
import com.unciv.JsonParser
|
import com.unciv.JsonParser
|
||||||
import com.unciv.logic.battle.BattleDamage
|
|
||||||
import com.unciv.models.metadata.BaseRuleset
|
import com.unciv.models.metadata.BaseRuleset
|
||||||
import com.unciv.models.ruleset.*
|
import com.unciv.models.ruleset.*
|
||||||
import com.unciv.models.ruleset.tech.TechColumn
|
import com.unciv.models.ruleset.tech.TechColumn
|
||||||
@ -228,10 +227,6 @@ object TranslationFileWriter {
|
|||||||
|
|
||||||
stringToTranslate = stringToTranslate.replace(parameter, parameterName)
|
stringToTranslate = stringToTranslate.replace(parameter, parameterName)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// substitute the regex for "Bonus/Penalty vs ..."
|
|
||||||
val match = Regex(BattleDamage.BONUS_VS_UNIT_TYPE).matchEntire(string)
|
|
||||||
if (match != null) stringToTranslate = "${match.groupValues[1]} vs [unitType]"
|
|
||||||
}
|
}
|
||||||
resultStrings!!.add("$stringToTranslate = ")
|
resultStrings!!.add("$stringToTranslate = ")
|
||||||
return
|
return
|
||||||
|
@ -202,6 +202,8 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
|
|||||||
try {
|
try {
|
||||||
tileToMoveTo = selectedUnit.movement.getTileToMoveToThisTurn(targetTile)
|
tileToMoveTo = selectedUnit.movement.getTileToMoveToThisTurn(targetTile)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
|
println("Exception in getTileToMoveToThisTurn: ${ex.message}")
|
||||||
|
ex.printStackTrace()
|
||||||
return@thread
|
return@thread
|
||||||
} // can't move here
|
} // can't move here
|
||||||
|
|
||||||
@ -224,7 +226,9 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
|
|||||||
if (selectedUnits.size > 1) { // We have more tiles to move
|
if (selectedUnits.size > 1) { // We have more tiles to move
|
||||||
moveUnitToTargetTile(selectedUnits.subList(1, selectedUnits.size), targetTile)
|
moveUnitToTargetTile(selectedUnits.subList(1, selectedUnits.size), targetTile)
|
||||||
} else removeUnitActionOverlay() //we're done here
|
} else removeUnitActionOverlay() //we're done here
|
||||||
} catch (e: Exception) {
|
} catch (ex: Exception) {
|
||||||
|
println("Exception in moveUnitToTargetTile: ${ex.message}")
|
||||||
|
ex.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user