Resolve MRF saving issues

Should now be able to save any MRF with no difference comparing to original files

Remove debug dield from MrfFile
This commit is contained in:
Disquse 2021-11-06 07:28:20 +03:00
parent 11eb44dbd6
commit ca8eb31ae2

View File

@ -579,8 +579,8 @@ namespace CodeWalker.GameFiles
w.Write(Unk6); w.Write(Unk6);
// FIXME: might be broken if changed without flags, see "iterations" // FIXME: might be broken if changed without flags, see "iterations"
foreach (var item in Items) for (int i = Items.Length - 1; i >= 0; i--)
item.Write(w); Items[i].Write(w);
// FIXME: might be broken if changed without flags // FIXME: might be broken if changed without flags
uint flags = Unk1 & 0xFFFBFFFF; uint flags = Unk1 & 0xFFFBFFFF;
@ -699,20 +699,14 @@ namespace CodeWalker.GameFiles
{ {
Sections = new MrfStructStateMainSection[(int)count]; Sections = new MrfStructStateMainSection[(int)count];
// FIXME: for-loop? for (int i = (int)count - 1; i >= 0; i--)
while (true) Sections[i] = new MrfStructStateMainSection(r);
{
Sections[(int)count - 1] = new MrfStructStateMainSection(r);
if (--count == 0)
return;
}
} }
public override void Write(DataWriter w) public override void Write(DataWriter w)
{ {
foreach (var section in Sections) for (int i = Sections.Length - 1; i >= 0; i--)
section.Write(w); Sections[i].Write(w);
} }
} }
@ -816,8 +810,6 @@ namespace CodeWalker.GameFiles
public MetaHash StateName { get; } public MetaHash StateName { get; }
public uint UnkValue { get; } public uint UnkValue { get; }
public MrfNodeStateInfo __StateInfoNode { get; set; }
public MrfStructStateMachineState(DataReader r) public MrfStructStateMachineState(DataReader r)
{ {
StateName = new MetaHash(r.ReadUInt32()); StateName = new MetaHash(r.ReadUInt32());
@ -1113,8 +1105,8 @@ namespace CodeWalker.GameFiles
{ {
Header.Write(w); Header.Write(w);
foreach (var item in States) foreach (var state in States)
item.Write(w); state.Write(w);
if (Header.Unk7 != 0) if (Header.Unk7 != 0)
Header_Unk7_Data.Write(w); Header_Unk7_Data.Write(w);