diff --git a/.idea/.idea.CommunityFixes/.idea/projectSettingsUpdater.xml b/.idea/.idea.CommunityFixes/.idea/projectSettingsUpdater.xml
index 4bb9f4d..86cc6c6 100644
--- a/.idea/.idea.CommunityFixes/.idea/projectSettingsUpdater.xml
+++ b/.idea/.idea.CommunityFixes/.idea/projectSettingsUpdater.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 21cb095..1c4da2e 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ This project aims to bring together community bug fixes for Kerbal Space Program
- **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)".
- **Time Warp Thrust Fix** by [SunSerega](https://github.com/SunSerega) - Fixes the bug where thrust under time warp was sometimes not working despite draining fuel.
- **Save/Load DateTime Fix** by [bizzehdee](https://github.com/bizzehdee) - Displays dates and times of save files in the correct locale format.
+- **Tracking Station Debris Name Fix** by [polo](https://github.com/pasalvetti) - Replaces the object's guid with a human-readable name: "Debris of [ship name]".
## Planned fixes
To see what fixes are planned to be implemented, you can visit the [Issues page](https://github.com/KSP2Community/CommunityFixes/issues) on the project's GitHub.
diff --git a/plugin_template/swinfo.json b/plugin_template/swinfo.json
index ffbee84..c3362fa 100644
--- a/plugin_template/swinfo.json
+++ b/plugin_template/swinfo.json
@@ -5,7 +5,7 @@
"name": "Community Fixes",
"description": "Community project that aims to bring together bug fixes for KSP 2.",
"source": "https://github.com/KSP2Community/CommunityFixes",
- "version": "0.14.0",
+ "version": "0.15.0",
"version_check": "https://github.com/raw/KSP2Community/CommunityFixes/main/plugin_template/swinfo.json",
"ksp2_version": {
"min": "0.2.2",
diff --git a/src/CommunityFixes/Fix/DecoupledCraftNameFix/DecoupledCraftNameFix.cs b/src/CommunityFixes/Fix/DecoupledCraftNameFix/DecoupledCraftNameFix.cs
index 23af1d9..a135832 100644
--- a/src/CommunityFixes/Fix/DecoupledCraftNameFix/DecoupledCraftNameFix.cs
+++ b/src/CommunityFixes/Fix/DecoupledCraftNameFix/DecoupledCraftNameFix.cs
@@ -39,9 +39,10 @@ private void HandleSeparationEvent(VesselComponent vessel1, VesselComponent vess
{
Logger.LogDebug($"Separated: {vessel1?.Name}, {vessel2?.Name}");
- if (vessel2 is not { Name: var newName } ||
+ if ((vessel2 is not { Name: var newName } ||
!newName.StartsWith("Default Name") ||
- string.IsNullOrEmpty(vessel1?.Name))
+ string.IsNullOrEmpty(vessel1?.Name)) &&
+ vessel1.Name!=vessel2.Name)
{
return;
}
diff --git a/src/CommunityFixes/Fix/TrackingStationDebrisNameFix/TrackingStationDebrisNameFix.cs b/src/CommunityFixes/Fix/TrackingStationDebrisNameFix/TrackingStationDebrisNameFix.cs
new file mode 100644
index 0000000..0ada8f8
--- /dev/null
+++ b/src/CommunityFixes/Fix/TrackingStationDebrisNameFix/TrackingStationDebrisNameFix.cs
@@ -0,0 +1,88 @@
+using HarmonyLib;
+using KSP.Map;
+using KSP.Sim.impl;
+
+namespace CommunityFixes.Fix.TrackingStationDebrisNameFix
+{
+ [Fix("Fix debris name in the tracking station")]
+ internal class TrackingStationDebrisNameFix : BaseFix
+ {
+ private static SpaceWarp.API.Logging.ILogger _logger;
+ public override void OnInitialized()
+ {
+ _logger = Logger;
+ HarmonyInstance.PatchAll(typeof(TrackingStationDebrisNameFix));
+ }
+
+ /**
+ * Postfix the display of debris in the Tracking Station. Instead of displaying 'Debris: ', we display its formal name.
+ ***/
+ [HarmonyPatch(typeof(MapUI), nameof(MapUI.HandleDebrisObjectEntryConfigurations))]
+ [HarmonyPostfix]
+ public static void HandleDebrisObjectEntryConfigurationsPostfix(
+ MapItem item,
+ MapUISelectableEntry obj
+ )
+ {
+ obj.Name = ((object)item._itemName).ToString();
+ }
+
+ /**
+ * Postfix the creation of a new vessel. If it's a debris, we give it an appropriate name.
+ **/
+ [HarmonyPatch(typeof(SpaceSimulation), nameof(SpaceSimulation.CreateVesselSimObjectFromPart))]
+ [HarmonyPostfix]
+ public static void CreateVesselSimObjectFromPartPostfix(
+ PartComponent rootPart,
+ ref SimulationObjectModel __result
+ )
+ {
+ System.Diagnostics.Debug.Write("requin");
+ VesselComponent vessel = __result.FindComponent();
+ if (!vessel._hasCommandModule)
+ {
+ renameVessel(vessel, "Unknown Debris");
+ }
+ }
+
+ /**
+ * Postfix the decoupling of a vessel into two subvessels, renaming the debris (if such vessel exists) and keeping the original name for the subvessel with a command module (in case the original root part ends up being a debris).
+ **/
+ [HarmonyPatch(typeof(SpaceSimulation), nameof(SpaceSimulation.SplitCombinedVesselSimObject))]
+ [HarmonyPostfix]
+ public static void SplitCombinedVesselSimObjectPostfix(
+ VesselComponent combinedVessel, // the vessel with the root part
+ IGGuid detachingPartId,
+ ref SimulationObjectModel __result
+ )
+ {
+ System.Diagnostics.Debug.Write("albatros");
+ VesselComponent vessel = __result.FindComponent(); // the new vessel splited from the vessel with the root part
+ String originalVesselName = combinedVessel.Name.Replace("Debris of ", ""); // recreating the original vessel name by removing 'Debris of' (in case more than one linear decouplings happened at the same time)
+ renameDebrisVessel(vessel, originalVesselName);
+ renameDebrisVessel(combinedVessel, originalVesselName);
+ if (vessel._hasCommandModule)
+ {
+ renameVessel(vessel, originalVesselName); // if a command module happens to be in the splitted vessel, we give it the name of the original vessel
+ }
+ }
+
+ /**
+ * Rename the vessel as 'Debris of xxx' if it's a debris.
+ **/
+ private static void renameDebrisVessel(VesselComponent vessel, string originalVesselName)
+ {
+ if (vessel._hasCommandModule) return;
+ renameVessel(vessel, "Debris of " + originalVesselName);
+ }
+
+ /**
+ * Rename the vessel with the specified name.
+ ***/
+ private static void renameVessel(VesselComponent vessel, string newName)
+ {
+ System.Diagnostics.Debug.Write("Renaming " + vessel.SimulationObject.Name + " to " + newName);
+ vessel.SimulationObject.Name = newName;
+ }
+ }
+}