Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
kdtree.hpp crash when Oil Rig is removed #7481
Version of OpenTTD
Newest Master (OpenTTD 20190406-master-gdef5d99e0e)
The game should carry on normally.
The game crashes unexpectedly.
Steps to reproduce
The game will crash with either of the two message after some time:
A few thoughts on this issue (without actually testing anything, so caveats apply):
In ViewportSignKdtreeItem::MakeStation there is the line:
The general use of RemapCoords2 appears to be potentially problematic as the kd tree coordinate depends on the GetSlopePixelZ height of the station xy tile, however changes to the height and/or foundation state of this tile do not result in the kd tree being updated. Therefore if GetSlopePixelZ returns different values when the station is added to and removed from the kd tree, an error of the form above could result.
The crash will only occur if the discrepancy between the element coordinate and the removal coordinate is such that RemoveRecursive looks into the wrong sub-tree when descending.
For reference, my fix is here: JGRennison/OpenTTD-patches@070160a, it seems to have stopped the kdtree-related bug reports at my end.