Skip to content

Commit 8e34d82

Browse files
authored
Merge pull request #41 from KSP2Community/dev
Version 0.10.0
2 parents 7beb952 + d738e2b commit 8e34d82

13 files changed

Lines changed: 215 additions & 37 deletions

File tree

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Build the solution
15+
run: dotnet build "CommunityFixes.sln" -c Release
16+
17+
- name: Find zip
18+
id: find-zip
19+
run: |
20+
echo "zip=$(ls -1 dist/CommunityFixes-*.zip | head -n 1)" >> $GITHUB_ENV
21+
echo "artifact_name=CommunityFixesRelease" >> $GITHUB_ENV
22+
23+
- name: Upload zip artifact
24+
uses: actions/upload-artifact@v3
25+
with:
26+
name: ${{ env.artifact_name }}
27+
path: ${{ env.zip }}

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Upload release
2+
3+
on:
4+
release:
5+
types: [ "published" ]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions: write-all
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Build the solution
16+
run: |
17+
dotnet build "CommunityFixes.sln" -c Release
18+
echo "zip=$(ls -1 dist/CommunityFixes-*.zip | head -n 1)" >> $GITHUB_ENV
19+
20+
- name: Upload zip to release
21+
uses: actions/upload-release-asset@v1.0.1
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
with:
25+
upload_url: ${{ env.upload_url }}
26+
asset_path: ${{ env.zip }}
27+
asset_name: ${{ env.artifact_name }}
28+
asset_content_type: application/zip

