public BattleScript() { // empty scripts aren't empty, they still return Init.Add(new BattleScriptInstruction()); Execute.Add(new BattleScriptInstruction()); Counter.Add(new BattleScriptInstruction()); Death.Add(new BattleScriptInstruction()); PreCounter.Add(new BattleScriptInstruction()); }
public void Build(Package package) { HashSet <UInt32> types = new HashSet <uint>(); Dictionary <UInt32, List <ProjectFile> > files = new Dictionary <uint, List <ProjectFile> >(); Big big = new Big(); Big bundle_patch = new Big(); foreach (var file in Files) { if (types.Add(file.Type)) { if (!files.ContainsKey(file.Type)) { files[file.Type] = new List <ProjectFile>(); } } files[file.Type].Add(file); String full_path = Path.GetFullPath(Path.Combine(DirPath, file.Filename)); if (file.Type == 0x100) // bundle { bundle_patch.AddFile(file.FileID, full_path, file.Flags); } else { big.AddFile(file.FileID, full_path, file.Flags); } } foreach (var t in types) { var init_id = Utils.SH(String.Format(".\\{0}\\{1}_init.bin", package.PackageName, Utils.BundleTypeName(t))); var bundle_id = Utils.SH(String.Format(".\\{0}\\bundles\\{1}.bundle", package.PackageName, Utils.BundleMgrName(t))); var init_file = package.Main.FindFirst(init_id); var bundle_file = package.Main.FindFirst(bundle_id); if (init_file != null) { Init init = new Init(); init.Load(init_file.GetStream()); bool changed = false; foreach (var file in files[t]) { if (init.Add(file.FileID, file.SymbolName.GetHash())) { changed = true; } } if (changed) { String init_filename = String.Format("tmp\\{0}_init.bin", Utils.BundleTypeName(t)); init.Save(new FileStream(init_filename, FileMode.Create)); big.AddFile(init_id, init_filename, 0x14); } } if (bundle_file != null) { Bundle bundle = new Bundle(); bundle.Load(bundle_file.GetStream()); bool changed = false; foreach (var file in files[t]) { if (bundle.Add(file.FileID, (byte)file.Type, false)) { changed = true; } } if (changed) { String bundle_filename = String.Format("tmp\\{0}.bundle", Utils.BundleMgrName(t)); bundle.Save(new FileStream(bundle_filename, FileMode.Create)); bundle_patch.AddFile(bundle_id, bundle_filename, 0x14); } } } Directory.CreateDirectory(Path.Combine(package.BasePath, "Patches")); big.Build(Path.Combine(package.BasePath, "Patches", "generated_patch.big")); bundle_patch.Build(Path.Combine(package.BasePath, "BundleTarget", "generated_patch.big")); }