Skip to content

Commit

Permalink
Исправление критического бага
Browse files Browse the repository at this point in the history
  • Loading branch information
mortany committed Jun 17, 2020
1 parent b562217 commit a620b37
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 15 deletions.
1 change: 0 additions & 1 deletion Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace OMF_Editor
{
public class OMFEditor
{

public void CopyAnims(AnimationsContainer omf_1, AnimationsContainer omf_2)
{
//bool omf_1.bone_cont.OGF_V != omf_2.bone_cont.OGF_V
Expand Down
23 changes: 18 additions & 5 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ private void AppendFile(string filename, List<string> list)
{
AnimationsContainer new_omf = OpenSecondOMF(filename);
if (new_omf == null) return;

for (int i = 0; i < Main_OMF.Anims.Count; i++)
{
list.Remove(Main_OMF.Anims[i].MotionName);
}

editor.CopyAnims(Main_OMF, new_omf, list);
UpdateList();

Expand Down Expand Up @@ -385,5 +391,12 @@ private void button4_Click(object sender, EventArgs e)
}
}
}

private void button5_Click(object sender, EventArgs e)
{
if (Main_OMF == null) return;

Main_OMF.GunslingerRepair();
}
}
}
55 changes: 46 additions & 9 deletions OMF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ public void RecalcSectionSize()
SectionSize = new_size;

// Recalc second section size
new_size = 2; // motions count ( short )
new_size = 6; // motions count ( short )

foreach (AnimationParams anim in AnimsParams)
new_size += (uint)anim.Size(bone_cont.OGF_V);
{
uint temp = (uint)anim.Size(bone_cont.OGF_V);

new_size += temp;
}


new_size += (uint)bone_cont.Size();

Expand Down Expand Up @@ -64,7 +69,22 @@ public void RecalcAllAnimIndex()
}
}


public void GunslingerRepair()
{
short i = 0;
foreach (AnimationParams anm in AnimsParams)
{
anm.MotionID = i;
i++;
}
i = 1;
foreach (AnimVector anm in Anims)
{
anm.Name = AnimsParams[i - 1].Name;
anm.SectionId = i;
i++;
}
}

public BoneContainer bone_cont;

Expand Down Expand Up @@ -200,7 +220,7 @@ public int Size()
new_size += bonesparts.Size();
}

return new_size + 4;
return new_size;
}

public List<BoneParts> parts = new List<BoneParts>();
Expand Down Expand Up @@ -274,6 +294,13 @@ public MotionMark(BinaryReader reader, OMFEditor editor)
}
}

public uint Size()
{
uint temp = (uint)(Name.Length + 8 * Count + 6);

return temp;
}

public void WriteMotionMark(BinaryWriter writer, OMFEditor editor)
{
editor.WriteMarkString(writer, Name);
Expand Down Expand Up @@ -310,16 +337,26 @@ public class AnimationParams
public float Falloff { get; set; }
public int MarksCount { get; set; }

public int Size(short motion_version)
public uint Size(short motion_version)
{
int new_size = 0;
uint new_size = 0;

if(motion_version == 4)
{
new_size += (8 * MarksCount) + 4;
}
new_size += 4;

return new_size + Name.Length + 25;
if (m_marks != null)
{
foreach (MotionMark mark in m_marks)
{
uint temp = mark.Size();
new_size += temp;
}

}
}

return new_size + (uint)(Name.Length + 25);
}

public List<MotionMark> m_marks; // = new List<MotionMark>();
Expand Down

0 comments on commit a620b37

Please sign in to comment.