Skip to content

Commit

Permalink
[MapleLib+HaRepacker] Added an option under SaveForm to save WZ files…
Browse files Browse the repository at this point in the history
… for 64-bit client
  • Loading branch information
lastbattle committed Dec 29, 2021
1 parent df3e587 commit 82b4933
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 204 deletions.
2 changes: 1 addition & 1 deletion HaCreator/GUI/Repack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private void RepackerThread()

try
{
wzf.SaveToDisk(tmpFile);
wzf.SaveToDisk(tmpFile, null);
wzf.Dispose();

if (!bSaveFileInHaCreatorDirectory) // only replace the original file if its saving in the maplestory folder
Expand Down
1 change: 0 additions & 1 deletion HaRepacker/GUI/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

370 changes: 185 additions & 185 deletions HaRepacker/GUI/MainForm.resx

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions HaRepacker/GUI/SaveForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private void SaveForm_Load(object sender, EventArgs e)
{
encryptionBox.SelectedIndex = MainForm.GetIndexByWzMapleVersion(wzf.MapleVersion);
versionBox.Value = wzf.Version;
checkBox_64BitFile.Checked = wzf.Is64BitWZFile;
}
else
{ // Data.wz uses BMS encryption... no sepcific version indicated
Expand Down Expand Up @@ -150,6 +151,7 @@ private void SaveButton_Click(object sender, EventArgs e)
if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;

bool bSaveAs64BitWzFile = checkBox_64BitFile.Checked;
WzMapleVersion wzMapleVersionSelected = MainForm.GetWzMapleVersionByWzEncryptionBoxSelection(encryptionBox.SelectedIndex); // new encryption selected
if (this.IsRegularWzFile)
{
Expand All @@ -164,7 +166,7 @@ private void SaveButton_Click(object sender, EventArgs e)

if (wzf.FilePath != null && wzf.FilePath.ToLower() == dialog.FileName.ToLower())
{
wzf.SaveToDisk(dialog.FileName + "$tmp", wzMapleVersionSelected);
wzf.SaveToDisk(dialog.FileName + "$tmp", bSaveAs64BitWzFile, wzMapleVersionSelected);
wzNode.DeleteWzNode();
try
{
Expand All @@ -177,7 +179,7 @@ private void SaveButton_Click(object sender, EventArgs e)
}
else
{
wzf.SaveToDisk(dialog.FileName, wzMapleVersionSelected);
wzf.SaveToDisk(dialog.FileName, bSaveAs64BitWzFile, wzMapleVersionSelected);
wzNode.DeleteWzNode();
}

Expand Down
9 changes: 9 additions & 0 deletions HaRepacker/GUI/SaveForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 33 additions & 6 deletions HaRepacker/GUI/SaveForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@
<value>$this</value>
</data>
<data name="&gt;&gt;encryptionBox.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="saveButton.Location" type="System.Drawing.Point, System.Drawing">
<value>1, 76</value>
<value>1, 93</value>
</data>
<data name="saveButton.Size" type="System.Drawing.Size, System.Drawing">
<value>263, 27</value>
Expand All @@ -162,7 +162,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;saveButton.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="versionBox.Location" type="System.Drawing.Point, System.Drawing">
<value>75, 39</value>
Expand All @@ -186,7 +186,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;versionBox.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -213,7 +213,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -240,6 +240,33 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="checkBox_64BitFile.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkBox_64BitFile.Location" type="System.Drawing.Point, System.Drawing">
<value>75, 70</value>
</data>
<data name="checkBox_64BitFile.Size" type="System.Drawing.Size, System.Drawing">
<value>166, 17</value>
</data>
<data name="checkBox_64BitFile.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="checkBox_64BitFile.Text" xml:space="preserve">
<value>Save as 64-bit client WZ file</value>
</data>
<data name="&gt;&gt;checkBox_64BitFile.Name" xml:space="preserve">
<value>checkBox_64BitFile</value>
</data>
<data name="&gt;&gt;checkBox_64BitFile.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkBox_64BitFile.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;checkBox_64BitFile.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Expand All @@ -249,7 +276,7 @@
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>265, 104</value>
<value>265, 121</value>
</data>
<data name="$this.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 8pt</value>
Expand Down
27 changes: 20 additions & 7 deletions MapleLib/WzLib/WzFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public override WzObjectType ObjectType
/// </summary>
public MapleStoryLocalisation MapleLocaleVersion { get { return mapleLocaleVersion; } private set { } }

public bool Is64BitWZFile { get { return b64BitClient; } private set { } }

public override WzObject Parent { get { return null; } internal set { } }

public override WzFile WzFileParent { get { return this; } }
Expand All @@ -106,8 +108,14 @@ public override void Dispose()
{
if (wzDir == null || wzDir.reader == null)
return;
wzDir.reader.Close();
wzDir.reader = null;
try
{
wzDir.reader.Close();
}
finally
{
wzDir.reader = null;
}
Header = null;
path = null;
name = null;
Expand Down Expand Up @@ -437,12 +445,10 @@ private static uint CheckAndGetVersionHash(int wzVersionHeader, int maplestoryPa
int VersionHash = 0;
string VersionNumberStr = VersionNumber.ToString();

int l = VersionNumberStr.Length;
for (int i = 0; i < l; i++)
for (int i = 0; i < VersionNumberStr.Length; i++)
{
VersionHash = (32 * VersionHash) + (int)VersionNumberStr[i] + 1;
}

int a = (VersionHash >> 24) & 0xFF;
int b = (VersionHash >> 16) & 0xFF;
int c = (VersionHash >> 8) & 0xFF;
Expand Down Expand Up @@ -476,7 +482,9 @@ private void CreateWZVersionHash()
/// Saves a wz file to the disk, AKA repacking.
/// </summary>
/// <param name="path">Path to the output wz file</param>
public void SaveToDisk(string path, WzMapleVersion savingToPreferredWzVer = WzMapleVersion.UNKNOWN)
/// <param name="bSaveAs64BitWzFile">Save as WZ file for the 64-bit client</param>
/// <param name="savingToPreferredWzVer"></param>
public void SaveToDisk(string path, bool? bSaveAs64BitWzFile, WzMapleVersion savingToPreferredWzVer = WzMapleVersion.UNKNOWN)
{
// WZ IV
if (savingToPreferredWzVer == WzMapleVersion.UNKNOWN)
Expand Down Expand Up @@ -522,7 +530,12 @@ public void SaveToDisk(string path, WzMapleVersion savingToPreferredWzVer = WzMa
{
wzWriter.Write(new byte[(int)extraHeaderLength]);
}
if (!b64BitClient)

if (bSaveAs64BitWzFile != null)
{
if (bSaveAs64BitWzFile == false)
wzWriter.Write(wzVersionHeader);
} else if (!b64BitClient)
wzWriter.Write(wzVersionHeader);

wzWriter.Header = Header;
Expand Down
4 changes: 2 additions & 2 deletions MapleLib/WzSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ public void Save()
string tempFile = Path.GetTempFileName();
string settingsPath = wzFile.FilePath;

wzFile.SaveToDisk(tempFile);
wzFile.SaveToDisk(tempFile, null);
wzFile.Dispose();
File.Delete(settingsPath);
File.Move(tempFile, settingsPath);
}
else
wzFile.SaveToDisk(wzPath);
wzFile.SaveToDisk(wzPath, null);
}
}
}

0 comments on commit 82b4933

Please sign in to comment.