Probably solved a bug where brushes would cause non-ruleset terrains for mods without grassland

This commit is contained in:
yairm210 2021-11-11 23:56:29 +02:00
parent 4ce8704969
commit 8aa99c03e2
2 changed files with 8 additions and 10 deletions

View File

@ -27,14 +27,10 @@ object Battle {
fun moveAndAttack(attacker: ICombatant, attackableTile: AttackableTile) {
if (attacker is MapUnitCombatant) {
attacker.unit.movement.moveToTile(attackableTile.tileToAttackFrom)
/** You might ask: When can this possibly happen?
* We always receive an AttackableTile, which means that it was returned from getAttackableTiles!
* And getAttackableTiles should ensure that we return only units that are in the range of movement!
*
* The answer is: when crossing a HIDDEN TILE.
/**
* When calculating movement distance, we assume that a hidden tile is 1 movement point,
* which can lead to EXCEEDINGLY RARE edge cases where you think
* that you can attack a tile by passing through a hidden tile,
* that you can attack a tile by passing through a HIDDEN TILE,
* but the hidden tile is actually IMPASSIBLE so you stop halfway!
*/
if (attacker.getTile() != attackableTile.tileToAttackFrom) return

View File

@ -299,12 +299,14 @@ class MapEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraS
tileInfo.ruleset = mapEditorScreen.ruleset
val terrain = resource.terrainsCanBeFoundOn.first { ruleset.terrains.containsKey(it) }
val terrainObject = ruleset.terrains[terrain]!!
if (terrainObject.type == TerrainType.TerrainFeature) {
if (terrainObject.type != TerrainType.TerrainFeature) tileInfo.baseTerrain = terrain
else {
tileInfo.baseTerrain =
if (terrainObject.occursOn.isNotEmpty()) terrainObject.occursOn.first()
else "Grassland"
if (terrainObject.occursOn.isNotEmpty()) terrainObject.occursOn.first()
else ruleset.terrains.values.first { it.type == TerrainType.Land }.name
tileInfo.terrainFeatures.add(terrain)
} else tileInfo.baseTerrain = terrain
}
tileInfo.resource = resource.name
tileInfo.setTerrainTransients()