Skip to content

Commit

Permalink
Initial change for geometry data and changes to header format
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyman192 committed Apr 25, 2024
1 parent fb64a74 commit 4214674
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 65 deletions.
7 changes: 0 additions & 7 deletions MBINCompiler/Source/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ internal set {
// --exclude
public static List<string> ExcludeFilters { get => optExcludeFilters; internal set => optExcludeFilters = value; }

// --format-version
public static HeaderFormat FormatVersion { get => optFormatVersion; internal set => optFormatVersion = value; }

// --no-threads
public static bool UseThreads { get => optUseThreads; internal set => optUseThreads = value; }

Expand Down Expand Up @@ -147,10 +144,6 @@ internal set {
"The default is --exclude=\"LANGUAGE\\*;*.GEOMETRY.*\".\n" +
"The --exclude filter is applied after --include." },

new Option { shortName = 'V', longName = "format-version", param = "[0|1|2]", isHidden = true,
description = "\nOutput using the specified MBIN format version.\n" +
"Default is version 2." },

new Option { longName = "no-threads", isHidden = true, description = "Disable multi-threading." },

new Option { longName = "stream", description = "Enable sending EXML to Console." },
Expand Down
2 changes: 1 addition & 1 deletion MBINCompiler/Source/Commands/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private static string ConvertEXML( string inputPath, FileStream fIn, MemoryStrea
if ( data is libMBIN.NMS.Toolkit.TkGeometryData | data is libMBIN.NMS.Toolkit.TkGeometryStreamData ) fileOut += ".PC";

var mbin = new MBINFile( msOut ) { Header = new MBINHeader() };
mbin.Header.SetDefaults( data.GetType(), FormatVersion );
mbin.Header.SetDefaults( data.GetType() );
mbin.SetData( data );
mbin.Save();
} catch ( Exception e ) {
Expand Down
7 changes: 0 additions & 7 deletions MBINCompiler/Source/Commands/ConvertMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ public override int ExecuteCommand( CommandLineParser options ) {
UseThreads = !options.GetOptionSwitch( "no-threads" );
StreamToConsole = options.GetOptionSwitch("stream");
HideVersionInfo = options.GetOptionSwitch("no-version");

var arg = options.GetOptionArg( "format-version" );
if ( arg != null ) {
MBINHeader.Format version;
if ( !Enum.TryParse( arg.value, out version ) ) return CommandLine.ShowInvalidCommandLineArg( $"{arg.name}={arg.value}" );
FormatVersion = version;
}

if ( paths.Count < 1 ) return CommandLine.ShowHelp( ErrorCode.CommandLine );
var inputDir = paths[0];
Expand Down
20 changes: 10 additions & 10 deletions MBINCompilerTests/Source/Tests/MBINHeaderTestsV0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class MBINHeaderTestsV0 {

private static MBINHeader CreateMockHeader(
uint magic = MBINHeader.MBIN_MAGIC,
uint formatID = MBINHeader.MBIN_VERSION,
uint formatID = MBINHeader.MBIN_VERSION_1,
ulong timestamp = TIMESTAMP,
ulong guid = TEMPLATE_GUID,
string name = TEMPLATE_NAME,
Expand Down Expand Up @@ -86,7 +86,7 @@ public void TestIsFormatV2() {
[TestMethod]
public void TestCreateHeaderCommon() {
Assert.AreEqual( MBINHeader.MBIN_MAGIC, HeaderCommon.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, HeaderCommon.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, HeaderCommon.FormatID );
Assert.AreEqual( TIMESTAMP, HeaderCommon.Timestamp );
Assert.AreEqual( TEMPLATE_GUID, HeaderCommon.TemplateGUID );
Assert.AreEqual( TEMPLATE_NAME, HeaderCommon.TemplateName );
Expand All @@ -98,7 +98,7 @@ public void TestCreateHeaderCommon() {
[TestMethod]
public void TestCreateHeaderTkGeometryData() {
Assert.AreEqual( MBINHeader.MBIN_MAGIC_PC, HeaderTkGeometryData.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, HeaderTkGeometryData.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, HeaderTkGeometryData.FormatID );
Assert.AreEqual( MBINHeader.TKGEOMETRYDATA_TAG, HeaderTkGeometryData.Timestamp );
Assert.AreEqual( TKGEOMETRYDATA_GUID, HeaderTkGeometryData.TemplateGUID );
Assert.AreEqual( TEMPLATE_NAME, HeaderTkGeometryData.TemplateName );
Expand All @@ -110,7 +110,7 @@ public void TestCreateHeaderTkGeometryData() {
[TestMethod]
public void TestCreateHeaderTkAnimMetadata() {
Assert.AreEqual( MBINHeader.MBIN_MAGIC, HeaderTkAnimMetadata.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, HeaderTkAnimMetadata.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, HeaderTkAnimMetadata.FormatID );
Assert.AreEqual( MBINHeader.TKANIMMETADATA_TAG, HeaderTkAnimMetadata.Timestamp );
Assert.AreEqual( TKANIMMETADATA_GUID, HeaderTkAnimMetadata.TemplateGUID );
Assert.AreEqual( TEMPLATE_NAME, HeaderTkAnimMetadata.TemplateName );
Expand All @@ -125,7 +125,7 @@ public void TestSetDefaultsV0Common() {
header.SetDefaultsV0();

Assert.AreEqual( MBINHeader.MBIN_MAGIC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( 0ul, header.Timestamp );
Assert.AreEqual( 0ul, header.TemplateGUID );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -140,7 +140,7 @@ public void TestSetDefaultsV0TkGeometry() {
header.SetDefaultsV0( typeof( NMS.Toolkit.TkGeometryData ) );

Assert.AreEqual( MBINHeader.MBIN_MAGIC_PC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.TKGEOMETRYDATA_TAG, header.Timestamp );
Assert.AreEqual( TKGEOMETRYDATA_GUID, header.TemplateGUID );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -155,7 +155,7 @@ public void TestSetDefaultsV0TkAnimMetadata() {
header.SetDefaultsV0( typeof( NMS.Toolkit.TkAnimMetadata ) );

Assert.AreEqual( MBINHeader.MBIN_MAGIC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.TKANIMMETADATA_TAG, header.Timestamp );
Assert.AreEqual( TKANIMMETADATA_GUID, header.TemplateGUID );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -170,7 +170,7 @@ public void TestSetDefaultsCommon() {
header.SetDefaults( format: MBINHeader.Format.V0 );

Assert.AreEqual( MBINHeader.MBIN_MAGIC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( 0ul, header.Timestamp );
Assert.AreEqual( 0ul, header.TemplateGUID );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -185,7 +185,7 @@ public void TestSetDefaultsTkGeometry() {
header.SetDefaults( typeof( NMS.Toolkit.TkGeometryData ), MBINHeader.Format.V0 );

Assert.AreEqual( MBINHeader.MBIN_MAGIC_PC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.TKGEOMETRYDATA_TAG, header.Timestamp );
Assert.AreEqual( TKGEOMETRYDATA_GUID, header.TemplateGUID );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -200,7 +200,7 @@ public void TestSetDefaultsTkAnimMetadata() {
header.SetDefaults( typeof( NMS.Toolkit.TkAnimMetadata ), MBINHeader.Format.V0 );

Assert.AreEqual( MBINHeader.MBIN_MAGIC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.TKANIMMETADATA_TAG, header.Timestamp );
Assert.AreEqual( TKANIMMETADATA_GUID, header.TemplateGUID );
Assert.AreEqual( "", header.TemplateName );
Expand Down
20 changes: 10 additions & 10 deletions MBINCompilerTests/Source/Tests/MBINHeaderTestsV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class MBINHeaderTestsV1 {

private MBINHeader CreateMockHeader(
uint magic = MBINHeader.MBIN_MAGIC,
uint formatID = MBINHeader.MBIN_VERSION,
uint formatID = MBINHeader.MBIN_VERSION_1,
ulong tag = MBINHeader.MBINCVER_TAG,
ulong version = ~0ul,
string name = TEMPLATE_NAME,
Expand Down Expand Up @@ -104,7 +104,7 @@ public void TestUlongToString() {
[TestMethod]
public void TestCreateHeaderCommon() {
Assert.AreEqual( MBINHeader.MBIN_MAGIC, HeaderCommon.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, HeaderCommon.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, HeaderCommon.FormatID );
Assert.AreEqual( MBINHeader.MBINCVER_TAG, HeaderCommon.Timestamp );
Assert.AreEqual( VERSION_ID, HeaderCommon.TemplateGUID );
Assert.AreEqual( TEMPLATE_NAME, HeaderCommon.TemplateName );
Expand All @@ -116,7 +116,7 @@ public void TestCreateHeaderCommon() {
[TestMethod]
public void TestCreateHeaderTkGeometryData() {
Assert.AreEqual( MBINHeader.MBIN_MAGIC_PC, HeaderTkGeometryData.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, HeaderTkGeometryData.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, HeaderTkGeometryData.FormatID );
Assert.AreEqual( MBINHeader.TKGEOMETRYDATA_TAG, HeaderTkGeometryData.Timestamp );
Assert.AreEqual( TKGEOMETRYDATA_GUID, HeaderTkGeometryData.TemplateGUID );
Assert.AreEqual( TEMPLATE_NAME, HeaderTkGeometryData.TemplateName );
Expand All @@ -128,7 +128,7 @@ public void TestCreateHeaderTkGeometryData() {
[TestMethod]
public void TestCreateHeaderTkAnimMetadata() {
Assert.AreEqual( MBINHeader.MBIN_MAGIC, HeaderTkAnimMetadata.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, HeaderTkAnimMetadata.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, HeaderTkAnimMetadata.FormatID );
Assert.AreEqual( MBINHeader.TKANIMMETADATA_TAG, HeaderTkAnimMetadata.Timestamp );
Assert.AreEqual( TKANIMMETADATA_GUID, HeaderTkAnimMetadata.TemplateGUID );
Assert.AreEqual( TEMPLATE_NAME, HeaderTkAnimMetadata.TemplateName );
Expand All @@ -141,7 +141,7 @@ public void TestSetDefaultsV1Common() {
header.SetDefaultsV1();

Assert.AreEqual( MBINHeader.MBIN_MAGIC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.MBINCVER_TAG, header.Tag );
Assert.AreEqual( VERSION_ID, header.MbinVersion );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -156,7 +156,7 @@ public void TestSetDefaultsV1TkGeometry() {
header.SetDefaultsV1( typeof( NMS.Toolkit.TkGeometryData ) );

Assert.AreEqual( MBINHeader.MBIN_MAGIC_PC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.TKGEOMETRYDATA_TAG, header.Tag );
Assert.AreEqual( TKGEOMETRYDATA_GUID, header.MbinVersion );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -171,7 +171,7 @@ public void TestSetDefaultsV1TkAnimMetadata() {
header.SetDefaultsV1( typeof( NMS.Toolkit.TkAnimMetadata ) );

Assert.AreEqual( MBINHeader.MBIN_MAGIC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.TKANIMMETADATA_TAG, header.Tag );
Assert.AreEqual( TKANIMMETADATA_GUID, header.MbinVersion );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -186,7 +186,7 @@ public void TestSetDefaultsCommon() {
header.SetDefaults( format: MBINHeader.Format.V1 );

Assert.AreEqual( MBINHeader.MBIN_MAGIC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.MBINCVER_TAG, header.Tag );
Assert.AreEqual( VERSION_ID, header.MbinVersion );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -201,7 +201,7 @@ public void TestSetDefaultsTkGeometry() {
header.SetDefaults( typeof( NMS.Toolkit.TkGeometryData ), MBINHeader.Format.V1 );

Assert.AreEqual( MBINHeader.MBIN_MAGIC_PC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.TKGEOMETRYDATA_TAG, header.Tag );
Assert.AreEqual( TKGEOMETRYDATA_GUID, header.MbinVersion );
Assert.AreEqual( "", header.TemplateName );
Expand All @@ -216,7 +216,7 @@ public void TestSetDefaultsTkAnimMetadata() {
header.SetDefaults( typeof( NMS.Toolkit.TkAnimMetadata ), MBINHeader.Format.V1 );

Assert.AreEqual( MBINHeader.MBIN_MAGIC, header.MagicID );
Assert.AreEqual( MBINHeader.MBIN_VERSION, header.FormatID );
Assert.AreEqual( MBINHeader.MBIN_VERSION_1, header.FormatID );
Assert.AreEqual( MBINHeader.TKANIMMETADATA_TAG, header.Tag );
Assert.AreEqual( TKANIMMETADATA_GUID, header.MbinVersion );
Assert.AreEqual( "", header.TemplateName );
Expand Down
Loading

0 comments on commit 4214674

Please sign in to comment.