From bf66767808a922fbdebee4498f592a8f36085f07 Mon Sep 17 00:00:00 2001 From: 8vogt <8vogt@informatik.uni-hamburg.de> Date: Thu, 4 Mar 2021 00:41:19 +0100 Subject: [PATCH] Fixed asteroid objects not using id for asteroid object identification --- .../AsteroidRing/MyAsteroidRingProvider.cs | 6 +++--- .../AsteroidSphere/MyAsteroidSphereProvider.cs | 8 ++++---- .../AsteroidObjects/MyAbstractAsteroidObjectProvider.cs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/SEWorldGenPlugin/Generator/AsteroidObjects/AsteroidRing/MyAsteroidRingProvider.cs b/SEWorldGenPlugin/Generator/AsteroidObjects/AsteroidRing/MyAsteroidRingProvider.cs index 3901c1c..4eef544 100644 --- a/SEWorldGenPlugin/Generator/AsteroidObjects/AsteroidRing/MyAsteroidRingProvider.cs +++ b/SEWorldGenPlugin/Generator/AsteroidObjects/AsteroidRing/MyAsteroidRingProvider.cs @@ -128,7 +128,7 @@ public override bool TryLoadObject(MySystemAsteroids asteroid) { if (m_loadedRings.ContainsKey(asteroid.Id)) return false; - var ring = MyFileUtils.ReadXmlFileFromWorld(GetFileName(asteroid.DisplayName), typeof(MyAsteroidRingProvider)); + var ring = MyFileUtils.ReadXmlFileFromWorld(GetFileName(asteroid), typeof(MyAsteroidRingProvider)); if (ring == null) return false; @@ -145,7 +145,7 @@ public override void OnSave() var instance = MyStarSystemGenerator.Static.StarSystem.GetObjectById(ringId); if (instance == null) continue; - MyFileUtils.WriteXmlFileToWorld(m_loadedRings[ringId], GetFileName(instance.DisplayName), typeof(MyAsteroidRingProvider)); + MyFileUtils.WriteXmlFileToWorld(m_loadedRings[ringId], GetFileName(instance as MySystemAsteroids), typeof(MyAsteroidRingProvider)); } } @@ -197,7 +197,7 @@ public override bool RemoveInstance(MySystemAsteroids systemInstance) m_loadedRings.Remove(systemInstance.Id); - MyFileUtils.DeleteFileInWorldStorage(GetFileName(systemInstance.DisplayName), typeof(MyAsteroidRingProvider)); + MyFileUtils.DeleteFileInWorldStorage(GetFileName(systemInstance), typeof(MyAsteroidRingProvider)); PluginEventHandler.Static.RaiseStaticEvent(NotifyRemoveInstance, systemInstance.Id); diff --git a/SEWorldGenPlugin/Generator/AsteroidObjects/AsteroidSphere/MyAsteroidSphereProvider.cs b/SEWorldGenPlugin/Generator/AsteroidObjects/AsteroidSphere/MyAsteroidSphereProvider.cs index 06883c0..e7a0d08 100644 --- a/SEWorldGenPlugin/Generator/AsteroidObjects/AsteroidSphere/MyAsteroidSphereProvider.cs +++ b/SEWorldGenPlugin/Generator/AsteroidObjects/AsteroidSphere/MyAsteroidSphereProvider.cs @@ -80,7 +80,7 @@ public override void OnSave() var instance = MyStarSystemGenerator.Static.StarSystem.GetObjectById(sphere.Key); if (instance == null) continue; - MyFileUtils.WriteXmlFileToWorld(sphere.Value, GetFileName(instance.DisplayName), typeof(MyAsteroidSphereProvider)); + MyFileUtils.WriteXmlFileToWorld(sphere.Value, GetFileName(instance as MySystemAsteroids), typeof(MyAsteroidSphereProvider)); } } @@ -93,7 +93,7 @@ public override bool RemoveInstance(MySystemAsteroids systemInstance) m_loadedSpheres.Remove(systemInstance.Id); - MyFileUtils.DeleteFileInWorldStorage(GetFileName(systemInstance.DisplayName), typeof(MyAsteroidSphereProvider)); + MyFileUtils.DeleteFileInWorldStorage(GetFileName(systemInstance), typeof(MyAsteroidSphereProvider)); PluginEventHandler.Static.RaiseStaticEvent(NotifyRemoveInstance, systemInstance.Id); @@ -106,9 +106,9 @@ public override bool TryLoadObject(MySystemAsteroids asteroid) { if (m_loadedSpheres.ContainsKey(asteroid.Id)) return false; - if (!MyFileUtils.FileExistsInWorldStorage(GetFileName(asteroid.DisplayName), typeof(MyAsteroidSphereProvider))) return false; + if (!MyFileUtils.FileExistsInWorldStorage(GetFileName(asteroid), typeof(MyAsteroidSphereProvider))) return false; - var data = MyFileUtils.ReadXmlFileFromWorld(GetFileName(asteroid.DisplayName), typeof(MyAsteroidSphereProvider)); + var data = MyFileUtils.ReadXmlFileFromWorld(GetFileName(asteroid), typeof(MyAsteroidSphereProvider)); m_loadedSpheres.Add(asteroid.Id, data); diff --git a/SEWorldGenPlugin/Generator/AsteroidObjects/MyAbstractAsteroidObjectProvider.cs b/SEWorldGenPlugin/Generator/AsteroidObjects/MyAbstractAsteroidObjectProvider.cs index c3c8239..07c146d 100644 --- a/SEWorldGenPlugin/Generator/AsteroidObjects/MyAbstractAsteroidObjectProvider.cs +++ b/SEWorldGenPlugin/Generator/AsteroidObjects/MyAbstractAsteroidObjectProvider.cs @@ -100,11 +100,11 @@ public IMyAsteroidAdminMenuCreator GetAdminMenuCreator() /// /// Converts an asteroid object name to a file name. /// - /// The asteroid object name + /// The asteroid object /// The file name for the asteroid object - protected string GetFileName(string objectName) + protected string GetFileName(MySystemAsteroids obj) { - return objectName.Replace(" ", "_") + ".roid"; + return (obj.DisplayName + obj.Id.ToString()).Replace(" ", "_") + ".roid"; } } }