OpenXcom Forum

OpenXcom Forks => OXCE Bugs => OpenXcom Extended (OXCE) => OXCE Bugs FIXED => Topic started by: jnarical on October 09, 2023, 12:55:28 am

Title: [FIXED] LOS penalty applies incorrectly to some units
Post by: jnarical on October 09, 2023, 12:55:28 am
The bug was described here: https://openxcom.org/forum/index.php/topic,10967.msg157865.html#msg157865 (https://openxcom.org/forum/index.php/topic,10967.msg157865.html#msg157865)
Suggested fix was on the very next comment.
(https://openxcom.org/forum/index.php?action=dlattach;topic=10967.0;attach=60683;image)
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: https://openxcom.org/forum/index.php/topic,10967.msg157827.html#msg157827 (https://openxcom.org/forum/index.php/topic,10967.msg157827.html#msg157827)
Title: Re: LOS penalty applies incorrectly to some units
Post by: Meridian on October 09, 2023, 09:51:58 pm
Thanks for the report.
I will look at it this week.
Title: Re: LOS penalty applies incorrectly to some units
Post by: Meridian on October 22, 2023, 10:03:31 am
Fix here: https://github.com/MeridianOXC/OpenXcom/commit/c60099271133078d30b64b158d1cbbd1fd254d6d

And a small improvement here: https://github.com/MeridianOXC/OpenXcom/commit/545317d4c6400246bd5c4bb72277ae7908b7cc9a