Fixed an infinite loop where foreign legion upgraded to the unit it replaced (#5808)

* Fixed an infinite loop where foreign legion upgraded to the unit it replaced

* Changed the wrong variable

* Maybe it is useful to also change its unlock tech

* Whoops, should only be for non-null values
This commit is contained in:
Xander Lenstra 2021-12-16 16:50:10 +01:00 committed by GitHub
parent a7b880c033
commit 58cc3b517e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -914,12 +914,12 @@
{
"name": "Foreign Legion",
"unitType": "Gunpowder",
"replaces": "Infantry",
"replaces": "Rifleman",
"uniqueTo": "France",
"movement": 2,
"strength": 50,
"cost": 320,
"requiredTech": "Replaceable Parts",
"requiredTech": "Rifling",
"upgradesTo": "Infantry",
"obsoleteTech": "Plastics",
"uniques": ["[+20]% Strength <when fighting in [Foreign Land] tiles>"],

View File

@ -767,7 +767,7 @@ object NextTurnAutomation {
unit.baseUnit.isRanged() -> rangedUnits.add(unit)
unit.baseUnit.isMelee() -> meleeUnits.add(unit)
unit.hasUnique("Bonus for units in 2 tile radius 15%")
-> generals.add(unit) //generals move after military units
-> generals.add(unit) // Generals move after military units
else -> civilianUnits.add(unit)
}
}

View File

@ -373,7 +373,7 @@ class Ruleset {
// When not checking the entire ruleset, we can only really detect ruleset-invariant errors in uniques
for (unit in units.values) {
if (unit.upgradesTo == unit.name)
if (unit.upgradesTo == unit.name || (unit.upgradesTo != null && unit.upgradesTo == unit.replaces))
lines += "${unit.name} upgrades to itself!"
if (!unit.isCivilian() && unit.strength == 0)
lines += "${unit.name} is a military unit but has no assigned strength!"