Skip to content

Commit 67dced4

Browse files
authored
Merge pull request #295 from SpaceWarpDev/dev
1.9.2 Hotfix
2 parents e31556b + 9396c52 commit 67dced4

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Space Warp",
66
"description": "Space Warp is an API for KSP 2 mod developers.",
77
"source": "https://github.com/SpaceWarpDev/SpaceWarp",
8-
"version": "1.9.1",
8+
"version": "1.9.2",
99
"version_check": "https://raw.githubusercontent.com/SpaceWarpDev/SpaceWarp/main/plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json",
1010
"ksp2_version": {
1111
"min": "0.2.1",

src/SpaceWarp.Game/API/Game/Waypoints/Waypoint.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ namespace SpaceWarp.API.Game.Waypoints;
1313
[PublicAPI]
1414
public class Waypoint
1515
{
16-
17-
1816
private SimulationObjectModel _waypointObject;
1917

2018
/// <summary>
@@ -130,7 +128,17 @@ public Waypoint(double latitude, double longitude, double? altitudeFromRadius =
130128
var body = celestialBodies.Find(c => c.Name == bodyName);
131129
if (body == null)
132130
throw new Exception($"Could not create waypoint as there is no body with the name of {bodyName}");
133-
altitudeFromRadius ??= body.SurfaceProvider.GetTerrainAltitudeFromCenter(latitude, longitude) - body.radius;
131+
if (altitudeFromRadius == null)
132+
{
133+
altitudeFromRadius = body.SurfaceProvider.GetTerrainAltitudeFromCenter(latitude, longitude) - body.radius;
134+
135+
// if the local space of the body is not loaded, then the altitude of the terrain from its center is equal to the radius
136+
if (altitudeFromRadius == 0)
137+
{
138+
// we'll set the altitude to the MaxTerrainHeight, so that the waypoint will always appear above the surface
139+
altitudeFromRadius += body.MaxTerrainHeight;
140+
}
141+
}
134142
AltitudeFromRadius = altitudeFromRadius.Value;
135143
_state = waypointState;
136144
if (_state == WaypointState.Visible)

0 commit comments

Comments
 (0)