.github/workflows/spacewarp.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/verify.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Verify swinfo.json
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
verify:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v4
14+
15+
- name: Verify KSP2 Mod
16+
uses: Rexicon226/VerifierAction@V0.5

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This project aims to bring together community bug fixes for Kerbal Space Program
44
## Compatibility
55
- Tested with Kerbal Space Program 2 v0.2.0.0.30291
66
- Requires **[SpaceWarp 1.6.0+](https://github.com/SpaceWarpDev/SpaceWarp/releases/)**
7+
- Requires **[Patch Manager 0.6+](https://github.com/KSP2Community/PatchManager/releases/)**
78

89
## Implemented fixes
910
- **KSP 2 Save Fix** by [jayouimet](https://github.com/jayouimet) - Replaces the Control Owner Part to the first available Command module or to the Root part if not found when it is set to null.
@@ -12,6 +13,8 @@ This project aims to bring together community bug fixes for Kerbal Space Program
1213
- **Suppress Transmissions Falsely Urgent Fix** by [schlosrat](https://github.com/schlosrat) - Suppresses unhelpful map view log messages.
1314
- **VAB Redo Tooltip Fix** by [coldrifting](https://github.com/coldrifting) - Fixes the VAB Redo button tooltip not being at the same height as the button.
1415
- **Revert After Recovery Fix** by [munix](https://github.com/jan-bures) - Fixes the Revert buttons being enabled after recovering a vessel.
16+
- **Experiment Biome Pause Fix** by [dmarcuse](https://github.com/dmarcuse) - Fixes experiments that don't care about biome pausing when the biome changes.
17+
- **Stock Mission Fix** by [Cheese](https://github.com/cheese3660) - Fixes the incorrect completion conditions of the mission _Second Dibs: Gold Edition_.
1518

1619
## Planned fixes
1720
To see what fixes are planned to be implemented, you can visit the [Issues page](https://github.com/Bit-Studios/CommunityFixes/issues) on the project's GitHub.
@@ -22,12 +25,13 @@ To see what fixes are planned to be implemented, you can visit the [Issues page]
2225
1. Use [CKAN](https://github.com/KSP-CKAN/CKAN/releases/latest) to download and install Community Fixes.
2326

2427
### Manual
25-
1. Download and extract [UITK for KSP 2](https://github.com/UitkForKsp2/UitkForKsp2/releases) into your game folder.
28+
1. Download and extract [UITK for KSP 2](https://github.com/UitkForKsp2/UitkForKsp2/releases) into your game folder (this is a dependency of SpaceWarp).
2629
2. Download and extract [SpaceWarp](https://github.com/SpaceWarpDev/SpaceWarp/releases) into your game folder.
27-
3. Download and extract this mod into the game folder. If done correctly, you should have the following folder structure: `<KSP Folder>/BepInEx/plugins/CommunityFixes`.
30+
3. Download and extract [Patch Manager](https://github.com/SpaceWarpDev/SpaceWarp/releases) into your game folder.
31+
4. Download and extract this mod into the game folder. If done correctly, you should have the following folder structure: `<KSP Folder>/BepInEx/plugins/CommunityFixes`.
2832

2933
## Configuration
3034
If you want to toggle any of the included fixes off, you can do so in game: `Main menu` -> `Settings` -> `Mods` -> `Community Fixes`. The changes will apply after restarting the game.
3135

32-
## Development wiki
36+
## Contributing
3337
If you'd like to contribute to this project, please take a look at [our wiki](https://github.com/Bit-Studios/CommunityFixes/wiki/Adding-your-fix).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
:missions #KSP2Mission_Secondary_Pol_Flag > missionStages > _0 > ConditionSet > PropertyCondition {
2+
isInput: false;
3+
Inputstring: "";
4+
TestWatchedstring: "Pol";
5+
}

plugin_template/swinfo.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Community Fixes",
66
"description": "Community project that aims to bring together bug fixes for KSP 2.",
77
"source": "https://github.com/KSP2Community/CommunityFixes",
8-
"version": "0.9.0",
8+
"version": "0.10.0",
99
"version_check": "https://raw.githubusercontent.com/KSP2Community/CommunityFixes/main/plugin_template/swinfo.json",
1010
"ksp2_version": {
1111
"min": "0.2.0",
@@ -18,6 +18,13 @@
1818
"min": "1.6.0",
1919
"max": "*"
2020
}
21+
},
22+
{
23+
"id": "PatchManager",
24+
"version": {
25+
"min": "0.6.0",
26+
"max": "*"
27+
}
2128
}
2229
]
23-
}
30+
}

src/CommunityFixes/CommunityFixes.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all"/>
66
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all"/>
77
<PackageReference Include="BepInEx.Core" Version="5.*"/>
8-
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*"/>
98
<PackageReference Include="HarmonyX" Version="2.10.1"/>
10-
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.1.5" PrivateAssets="all"/>
11-
<PackageReference Include="SpaceWarp" Version="1.5.2"/>
9+
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.2.0" PrivateAssets="all" Publicize="true"/>
10+
<PackageReference Include="SpaceWarp" Version="1.6.0"/>
11+
<PackageReference Include="SpaceWarp.PluginInfoProps" Version="1.*"/>
1212
<PackageReference Include="UnityEngine.Modules" Version="2022.3.5"/>
1313
</ItemGroup>
1414
</Project>

src/CommunityFixes/Directory.Build.targets

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
3+
<PropertyGroup>
4+
<PowerShellExecutable Condition="'$(OS)' == 'Windows_NT'">powershell</PowerShellExecutable>
5+
<PowerShellExecutable Condition="'$(OS)' != 'Windows_NT'">pwsh</PowerShellExecutable>
6+
</PropertyGroup>
37
<Target Label="Post build events" Name="PostBuild" AfterTargets="PostBuildEvent">
48
<Message Text="Cleaning up previous build directory"/>
59
<RemoveDir Directories="$(SolutionDir)/dist/$(ConfigurationName)"/>
@@ -33,8 +37,8 @@
3337
<Message Text="Compressing built plugin folder" Condition="$(ConfigurationName) == Release"/>
3438
<Delete Condition="$(ConfigurationName) == Release"
3539
Files="$(SolutionDir)/dist/$(SolutionName)-$(Version).zip"/>
36-
<Exec Condition="$(ConfigurationName) == Release"
37-
Command="powershell Compress-Archive -Path '$(SolutionDir)/dist/$(ConfigurationName)/BepInEx' -DestinationPath '$(SolutionDir)/dist/$(SolutionName)-$(Version).zip'"/>
40+
<Exec Condition="$(ConfigurationName) == 'Release'"
41+
Command="$(PowerShellExecutable) -Command &quot;&amp; {Push-Location '$(SolutionDir)/dist/$(ConfigurationName)'; Compress-Archive -Path './*' -DestinationPath '$(SolutionDir)/dist/$(SolutionName)-$(Version).zip'; Pop-Location}&quot;"/>
3842

3943
<Message Text="Clean up the game's plugin folder" Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"/>
4044
<RemoveDir Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using HarmonyLib;
2+
using KSP.Game.Science;
3+
using KSP.Sim.impl;
4+
using KSP.Modules;
5+
using System.Reflection;
6+
7+
namespace CommunityFixes.Fix.ExperimentBiomePauseFix;
8+
9+
[Fix("Fix experiments pausing when switching biome for scenarios where biome is irrelevant")]
10+
public class ExperimentBiomePauseFix : BaseFix
11+
{
12+
private static ExperimentBiomePauseFix _instance;
13+
14+
// This fix makes assumptions about the game's code and reads/writes private state, which can end up in save files.
15+
// In order to avoid accidentally breaking anything, we only apply the patch to known-broken versions of the game.
16+
private static readonly HashSet<string> KnownBrokenVersions = new() { "0.2.0.0.30291" };
17+
18+
private static readonly string GameVersion = typeof(VersionID)
19+
.GetField("VERSION_TEXT", BindingFlags.Static | BindingFlags.Public)
20+
?.GetValue(null) as string;
21+
22+
public override void OnInitialized()
23+
{
24+
_instance = this;
25+
if (KnownBrokenVersions.Contains(GameVersion))
26+
{
27+
HarmonyInstance.PatchAll(typeof(ExperimentBiomePauseFix));
28+
}
29+
else
30+
{
31+
Logger.LogError($"Not enabling experiment biome pause fix - game version {GameVersion} may not be broken");
32+
}
33+
}
34+
35+
// RefreshLocationsValidity has a bug where it unconditionally pauses experiments when switching biome, even if the
36+
// experiment is still valid and doesn't care about the biome. To fix this, we prevent the function from being
37+
// called if the part has running experiments, the experiments don't care about the biome, and the other parameters
38+
// of the experiment are unchanged.
39+
// To avoid breaking things when we skip RefreshLocationsValidity, we also update some private state that the method
40+
// is responsible for when skipping it.
41+
[HarmonyPatch(
42+
typeof(PartComponentModule_ScienceExperiment),
43+
nameof(PartComponentModule_ScienceExperiment.RefreshLocationsValidity)
44+
)]
45+
[HarmonyPrefix]
46+
public static bool RefreshLocationsValidityPrefix(
47+
// ReSharper disable once InconsistentNaming
48+
ref VesselComponent ____vesselComponent,
49+
// ReSharper disable once InconsistentNaming
50+
ref ResearchLocation ____currentLocation,
51+
// ReSharper disable once InconsistentNaming
52+
ref Data_ScienceExperiment ___dataScienceExperiment
53+
)
54+
{
55+
if (____vesselComponent?.mainBody == null ||
56+
____vesselComponent?.VesselScienceRegionSituation.ResearchLocation == null)
57+
{
58+
return true;
59+
}
60+
61+
var newLocation = new ResearchLocation(
62+
requiresRegion: true, // Placeholder, assigned per-experiment below
63+
bodyName: ____vesselComponent.mainBody.bodyName,
64+
scienceSituation: ____vesselComponent.VesselScienceRegionSituation.ResearchLocation.ScienceSituation,
65+
scienceRegion: ____vesselComponent.VesselScienceRegionSituation.ResearchLocation.ScienceRegion
66+
);
67+
68+
bool safeToSkip = true;
69+
var newRegions = new List<string>();
70+
foreach (var standing in ___dataScienceExperiment.ExperimentStandings)
71+
{
72+
if (standing.CurrentExperimentState == ExperimentState.RUNNING &&
73+
!standing.RegionRequired &&
74+
standing.ExperimentLocation.BodyName == newLocation.BodyName &&
75+
standing.ExperimentLocation.ScienceSituation == newLocation.ScienceSituation)
76+
{
77+
newLocation.RequiresRegion = standing.RegionRequired;
78+
newRegions.Add(newLocation.ScienceRegion);
79+
continue;
80+
}
81+
82+
safeToSkip = false;
83+
}
84+
85+
if (safeToSkip)
86+
{
87+
_instance.Logger.LogInfo(
88+
"Skipping PartComponentModule_ScienceExperiment.RefreshLocationsValidity - experiment is still valid."
89+
);
90+
91+
____currentLocation = newLocation;
92+
for (int i = 0; i < newRegions.Count; i++)
93+
{
94+
___dataScienceExperiment.ExperimentStandings[i].ExperimentLocation.SetScienceRegion(newRegions[i]);
95+
}
96+
}
97+
98+
return !safeToSkip;
99+
}
100+
}

0 commit comments

Comments
 (0)