Skip to content

Commit

Permalink
Renamed DrillPerformance to AsteroidAndCometDrillCache, added info ab…
Browse files Browse the repository at this point in the history
…out the patch.
  • Loading branch information
gotmachine committed Jul 22, 2022
1 parent e076f9b commit ef6f5d9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
12 changes: 5 additions & 7 deletions GameData/KSPCommunityFixes/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ KSP_COMMUNITY_FIXES
// decent performance gains in games having a large amount of celestial bodies and/or vessels.
DisableMapUpdateInFlight = true
// Reduce constant overhead of ModuleAsteroidDrill and ModuleCometDrill by using the cached
// asteroid/comet part lookup results from ModuleResourceHarvester. Improves performance with
// large part count vessels having at least one drill part.
AsteroidAndCometDrillCache = 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 Expand Up @@ -247,13 +252,6 @@ KSP_COMMUNITY_FIXES
packedInterval = 0.5 // interval when the active vessel is timewarping
}
// The stock ModuleAsteroidDrill and ModuleCometDrill do a lot of unnecessary iterating over all
// PartModules on the vessel to see if an asteroid or comet is attached.
// ModuleResourceHarvester already keeps a cache of this information, and all the stock drills
// have all 3 modules. This patch replaces the logic in the asteroid and comet drills with
// lookups in the cache. This has a bigger effect the more drills and parts/partmodules on the ship.
DrillPerformance = true
// ##########################
// Modding
// ##########################
Expand Down
2 changes: 1 addition & 1 deletion KSPCommunityFixes/KSPCommunityFixes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<Compile Include="BugFixes\AsteroidInfiniteMining.cs" />
<Compile Include="BugFixes\CometMiningNotRemovingMass.cs" />
<Compile Include="BugFixes\EnginePlateAirstreamShieldedTopPart.cs" />
<Compile Include="Performance\DrillPerformance.cs" />
<Compile Include="Performance\AsteroidAndCometDrillCache.cs" />
<Compile Include="Performance\CommNetThrottling.cs" />
<Compile Include="Performance\DisableMapUpdateInFlight.cs" />
<Compile Include="Performance\MemoryLeaks.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
using HarmonyLib;
// see https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/67

// The stock ModuleAsteroidDrill and ModuleCometDrill do a lot of unnecessary iterating over all
// PartModules on the vessel to see if an asteroid or comet is attached.
// ModuleResourceHarvester already keeps a cache of this information, and all the stock drills
// have all 3 modules. This patch replaces the logic in the asteroid and comet drills with
// lookups in the cache. This has a bigger effect the more drills and parts/partmodules on the ship.

// Note from @Got : this introduce a behavior change in which asteroid/comet will be selected by drills
// on a multi-asteroid vessel when a new asteroid is attached. But since the whole multi-asteroid
// situation isn't handled correctly by stock anyway (all drills on the vessel will mine the first
// found one regardless of which asteroid part the drill is actually in contact with), we don't care.

using System;
using HarmonyLib;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KSPCommunityFixes.Performance
{
class DrillPerformance : BasePatch
class AsteroidAndCometDrillCache : BasePatch
{
protected override Version VersionMin => new Version(1, 12, 3);

protected override void ApplyPatches(List<PatchInfo> patches)
{
patches.Add(
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ User options are available from the "ESC" in-game settings menu :<br/><img src="
- [**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.
- [**DisableMapUpdateInFlight**](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.
- [**CommNetThrottling**](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/56) [KSP 1.12.0 - 1.12.3]<br/>Disabled by default, you can enable it with a MM patch. Prevent full CommNet network updates from happening every frame, but instead to happen at a regular real-world time interval of 5 seconds while in flight. Enabling this can provide a decent performance uplift in games having an large amount of celestial bodies and/or vessels, but has a detrimental impact on the precision of the simulation and can potentially cause issues with mods relying on the stock behavior.
- [**AsteroidAndCometDrillCache**](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/67) [KSP 1.12.3]<br/>Reduce constant overhead of ModuleAsteroidDrill and ModuleCometDrill by using the cached asteroid/comet part lookup results from ModuleResourceHarvester. Improves performance with large part count vessels having at least one drill part.

#### 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 @@ -145,7 +146,8 @@ If doing so in the `Debug` configuration and if your KSP install is modified to
### Changelog

##### 1.21.0
- New KSP bugfix : CometMiningNotRemovingMass // Fix mass of comets not actually reducing when mining them, despite the PAW saying so.
- New KSP bugfix : CometMiningNotRemovingMass
- New performance patch : AsteroidAndCometDrillCache (Contributed by @JonnyOThan)

##### 1.20.0
- OnSymmetryFieldChanged : fixed mistakenly inverted "changed" condition resulting in the patch not actually preventing symmetry events to be fired when the value hasn't changed.
Expand Down

0 comments on commit ef6f5d9

Please sign in to comment.