Author Topic: [FIXED] LOS penalty applies incorrectly to some units  (Read 730 times)

Offline jnarical

  • Captain
  • ***
  • Posts: 68
    • View Profile
[FIXED] LOS penalty applies incorrectly to some units
« on: October 09, 2023, 12:55:28 am »
The bug was described here:,10967.msg157865.html#msg157865
Suggested fix was on the very next comment.

When you're targeting a unit, which stands on a high terrain level, sometimes you get target voxel on the upper tile.
Tile *t = ... target->toTile() gives a pointer to that upper tile
getOverlappingUnit() gives a pointer to the unit which "pokes" to the upper tile

but then hasLOS = ... visible( bu, t ) uses that old upper tile, doesn't find a unit in it and returns false, thus incorrectly applying noLOSAccuracyPenalty.

Suggested solutions: either locally redefine Tile *t from found unit inside if (targetUnit) { ... } block, or change tile->getUnit() to tile->getOverlappingUnit() inside TileEngine::visible()

Savefile (XPZ) with the issue is attached here:,10967.msg157827.html#msg157827

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8719
    • View Profile
Re: LOS penalty applies incorrectly to some units
« Reply #1 on: October 09, 2023, 09:51:58 pm »
Thanks for the report.
I will look at it this week.