diff --git a/WolvenKit.CR2W/CR2W/CR2WReaderExtensions.cs b/WolvenKit.CR2W/CR2W/CR2WReaderExtensions.cs index eb6191183..d434413eb 100644 --- a/WolvenKit.CR2W/CR2W/CR2WReaderExtensions.cs +++ b/WolvenKit.CR2W/CR2W/CR2WReaderExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -27,10 +27,16 @@ public static string ReadCR2WString(this BinaryReader file, int len = 0) var sb = new StringBuilder(); while (true) { - var c = (char)file.ReadByte(); - if (c == 0) + if (file.BaseStream.Position <= file.BaseStream.Length) + { + var c = (char)file.ReadByte(); + if (c == 0) + break; + sb.Append(c); + } else + { break; - sb.Append(c); + } } str = sb.ToString(); } @@ -73,4 +79,4 @@ public static byte[] ReadRemainingData(this BinaryReader br) } -} \ No newline at end of file +} diff --git a/WolvenKit.Wwise/SoundCache/Sound_Cache.cs b/WolvenKit.Wwise/SoundCache/Sound_Cache.cs index cd7a5a6dc..3e4346518 100644 --- a/WolvenKit.Wwise/SoundCache/Sound_Cache.cs +++ b/WolvenKit.Wwise/SoundCache/Sound_Cache.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.IO.MemoryMappedFiles; @@ -73,7 +73,7 @@ public SoundCache() /// The concatenated string. private static byte[] GetNames(List FileList) { - return Encoding.UTF8.GetBytes(string.Join("\0",FileList.Select(x=> Path.GetFileName(GetIDFromPath(x)).Trim())) + "\0"); + return Encoding.UTF8.GetBytes(string.Join("\0", FileList.Select(x => Path.GetFileName(GetIDFromPath(x)).Trim())) + "\0"); } /// @@ -102,7 +102,7 @@ private static List BuildInfo(List FileList) /// The list of files to build the info for. /// private static byte[] GetInfo(List FileList) - { + { using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { @@ -154,7 +154,7 @@ private static ulong CalculateChecksum(List Files2Buffer) /// Reads the soundcache file. /// /// The binaryreader to read the file contents from. - public void Read(BinaryReader br) + public void Read(BinaryReader br) { Files = new List(); if (!br.ReadBytes(4).SequenceEqual(Magic)) @@ -176,32 +176,39 @@ public void Read(BinaryReader br) } NamesSize = br.ReadUInt32(); if (Version >= 2) - Unk3 = br.ReadUInt32(); + Unk3 = br.ReadUInt32(); buffsize = br.ReadInt64(); checksum = br.ReadInt64(); br.BaseStream.Seek(InfoOffset, SeekOrigin.Begin); for (var i = 0; i < FileCount; i++) { - var sf = new SoundCacheItem(this); - if (Version >= 2) + if (br.BaseStream.Position != br.BaseStream.Length) { - sf.NameOffset = br.ReadInt64(); - sf.PageOffset = br.ReadInt64(); - sf.Size = (uint)br.ReadInt64(); + var sf = new SoundCacheItem(this); + if (Version >= 2) + { + sf.NameOffset = br.ReadInt64(); + sf.PageOffset = br.ReadInt64(); + sf.Size = (uint)br.ReadInt64(); + } + else + { + sf.NameOffset = br.ReadUInt32(); + sf.PageOffset = br.ReadUInt32(); + sf.Size = br.ReadUInt32(); + } + Files.Add(sf); } else { - sf.NameOffset = br.ReadUInt32(); - sf.PageOffset = br.ReadUInt32(); - sf.Size = br.ReadUInt32(); + break; } - Files.Add(sf); } foreach (var f in Files) { br.BaseStream.Seek(NamesOffset + f.NameOffset, SeekOrigin.Begin); f.Name = br.ReadCR2WString(); - if(f.Name.EndsWith(".wem") && info.StreamedFiles.Any(x => x.Id == (f.Name.Split('.')[0]))) + if (f.Name.EndsWith(".wem") && info.StreamedFiles.Any(x => x.Id == (f.Name.Split('.')[0]))) { f.Name = info.StreamedFiles.First(x => x.Id == (f.Name.Split('.')[0])).Path; } @@ -251,6 +258,10 @@ public static void Write(List FileList, string OutPath) for (int i = 0; i < data_array.Count; i++) data_array[i].PageOffset = -1; } + else + { + Version = 1; + } if (buffersize <= CACHE_BUFFER_SIZE) buffersize = CACHE_BUFFER_SIZE; @@ -258,7 +269,7 @@ public static void Write(List FileList, string OutPath) { var fremainder = buffersize % CACHE_BUFFER_SIZE; buffersize += (CACHE_BUFFER_SIZE - fremainder); - } + } bw.Write(Magic); bw.Write((UInt32)Version); @@ -290,7 +301,7 @@ public static void Write(List FileList, string OutPath) bw.Write(File.ReadAllBytes(FileList[i])); //Write filenames and the offsets and such for the files. bw.Write(GetNames(FileList)); - bw.Write(GetInfo(FileList)); + bw.Write(GetInfo(FileList)); } } } diff --git a/WolvenKit.Wwise/Wwise/WemFile.cs b/WolvenKit.Wwise/Wwise/WemFile.cs index ffc1fb1f3..3c7e8ae55 100644 --- a/WolvenKit.Wwise/Wwise/WemFile.cs +++ b/WolvenKit.Wwise/Wwise/WemFile.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; @@ -278,7 +278,7 @@ public void LoadFromFile(string path, WwAudioFileType filetype) case "LIST": { LIST_offset = chunk_offset + 8; - LIST_offset = size; + LIST_size = size; break; } case "smpl": @@ -299,6 +299,8 @@ public void LoadFromFile(string path, WwAudioFileType filetype) data_size = size; break; } + case "hash": + break; default: throw new Exception("Unknown chunk with type: " + type + "!"); } @@ -422,8 +424,8 @@ public void LoadFromFile(string path, WwAudioFileType filetype) br.BaseStream.Seek(LIST_offset, SeekOrigin.Begin); adtlbuf = new String(br.ReadChars(4)); - if (adtlbuf != "adtl") - throw new Exception("List is not adtl!"); + //if (adtlbuf != "adtl") + // throw new Exception("List is not adtl!"); LIST_remain = br.ReadBytes((int)(LIST_size - 4)); } diff --git a/WolvenKit/Forms/MVVM/frmMain.cs b/WolvenKit/Forms/MVVM/frmMain.cs index fa6f11a80..ec84e6792 100644 --- a/WolvenKit/Forms/MVVM/frmMain.cs +++ b/WolvenKit/Forms/MVVM/frmMain.cs @@ -2236,7 +2236,8 @@ private void SetupUnbundling() return; // check path length - if (MainController.Get().Configuration.DepotPath.Length > 38) + //if (MainController.Get().Configuration.DepotPath.Length > 38) + if (MainController.Get().Configuration.DepotPath.Length > 255) { MainController.LogString("Wcc probably does not support path lengths > 255. " + "Please move your wcc_lite Modkit directory closer to root, e.g. C:\\Modkit\\.", Common.Services.Logtype.Error); diff --git a/WolvenKit/Forms/frmWelcome.cs b/WolvenKit/Forms/frmWelcome.cs index 80f67fd87..7f9af8cca 100644 --- a/WolvenKit/Forms/frmWelcome.cs +++ b/WolvenKit/Forms/frmWelcome.cs @@ -1,4 +1,4 @@ -using BrightIdeasSoftware; +using BrightIdeasSoftware; using System; using System.Collections.Generic; using System.ComponentModel; @@ -107,10 +107,11 @@ private void PopulateRecentFileList() +
  • Features and Guidelines
  • WolvenKit Wiki
  • GitHub Repository
  • Package creation
  • -
  • Sound modding
  • +
  • Sound modding
  • "; @@ -149,8 +150,10 @@ protected void ApplyCustomTheme() wolvenKitLbl.ForeColor = UIController.GetForeColor(); helpWebBrowser.DocumentText = DocumentText; + helpWebBrowser.Navigating += HelpWebBrowser_Navigating; } + public const int WM_NCLBUTTONDOWN = 0xA1; public const int HT_CAPTION = 0x2; @@ -158,8 +161,14 @@ protected void ApplyCustomTheme() public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern bool ReleaseCapture(); - + // UI Events // + + private void HelpWebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) + { + e.Cancel = true; + Process.Start(e.Url.ToString()); + } private void mainMenuStrip_MouseDown(object sender, MouseEventArgs e) {