Fix crash when melee unit captures civilian then tries to attack it (#7282)

This commit is contained in:
OptimizedForDensity 2022-06-24 08:05:49 -04:00 committed by GitHub
parent 51caf7a4ed
commit 50a8ff3ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,6 +58,10 @@ object Battle {
* but the hidden tile is actually IMPASSIBLE so you stop halfway!
*/
if (attacker.getTile() != attackableTile.tileToAttackFrom) return false
/** Rarely, a melee unit will target a civilian then move through the civilian to get
* to attackableTile.tileToAttackFrom, meaning that they take the civilian. This check stops
* the melee unit from trying to capture their own unit if this happens */
if (getMapCombatantOfTile(attackableTile.tileToAttack)!!.getCivInfo() == attacker.getCivInfo()) return false
/** Alternatively, maybe we DID reach that tile, but it turned out to be a hill or something,
* so we expended all of our movement points!
*/