static void Main(string[] args) { if (args.Length == 1) { if (File.Exists(args[0])) { LeagueFileType meshType = Utilities.GetExtensionType(Path.GetExtension(args[0])); if (meshType == LeagueFileType.SKN) { Processor.Process(args[0], new SKNFile(args[0])); } else { WriteError("File type must be SKN"); } } else { WriteError("File does not exist"); } } else { WriteError("Please input SKN file"); } }
public static string GetEntryExtension(LeagueFileType extensionType) { switch (extensionType) { case LeagueFileType.ANM: return("anm"); case LeagueFileType.BIN: return("bin"); case LeagueFileType.BNK: return("bnk"); case LeagueFileType.DDS: return("dds"); case LeagueFileType.LUAOBJ: return("luaobj"); case LeagueFileType.PRELOAD: return("preload"); case LeagueFileType.PNG: return("png"); case LeagueFileType.SCB: return("scb"); case LeagueFileType.SCO: return("sco"); case LeagueFileType.SKL: return("skl"); case LeagueFileType.SKN: return("skn"); case LeagueFileType.WPK: return("wpk"); case LeagueFileType.MAPGEO: return("mapgeo"); case LeagueFileType.WGEO: return("wgeo"); case LeagueFileType.LIGHTGRID: return("dat"); case LeagueFileType.JPG: return("jpg"); default: return(""); } }
public static List <WadResult> GenerateWADStrings(WADFile wad, List <WadResult> wadResults) { List <string> strings = new List <string>(); foreach (WADEntry entry in wad.Entries.Where(x => x.Type != EntryType.FileRedirection)) { byte[] entryContent = entry.GetContent(true); LeagueFileType fileType = Utilities.GetLeagueFileExtensionType(entryContent); if (fileType == LeagueFileType.BIN) { BINFile bin = null; try { bin = new BINFile(new MemoryStream(entryContent)); strings.AddRange(ProcessBINLinkedFiles(bin.LinkedFiles)); strings.AddRange(ProcessBINFile(bin)); } catch (Exception excp) { throw new Exception(TAG + "解析wad文件失败,创建BIN文件失败...|" + excp.Message); } } } Dictionary <ulong, string> stringDictionary = new Dictionary <ulong, string>(); strings = strings.Distinct().ToList(); using (XXHash64 xxHash = XXHash64.Create()) { foreach (string fetchedString in strings) { if (!string.IsNullOrEmpty(fetchedString)) { // 计算路径的哈希值 byte[] b = Encoding.ASCII.GetBytes(fetchedString.ToLower()); byte[] hashVal = xxHash.ComputeHash(b); ulong hash = BitConverter.ToUInt64(hashVal, 0); string hex = BitConverter.ToString(hashVal, 0); if (!stringDictionary.ContainsKey(hash)) { stringDictionary.Add(hash, fetchedString); WadResult wadResult = new WadResult(); wadResult.hash = hash; wadResult.hex = hex; wadResult.name = fetchedString; //wadResult.type = Utilities.GetLeagueFileExtensionType(b); wadResults.Add(wadResult); } } } } GC.Collect(); return(wadResults); }
public static Dictionary <ulong, string> Generate(Wad wad) { Dictionary <ulong, string> hashtable = new Dictionary <ulong, string>(); List <string> strings = new List <string>(); foreach (WadEntry entry in wad.Entries.Values.Where(x => x.Type != WadEntryType.FileRedirection)) { using Stream entryStream = entry.GetDataHandle().GetDecompressedStream(); LeagueFileType fileType = LeagueUtilities.GetExtensionType(entryStream); if (fileType == LeagueFileType.BIN) { BinTree bin = null; try { bin = new BinTree(entryStream); } catch (Exception) { } if (bin != null) { strings.AddRange(ProcessBinDependencies(bin.Dependencies)); strings.AddRange(ProcessBinTree(bin)); } } else if (IsLegacyDirList(entry.XXHash)) { strings.AddRange(ProcessLegacyDirList(entry)); } } using (XXHash64 xxHash = XXHash64.Create()) { foreach (string fetchedString in strings.Distinct()) { if (!string.IsNullOrEmpty(fetchedString)) { ulong hash = BitConverter.ToUInt64(xxHash.ComputeHash(Encoding.ASCII.GetBytes(fetchedString.ToLower())), 0); if (!hashtable.ContainsKey(hash)) { hashtable.Add(hash, fetchedString); } } } } return(hashtable); }
public static Dictionary <ulong, string> Generate(WADFile wad) { Dictionary <ulong, string> hashtable = new Dictionary <ulong, string>(); List <string> strings = new List <string>(); foreach (WADEntry entry in wad.Entries.Where(x => x.Type != EntryType.FileRedirection)) { byte[] entryContent = entry.GetContent(true); LeagueFileType fileType = LeagueUtilities.GetExtension(entryContent); if (fileType == LeagueFileType.BIN) { BINFile bin = null; try { bin = new BINFile(new MemoryStream(entryContent)); } catch (Exception) { } if (bin != null) { strings.AddRange(ProcessBINLinkedFiles(bin.LinkedFiles)); strings.AddRange(ProcessBINFile(bin)); } } else if (IsLegacyDirList(entry.XXHash)) { strings.AddRange(ProcessLegacyDirList(entry)); } } using (XXHash64 xxHash = XXHash64.Create()) { foreach (string fetchedString in strings.Distinct()) { if (!string.IsNullOrEmpty(fetchedString)) { ulong hash = BitConverter.ToUInt64(xxHash.ComputeHash(Encoding.ASCII.GetBytes(fetchedString.ToLower())), 0); if (!hashtable.ContainsKey(hash)) { hashtable.Add(hash, fetchedString); } } } } return(hashtable); }
public static string Get(WADEntry entry) { if (_hashtable.ContainsKey(entry.XXHash)) { return(_hashtable[entry.XXHash]); } else { LeagueFileType fileType = LeagueUtilities.GetExtension(entry.GetContent(true)); string extension = LeagueUtilities.GetExtension(fileType); return(string.Format("{0}.{1}", entry.XXHash.ToString("x16"), extension)); } }
public static void GenerateWADStrings(WADFile wad, Dictionary <ulong, string> stringDictionary) { List <string> strings = new List <string>(); foreach (WADEntry entry in wad.Entries.Where(x => x.Type != EntryType.FileRedirection)) { byte[] entryContent = entry.GetContent(true); LeagueFileType fileType = Utilities.GetLeagueFileExtensionType(entryContent); if (fileType == LeagueFileType.BIN) { BINFile bin = null; try { bin = new BINFile(new MemoryStream(entryContent)); } catch (Exception excp) { Console.WriteLine(excp.Message); } if (bin != null) { strings.AddRange(ProcessBINLinkedFiles(bin.LinkedFiles)); strings = strings.Distinct().ToList(); strings.AddRange(ProcessBINFile(bin)); } } } using (XXHash64 xxHash = XXHash64.Create()) { for (int i = 0; i < strings.Count; i++) { string fetchedString = strings[i]; if (!string.IsNullOrEmpty(fetchedString)) { ulong hash = BitConverter.ToUInt64(xxHash.ComputeHash(Encoding.ASCII.GetBytes(fetchedString.ToLower())), 0); if (!stringDictionary.ContainsKey(hash)) { stringDictionary.Add(hash, fetchedString); } } } } }
public static FileConversionOptions GetFileConversionOptions(LeagueFileType fileType) { if (fileType == LeagueFileType.SimpleSkin) { return(new FileConversionOptions(new List <FileConversion> { new FileConversion("glTF", ".glb", null, ConvertSimpleSkinToGltf), new FileConversion("glTF (with Skeleton)", ".glb", ConstructSimpleSkinWithSkeletonParameter, ConvertSimpleSkinWithSkeletonToGltf) })); } else if (fileType == LeagueFileType.StaticObjectBinary) { return(new FileConversionOptions(new List <FileConversion>() { new FileConversion("glTF", ".glb", null, ConvertScbToGltf), new FileConversion("OBJ", ".obj", null, ConvertScbToObj) })); } else if (fileType == LeagueFileType.StaticObjectAscii) { return(new FileConversionOptions(new List <FileConversion>() { new FileConversion("glTF", ".glb", null, ConvertScoToGltf), new FileConversion("OBJ", ".obj", null, ConvertScoToObj) })); } else if (fileType == LeagueFileType.MapGeometry) { return(new FileConversionOptions(new List <FileConversion>() { new FileConversion("glTF", ".glb", null, ConvertMapGeometryToGltf) })); } else { return(new FileConversionOptions(new List <FileConversion>())); } }
static void ProcessJsonFile(JToken root, string file, Options options) { LeagueFileType type = GetLeagueFileType(root); string outPath = options.OutDirectory; string name = Enum.GetName(typeof(LeagueFileType), type); string foundMessage = null; switch (type) { case LeagueFileType.Champion: outPath = Path.Combine(outPath, "Champions"); name = root["name"].ToString(); foundMessage = $"Found champion {name}"; break; } if (type != LeagueFileType.Unknown) { string fileName = name; foreach (char c in Path.GetInvalidFileNameChars()) { fileName = fileName.Replace(c, '_'); } fileName += ".json"; outPath = Path.Combine(outPath, fileName); if (options.PrintFound) { if (foundMessage == null) { foundMessage = $"Found {name}"; } Console.WriteLine(foundMessage.PadRight(32) + $"'{outPath}'"); } try { File.WriteAllText(outPath, JsonConvert.SerializeObject(root, Formatting.Indented)); if (options.DeleteSource) { File.Delete(file); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { if (options.PrintUndetected) { Console.WriteLine("Unknown JSON file!".PadRight(32) + $"'{file}'"); } } }
public static string GetExtension(LeagueFileType extensionType) { switch (extensionType) { case LeagueFileType.Animation: return("anm"); case LeagueFileType.PropertyBin: return("bin"); case LeagueFileType.WwiseBank: return("bnk"); case LeagueFileType.DdsImage: return("dds"); case LeagueFileType.LuaObj: return("luaobj"); case LeagueFileType.Preload: return("preload"); case LeagueFileType.PngImage: return("png"); case LeagueFileType.StaticObjectBinary: return("scb"); case LeagueFileType.StaticObjectAscii: return("sco"); case LeagueFileType.Skeleton: return("skl"); case LeagueFileType.SimpleSkin: return("skn"); case LeagueFileType.WwisePackage: return("wpk"); case LeagueFileType.MapGeometry: return("mapgeo"); case LeagueFileType.WorldGeometry: return("wgeo"); case LeagueFileType.Lightgrid: return("dat"); case LeagueFileType.RiotStringTable: return("txt"); case LeagueFileType.PatchPropertyBin: return("bin"); case LeagueFileType.JpegImage: return("jpg"); default: return(""); } }