Skip to content
Permalink
Browse files

- added RocksmithToolkitLib.SongAppId.xml validation

- updated RocksmithToolkitLib.SongAppId.xml dlc AppIDs
- improved auto repair of some old toolkit multitone exceptions
  • Loading branch information
cozy1 committed Feb 13, 2020
1 parent 5c76cd1 commit 0b6278e42e2c5375abd0c06a32c86265d6506adb
@@ -389,13 +389,14 @@ public bool AddXmlArrangement(string xmlFilePath)
// Detect Arrangement XML Version
var xmlVersion = GameVersion.None;
var verAttrib = Convert.ToInt32(_song2014.Version);
if (verAttrib < 7) // RS1 format

if (verAttrib == 0 || verAttrib == 4) // RS1 is null (0) or 4
{
xmlVersion = GameVersion.RS2012;
}
else if (verAttrib > 6) // RS2014 format
else if (verAttrib >= 7) // RS2014 is 7 or above
{
// CAUTION newer RS1 use RS2014 XML Arrangement format
// CAUTION newer RS1 may use RS2014 XML Arrangement format
xmlVersion = GameVersion.RS2014;
}
else

Large diffs are not rendered by default.

@@ -1470,17 +1470,30 @@ private void ImportTone(string toneImportFile)

private void PopulateAppIdCombo()
{
var i = 0;
var currentGameVersion = CurrentGameVersion;
if (rbConvert.Checked)
currentGameVersion = GameVersion.RS2014;

cmbAppIds.Items.Clear();

foreach (var song in SongAppIdRepository.Instance().Select(currentGameVersion))
cmbAppIds.Items.Add(song);
{
var delimiters = new[] { "-" };
var songSplit = song.Name.Split(delimiters, StringSplitOptions.None);
if (songSplit.Length != 2)
{
i++;
throw new DataException("<ERROR> Invalid RocksmithToolkitLib.SongAppId.xml entry. Found too many dashes '-' in: " + song.Name);
}

cmbAppIds.Items.Add(song);
}

var songAppId = SongAppIdRepository.Instance().Select((currentGameVersion == GameVersion.RS2014) ? ConfigRepository.Instance()["general_defaultappid_RS2014"] : ConfigRepository.Instance()["general_defaultappid_RS2012"], currentGameVersion);
cmbAppIds.SelectedItem = songAppId;
AppId = songAppId.AppId;
Debug.WriteLine("<DebugMe> RocksmithToolkitLib.SongAppId.xml contains (" + i + ") invalid entries ...");
}

