Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions QueenBee/InfoForm.Designer.cs

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

13 changes: 12 additions & 1 deletion QueenBee/InfoForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void InfoForm_Load(object sender, EventArgs e)
\lang1024\f1\'b7\tab\lang2057\f0 Edits a PAK's QB file in memory (No Import / Export required).\par
\lang1024\f1\'b7\tab\lang2057\f0 Import / Export / Export All functionality for PAK files.\par
\lang1024\f1\'b7\tab\lang2057\f0 Create New / Add / Rename / Remove files in PAK files.\par
\lang1024\f1\'b7\tab\lang2057\f0 Supports all internal QB structures contained in Guitar Hero 3 / Aerosmith / World Tour / Metallica / Smash Hits / Greatest Hits / Tony Hawk's Proving Ground and Downhill Jam.\par
\lang1024\f1\'b7\tab\lang2057\f0 Supports all internal QB structures contained in Guitar Hero 3 / Aerosmith / World Tour / Metallica / Smash Hits / Greatest Hits / Guitar Hero 5 / Warriors of Rock / Tony Hawk's Proving Ground and Downhill Jam.\par
\lang1024\f1\'b7\tab\lang2057\f0 QB structure and array items can be created, removed, copied and pasted.\par
\lang1024\f1\'b7\tab\lang2057\f0 All items are editable including increasing the size of text and script items.\par
\lang1024\f1\'b7\tab\lang2057\f0 Array items can be saved to text files for easy editing.\par
Expand Down Expand Up @@ -235,6 +235,17 @@ Queen Bee creates various files in the same folder as the source files (PAK/PAB/
txtVersionHistory.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Tahoma;}}
{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\lang2057\b\f0\fs24 Version History\b0\fs16\par
\par
\b\fs20 v1.9\b0\fs16\par
- \b Added\b0 : Warriors of Rock (WoR) DLC support. PAK files with duplicate CRC-based filenames (e.g. localized .qs files) are now handled gracefully.\par
- \b Added\b0 : Guitar Hero 5 and Warriors of Rock to the supported games list.\par
- \b Fixed\b0 : Export/Import file dialogs in Script Editor and Array Editor now correctly remember the last used directory.\par
- \b Fixed\b0 : QbKey.GetHashCode() was inconsistent with Equals(), which could cause incorrect Dictionary/HashSet lookups.\par
- \b Fixed\b0 : PAK file extraction opened files with ReadWrite access instead of Read, preventing read-only files from loading.\par
- \b Fixed\b0 : Undisposed BinaryReader/BinaryWriter in PAK data copy operations.\par
- \b Fixed\b0 : Undisposed BinaryEndianWriter when writing QB files.\par
- \b Changed\b0 : Widened the Information dialog to prevent text wrapping in Version History and About tabs.\par
- \b Changed\b0 : Upgraded to .NET 10 single-target build.\par
\par
\b\fs20 v1.8\b0\fs16\par
- \b Fixed\b0 : Certain item types were being saved with the wrong ID.\par
- \b Fixed\b0 : Handle Invalid path exception without crashing.\par
Expand Down
4 changes: 2 additions & 2 deletions QueenBee/QbItemEditors/ScriptEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private void btnExport_Click(object sender, EventArgs e)
{
string fname = string.Format("{0}_{1}.{2}", _qbItem.Root.Filename.Replace('\\', '#').Replace('/', '#').Replace('.', '#'), _qbItem.ItemQbKey.Crc.ToString("X").PadLeft(8, '0'), _fileExt);

if (AppState.LastScriptPath.Length == 0)
if (AppState.LastScriptPath.Length != 0)
fname = Path.Combine(AppState.LastScriptPath, fname);

fname = getBestFullFilename(fname);
Expand Down Expand Up @@ -313,7 +313,7 @@ private void btnImport_Click(object sender, EventArgs e)
{
string fname = string.Format("{0}_{1}.{2}", _qbItem.Root.Filename.Replace('\\', '#').Replace('/', '#').Replace('.', '#'), _qbItem.ItemQbKey.Crc.ToString("X").PadLeft(8, '0'), _fileExt);

if (AppState.LastScriptPath.Length == 0)
if (AppState.LastScriptPath.Length != 0)
fname = Path.Combine(AppState.LastScriptPath, fname);

fname = getBestFullFilename(fname);
Expand Down
4 changes: 2 additions & 2 deletions QueenBee/QbItemEditors/SimpleArrayEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ private void btnExport_Click(object sender, EventArgs e)
{
string fname = string.Empty; // string.Format("{0}.{1}", base.QbItem.Root.Filename.Replace('\\', '#').Replace('/', '#').Replace('.', '#'), _fileExt);

if (AppState.LastArrayPath.Length == 0)
if (AppState.LastArrayPath.Length != 0)
fname = Path.Combine(AppState.LastArrayPath, fname);

fname = getBestFullFilename(fname);
Expand Down Expand Up @@ -785,7 +785,7 @@ private void btnImport_Click(object sender, EventArgs e)
{
string fname = string.Empty; // string.Format("{0}_{1}.array.txt", base.QbItem.Root.Filename.Replace('\\', '#').Replace('/', '#').Replace('.', '#'), base.QbItem.ItemQbKey.Crc.ToString("X").PadLeft(8, '0'));

if (AppState.LastArrayPath.Length == 0)
if (AppState.LastArrayPath.Length != 0)
fname = Path.Combine(AppState.LastArrayPath, fname);

fname = getBestFullFilename(fname);
Expand Down
5 changes: 5 additions & 0 deletions QueenBeeParser/BinaryEndianWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public BinaryEndianWriter(Stream input)
: base(input)
{
}

public BinaryEndianWriter(Stream input, bool leaveOpen)
: base(input, System.Text.Encoding.UTF8, leaveOpen)
{
}

public void Write(UInt32 value, EndianType endianType)
{
Expand Down
45 changes: 30 additions & 15 deletions QueenBeeParser/Pak/PakEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,21 @@ private void parsePak(PakFormat pakFormat, bool debugFile)

try
{
_pakHeaders.Add(phi.Filename.ToLower(), phi);
string key = phi.Filename.ToLower();
if (_pakHeaders.ContainsKey(key))
{
int dupIndex = 2;
string newKey;
do
{
newKey = key + "_" + dupIndex;
dupIndex++;
}
while (_pakHeaders.ContainsKey(newKey));
phi.Filename = phi.Filename + "_" + (dupIndex - 1);
key = newKey;
}
_pakHeaders.Add(key, phi);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -377,7 +391,7 @@ public void ExtractFile(string qbFilename, Stream stream)
using (BinaryWriter bw = new BinaryWriter(stream))
{
//open input pak
using (FileStream fsPak = File.Open(fname, FileMode.Open, FileAccess.ReadWrite))
using (FileStream fsPak = File.Open(fname, FileMode.Open, FileAccess.Read))
{
if ((offset + phi.FileLength) - 1 > fsPak.Length)
throw new ApplicationException(string.Format("End of file '{0}' is located at 0x{1} which is beyond the PAK/PAB size 0x{2}", qbFilename, (offset + phi.FileLength).ToString("X").PadLeft(8, '0'), fsPak.Length.ToString("X").PadLeft(8, '0')));
Expand Down Expand Up @@ -935,22 +949,23 @@ private void writeHeaderItem(BinaryEndianWriter bwPakO, PakHeaderItem ph)
/// <param name="length"></param>
private void copyData(Stream sr, Stream sw, long length)
{
BinaryReader br = new BinaryReader(sr);
BinaryWriter bw = new BinaryWriter(sw);
long chunk = 1000000;
while (length > 0)
using (BinaryReader br = new BinaryReader(sr, Encoding.UTF8, leaveOpen: true))
using (BinaryWriter bw = new BinaryWriter(sw, Encoding.UTF8, leaveOpen: true))
{
if (length > chunk)
{
bw.Write(br.ReadBytes((int)chunk));
length -= chunk;
}
else
long chunk = 1000000;
while (length > 0)
{
bw.Write(br.ReadBytes((int)length));
length = 0;
if (length > chunk)
{
bw.Write(br.ReadBytes((int)chunk));
length -= chunk;
}
else
{
bw.Write(br.ReadBytes((int)length));
length = 0;
}
}

}
}

Expand Down
8 changes: 3 additions & 5 deletions QueenBeeParser/Qb/QbFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,8 @@ public void Write(string filename)

public void Write(Stream s)
{
BinaryEndianWriter bw = new BinaryEndianWriter(s);
//using (BinaryEndianWriter bw = new BinaryEndianWriter(s))
//{
using (BinaryEndianWriter bw = new BinaryEndianWriter(s, leaveOpen: true))
{
this.startLengthCheck(bw);

bw.Write(_magic, this.PakFormat.EndianType);
Expand All @@ -656,10 +655,9 @@ public void Write(Stream s)
foreach (QbItemBase qib in _items)
qib.Write(bw);


ApplicationException ex = this.testLengthCheck(this, bw);
if (ex != null) throw ex;
//}
}

}

Expand Down
2 changes: 1 addition & 1 deletion QueenBeeParser/Qb/QbKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public string Text

public override int GetHashCode()
{
return base.GetHashCode() & (int)this._crc; //Hmm
return this._crc.GetHashCode();
}

public bool HasText
Expand Down
2 changes: 1 addition & 1 deletion QueenBeeParser/Qb/base/QbItemBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public virtual IsValidReturnType IsValid
}
else if (_childMode == 2)
{
if (this.ItemCount < 0)
if (this.ItemCount < 0) // uint is always >= 0; validation is a no-op
return IsValidReturnType.ItemMustHave0OrMoreItems;
}
else if (_childMode == 3)
Expand Down
2 changes: 1 addition & 1 deletion QueenBeeParser/QueenBeeParser.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net10.0;net9.0;net8.0;net7.0;net6.0;net5.0;net48;net46;net35;net20</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
Expand Down
Loading