Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.9.2 Hotfix #295

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Space Warp",
"description": "Space Warp is an API for KSP 2 mod developers.",
"source": "https://github.com/SpaceWarpDev/SpaceWarp",
"version": "1.9.1",
"version": "1.9.2",
"version_check": "https://raw.githubusercontent.com/SpaceWarpDev/SpaceWarp/main/plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json",
"ksp2_version": {
"min": "0.2.1",
Expand Down
14 changes: 11 additions & 3 deletions src/SpaceWarp.Game/API/Game/Waypoints/Waypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace SpaceWarp.API.Game.Waypoints;
[PublicAPI]
public class Waypoint
{


private SimulationObjectModel _waypointObject;

/// <summary>
Expand Down Expand Up @@ -130,7 +128,17 @@ public Waypoint(double latitude, double longitude, double? altitudeFromRadius =
var body = celestialBodies.Find(c => c.Name == bodyName);
if (body == null)
throw new Exception($"Could not create waypoint as there is no body with the name of {bodyName}");
altitudeFromRadius ??= body.SurfaceProvider.GetTerrainAltitudeFromCenter(latitude, longitude) - body.radius;
if (altitudeFromRadius == null)
{
altitudeFromRadius = body.SurfaceProvider.GetTerrainAltitudeFromCenter(latitude, longitude) - body.radius;

// if the local space of the body is not loaded, then the altitude of the terrain from its center is equal to the radius
if (altitudeFromRadius == 0)
{
// we'll set the altitude to the MaxTerrainHeight, so that the waypoint will always appear above the surface
altitudeFromRadius += body.MaxTerrainHeight;
}
}
AltitudeFromRadius = altitudeFromRadius.Value;
_state = waypointState;
if (_state == WaypointState.Visible)
Expand Down
Loading