Unciv
Unciv copied to clipboard
Oversight with some usages of `unit.movement.canMoveTo()`
If you call code such as unit.movement.canMoveTo(someTileInfo), this function always returns false if someTileInfo == unit.getTile(). While this may seem logical (can't move to a tile you're standing in because movement implies changing location), many places in the code filter tiles based on a predicate such as [some tile sequence].filter { unit.canMoveTo(it) } which means the tile the unit is standing on is never highlighted as a valid tile unless you add || it == unit.getTile() to the predicate as some instances of code do. This leads to weird behavior, such as where AI great prophets would randomly wander around foreign territory looking for a tile to spread religion, but since the tile they're standing on is not valid, they constantly try to go to a neighboring tile first before spreading religion. There are a few dozen usages of canMoveTo() so I don't know how many other places are affected.
I think the solution is to add an "includeCurrentTile" parameter, but to keep current usage consistent it would have to be default false, and then we'll need to go over all usages to see if we should override that
I'm going to have to say no to this, the scale of refactor is not worth the effort.