Permalink
Browse files

- Rewrote AppId Updater code as a memory process to improve overall p…

…erformance
  • Loading branch information...
cozy1 committed Nov 11, 2018
1 parent 79a2304 commit 14db7b4e4c7a30af195e0f999dd36ca7bd3b250f
@@ -66,8 +66,8 @@
\leveltemplateid67698693\'01\u-3929 ?;}{\levelnumbers;}\f10\fbias0 \fi-360\li6480\jclisttab\tx6480\lin6480 }{\listname ;}\listid1685859046}}{\*\listoverridetable{\listoverride\listid845022685\listoverridecount0\ls1}{\listoverride\listid359166142
\listoverridecount0\ls2}{\listoverride\listid1333413571\listoverridecount0\ls3}{\listoverride\listid1685859046\listoverridecount0\ls4}{\listoverride\listid338965384\listoverridecount0\ls5}{\listoverride\listid1120688297\listoverridecount0\ls6}}
{\*\rsidtbl \rsid143938\rsid208069\rsid276887\rsid1010091\rsid1596048\rsid2703131\rsid3495053\rsid4289800\rsid6300002\rsid7086855\rsid8091389\rsid8338931\rsid8457098\rsid9002083\rsid9046583\rsid9456744\rsid9846673\rsid10357349\rsid11038411\rsid11229351
\rsid11405303\rsid12549519\rsid13112591\rsid13443476\rsid13593537\rsid13636370\rsid13643383\rsid13981760\rsid14635904\rsid15667500}{\*\generator Microsoft Word 10.0.6612;}{\info{\author PowerUser}{\operator PowerUser}{\creatim\yr2018\mo9\dy24\hr19\min15}
{\revtim\yr2018\mo11\dy7\hr10\min59}{\printim\yr2018\mo11\dy5\hr10\min23}{\version30}{\edmins50}{\nofpages2}{\nofwords400}{\nofchars2283}{\*\company Cozumel}{\nofcharsws2678}{\vern16389}}
\rsid11405303\rsid12549519\rsid13112591\rsid13178679\rsid13443476\rsid13593537\rsid13636370\rsid13643383\rsid13981760\rsid14635904\rsid15667500}{\*\generator Microsoft Word 10.0.6612;}{\info{\author PowerUser}{\operator PowerUser}
{\creatim\yr2018\mo9\dy24\hr19\min15}{\revtim\yr2018\mo11\dy10\hr19\min52}{\printim\yr2018\mo11\dy5\hr10\min23}{\version31}{\edmins52}{\nofpages2}{\nofwords412}{\nofchars2351}{\*\company Cozumel}{\nofcharsws2758}{\vern16389}}
\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind4\viewscale100\nolnhtadjtbl\rsidroot13643383 \fet0\sectd
\linex0\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4
\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}
@@ -77,6 +77,9 @@
\par What's new for the toolkit:
\par }\pard \ql \li0\ri0\widctlpar\faauto\rin0\lin0\itap0\pararsid11229351 {\f36\fs20\cf11\insrsid9046583\charrsid9046583 }{\f2\fs22\insrsid11229351
\par }\pard \ql \li0\ri0\widctlpar\faauto\rin0\lin0\itap0\pararsid9046583 {\f36\fs20\insrsid9046583\charrsid9046583
\par {\listtext\pard\plain\f3\fs20\cf1\insrsid13178679 \loch\af3\dbch\af0\hich\f3 \'b7\tab}}\pard \ql \fi-360\li360\ri0\widctlpar\jclisttab\tx360\faauto\ls6\rin0\lin360\itap0\pararsid11229351 {\f36\fs20\cf1\insrsid13178679 Rewrote AppId Updater code as a
memory process to improve overall performance }{\f3\fs20\cf1\insrsid13178679\charrsid13178679
\par }\pard \ql \li0\ri0\widctlpar\faauto\rin0\lin0\itap0\pararsid13178679 {\f3\fs20\cf1\insrsid13178679\charrsid13178679
\par {\listtext\pard\plain\f3\fs20\cf1\insrsid13636370 \loch\af3\dbch\af0\hich\f3 \'b7\tab}}\pard \ql \fi-360\li360\ri0\widctlpar\jclisttab\tx360\faauto\ls6\rin0\lin360\itap0\pararsid11229351 {\f36\fs20\cf1\insrsid13636370 Fixed typo/bug in GenerateSng}{
\f3\fs20\cf1\insrsid13636370\charrsid13636370
\par }\pard \ql \li0\ri0\widctlpar\faauto\rin0\lin0\itap0\pararsid13636370 {\f3\fs20\cf1\insrsid13636370\charrsid13636370

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1689,7 +1689,7 @@ public DLCPackageData PackageGenerate()
}
// TODO: monitor this change
var illegalRepresent = packageData.Arrangements.Any(ar => ar.Represent && ar.BonusArr);
var invalidRepresent = packageData.Arrangements.Any(ar => ar.Represent && ar.BonusArr);
var hasRepresent = packageData.Arrangements.Any(ar => ar.Represent == true);
// TODO: confirm before releasing
@@ -1730,9 +1730,9 @@ public DLCPackageData PackageGenerate()
// }
//}
if (illegalRepresent && !hasRepresent)
if (invalidRepresent && !hasRepresent)
{
var diaMsg = "Illegal Arrangement Default/Bonus/Alternate Conditon ..." + Environment.NewLine + Environment.NewLine +
var diaMsg = "Invalid Arrangement Default/Bonus/Alternate Conditon ..." + Environment.NewLine + Environment.NewLine +
"Reauthor using EOF, or open each arrangement seperately" + Environment.NewLine +
"using toolkit Edit Arrangement and make necessary changes. ";
if (DialogResult.No == BetterDialog2.ShowDialog(diaMsg, "<WARNING> Arrangement Represent", null, "Ignore", "Abort", Bitmap.FromHicon(SystemIcons.Warning.Handle), "Warning", 150, 150))
@@ -120,6 +120,9 @@
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>23, 3</value>
</metadata>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>23, 3</value>
</metadata>
<data name="chkShowlights.ToolTip" xml:space="preserve">
<value>CAUTION - FOR DEVELOPER USE ONLY -
If checked, generates only the minimum

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -16,17 +16,13 @@
using RocksmithToolkitLib.XML;
using RocksmithToolkitLib.XmlRepository;
using RocksmithToolkitGUI.Config;
using RocksmithToolkitLib.PsarcLoader;
namespace RocksmithToolkitGUI.DLCPackerUnpacker
{
public partial class DLCPackerUnpacker : UserControl
{
#region Constants
private const string MESSAGEBOX_CAPTION = "CDLC Packer/Unpacker";
#endregion
private BackgroundWorker bwRepack = new BackgroundWorker();
private string destPath;
private StringBuilder errorsFound;
@@ -48,36 +44,42 @@ public DLCPackerUnpacker()
bwRepack.WorkerReportsProgress = true;
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // perma fix to prevent creating a property value in designer
public bool DecodeAudio
{
get { return chkDecodeAudio.Checked; }
set { chkDecodeAudio.Checked = value; }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // perma fix to prevent creating a property value in designer
public bool OverwriteSongXml
{
get { return chkOverwriteSongXml.Checked; }
set { chkOverwriteSongXml.Checked = value; }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // perma fix to prevent creating a property value in designer
public bool UpdateManifest
{
get { return chkUpdateManifest.Checked; }
set { chkUpdateManifest.Checked = value; }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // perma fix to prevent creating a property value in designer
public bool UpdateSng
{
get { return chkUpdateSng.Checked; }
set { chkUpdateSng.Checked = value; }
}
public string AppId
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // perma fix to prevent creating a property value in designer
public string UpdatedAppId
{
get { return txtAppId.Text; }
set { txtAppId.Text = value; }
set { txtAppId.Text = value.GetValidAppIdSixDigits(); }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // perma fix to prevent creating a property value in designer
public GameVersion Version { get; set; }
private void PopulateGameVersionCombo()
@@ -99,7 +101,7 @@ private void PopulateAppIdCombo(GameVersion gameVersion)
var songAppId = SongAppIdRepository.Instance().Select((gameVersion == GameVersion.RS2014) ? ConfigRepository.Instance()["general_defaultappid_RS2014"] : ConfigRepository.Instance()["general_defaultappid_RS2012"], gameVersion);
cmbAppId.SelectedItem = songAppId;
AppId = songAppId.AppId;
UpdatedAppId = songAppId.AppId;
}
private void PromptComplete(string destDirPath, bool actionPacking = true, string errMsg = null)
@@ -290,41 +292,61 @@ private void ProgressChanged(object sender, ProgressChangedEventArgs e)
public void UpdateAppId(object sender, DoWorkEventArgs e)
{
var sourceFileNames = e.Argument as string[];
var srcFilePaths = e.Argument as string[];
errorsFound = new StringBuilder();
var step = (int)Math.Round(1.0 / sourceFileNames.Length * 100, 0);
var step = (int)Math.Round(1.0 / srcFilePaths.Length * 100, 0);
int progress = 0;
// show some initial progress if only one song
if (step > 99) progress = 50;
var tmpDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())).FullName;
var appId = AppId;
var appId = UpdatedAppId;
if (String.IsNullOrEmpty(appId))
throw new InvalidDataException("<ERROR> AppID is null or empty ...");
foreach (string sourceFileName in sourceFileNames)
foreach (string srcFilePath in srcFilePaths)
{
Application.DoEvents();
var srcPlatform = sourceFileName.GetPlatform();
bwRepack.ReportProgress(progress, String.Format("Updating '{0}'", Path.GetFileName(sourceFileName)));
var srcPlatform = srcFilePath.GetPlatform();
bwRepack.ReportProgress(progress, String.Format("Updating '{0}'", Path.GetFileName(srcFilePath)));
if (!srcPlatform.IsConsole)
{
// TODO: monitor this change
// proces is so fast we may need to add
// Thread.Sleep(100);
// if too many errors get thrown
NoCloseStream dataStream = new NoCloseStream();
try
{
// TODO: use PsarcLoader memory methods to plant a new AppId
var unpackedDir = Packer.Unpack(sourceFileName, tmpDir, overwriteSongXml: OverwriteSongXml);
var appIdFile = Path.Combine(unpackedDir, (srcPlatform.version == GameVersion.RS2012) ? "APP_ID" : "appid.appid");
File.WriteAllText(appIdFile, appId);
Packer.Pack(unpackedDir, sourceFileName, srcPlatform, UpdateSng, UpdateManifest);
// use fast PsarcLoader memory methods to push a new AppId
using (PSARC p = new PSARC(true))
{
using (var fs = File.OpenRead(srcFilePath))
p.Read(fs);
dataStream = p.ReplaceData(x => x.Name.Equals("appid.appid"), appId);
using (var fs = File.Create(srcFilePath))
p.Write(fs, true);
}
}
catch (Exception ex)
{
errorsFound.AppendLine(String.Format("Error trying repack file '{0}': {1}", Path.GetFileName(sourceFileName), ex.Message));
errorsFound.AppendLine(String.Format("Error trying repack file '{0}': {1}", Path.GetFileName(srcFilePath), ex.Message));
}
if (dataStream != null)
dataStream.CloseEx();
progress += step;
bwRepack.ReportProgress(progress);
}
else
errorsFound.AppendLine(String.Format("File '{0}' is not a valid desktop platform package.", Path.GetFileName(sourceFileName)));
errorsFound.AppendLine(String.Format("File '{0}' is not a valid desktop platform package.", Path.GetFileName(srcFilePath)));
}
bwRepack.ReportProgress(100);
e.Result = "repack";
}
@@ -537,7 +559,7 @@ private void btnPackSongPack_Click(object sender, EventArgs e)
Stopwatch sw = new Stopwatch();
sw.Restart();
var songPackDir = AggregateGraph2014.DoLikeSongPack(srcPath, AppId);
var songPackDir = AggregateGraph2014.DoLikeSongPack(srcPath, UpdatedAppId);
destPath = Path.Combine(Path.GetDirectoryName(srcPath), String.Format("{0}_songpack_p.psarc", Path.GetFileName(srcPath)));
// PC Only for now can't mix platform packages
Packer.Pack(songPackDir, destPath, predefinedPlatform: new Platform(GamePlatform.Pc, GameVersion.RS2014));
@@ -740,7 +762,7 @@ private void btnUnpack_Click(object sender, EventArgs e)
private void cmbAppIds_SelectedValueChanged(object sender, EventArgs e)
{
if (cmbAppId.SelectedItem != null)
AppId = ((SongAppId)cmbAppId.SelectedItem).AppId;
UpdatedAppId = ((SongAppId)cmbAppId.SelectedItem).AppId;
}
private void cmbGameVersion_SelectedIndexChanged(object sender, EventArgs e)

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.1.0")]
[assembly: AssemblyInformationalVersion("8c8e32f2")]
[assembly: AssemblyInformationalVersion("79a2304b")]
[assembly: AssemblyConfiguration("BETA")]
@@ -130,7 +130,7 @@ public void TestRepackAppId(string appId, GameVersion gameVersion)
Assert.Fail("TestSettings CopyResources Failed ...");
packerUnpacker.Version = gameVersion;
packerUnpacker.AppId = appId;
packerUnpacker.UpdatedAppId = appId;
foreach (var archivePath in TestSettings.Instance.ArchivePaths)
{
@@ -149,7 +149,7 @@ public void TestRepackAppId(string appId, GameVersion gameVersion)
}
// test AppId validation method
packerUnpacker.SelectComboAppId(packerUnpacker.AppId);
packerUnpacker.SelectComboAppId(packerUnpacker.UpdatedAppId);
// call background worker method from unit test to avoid threading issues
packerUnpacker.UpdateAppId(null, new DoWorkEventArgs(new string[] { archivePath }));
@@ -164,7 +164,7 @@ public void TestRepackAppId(string appId, GameVersion gameVersion)
using (var psarcLoader = new PsarcLoader(archivePath, true))
{
var entryAppId = psarcLoader.ExtractAppId();
Assert.AreEqual(packerUnpacker.AppId, entryAppId);
Assert.AreEqual(packerUnpacker.UpdatedAppId, entryAppId);
}
}
}
@@ -103,8 +103,8 @@ public AttributesHeader2014(string arrangementFileName, Arrangement arrangement,
PersistentID = arrangement.Id.ToString().Replace("-", "").ToUpper();
Shipping = true;
// DLC controls wheter album artwork marker is shown in-game setlist, but has
// negative effect that 'Alternate Arrangements' are locked for new player profiles
// DLC property controls whether album artwork marker is shown in-game setlist, but
// has side effect that 'Alternate Arrangements' are locked for newer player profiles
DLC = true;
// TODO: monitor this change
@@ -27,5 +27,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.1.0")]
[assembly: AssemblyInformationalVersion("8c8e32f2")]
[assembly: AssemblyInformationalVersion("79a2304b")]
[assembly: AssemblyConfiguration("BETA")]
@@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.1.0")]
[assembly: AssemblyInformationalVersion("8c8e32f2")]
[assembly: AssemblyInformationalVersion("79a2304b")]
[assembly: AssemblyConfiguration("BETA")]
@@ -1,3 +1,3 @@
2.9.1.0
8c8e32f2
79a2304b
BETA

0 comments on commit 14db7b4

Please sign in to comment.