Skip to content

Commit

Permalink
Fixed issues with saving STSC2 files
Browse files Browse the repository at this point in the history
  • Loading branch information
thesupersonic16 committed Sep 8, 2024
1 parent 611e8cb commit 3d75566
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
14 changes: 11 additions & 3 deletions DALTools/DALLib/File/STSC2File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,17 @@ public override void Load(ExtendedBinaryReader reader, bool keepOpen = false)
if (CheckFlag(STSC2Flags.Security))
_data = SecurityDecode(_data, _data.Length, 0);

// Decompress stream
using (var deflate = new DeflateStream(new MemoryStream(_data, 2, _data.Length - 2), CompressionMode.Decompress, false))
scriptStream = new VirtualStream(deflate.CacheStream(), keepOpen);
// Decompress stream
using (var deflate = new DeflateStream(new MemoryStream(_data, 2, _data.Length - 2), CompressionMode.Decompress, false))
{
var memoryStream = deflate.CacheStream();

// Test
//System.IO.File.WriteAllBytes("out.bin", memoryStream.ToArray());
//memoryStream.Position = 0;

scriptStream = new VirtualStream(memoryStream, keepOpen);
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion DALTools/DALLib/Scripting/STSC2Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void WriteSequence(ExtendedBinaryWriter writer, bool incudeCmdLineInfo)
foreach (var line in Lines)
for (int i = 0; i < line.arguments.Count; i++)
if (line.arguments[i] is STSC2Commands.Command refLine)
writer.FillInOffset($"{line.GetHashCode()}{refLine.GetHashCode()}", lines[line]);
writer.FillInOffset($"{line.GetHashCode()}{refLine.GetHashCode()}", lines[refLine]);


// TODO: Handle trees
Expand Down
1 change: 1 addition & 0 deletions DALTools/ScriptDialogueEditor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void LoadScriptDatabase()
if (File.Exists(path))
{
CharacterNames.Clear();
CharacterNames.Add(0xFF, "None");
var table = new TableFile();
table.Load(path);
var entries = table.ToObject<CharaEntry>();
Expand Down
2 changes: 1 addition & 1 deletion DALTools/ScriptDialogueEditor/STSC2FileDialogue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void Save(ExtendedBinaryWriter writer)
case "Voice":
break;
case "Mes":
line.arguments[3] = code.Text;
line.arguments[3] = code.Text.Replace("\\n", "\n");
break;
case "Script":
break;
Expand Down

0 comments on commit 3d75566

Please sign in to comment.