From b904415c4512da8b0c5dc09b2fa441ad3b253c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bure=C5=A1?= Date: Sat, 30 Dec 2023 16:04:13 +0100 Subject: [PATCH 1/5] Check altitude more accurately in the VesselLandedStateFix --- .../Fix/VesselLandedState/VesselLandedStateFix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommunityFixes/Fix/VesselLandedState/VesselLandedStateFix.cs b/src/CommunityFixes/Fix/VesselLandedState/VesselLandedStateFix.cs index 99993e1..bc295a3 100644 --- a/src/CommunityFixes/Fix/VesselLandedState/VesselLandedStateFix.cs +++ b/src/CommunityFixes/Fix/VesselLandedState/VesselLandedStateFix.cs @@ -11,7 +11,7 @@ private void LateUpdate() if (gameStateConfiguration is { IsFlightMode: true }) { var vessel = Game?.ViewController?.GetActiveSimVessel(); - if (vessel is { Situation: VesselSituations.Landed, AltitudeFromTerrain: > 50, SrfSpeedMagnitude: > 5 }) + if (vessel is { Situation: VesselSituations.Landed, AltitudeFromSurface: > 50, SrfSpeedMagnitude: > 5 }) { vessel.Landed = false; } From 856a908c8f4cc265c0c1d2e1f0739629d359ccd7 Mon Sep 17 00:00:00 2001 From: cheese3660 Date: Sun, 31 Dec 2023 11:28:47 -0500 Subject: [PATCH 2/5] Create three_is_company.patch --- plugin_template/patches/three_is_company.patch | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 plugin_template/patches/three_is_company.patch diff --git a/plugin_template/patches/three_is_company.patch b/plugin_template/patches/three_is_company.patch new file mode 100644 index 0000000..18dd968 --- /dev/null +++ b/plugin_template/patches/three_is_company.patch @@ -0,0 +1,3 @@ +:missions #KSP2Mission_Secondary_Ike_LandingCrewed > missionStages > _0 > ConditionSet > PropertyCondition { + RequireCurrentValue: true; +} From 86e174c501160452e05b8ea343efca35bc1c2f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bure=C5=A1?= Date: Fri, 2 Feb 2024 00:18:55 +0100 Subject: [PATCH 3/5] Removed ExperimentBiomePauseFix, VelocityDisplayPrecisionFix --- README.md | 8 +- .../ExperimentBiomePauseFix.cs | 100 ------------------ .../VelocityDisplayPrecisionFix.cs | 31 ------ 3 files changed, 3 insertions(+), 136 deletions(-) delete mode 100644 src/CommunityFixes/Fix/ExperimentBiomePauseFix/ExperimentBiomePauseFix.cs delete mode 100644 src/CommunityFixes/Fix/VelocityDisplayPrecisionFix/VelocityDisplayPrecisionFix.cs diff --git a/README.md b/README.md index cf4e398..ccab024 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,17 @@ This project aims to bring together community bug fixes for Kerbal Space Program 2 in one centralized place. ## Compatibility -- Tested with Kerbal Space Program 2 v0.2.0.0.30291 +- Tested with Kerbal Space Program 2 v0.2.1.0.30833 - Requires **[SpaceWarp 1.6.0+](https://github.com/SpaceWarpDev/SpaceWarp/releases/)** - Requires **[Patch Manager 0.6+](https://github.com/KSP2Community/PatchManager/releases/)** ## Implemented fixes - **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. - **Vessel Landed State Fix** by [munix](https://github.com/jan-bures) - Checks if the vessel's state is Landed when not actually near the ground and resets it. Should fix [this persistent bug](https://forum.kerbalspaceprogram.com/topic/220260-incorrect-landed-state-causing-lack-of-trajectory-lines/). -- **Velocity Display Precision Fix** by [arthomnix](https://github.com/arthomnix) - Fixes the digit after the decimal point on the navball velocity display always being zero at velocities above 100m/s. - **Suppress Transmissions Falsely Urgent Fix** by [schlosrat](https://github.com/schlosrat) - Suppresses unhelpful map view log messages. - **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. - **Revert After Recovery Fix** by [munix](https://github.com/jan-bures) - Fixes the Revert buttons being enabled after recovering a vessel. -- **Experiment Biome Pause Fix** by [dmarcuse](https://github.com/dmarcuse) - Fixes experiments that don't care about biome pausing when the biome changes. -- **Stock Mission Fix** by [Cheese](https://github.com/cheese3660) - Fixes the incorrect completion conditions of the mission _Second Dibs: Gold Edition_. +- **Stock Mission Fix** by [Cheese](https://github.com/cheese3660) - Fixes the incorrect completion conditions of some stock missions. - **Resource Manager UI Fix** by [munix](https://github.com/jan-bures) - Fixes the Resource Manager bug where moving a tank from the right pane back to the left pane caused it to duplicate. - **Decoupled Craft Name Fix** by [munix](https://github.com/jan-bures) - Decoupled and docked/undocked vessels get names based on the original vessels instead of "Default Name" and "(Combined)". @@ -36,4 +34,4 @@ To see what fixes are planned to be implemented, you can visit the [Issues page] 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. ## Contributing -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). +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). \ No newline at end of file diff --git a/src/CommunityFixes/Fix/ExperimentBiomePauseFix/ExperimentBiomePauseFix.cs b/src/CommunityFixes/Fix/ExperimentBiomePauseFix/ExperimentBiomePauseFix.cs deleted file mode 100644 index 185fc15..0000000 --- a/src/CommunityFixes/Fix/ExperimentBiomePauseFix/ExperimentBiomePauseFix.cs +++ /dev/null @@ -1,100 +0,0 @@ -using HarmonyLib; -using KSP.Game.Science; -using KSP.Sim.impl; -using KSP.Modules; -using System.Reflection; - -namespace CommunityFixes.Fix.ExperimentBiomePauseFix; - -[Fix("Fix experiments pausing when switching biome for scenarios where biome is irrelevant")] -public class ExperimentBiomePauseFix : BaseFix -{ - private static ExperimentBiomePauseFix _instance; - - // This fix makes assumptions about the game's code and reads/writes private state, which can end up in save files. - // In order to avoid accidentally breaking anything, we only apply the patch to known-broken versions of the game. - private static readonly HashSet KnownBrokenVersions = new() { "0.2.0.0.30291" }; - - private static readonly string GameVersion = typeof(VersionID) - .GetField("VERSION_TEXT", BindingFlags.Static | BindingFlags.Public) - ?.GetValue(null) as string; - - public override void OnInitialized() - { - _instance = this; - if (KnownBrokenVersions.Contains(GameVersion)) - { - HarmonyInstance.PatchAll(typeof(ExperimentBiomePauseFix)); - } - else - { - Logger.LogError($"Not enabling experiment biome pause fix - game version {GameVersion} may not be broken"); - } - } - - // RefreshLocationsValidity has a bug where it unconditionally pauses experiments when switching biome, even if the - // experiment is still valid and doesn't care about the biome. To fix this, we prevent the function from being - // called if the part has running experiments, the experiments don't care about the biome, and the other parameters - // of the experiment are unchanged. - // To avoid breaking things when we skip RefreshLocationsValidity, we also update some private state that the method - // is responsible for when skipping it. - [HarmonyPatch( - typeof(PartComponentModule_ScienceExperiment), - nameof(PartComponentModule_ScienceExperiment.RefreshLocationsValidity) - )] - [HarmonyPrefix] - public static bool RefreshLocationsValidityPrefix( - // ReSharper disable once InconsistentNaming - ref VesselComponent ____vesselComponent, - // ReSharper disable once InconsistentNaming - ref ResearchLocation ____currentLocation, - // ReSharper disable once InconsistentNaming - ref Data_ScienceExperiment ___dataScienceExperiment - ) - { - if (____vesselComponent?.mainBody == null || - ____vesselComponent?.VesselScienceRegionSituation.ResearchLocation == null) - { - return true; - } - - var newLocation = new ResearchLocation( - requiresRegion: true, // Placeholder, assigned per-experiment below - bodyName: ____vesselComponent.mainBody.bodyName, - scienceSituation: ____vesselComponent.VesselScienceRegionSituation.ResearchLocation.ScienceSituation, - scienceRegion: ____vesselComponent.VesselScienceRegionSituation.ResearchLocation.ScienceRegion - ); - - bool safeToSkip = true; - var newRegions = new List(); - foreach (var standing in ___dataScienceExperiment.ExperimentStandings) - { - if (standing.CurrentExperimentState == ExperimentState.RUNNING && - !standing.RegionRequired && - standing.ExperimentLocation.BodyName == newLocation.BodyName && - standing.ExperimentLocation.ScienceSituation == newLocation.ScienceSituation) - { - newLocation.RequiresRegion = standing.RegionRequired; - newRegions.Add(newLocation.ScienceRegion); - continue; - } - - safeToSkip = false; - } - - if (safeToSkip) - { - _instance.Logger.LogInfo( - "Skipping PartComponentModule_ScienceExperiment.RefreshLocationsValidity - experiment is still valid." - ); - - ____currentLocation = newLocation; - for (int i = 0; i < newRegions.Count; i++) - { - ___dataScienceExperiment.ExperimentStandings[i].ExperimentLocation.SetScienceRegion(newRegions[i]); - } - } - - return !safeToSkip; - } -} \ No newline at end of file diff --git a/src/CommunityFixes/Fix/VelocityDisplayPrecisionFix/VelocityDisplayPrecisionFix.cs b/src/CommunityFixes/Fix/VelocityDisplayPrecisionFix/VelocityDisplayPrecisionFix.cs deleted file mode 100644 index 669eb13..0000000 --- a/src/CommunityFixes/Fix/VelocityDisplayPrecisionFix/VelocityDisplayPrecisionFix.cs +++ /dev/null @@ -1,31 +0,0 @@ -using KSP.Game; -using KSP.UI.Binding; -using UnityEngine; - -namespace CommunityFixes.Fix.VelocityDisplayPrecisionFix; - -[Fix("Velocity Display Precision Fix")] -public class VelocityDisplayPrecisionFix : BaseFix -{ - private bool _fixed = false; - - public void Update() - { - var gameState = Game?.GlobalGameState?.GetGameState(); - if (gameState == null || - gameState.GameState is GameState.MainMenu or GameState.WarmUpLoading or GameState.Loading) - _fixed = false; - - if (_fixed) return; - - var velocityValue = GameObject.Find("GameManager/Default Game Instance(Clone)/UI Manager(Clone)/" + - "Scaled Main Canvas/FlightHudRoot(Clone)/group_navball(Clone)/Container/" + - "GRP-VEL/Container/DataContainer/Items/Value"); - if (velocityValue == null) return; - var entries = velocityValue.GetComponent().unitEntryArray; - for (int i = 0; i < entries.Length; ++i) - entries[i].dontTruncateValue = true; - - _fixed = true; - } -} \ No newline at end of file From 6c458e1a603842b1db73ca178a896c12739f6c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bure=C5=A1?= Date: Fri, 2 Feb 2024 00:19:07 +0100 Subject: [PATCH 4/5] Added check for Splashes state to VesselLandedStateFix --- .../VesselLandedState/VesselLandedStateFix.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/CommunityFixes/Fix/VesselLandedState/VesselLandedStateFix.cs b/src/CommunityFixes/Fix/VesselLandedState/VesselLandedStateFix.cs index bc295a3..c1d59bb 100644 --- a/src/CommunityFixes/Fix/VesselLandedState/VesselLandedStateFix.cs +++ b/src/CommunityFixes/Fix/VesselLandedState/VesselLandedStateFix.cs @@ -7,14 +7,20 @@ public class VesselLandedStateFix: BaseFix { private void LateUpdate() { - var gameStateConfiguration = Game?.GlobalGameState?.GetGameState(); - if (gameStateConfiguration is { IsFlightMode: true }) + if (Game?.GlobalGameState?.GetGameState() is not { IsFlightMode: true }) { - var vessel = Game?.ViewController?.GetActiveSimVessel(); - if (vessel is { Situation: VesselSituations.Landed, AltitudeFromSurface: > 50, SrfSpeedMagnitude: > 5 }) + return; + } + + var vessel = Game?.ViewController?.GetActiveSimVessel(); + if (vessel is { - vessel.Landed = false; - } + Situation: VesselSituations.Landed or VesselSituations.Splashed, + AltitudeFromSurface: > 50, SrfSpeedMagnitude: > 5 + }) + { + vessel.Landed = false; + vessel.Splashed = false; } } -} +} \ No newline at end of file From 6f7d5f15206670ca9738460aca7bff20afdea35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bure=C5=A1?= Date: Fri, 2 Feb 2024 00:20:18 +0100 Subject: [PATCH 5/5] Update dependency, game and mod versions --- plugin_template/swinfo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin_template/swinfo.json b/plugin_template/swinfo.json index 26366dc..eb3e814 100644 --- a/plugin_template/swinfo.json +++ b/plugin_template/swinfo.json @@ -5,26 +5,26 @@ "name": "Community Fixes", "description": "Community project that aims to bring together bug fixes for KSP 2.", "source": "https://github.com/KSP2Community/CommunityFixes", - "version": "0.11.0", + "version": "0.12.0", "version_check": "https://raw.githubusercontent.com/KSP2Community/CommunityFixes/main/plugin_template/swinfo.json", "ksp2_version": { - "min": "0.2.0", + "min": "0.2.1", "max": "*" }, "dependencies": [ { "id": "com.github.x606.spacewarp", "version": { - "min": "1.6.0", + "min": "1.9.0", "max": "*" } }, { "id": "PatchManager", "version": { - "min": "0.6.0", + "min": "0.9.3", "max": "*" } } ] -} +} \ No newline at end of file