Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions HSDRaw/HSDRawFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ public static int BinarySearch(List<int> a, int item)
/// Saves dat data to filepath
/// </summary>
/// <param name="fileName"></param>
public void Save(string fileName, bool bufferAlign = true, bool optimize = true, bool trim = false)
public void Save(string fileName, bool optimize = true, bool trim = false)
{
Save(new FileStream(fileName, FileMode.Create), bufferAlign, optimize, trim);
Save(new FileStream(fileName, FileMode.Create), optimize, trim);
}

/// <summary>
Expand Down Expand Up @@ -580,12 +580,8 @@ public void SetStructFlags()
/// saves dat data to stream with optional alignment
/// </summary>
/// <param name="stream"></param>
/// <param name="bufferAlign"></param>
public void Save(Stream stream, bool bufferAlign = true, bool optimize = true, bool trim = false)
public void Save(Stream stream, bool optimize = true, bool trim = false)
{
if (Roots.Count > 0 && (Roots[0].Data is MEX_Data || Roots[0].Data is kexData))
bufferAlign = false;

// trim data if desired
if (trim)
TrimData();
Expand Down Expand Up @@ -658,22 +654,13 @@ public void Save(Stream stream, bool bufferAlign = true, bool optimize = true, b
// write structs
foreach (var s in _structCache)
{
// align buffers and general alignment
// TODO: trim extra data? Not a problem aside from potential filesize
// no refereneces = buffer?
// textures need to be 0x20 aligned... but there is no way to detect which structures are textures
// this can result in unnessecary padding
if (IsBuffer(s) && bufferAlign)
writer.Align(0x20);
else
if(s.Align)
writer.Align(4);
writer.Align(0x20);

structToOffset.Add(s, (int)writer.BaseStream.Position - 0x20);
writer.Write(s.GetData());
}

writer.Align(4);
writer.Align(0x20);
var relocationOffset = writer.BaseStream.Position;

List<int> relocationOffsets = new List<int>();
Expand Down