Skip to content

Commit 79a3622

Browse files
authored
Merge pull request #688 from GreemDev/development
Omit more debug logs by default
2 parents 93cc28f + 61cc1a4 commit 79a3622

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

libMBIN/Source/Common/BinaryStreamExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static void Align( this BinaryWriter writer, int alignBy, string name, by
2727
} else {
2828
writer.Write( new byte[alignBy - mod] );
2929
}
30-
NMSTemplate.DebugLogTemplate( $"[C] aligned {name} to offset 0x{writer.BaseStream.Position:X}" );
30+
//NMSTemplate.DebugLogTemplate( $"[C] aligned {name} to offset 0x{writer.BaseStream.Position:X}" );
3131
}
3232
}
3333

libMBIN/Source/Template/NMSTemplate.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,9 @@ public void SerializeValue(
909909

910910
public void AppendToWriter( BinaryWriter writer, ref List<Tuple<long, object>> additionalData, ref int addtDataIndex, Type parent, UInt32 listEnding = 0xAAAAAA01, byte paddingByte = 0 ) {
911911
long templatePosition = writer.BaseStream.Position;
912+
#if DEBUG_TEMPLATE
912913
Logger.LogDebug( $"[C] writing {GetType().Name} to offset 0x{templatePosition:X} (parent: {parent.Name})" );
914+
#endif
913915
var type = GetType();
914916
var fields = type.GetFields().OrderBy( field => field.MetadataToken ); // hack to get fields in order of declaration (todo: use something less hacky, this might break mono?)
915917

@@ -963,7 +965,9 @@ public void SerializeGenericList( BinaryWriter writer, IList list, long listHead
963965
var template = (NMSTemplate) entry;
964966
var listObjects = new List<Tuple<long, object>>(); // new list of objects so that this data is serialised first
965967
var addtData = new Dictionary<long, object>();
968+
#if DEBUG_TEMPLATE
966969
Logger.LogDebug( $"[C] writing {template.GetType().Name} to offset 0x{writer.BaseStream.Position:X}" );
970+
#endif
967971
// pass the new listObject object in place of additionalData so that this branch is serialised before the whole layer
968972
template.AppendToWriter( writer, ref listObjects, ref addtDataIndexThis, GetType(), paddingByte: paddingByte );
969973
for ( int i = 0; i < listObjects.Count; i++ ) {
@@ -1062,7 +1066,9 @@ public void SerializeList( BinaryWriter writer, IList list, long listHeaderPosit
10621066
int addtDataIndexThis = addtDataIndex;
10631067

10641068
foreach ( var entry in list ) {
1069+
#if DEBUG_TEMPLATE
10651070
DebugLogTemplate( $"[C] writing {entry.GetType().Name} to offset 0x{writer.BaseStream.Position:X}" );
1071+
#endif
10661072
SerializeValue( writer, entry.GetType(), entry, null, null, ref additionalData, ref addtDataIndexThis, listEnding, paddingByte );
10671073
}
10681074
}
@@ -1125,7 +1131,9 @@ public byte[] SerializeBytes() {
11251131

11261132
if ( typeof(INMSVariableLengthString).IsAssignableFrom(data.Item2.GetType()) ) {
11271133
var str = (INMSVariableLengthString) data.Item2;
1134+
#if DEBUG_TEMPLATE
11281135
Logger.LogDebug($"[C+] Writing {str.StringValue()} to 0x{writer.BaseStream.Position:X}");
1136+
#endif
11291137
long stringPos = writer.BaseStream.Position;
11301138
writer.WriteString(str.StringValue(), Encoding.UTF8, null, true, paddingByte);
11311139
long stringEndPos = writer.BaseStream.Position;

0 commit comments

Comments
 (0)