diff --git a/GameData/KSPCommunityFixes/KSPCommunityFixes.version b/GameData/KSPCommunityFixes/KSPCommunityFixes.version index 2f79c1b..273c570 100644 --- a/GameData/KSPCommunityFixes/KSPCommunityFixes.version +++ b/GameData/KSPCommunityFixes/KSPCommunityFixes.version @@ -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": 16, "PATCH": 1, "BUILD": 0}, + "VERSION": {"MAJOR": 1, "MINOR": 17, "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} diff --git a/KSPCommunityFixes/BugFixes/StickySplashedFixer.cs b/KSPCommunityFixes/BugFixes/StickySplashedFixer.cs index 328aac4..879789f 100644 --- a/KSPCommunityFixes/BugFixes/StickySplashedFixer.cs +++ b/KSPCommunityFixes/BugFixes/StickySplashedFixer.cs @@ -1,17 +1,6 @@ -/* -The core of the issue is the asteroid/comet spawner passing a random int for the "id" argument of the ProtoVessel.CreatePartNode() method. -This id is affected to the part.flightId field, which must be unique game-wide and should have been generated by calling -ShipConstruction.GetUniqueFlightID(). Failing to produce an unique flightId result in various issues, especially with mods as they often -rely on that id. - -Note that by fixing this, we replace how the asteroid/comet "seed" is generated, which technically affect further calls to UnityEngine.Random(), -but this shouldn't have any effect on the actual randomness/distribution of the generated stuff. -*/ - -using System; +using System; using System.Collections.Generic; using HarmonyLib; -using KSP.UI.Screens; namespace KSPCommunityFixes.BugFixes { @@ -23,27 +12,27 @@ protected override void ApplyPatches(List patches) { patches.Add(new PatchInfo( PatchMethodType.Prefix, - AccessTools.Method(typeof(Vessel), "updateSituation"), + AccessTools.Method(typeof(Vessel), nameof(Vessel.updateSituation)), this)); patches.Add(new PatchInfo( PatchMethodType.Prefix, - AccessTools.Method(typeof(Part), "Die"), + AccessTools.Method(typeof(Part), nameof(Part.Die)), this)); patches.Add(new PatchInfo( PatchMethodType.Postfix, - AccessTools.Method(typeof(Part), "Die"), + AccessTools.Method(typeof(Part), nameof(Part.Die)), this)); patches.Add(new PatchInfo( PatchMethodType.Prefix, - AccessTools.Method(typeof(Part), "decouple"), + AccessTools.Method(typeof(Part), nameof(Part.decouple)), this)); patches.Add(new PatchInfo( PatchMethodType.Postfix, - AccessTools.Method(typeof(Part), "decouple"), + AccessTools.Method(typeof(Part), nameof(Part.decouple)), this)); } @@ -114,25 +103,25 @@ static bool Vessel_updateSituation_Prefix(Vessel __instance) // so a vessel isn't processed more than once if, say, multiple parts detach on the // same frame. But the landed/splash check isn't very expensive so I'm not worried. - static void Part_die_Prefix(Part __instance, out Vessel __state) + static void Part_Die_Prefix(Part __instance, out Vessel __state) { __state = __instance.vessel; } - static void Part_die_Postfix(Part __instance, Vessel __state) + static void Part_Die_Postfix(Vessel __state) { - if (__state.IsNotNullOrDestroyed()) + if (__state.IsNotNullOrDestroyed() && __state.state != Vessel.State.DEAD) __state.UpdateLandedSplashed(); } - static void Part_Decouple_Prefix(Part __instance, out Vessel __state) + static void Part_decouple_Prefix(Part __instance, out Vessel __state) { __state = __instance.vessel; } - static void Part_Decouple_Postfix(Part __instance, Vessel __state) + static void Part_decouple_Postfix(Vessel __state) { - if (__state.IsNotNullOrDestroyed()) + if (__state.IsNotNullOrDestroyed() && __state.state != Vessel.State.DEAD) __state.UpdateLandedSplashed(); // New vessel (on __instance) will run Initialize. diff --git a/KSPCommunityFixes/BugFixes/DepartmentHeadImage.cs b/KSPCommunityFixes/Modding/DepartmentHeadImage.cs similarity index 54% rename from KSPCommunityFixes/BugFixes/DepartmentHeadImage.cs rename to KSPCommunityFixes/Modding/DepartmentHeadImage.cs index 047b1ef..2d87a5a 100644 --- a/KSPCommunityFixes/BugFixes/DepartmentHeadImage.cs +++ b/KSPCommunityFixes/Modding/DepartmentHeadImage.cs @@ -1,19 +1,9 @@ -/* -The core of the issue is the asteroid/comet spawner passing a random int for the "id" argument of the ProtoVessel.CreatePartNode() method. -This id is affected to the part.flightId field, which must be unique game-wide and should have been generated by calling -ShipConstruction.GetUniqueFlightID(). Failing to produce an unique flightId result in various issues, especially with mods as they often -rely on that id. - -Note that by fixing this, we replace how the asteroid/comet "seed" is generated, which technically affect further calls to UnityEngine.Random(), -but this shouldn't have any effect on the actual randomness/distribution of the generated stuff. -*/ - -using System; +using System; using System.Collections.Generic; using HarmonyLib; using KSP.UI.Screens; -namespace KSPCommunityFixes.BugFixes +namespace KSPCommunityFixes.Modding { class DepartmentHeadImage : BasePatch { @@ -23,7 +13,7 @@ protected override void ApplyPatches(List patches) { patches.Add(new PatchInfo( PatchMethodType.Postfix, - AccessTools.Method(typeof(Administration), "AddKerbalListItem"), + AccessTools.Method(typeof(Administration), nameof(Administration.AddKerbalListItem)), this)); } diff --git a/KSPCommunityFixes/Modding/PersistentIConfigNode.cs b/KSPCommunityFixes/Modding/PersistentIConfigNode.cs index cb24ece..1d76552 100644 --- a/KSPCommunityFixes/Modding/PersistentIConfigNode.cs +++ b/KSPCommunityFixes/Modding/PersistentIConfigNode.cs @@ -1,4 +1,7 @@ -using HarmonyLib; +// - Add support for IConfigNode serialization +// - Add support for Guid serialization + +using HarmonyLib; using System; using System.Collections.Generic; using System.Reflection; @@ -6,8 +9,6 @@ using static ConfigNode; using Random = System.Random; -// TODO: use transpilers instead of overriding the stock methods... - namespace KSPCommunityFixes.Modding { class PersistentIConfigNode : BasePatch @@ -247,7 +248,7 @@ public class PersistentIConfigNodeTestModule : PartModule [KSPEvent(active = true, guiActive = true, guiActiveEditor = true, guiName = "IConfigNode test")] public void Test() { - Random rnd = new Random(); + System.Random rnd = new System.Random(); foo = new FloatCurve(); float time = rnd.Next(100); diff --git a/KSPCommunityFixes/Properties/AssemblyInfo.cs b/KSPCommunityFixes/Properties/AssemblyInfo.cs index 0133838..cfc784f 100644 --- a/KSPCommunityFixes/Properties/AssemblyInfo.cs +++ b/KSPCommunityFixes/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.16.1.0")] -[assembly: AssemblyFileVersion("1.16.1.0")] +[assembly: AssemblyVersion("1.17.0.0")] +[assembly: AssemblyFileVersion("1.17.0.0")] diff --git a/README.md b/README.md index 7b3a089..774457a 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ User options are available from the "ESC" in-game settings menu :
Disabled by default, you can enable it with a MM patch. Implement `IConfigNode` members marked as `[Persistent]` serialization support when using the `CreateObjectFromConfig()`, `LoadObjectFromConfig()` and `CreateConfigFromObject()` methods. +- **PersistentIConfigNode** [KSP 1.8.0 - 1.12.3]
Disabled by default, you can enable it with a MM patch. Implement `IConfigNode` members marked as `[Persistent]` serialization support when using the `CreateObjectFromConfig()`, `LoadObjectFromConfig()` and `CreateConfigFromObject()` methods. Also implements `Guid` serialization support for those methods. - **ReflectionTypeLoadExceptionHandler** [KSP 1.8.0 - 1.12.3]
Patch the BCL `Assembly.GetTypes()` method to always handle (gracefully) an eventual `ReflectionTypeLoadException`. Since having an assembly failing to load is a quite common scenario, this ensure such a situation won't cause issues with other plugins. Those exceptions are logged (but not re-thrown), and detailed information about offending plugins is shown on screen during loading so users are aware there is an issue with their install. This patch is always enabled and has no entry in `Settings.cfg`. +- **[DepartmentHeadImage](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/47)** [KSP 1.8.0 - 1.12.3]
Fix administration building custom departement head image not being used when added by a mod. ### License @@ -127,6 +128,11 @@ If doing so in the `Debug` configuration and if your KSP install is modified to ### Changelog +##### 1.17.0 +- New KSP bugfix : [StickySplashedFixer](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/44) (@NathanKell) +- New modding bugfix : [DepartmentHeadImage](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/47) (@NathanKell) +- PersistentIConfigNode patch : added `Guid` serialization support to `CreateObjectFromConfig()`, `LoadObjectFromConfig()` and `CreateConfigFromObject()` methods (@NathanKell). + ##### 1.16.1 - RoboticsDrift : fix "Servo info not found" log spam originating from servo parts for which the drift correction isn't enabled.