Skip to content

Commit

Permalink
Add error logging for weird track
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Sep 29, 2023
1 parent e8cde6d commit d8c9021
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,16 @@ public static Vec3d nextPositionDirect(World world, Vec3d currentPosition, TileR
* trying to move. Instead we should probably calculate the vector between the closest pos
* and the current pos and move distance along that. How would that work for slopes at the ends? just fine?
*/
List<PosStep> positions = ((IIterableTrack) rail.info.getBuilder(world)).getPath(0.25);
List<PosStep> positions = ((IIterableTrack) rail.info.getBuilder(world)).getPath(0.25 * rail.info.settings.gauge.scale());
Vec3d center = rail.info.placementInfo.placementPosition.add(rail.getPos()).add(0, heightOffset, 0);
Vec3d target = currentPosition.add(delta);
Vec3d relative = target.subtract(center);

if (positions.size() < 2) {
ImmersiveRailroading.error("Invalid track path %s: %s", positions.size(), rail.info.uniqueID);
return currentPosition; // keep in same place for debugging
}

/* Simple ordered binary search
l c r
l c r
Expand Down

0 comments on commit d8c9021

Please sign in to comment.