public static void AddEBXLUTFile(EBXInformation ebx, SQLiteConnection con) { string ftype = "b"; if (ebx.isDLC) { ftype = "u"; } if (ebx.isPatch) { ftype = "p"; } string guid = ""; byte[] data = new byte[0]; if (ebx.incas) { data = SHA1Access.GetDataBySha1(Helpers.HexStringToByteArray(ebx.sha1)); } else { BinaryBundle b = null; foreach (AddEBXHelpStruct h in aehelp) { if (h.tocpath == ebx.tocfilepath && h.bpath == ebx.bundlepath) { b = h.b; break; } } if (b == null) { TOCFile toc = new TOCFile(ebx.tocfilepath); byte[] bundledata = toc.ExportBundleDataByPath(ebx.bundlepath); b = new BinaryBundle(new MemoryStream(bundledata)); AddEBXHelpStruct h = new AddEBXHelpStruct(); h.tocpath = ebx.tocfilepath; h.bpath = ebx.bundlepath; h.b = b; if (aehelp.Count > 10) { aehelp.RemoveAt(0); } } foreach (BinaryBundle.EbxEntry ebx2 in b.EbxList) { if (ebx.ebxname == ebx2._name) { data = ebx2._data; } } } guid = Helpers.ByteArrayToHexString(data, 0x28, 0x10); SQLCommand("INSERT INTO ebxlut (path,sha1,basesha1,deltasha1,casptype,guid,bundlepath,offset,size,isbase,isdelta,tocpath,incas,filetype) VALUES ('" + ebx.ebxname.Replace("'", "''") + "','" + ebx.sha1 + "','" + ebx.basesha1 + "','" + ebx.deltasha1 + "'," + ebx.casPatchType + ",'" + guid + "','" + ebx.bundlepath + "'," + ebx.offset + "," + ebx.size + ",'" + ebx.isbase + "','" + ebx.isdelta + "','" + ebx.tocfilepath + "','" + ebx.incas + "','" + ftype + "')", con); }
public static void AddBundle(int tocid, bool incas, Bundle b, TOCFile.TOCBundleInfoStruct info, SQLiteConnection con) { Debug.LogLn(" EBX:" + b.ebx.Count + " RES:" + b.res.Count + " CHUNK:" + b.chunk.Count, true); SQLCommand("INSERT INTO bundles (tocfile, frostid, offset, size, base, delta) VALUES (" + tocid + ",'" + info.id + "'," + info.offset + ", " + info.size + ", '" + info.isbase + "', '" + info.isdelta + "' )", con); int bundleid = (int)GetLastRowId(con); TOCInformation toci = GetTocInformationByIndex(tocid); var transaction = con.BeginTransaction(); int counter = 0; if (b.ebx != null) { foreach (Bundle.ebxtype ebx in b.ebx) { try { if (ebx.name != null && ebx.originalSize != null && ebx.size != null) { EBXInformation inf = new EBXInformation(); inf.basesha1 = Helpers.ByteArrayToHexString(ebx.baseSha1); inf.bundlepath = b.path; inf.casPatchType = ebx.casPatchType; inf.deltasha1 = Helpers.ByteArrayToHexString(ebx.deltaSha1); inf.ebxname = ebx.name; inf.incas = incas; inf.isbase = info.isbase; inf.isdelta = info.isdelta; if (toci.type == TYPE_BASEGAME) { inf.isbasegamefile = true; } if (toci.type == TYPE_UPDATE) { inf.isDLC = true; } if (toci.type == TYPE_PATCH) { inf.isPatch = true; } inf.offset = info.offset; inf.sha1 = Helpers.ByteArrayToHexString(ebx.Sha1); inf.size = info.size; inf.tocfilepath = toci.path; byte[] data = new byte[0]; if (inf.incas) { data = SHA1Access.GetDataBySha1(ebx.Sha1, 0x38); } else { BinaryBundle bb = null; foreach (AddEBXHelpStruct h in aehelp) { if (h.tocpath == inf.tocfilepath && h.bpath == inf.bundlepath) { bb = h.b; break; } } if (bb == null) { TOCFile toc = new TOCFile(inf.tocfilepath); byte[] bundledata = toc.ExportBundleDataByPath(inf.bundlepath); bb = new BinaryBundle(new MemoryStream(bundledata)); AddEBXHelpStruct h = new AddEBXHelpStruct(); h.tocpath = inf.tocfilepath; h.bpath = inf.bundlepath; h.b = bb; if (aehelp.Count > 10) { aehelp.RemoveAt(0); } } foreach (BinaryBundle.EbxEntry ebx2 in bb.EbxList) { if (inf.ebxname == ebx2._name) { data = ebx2._data; } } } inf.guid = Helpers.ByteArrayToHexString(data, 0x28, 0x10); AddEBXLUTFile(inf, con); if ((counter++) % 100 == 0) { transaction.Commit(); transaction = con.BeginTransaction(); } } } catch (Exception ex) { throw ex; } } } transaction.Commit(); transaction = con.BeginTransaction(); if (b.res != null) { foreach (Bundle.restype res in b.res) { try { if (res.name != null) { AddRESFile(res.name, res.SHA1, res.rtype, bundleid, con); } } catch (Exception ex) { throw ex; } } } transaction.Commit(); transaction = con.BeginTransaction(); if (b.chunk != null) { foreach (Bundle.chunktype chunk in b.chunk) { try { AddChunk(chunk.id, chunk.SHA1, bundleid, con); } catch (Exception ex) { throw ex; } } } transaction.Commit(); }