Skip to content

Commit

Permalink
-Fixed bug with chat system not initializing properly with the "nogui…
Browse files Browse the repository at this point in the history
…" command line arg enabled

-Implemented disposal of FloatingObject entities
  • Loading branch information
chessmaster42 committed Aug 23, 2014
1 parent ecb183a commit bdff842
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 11 deletions.
12 changes: 12 additions & 0 deletions SEModAPIExtensions/API/BasicUnitTestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions SEModAPIExtensions/API/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> messages = ChatManager.Instance.ChatMessages;

//Run the plugin update
m_pluginManager.Update();
}
}
Expand Down
4 changes: 2 additions & 2 deletions SEModAPIExtensions/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
6 changes: 6 additions & 0 deletions SEModAPIInternal/API/Entity/BaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,9 @@ public static bool ReflectionUnitTest()

public void RemoveEntity()
{
if (NetworkManager == null)
return;

Action action = InternalRemoveEntity;
SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
}
Expand All @@ -869,6 +872,9 @@ protected void InternalRemoveEntity()
{
try
{
if (NetworkManager == null)
return;

BaseObject.InvokeEntityMethod(NetworkManager, BaseEntityBroadcastRemovalMethod);
}
catch (Exception ex)
Expand Down
5 changes: 1 addition & 4 deletions SEModAPIInternal/API/Entity/Sector/SectorObject/CubeGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
109 changes: 108 additions & 1 deletion SEModAPIInternal/API/Entity/Sector/SectorObject/FloatingObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
}
4 changes: 2 additions & 2 deletions SEModAPIInternal/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions SEServerExtender/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit bdff842

Please sign in to comment.