From bdff842a74f153c18dd782673c4e6ec75434b8f7 Mon Sep 17 00:00:00 2001 From: Joseph Pearson Date: Sat, 23 Aug 2014 12:12:46 -0500 Subject: [PATCH] -Fixed bug with chat system not initializing properly with the "nogui" command line arg enabled -Implemented disposal of FloatingObject entities --- .../API/BasicUnitTestManager.cs | 12 ++ SEModAPIExtensions/API/Server.cs | 4 + SEModAPIExtensions/Properties/AssemblyInfo.cs | 4 +- SEModAPIInternal/API/Entity/BaseEntity.cs | 6 + .../Entity/Sector/SectorObject/CubeGrid.cs | 5 +- .../Sector/SectorObject/FloatingObject.cs | 109 +++++++++++++++++- SEModAPIInternal/Properties/AssemblyInfo.cs | 4 +- SEServerExtender/Properties/AssemblyInfo.cs | 4 +- 8 files changed, 137 insertions(+), 11 deletions(-) diff --git a/SEModAPIExtensions/API/BasicUnitTestManager.cs b/SEModAPIExtensions/API/BasicUnitTestManager.cs index 2ce49ca5..f9b1e75c 100644 --- a/SEModAPIExtensions/API/BasicUnitTestManager.cs +++ b/SEModAPIExtensions/API/BasicUnitTestManager.cs @@ -200,6 +200,18 @@ protected bool RunEntityReflectionUnitTests() Console.WriteLine("CharacterEntity reflection validation failed!"); } + if (!FloatingObject.ReflectionUnitTest()) + { + result = false; + Console.WriteLine("FloatingObject reflection validation failed!"); + } + + if (!FloatingObjectManager.ReflectionUnitTest()) + { + result = false; + Console.WriteLine("FloatingObjectManager reflection validation failed!"); + } + if (!InventoryEntity.ReflectionUnitTest()) { result = false; diff --git a/SEModAPIExtensions/API/Server.cs b/SEModAPIExtensions/API/Server.cs index 0263827f..2994016e 100644 --- a/SEModAPIExtensions/API/Server.cs +++ b/SEModAPIExtensions/API/Server.cs @@ -538,6 +538,10 @@ private void PluginManagerMain(object sender, EventArgs e) } else { + //Force a refresh of the chat messages before running the plugin update + List messages = ChatManager.Instance.ChatMessages; + + //Run the plugin update m_pluginManager.Update(); } } diff --git a/SEModAPIExtensions/Properties/AssemblyInfo.cs b/SEModAPIExtensions/Properties/AssemblyInfo.cs index 8d4762f2..63f9d6b0 100644 --- a/SEModAPIExtensions/Properties/AssemblyInfo.cs +++ b/SEModAPIExtensions/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("0.1.5.7")] -[assembly: AssemblyFileVersion("0.1.5.7")] +[assembly: AssemblyVersion("0.1.6.0")] +[assembly: AssemblyFileVersion("0.1.6.0")] diff --git a/SEModAPIInternal/API/Entity/BaseEntity.cs b/SEModAPIInternal/API/Entity/BaseEntity.cs index eb61e20d..2e4c4edb 100644 --- a/SEModAPIInternal/API/Entity/BaseEntity.cs +++ b/SEModAPIInternal/API/Entity/BaseEntity.cs @@ -861,6 +861,9 @@ public static bool ReflectionUnitTest() public void RemoveEntity() { + if (NetworkManager == null) + return; + Action action = InternalRemoveEntity; SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action); } @@ -869,6 +872,9 @@ protected void InternalRemoveEntity() { try { + if (NetworkManager == null) + return; + BaseObject.InvokeEntityMethod(NetworkManager, BaseEntityBroadcastRemovalMethod); } catch (Exception ex) diff --git a/SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs b/SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs index e03fc7ca..bcf6a1a0 100644 --- a/SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs +++ b/SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs @@ -456,15 +456,12 @@ public override void Dispose() m_isDisposed = true; - //base.Dispose(); - - /* EntityEventManager.EntityEvent newEvent = new EntityEventManager.EntityEvent(); newEvent.type = EntityEventManager.EntityEventType.OnCubeGridDeleted; newEvent.timestamp = DateTime.Now; newEvent.entity = this; newEvent.priority = 1; - EntityEventManager.Instance.AddEvent(newEvent);*/ + EntityEventManager.Instance.AddEvent(newEvent); } public override void Export(FileInfo fileInfo) diff --git a/SEModAPIInternal/API/Entity/Sector/SectorObject/FloatingObject.cs b/SEModAPIInternal/API/Entity/Sector/SectorObject/FloatingObject.cs index 7c2be2be..005541d9 100644 --- a/SEModAPIInternal/API/Entity/Sector/SectorObject/FloatingObject.cs +++ b/SEModAPIInternal/API/Entity/Sector/SectorObject/FloatingObject.cs @@ -102,9 +102,29 @@ public InventoryItemEntity Item #region "Methods" + new public static bool ReflectionUnitTest() + { + try + { + Type type = InternalType; + if (type == null) + throw new Exception("Could not find internal type for FloatingObject"); + bool result = true; + + return result; + } + catch (Exception ex) + { + LogManager.APILog.WriteLine(ex); + return false; + } + } + public override void Dispose() { - //TODO - Get this to work after 1.040 + FloatingObjectManager.Instance.RemoveFloatingObject(this); + + m_isDisposed = true; } protected void InternalUpdateItem() @@ -124,7 +144,94 @@ protected void InternalUpdateItem() public class FloatingObjectManager { + #region "Attributes" + + private static FloatingObjectManager m_instance; + private static Type m_internalType; + + private FloatingObject m_floatingObjectToChange; + public static string FloatingObjectManagerNamespace = "5BCAC68007431E61367F5B2CF24E2D6F"; public static string FloatingObjectManagerClass = "66E5A072764E86AD0AC8B63304F0DC31"; + + public static string FloatingObjectManagerRemoveFloatingObjectMethod = "CDD52493D4DD9E7D7BDB9AFC5512A9E1"; + + #endregion + + #region "Constructors and Initializers" + + protected FloatingObjectManager() + { + m_instance = this; + } + + #endregion + + #region "Properties" + + internal static Type InternalType + { + get + { + if (m_internalType == null) + m_internalType = SandboxGameAssemblyWrapper.Instance.GetAssemblyType(FloatingObjectManagerNamespace, FloatingObjectManagerClass); + return m_internalType; + } + } + + public static FloatingObjectManager Instance + { + get + { + if (m_instance == null) + m_instance = new FloatingObjectManager(); + + return m_instance; + } + } + + #endregion + + #region "Methods" + + new public static bool ReflectionUnitTest() + { + try + { + Type type = InternalType; + if (type == null) + throw new Exception("Could not find internal type for FloatingObjectManager"); + bool result = true; + result &= BaseObject.HasMethod(type, FloatingObjectManagerRemoveFloatingObjectMethod); + + return result; + } + catch (Exception ex) + { + LogManager.APILog.WriteLine(ex); + return false; + } + } + + public void RemoveFloatingObject(FloatingObject floatingObject) + { + m_floatingObjectToChange = floatingObject; + + Action action = InternalRemoveFloatingObject; + SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action); + } + + protected void InternalRemoveFloatingObject() + { + if (m_floatingObjectToChange == null) + return; + + Object backingObject = m_floatingObjectToChange.BackingObject; + BaseObject.InvokeStaticMethod(InternalType, FloatingObjectManagerRemoveFloatingObjectMethod, new object[] { backingObject }); + + m_floatingObjectToChange = null; + } + + #endregion } } diff --git a/SEModAPIInternal/Properties/AssemblyInfo.cs b/SEModAPIInternal/Properties/AssemblyInfo.cs index 2c1cb8b8..3dd722f8 100644 --- a/SEModAPIInternal/Properties/AssemblyInfo.cs +++ b/SEModAPIInternal/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("0.2.2.1")] -[assembly: AssemblyFileVersion("0.2.2.1")] +[assembly: AssemblyVersion("0.2.2.3")] +[assembly: AssemblyFileVersion("0.2.2.3")] diff --git a/SEServerExtender/Properties/AssemblyInfo.cs b/SEServerExtender/Properties/AssemblyInfo.cs index bc7b9d6d..5d40bc0a 100644 --- a/SEServerExtender/Properties/AssemblyInfo.cs +++ b/SEServerExtender/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("0.2.9.14")] -[assembly: AssemblyFileVersion("0.2.9.14")] +[assembly: AssemblyVersion("0.2.9.15")] +[assembly: AssemblyFileVersion("0.2.9.15")]