private void PopulateArrangements(GameVersion oldGameVersion)
@@ -1671,6 +1684,7 @@ private void btnArrangementAdd_Click(object sender, EventArgs e)
private void btnPackageGenerate_Click(object sender, EventArgs e)
{
// perform an intial check of Wwise configuration before attempting PackageGeneration

if (CurrentGameVersion == GameVersion.RS2014 &&
Path.GetExtension(AudioPath) == ".wem" &&
File.Exists(String.Format(Path.Combine(Path.GetDirectoryName(AudioPath), Path.GetFileNameWithoutExtension(AudioPath)) + "_preview.wem")))
@@ -689,7 +689,8 @@ public string PackSong(string srcPath, string destPath)
catch (Exception ex)
{
errMsg = String.Format("{0}\n{1}", ex.Message, ex.InnerException) + Environment.NewLine + Environment.NewLine +
"Confirm GamePlatform and GameVersion are set correctly for desired destination in GeneraConfig";
"Confirm GamePlatform and GameVersion are set correctly for" + Environment.NewLine +
"the desired destination in the toolkit Configuration settings." + Environment.NewLine + Environment.NewLine;
}

if (!GlobalsLib.IsUnitTest)
@@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.1")]
[assembly: AssemblyInformationalVersion("4dfa389c")]
[assembly: AssemblyConfiguration("2020-02-02T18:04:33")]
[assembly: AssemblyInformationalVersion("5c76cd1f")]
[assembly: AssemblyConfiguration("2020-02-12T23:57:55")]
@@ -1,5 +1,8 @@
Rocksmith Toolkit Release Notes

- added RocksmithToolkitLib.SongAppId.xml validation
- 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
- fixed packer/unpacker PromptComplete now comes to front
- autoconvert old template relative path format to the new format
@@ -121,7 +121,7 @@ public Arrangement(Attributes2014 attr, string xmlSongFile, bool fixMultiTone =
this.TuningStrings = attr.Tuning;
this.Id = Guid.Parse(attr.PersistentID);
this.MasterId = attr.MasterID_RDV;

// Save xml comments
this.XmlComments = Song2014.ReadXmlComments(xmlSongFile);

@@ -184,16 +184,27 @@ public Arrangement(Attributes2014 attr, string xmlSongFile, bool fixMultiTone =
if (song.Tones != null)
foreach (var xmlTone in song.Tones)
{
// fix some old toolkit behavior
if (xmlTone.Name == "ToneA")
// auto fix some old toolkit behavior that causes multitone exceptions
if (xmlTone.Name == "ToneA" || xmlTone.Name == "tone_a")
{
xmlTone.Name = attr.Tone_A;
if (xmlTone.Name == "ToneB")
xmlTone.Id = 0;
}
if (xmlTone.Name == "ToneB" || xmlTone.Name == "tone_b")
{
xmlTone.Name = attr.Tone_B;
if (xmlTone.Name == "ToneC")
xmlTone.Id = 1;
}
if (xmlTone.Name == "ToneC" || xmlTone.Name == "tone_c")
{
xmlTone.Name = attr.Tone_C;
if (xmlTone.Name == "ToneD")
xmlTone.Id = 2;
}
if (xmlTone.Name == "ToneD" || xmlTone.Name == "tone_d")
{
xmlTone.Name = attr.Tone_D;

xmlTone.Id = 3;
}
if (xmlTone.Name.ToLower() == jsonTone.Name.ToLower() || jsonTone.Name.ToLower().EndsWith(xmlTone.Name.ToLower())) //todo: SAMENAME tone fix?
{
xmlTone.Name = jsonTone.Name;
@@ -230,11 +230,11 @@ public static DLCPackageData RS1LoadFromFolder(string unpackedDir, Platform plat
// Detect Arrangement XML Version
var xmlVersion = GameVersion.None;
var verAttrib = Convert.ToInt32(song2014.Version);
if (verAttrib < 7) // RS1 format
if (verAttrib == 0 || verAttrib == 4) // RS1 is null (0) or 4
{
xmlVersion = GameVersion.RS2012;
}
else if (verAttrib > 6) // RS2014 format
else if (verAttrib >= 7) // RS2014 is 7 or above
{
// CAUTION newer RS1 may use RS2014 XML Arrangement format
xmlVersion = GameVersion.RS2014;
@@ -11,6 +11,7 @@
using RocksmithToolkitLib.DLCPackage.Manifest.Functions;
using RocksmithToolkitLib.DLCPackage.Manifest2014;
using RocksmithToolkitLib.DLCPackage.Manifest2014.Header;
using RocksmithToolkitLib.PSARC;
using RocksmithToolkitLib.XML;
using X360.STFS;
using X360.Other;
@@ -309,6 +309,7 @@ private static void Crypto(Stream input, Stream output, ICryptoTransform transfo
input.Read(buffer, 0, size);
coder.Write(buffer, 0, size);
}

if (pad > 0)
coder.Write(new byte[pad], 0, pad);

@@ -90,6 +90,7 @@ protected byte[] block
{
while (blocks.Count <= blockId)
blocks.Add(new byte[blockSize]);

return blocks[(int)blockId];
}
}
@@ -137,13 +138,13 @@ public override int Read(byte[] buffer, int offset, int count)
}
if (offset < 0)
{
throw new ArgumentOutOfRangeException("offset",offset,"Destination offset cannot be negative.");
throw new ArgumentOutOfRangeException("offset", offset, "Destination offset cannot be negative.");
}

int read = 0;
long copysize = 0;
do
{
{
copysize = Math.Min(lcount, (blockSize - blockOffset));
Buffer.BlockCopy(block, (int)blockOffset, buffer, offset, (int)copysize);
lcount -= copysize;
@@ -152,10 +153,10 @@ public override int Read(byte[] buffer, int offset, int count)
read += (int)copysize;
Position += copysize;

} while (lcount > 0);
} while (lcount > 0);

return read;

}

public override long Seek(long offset, SeekOrigin origin)
@@ -72,10 +72,17 @@ public static string GetValidAcronym(this string value)
}

public static string GetValidAppIdSixDigits(this string value)
{
{
value = value.Trim();

// social engineering code
if (value.Equals("221680"))

This comment has been minimized.

Copy link
@L0FKA

L0FKA Feb 15, 2020

Contributor

This should be here like whole 6 years already, but yeah, nice one

throw new InvalidDataException("<WARNING> Sentinel has detected futile human resistance ..." + Environment.NewLine +
"Buy Cherub Rock and you wont have to mess around changing AppId's.");

// simple six digit number validation, eg. 248750
if (Regex.IsMatch(value, ("^([0-9]{6})$")))
// can be seven digits too eg. 1089163
if (Regex.IsMatch(value, ("^([0-9]{6}|[0-9]{7})$")))
return value;

return "";
@@ -322,7 +329,7 @@ public static string GetValidYear(this string value)
return String.Empty;

// check for valid four digit song year
if (!Regex.IsMatch(value, "^(15[0-9][0-9]|16[0-9][0-9]|17[0-9][0-9]|18[0-9][0-9]|19[0-9][0-9]|20[0-2][0-9])"))
if (!Regex.IsMatch(value, "^(15[0-9][0-9]|16[0-9][0-9]|17[0-9][0-9]|18[0-9][0-9]|19[0-9][0-9]|20[0-3][0-9])"))
value = ""; // clear if not valid

return value;
@@ -162,18 +162,19 @@ public static Stream ConvertAudioPlatform(string inputFile)

EndianBitConverter bitConverter;
EndianBitConverter targetbitConverter;
if (!platform.IsConsole) // little endian
{
bitConverter = EndianBitConverter.Little;
targetbitConverter = EndianBitConverter.Big;
}

if (platform.platform == GamePlatform.None)
throw new InvalidDataException("The input file doesn't appear to be a valid Wwise file.");
else if (platform.IsConsole) // big endian
{
bitConverter = EndianBitConverter.Big;
targetbitConverter = EndianBitConverter.Little;
}
else
throw new InvalidDataException("The input file doesn't appear to be a valid Wwise file.");
else // little endian
{
bitConverter = EndianBitConverter.Little;
targetbitConverter = EndianBitConverter.Big;
}

using (var outputFileStream = new MemoryStream())
using (var inputFileStream = File.Open(inputFile, FileMode.Open))
@@ -1,16 +1,14 @@
using System;
using System.IO;
using RocksmithToolkitLib.Extensions;
using System.Threading;
using System.Diagnostics;

namespace RocksmithToolkitLib.PSARC
{
public class BigEndianBinaryWriter : IDisposable
{
public Stream BaseStream
{
get;
private set;
}
public Stream BaseStream { get; private set; }

public BigEndianBinaryWriter(Stream input)
{
@@ -21,10 +19,28 @@ public void Dispose()
{
this.BaseStream.Dispose();
}

public void Flush()
{
this.BaseStream.Flush();
GC.Collect();
}

public void Write(byte v)
{
this.BaseStream.WriteByte(v);
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)
{
byte[] bytes = BitConverter.GetBytes(v);
@@ -105,13 +121,36 @@ public void WriteUInt40(ulong v)
this.Write(bytes[bytes.Length - i - 1]);
}
}

public void Write(byte[] val)
{
for (int i = 0; i < val.Length; i++)
try
{
for (int i = 0; i < val.Length; i++)
{
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)
{
byte[] buffer = new byte[32768];
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
byte v = val[i];
this.Write(v);
output.Write(buffer, 0, read);
}
}


}
}

0 comments on commit 0b6278e

Please sign in to comment.
You can’t perform that action at this time.