Skip to content

Commit

Permalink
- improved large file Out Of Memory exception handling and messages
Browse files Browse the repository at this point in the history
- changed audio/tone volume (LF) min/max range (45 to -45) user suggestion
  • Loading branch information
cozy1 committed Feb 27, 2020
1 parent 4fe239f commit 0be6dc2
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 82 deletions.
24 changes: 15 additions & 9 deletions RocksmithTookitGUI/DLCPackerUnpacker/DLCPackerUnpacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ private void PromptComplete(string destDirPath, bool actionPacking = true, strin
if (actionPacking)
destDirPath = Path.GetDirectoryName(destDirPath);

var actionMsg = "Packing";
var diaMsg = "Packing";
if (!actionPacking)
actionMsg = "Unpacking";
diaMsg = "Unpacking";

if (String.IsNullOrEmpty(errMsg))
errMsg = actionMsg + " is complete." + Environment.NewLine + Environment.NewLine;
diaMsg = diaMsg + " is complete.";
else
errMsg = actionMsg + " is complete with the following errors:" + Environment.NewLine + Environment.NewLine +
diaMsg = diaMsg + " is complete with the following errors:" + Environment.NewLine +
errMsg;

errMsg += "Would you like to open the destination path? ";

if (MessageBox.Show(errMsg, MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
diaMsg = diaMsg + Environment.NewLine + Environment.NewLine + "Would you like to open the destination path? ";
if (MessageBox.Show(diaMsg, MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
Process.Start(destDirPath);
}

Expand Down Expand Up @@ -686,11 +686,17 @@ public string PackSong(string srcPath, string destPath)
sw.Stop();
GlobalExtension.ShowProgress("Finished packing archive (elapsed time): " + sw.Elapsed, 100);
}
catch (OutOfMemoryException ex)
{
errMsg = String.Format("{0}\n{1}", ex.Message, ex.InnerException) + Environment.NewLine +
"Toolkit is not capable of repacking some large system artifact files. " + Environment.NewLine +
"Defragging the hard drive and clearing the 'pagefile.sys' may help.";
}
catch (Exception ex)
{
errMsg = String.Format("{0}\n{1}", ex.Message, ex.InnerException) + Environment.NewLine + Environment.NewLine +
errMsg = String.Format("{0}\n{1}", ex.Message, ex.InnerException) + Environment.NewLine +
"Confirm GamePlatform and GameVersion are set correctly for" + Environment.NewLine +
"the desired destination in the toolkit Configuration settings." + Environment.NewLine + Environment.NewLine;
"the desired destination in the toolkit Configuration settings.";
}

if (!GlobalsLib.IsUnitTest)
Expand Down
4 changes: 2 additions & 2 deletions RocksmithTookitGUI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.1")]
[assembly: AssemblyInformationalVersion("ef67384e")]
[assembly: AssemblyConfiguration("2020-02-18T15:58:11")]
[assembly: AssemblyInformationalVersion("4fe239f9")]
[assembly: AssemblyConfiguration("2020-02-27T18:35:45")]
5 changes: 3 additions & 2 deletions RocksmithTookitGUI/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Rocksmith Toolkit Release Notes

- based on feedback changed audio/tone volume (LF) min/max range (45 to -45)
- improved large file out of memory exception handling and messages
- changed audio/tone volume (LF) min/max range (45 to -45) user suggestion
- fixed update Arrangement Identification bug
- updated RocksmithToolkitLib.SongAppId.xml dlc AppIds
- improved auto repair of some old toolkit multitone exceptions
- volume ranges settable from 0 to -30 with better defaults
- volume ranges settable from 0 to -30 with defaults representative of odlc
- fixed packer/unpacker PromptComplete now comes to front
- autoconvert old template relative path format to the new format
- added additional exception handling for corrupt '*.dlc.xml' templates
Expand Down
48 changes: 24 additions & 24 deletions RocksmithToolkitLib/PSARC/BigEndianBinaryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ public void Flush()

public void Write(byte v)
{
try
{
this.BaseStream.WriteByte(v);
}
catch (Exception ex)
{
// little fish
Console.WriteLine("<ERROR> Little Fish: " + ex.Message);
this.Flush();
Thread.Sleep(200);
}
//try
//{
this.BaseStream.WriteByte(v);
//}
//catch (Exception ex)
//{
// // little fish
// Console.WriteLine("<ERROR> Little Fish: " + ex.Message);
// this.Flush();
// Thread.Sleep(200);
//}
}

public void Write(short v)
Expand Down Expand Up @@ -124,21 +124,21 @@ public void WriteUInt40(ulong v)

public void Write(byte[] val)
{
try
{
for (int i = 0; i < val.Length; i++)
{
byte v = val[i];
this.Write(v);
}
}
catch (Exception ex)
//try
//{
for (int i = 0; i < val.Length; i++)
{
// big fish
Console.WriteLine("<ERROR> Big Fish: " + ex.Message);
this.Flush();
Thread.Sleep(200);
byte v = val[i];
this.Write(v);
}
//}
//catch (Exception ex)
//{
// // big fish
// Console.WriteLine("<ERROR> Big Fish: " + ex.Message);
// this.Flush();
// Thread.Sleep(200);
//}
}

public static void CopyStream(Stream input, Stream output)
Expand Down
78 changes: 39 additions & 39 deletions RocksmithToolkitLib/PSARC/PSARC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,52 +581,52 @@ public void Write(Stream inputStream, bool encrypt = false, bool seek = true)
//if (current.Name == "NamesBlock.bin")
// continue;

try
//try
//{
// use chunk write method to avoid OOM Exceptions
var z = zStreams[entry];
var len = z.Length;
if (len > _header.BlockSizeAlloc)
{
// use chunk write method to avoid OOM Exceptions
//var z = zStreams[entry];
//var len = z.Length;
//if (len > 4096)
//{
// using (var msInput = new MemoryStream(z))
// using (var msExt = new MemoryStreamExtension())
// using (var _writer2 = new BigEndianBinaryWriter(msExt))
// {
// int bytesRead;
// int totalBytesRead = 0;
// var buffer = new byte[4096];
// while ((bytesRead = msInput.Read(buffer, 0, buffer.Length)) > 0)
// {
// totalBytesRead += bytesRead;
// if (totalBytesRead > len)
// bytesRead = len - (totalBytesRead - bytesRead);

// using (var msOutput = new MemoryStream())
// {
// msOutput.Write(buffer, 0, bytesRead);
// _writer2.Write(msOutput.ToArray());
// }
// }

// _writer.Write(msExt.ToArray());
// }
//}
//else
using (var msInput = new MemoryStreamExtension(z))
using (var msExt = new MemoryStreamExtension())
using (var _writer2 = new BigEndianBinaryWriter(msExt))
{
_writer.Write(zStreams[entry]);
int bytesRead;
int totalBytesRead = 0;
var buffer = new byte[_header.BlockSizeAlloc];
while ((bytesRead = msInput.Read(buffer, 0, buffer.Length)) > 0)
{
totalBytesRead += bytesRead;
if (totalBytesRead > len)
bytesRead = len - (totalBytesRead - bytesRead);

using (var msOutput = new MemoryStreamExtension())
{
msOutput.Write(buffer, 0, bytesRead);
_writer2.Write(msOutput.ToArray());
}
}

_writer.Write(msExt.ToArray());
}
}
catch //(Exception ex)
{
//Console.WriteLine("<ERROR> _writer.Write: " + ex.Message);
_writer.Flush();
}
finally
else
{
if (entry.Data != null)
entry.Data.Close();
_writer.Write(zStreams[entry]);
}

if (entry.Data != null)
entry.Data.Close();
//}
//catch (Exception ex)
//{
// Console.WriteLine("<ERROR> _writer.Write: " + ex.Message);
// _writer.Flush();
// _writer.Dispose();
// break;
//}

progress += step;
GlobalExtension.UpdateProgress.Value = (int)progress;
Console.WriteLine("Writing zData: " + entry.Id);
Expand Down
4 changes: 2 additions & 2 deletions RocksmithToolkitLib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.1")]
[assembly: AssemblyInformationalVersion("ef67384e")]
[assembly: AssemblyConfiguration("2020-02-18T15:58:11")]
[assembly: AssemblyInformationalVersion("4fe239f9")]
[assembly: AssemblyConfiguration("2020-02-27T18:35:45")]
4 changes: 2 additions & 2 deletions RocksmithToolkitUpdater/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.1")]
[assembly: AssemblyInformationalVersion("ef67384e")]
[assembly: AssemblyConfiguration("2020-02-18T15:58:11")]
[assembly: AssemblyInformationalVersion("4fe239f9")]
[assembly: AssemblyConfiguration("2020-02-27T18:35:45")]
4 changes: 2 additions & 2 deletions VersionInfo.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2.9.2.1
ef67384e
2020-02-18T15:58:11
4fe239f9
2020-02-27T18:35:45

0 comments on commit 0be6dc2

Please sign in to comment.