Skip to content

Commit

Permalink
DisableMapOrbitsInFlight : Fix for #59
Browse files Browse the repository at this point in the history
  • Loading branch information
gotmachine committed Jul 14, 2022
1 parent 9491dcf commit b3b7399
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
6 changes: 5 additions & 1 deletion GameData/KSPCommunityFixes/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,13 @@ KSP_COMMUNITY_FIXES
PQSUpdateNoMemoryAlloc = true

// Remove unused ProgressTracking update handlers. Provides a very noticeable performance uplift in
// modded career games having a large amount of celestial bodies and many vessels.
// career games having a large amount of celestial bodies and/or vessels.
ProgressTrackingSpeedBoost = true

// Disable the update of orbit lines and markers in flight when the map view isn't shown. Provides
// decent performance gains in games having a large amount of celestial bodies and/or vessels.
DisableMapOrbitsInFlight = true
// Fix a bunch of managed memory leaks, mainly by proactively removing GameEvents delegates
// originating from destroyed UnityEngine.Object instances. Will log detected leaks and memory
// usage on scene switches.
Expand Down
1 change: 1 addition & 0 deletions KSPCommunityFixes/KSPCommunityFixes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<Compile Include="BasePatch.cs" />
<Compile Include="BugFixes\AsteroidInfiniteMining.cs" />
<Compile Include="BugFixes\EnginePlateAirstreamShieldedTopPart.cs" />
<Compile Include="Performance\DisableMapUpdateInFlight.cs" />
<Compile Include="Performance\MemoryLeaks.cs" />
<Compile Include="BugFixes\RescaledRoboticParts.cs" />
<Compile Include="Modding\DepartmentHeadImage.cs" />
Expand Down
26 changes: 26 additions & 0 deletions KSPCommunityFixes/Performance/DisableMapUpdateInFlight.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// see https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/59

using System;
using HarmonyLib;
using System.Collections.Generic;

namespace KSPCommunityFixes.Performance
{
class DisableMapOrbitsInFlight : BasePatch
{
protected override Version VersionMin => new Version(1, 8, 0);

protected override void ApplyPatches(List<PatchInfo> patches)
{
patches.Add(new PatchInfo(
PatchMethodType.Prefix,
AccessTools.Method(typeof(OrbitRendererBase), nameof(OrbitRendererBase.LateUpdate)),
this));
}

static bool OrbitRendererBase_LateUpdate_Prefix()
{
return MapView.fetch.updateMap;
}
}
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ User options are available from the "ESC" in-game settings menu :<br/><img src="
- **TextureLoaderOptimizations** [KSP 1.10.0 - 1.12.3]<br/> Speedup loading time by caching on disk the PNG textures KSP converts to DXT5 on every launch. Also make PNG `@thumbs` cargo part textures non-readable to free some RAM. This patch has no entry in `settings.cfg`, but is opt-in (a popup is shown on first KSP launch) and can be disabled latter in the in-game settings menu.
- **PQSUpdateNoMemoryAlloc** [KSP 1.11.0 - 1.12.3]<br/> Prevent huge memory allocations and resulting occasional stutter on PQS creation happening when moving around near a body surface.
- [**MemoryLeaks**](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/49) [KSP 1.12.0 - 1.12.3]<br/>Fix a bunch of managed memory leaks, mainly by proactively removing `GameEvents` delegates originating from destroyed `UnityEngine.Object` instances on scene switches. Will log detected leaks and memory usage. Also see`Settings.cfg` to enable advanced logging options that can be useful to hunt down memory leaks in mods.
- [**ProgressTrackingSpeedBoost**](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/57) [KSP 1.12.0 - 1.12.3]<br/>Remove unused ProgressTracking update handlers. Provides a very noticeable performance uplift in modded career games having a large amount of celestial bodies and many vessels.
- [**ProgressTrackingSpeedBoost**](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/57) [KSP 1.12.0 - 1.12.3]<br/>Remove unused ProgressTracking update handlers. Provides a very noticeable performance uplift in career games having a large amount of celestial bodies and/or vessels.
- [**DisableMapOrbitsInFlight**](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/59) [KSP 1.8.0 - 1.12.3]<br/>Disable the update of orbit lines and markers in flight when the map view isn't shown. Provides decent performance gains in games having a large amount of celestial bodies and/or vessels.

#### API and modding tools
- **MultipleModuleInPartAPI** [KSP 1.8.0 - 1.12.3]<br/>This API allow other plugins to implement PartModules that can exist in multiple occurrence in a single part and won't suffer "module indexing mismatch" persistent data losses following part configuration changes. [See documentation on the wiki](https://github.com/KSPModdingLibs/KSPCommunityFixes/wiki/MultipleModuleInPartAPI).
Expand Down Expand Up @@ -137,6 +138,7 @@ If doing so in the `Debug` configuration and if your KSP install is modified to
### Changelog

##### 1.19.0
- New performance patch : [DisableMapOrbitsInFlight](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/59) (contributed by @JonnyOThan)
- New performance patch : [ProgressTrackingSpeedBoost](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/57) (contributed by @JonnyOThan)
- New QoL patch : [ToolbarShowHide](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/53) (contributed by @NathanKell)
- New QoL patch : ResourceLockActions
Expand Down

0 comments on commit b3b7399

Please sign in to comment.