Skip to content

Commit

Permalink
V1.19 bump + new KSP bugfixes :
Browse files Browse the repository at this point in the history
- New KSP bugfix : [EnginePlateAirstreamShieldedTopPart](#52) (Thanks to @yalov (flart) for reporting and to @Aelfhe1m for coming up with a clever solution).
- New KSP bugfix : [AsteroidInfiniteMining](#51) (Thanks to @Rodg88 for reporting).
  • Loading branch information
gotmachine committed Jan 30, 2023
1 parent b2cc5aa commit 715faab
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GameData/KSPCommunityFixes/KSPCommunityFixes.version
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"NAME": "KSPCommunityFixes",
"URL": "https://raw.githubusercontent.com/KSPModdingLibs/KSPCommunityFixes/master/GameData/KSPCommunityFixes/KSPCommunityFixes.version",
"DOWNLOAD": "https://github.com/KSPModdingLibs/KSPCommunityFixes/releases",
"VERSION": {"MAJOR": 1, "MINOR": 18, "PATCH": 3, "BUILD": 0},
"VERSION": {"MAJOR": 1, "MINOR": 19, "PATCH": 0, "BUILD": 0},
"KSP_VERSION": {"MAJOR": 1, "MINOR": 12, "PATCH": 3},
"KSP_VERSION_MIN": {"MAJOR": 1, "MINOR": 8, "PATCH": 0},
"KSP_VERSION_MAX": {"MAJOR": 1, "MINOR": 12, "PATCH": 3}
Expand Down
6 changes: 6 additions & 0 deletions GameData/KSPCommunityFixes/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ KSP_COMMUNITY_FIXES
// Fix rescaled servo parts propagating their scale to childrens after actuating the servo in the editor
RescaledRoboticParts = true
// Fix engine plates causing the part attached above them to be incorrectly shielded from airstream
EnginePlateAirstreamShieldedTopPart = true
// Fix asteroid/comet mass being restored to 100% when reloading after having mined it down to 0%
AsteroidInfiniteMining = true
// Fix Admin Building not using HeadImage if that is defined for a Department but a kerbal prefab is not
DepartmentHeadImage = true
Expand Down
30 changes: 30 additions & 0 deletions KSPCommunityFixes/BugFixes/AsteroidInfiniteMining.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// see https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/51

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

namespace KSPCommunityFixes.BugFixes
{
class AsteroidInfiniteMining : BasePatch
{
protected override Version VersionMin => new Version(1, 10, 0);

protected override void ApplyPatches(List<PatchInfo> patches)
{
patches.Add(new PatchInfo(
PatchMethodType.Prefix,
AccessTools.PropertySetter(typeof(ModuleSpaceObjectInfo), nameof(ModuleSpaceObjectInfo.currentMassVal)),
this, nameof(ModuleSpaceObjectInfo_currentMassVal_Setter_Prefix)));
}

static bool ModuleSpaceObjectInfo_currentMassVal_Setter_Prefix(ModuleSpaceObjectInfo __instance, double value)
{
if (value <= 1e-9)
value = 1e-8;

__instance.currentMass = value.ToString("G17");
return false;
}
}
}
53 changes: 53 additions & 0 deletions KSPCommunityFixes/BugFixes/EnginePlateAirstreamShieldedTopPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// see https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/52

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

namespace KSPCommunityFixes.BugFixes
{
class EnginePlateAirstreamShieldedTopPart : BasePatch
{
protected override Version VersionMin => new Version(1, 11, 0);

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

static bool ModuleDecouplerBase_SetAirstream_Prefix(ModuleDecouplerBase __instance, bool enclosed)
{
__instance.shroudOn = enclosed;

if (__instance.jettisonModule.IsNullOrDestroyed())
return false;

List<AttachNode> attachNodes = __instance.part.attachNodes;
AttachNode bottomNode = attachNodes.Find(node => node.id == __instance.jettisonModule.bottomNodeName);

foreach (AttachNode attachNode in attachNodes)
{
if (attachNode.attachedPart.IsNullOrDestroyed())
continue;

if (attachNode == bottomNode)
continue;

if (Vector3.Angle(bottomNode.orientation, attachNode.orientation) < 30f)
{
attachNode.attachedPart.ShieldedFromAirstream = enclosed;
if (enclosed)
attachNode.attachedPart.AddShield(__instance);
else
attachNode.attachedPart.RemoveShield(__instance);
}
}

return false;
}
}
}
2 changes: 2 additions & 0 deletions KSPCommunityFixes/KSPCommunityFixes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BasePatch.cs" />
<Compile Include="BugFixes\AsteroidInfiniteMining.cs" />
<Compile Include="BugFixes\EnginePlateAirstreamShieldedTopPart.cs" />
<Compile Include="Performance\MemoryLeaks.cs" />
<Compile Include="BugFixes\RescaledRoboticParts.cs" />
<Compile Include="BugFixes\StickySplashedFixer.cs" />
Expand Down
4 changes: 2 additions & 2 deletions KSPCommunityFixes/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.18.3.0")]
[assembly: AssemblyFileVersion("1.18.3.0")]
[assembly: AssemblyVersion("1.19.0.0")]
[assembly: AssemblyFileVersion("1.19.0.0")]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ User options are available from the "ESC" in-game settings menu :<br/><img src="
- **[EVAKerbalRecovery](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/43)** [KSP 1.11.0 - 1.12.3]<br/> Fix recovery of EVAing kerbals either causing their inventory to be recovered twice or the science data they carry not being recovered, depending on the EVA kerbal variant/suit.
- **[StickySplashedFixer](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/44)** [KSP 1.8.0 - 1.12.3]<br/> Fix vessel never leaving the splashed state if it starts out splashed, and decouples from its only splashed parts. This also fixes an issue where Splashed overrides Prelaunch as a situation.
- **[RescaledRoboticParts](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/48)** [KSP 1.8.0 - 1.12.3]<br/> Fix rescaled robotics parts propagating their scale to childrens after actuating the servo in the editor
- **[EnginePlateAirstreamShieldedTopPart](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/52)** [KSP 1.11.0 - 1.12.3]<br/>Fix engine plates causing the part attached above them to be incorrectly shielded from airstream.
- **[AsteroidInfiniteMining](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/51)** [KSP 1.10.0 - 1.12.3]<br/>Fix asteroid/comet mass being restored to 100% when reloading after having mined it down to 0%.

#### Quality of Life tweaks

Expand Down Expand Up @@ -131,6 +133,10 @@ If doing so in the `Debug` configuration and if your KSP install is modified to

### Changelog

##### 1.19.0
- New KSP bugfix : [EnginePlateAirstreamShieldedTopPart](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/52) (Thanks to @yalov (flart) for reporting and to @Aelfhe1m for coming up with a clever solution).
- New KSP bugfix : [AsteroidInfiniteMining](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/51) (Thanks to @Rodg88 for reporting).

##### 1.18.3
- MemoryLeaks : Only remove GameEvent delegates owned by destroyed UnityEngine.Object instances if they are declared by the stock assembly, or a PartModule, or a VesselModule. Some mods are relying on a singleton pattern by instantiating a KSPAddon once, registering GameEvents there and relying on those being called on the dead instance to manipulate static data (sigh...). Those cases will still be logged when the LogDestroyedUnityObjectGameEventsLeaks flag is set in settings.

Expand Down

0 comments on commit 715faab

Please sign in to comment.