public void FillData(BinaryReader binred, uint dataOffset, int dataSize, uint nameOffset, uint fileId) { binred.BaseStream.Position = nameOffset; fileName = Tools.ReadCharTillNull(binred); binred.BaseStream.Position = dataOffset; this.fileId = fileId; startPos = binred.BaseStream.Position; idk = binred.ReadUInt32(); fileSize = binred.ReadUInt32(); idk2 = binred.ReadUInt32(); idRangeCount = binred.ReadUInt32(); stringOffsetCount = binred.ReadUInt32(); idk3 = binred.ReadUInt32(); stringOffsetsOffset = binred.ReadInt64(); idk4 = binred.ReadUInt32(); idk5 = binred.ReadUInt32(); idRangesList = new List <FmgIdRange>(); for (int i = 0; i < idRangeCount; i++) { FmgIdRange fid = new FmgIdRange(); fid.offsetIndex = binred.ReadUInt32(); fid.firstId = binred.ReadUInt32(); fid.lastId = binred.ReadUInt32(); fid.idk = binred.ReadUInt32(); fid.idCount = fid.lastId - fid.firstId + 1; idRangesList.Add(fid); } binred.BaseStream.Position = startPos + stringOffsetsOffset; stringOffsetsArray = new long[stringOffsetCount]; for (int i = 0; i < stringOffsetCount; i++) { stringOffsetsArray[i] = binred.ReadInt64(); } linesList = new List <FmgString>(); foreach (FmgIdRange idRange in idRangesList) { for (int i = 0; i < idRange.idCount; i++) { binred.BaseStream.Position = startPos + stringOffsetsArray[idRange.offsetIndex + i]; FmgString line = new FmgString(); line.id = (uint)(idRange.firstId + i); line.str = Tools.ReadCharTillNull(binred); line.firstorLast = 0; if (i == 0) { line.firstorLast = 1; } else if (i == idRange.idCount - 1) { line.firstorLast = -1; } linesList.Add(line); } } }
public void Parse() { string[] allLines = File.ReadAllLines(filePath); TextBlock curBlock; int i = 0; while (i < allLines.Length) { if (allLines[i].Contains(@"N:\FDP\")) { curBlock = new TextBlock(); int idComaPos = allLines[i].IndexOf(","); curBlock.fileId = int.Parse(allLines[i].Substring(0, idComaPos)); curBlock.pathName = allLines[i].Substring(idComaPos + 1) + "\0"; i++; while (i < allLines.Length && allLines[i] != "") { string lin = allLines[i]; int idPos = lin.IndexOf(','); int foLPos = lin.IndexOf(',', idPos + 1); int id = int.Parse(lin.Substring(0, idPos)); int firstOrLast = int.Parse(lin.Substring(idPos + 1, foLPos - idPos - 1)); string str = lin.Substring(foLPos + 1); FmgString fmgstr = new FmgString(); fmgstr.id = (uint)id; fmgstr.str = str.Replace("\\n", "\n").Replace("\\r", "\r").Replace("\\t", "\t") + "\0"; fmgstr.firstorLast = firstOrLast; curBlock.lines.Add(fmgstr); i++; } blocks.Add(curBlock); FmgIdRange idrange = new FmgIdRange(); int k = 0; while (k < curBlock.lines.Count) { if (curBlock.lines[k].firstorLast == 1) { idrange = new FmgIdRange(); idrange.firstId = curBlock.lines[k].id; idrange.offsetIndex = (uint)k; while (k + 1 < curBlock.lines.Count && curBlock.lines[k + 1].firstorLast < 1) { k++; } idrange.lastId = curBlock.lines[k].id; curBlock.idRanges.Add(idrange); } k++; } } i++; } }
public void WriteByteData() { fileSize = 0; idRangeCount = (uint)idRangesList.Count; stringOffsetCount = (uint)linesList.Count; int headerSize = 40; int idRangeSize = (int)(idRangeCount * 16); stringOffsetsOffset = headerSize + idRangeSize; MemoryStream data = new MemoryStream(); using (BinaryWriter binwr = new BinaryWriter(data, Encoding.Unicode)) { for (int i = 0; i < 10; i++) { binwr.Write((uint)0); } for (int i = 0; i < idRangeCount; i++) { FmgIdRange fid = idRangesList[i]; binwr.Write(fid.offsetIndex); binwr.Write(fid.firstId); binwr.Write(fid.lastId); binwr.Write(fid.idk); } long strOffsets = (int)binwr.BaseStream.Position + linesList.Count * 8; List <long> offlist = new List <long>(); for (int i = 0; i < stringOffsetCount; i++) { binwr.Write(strOffsets); offlist.Add(strOffsets); strOffsets += Encoding.Unicode.GetByteCount(linesList[i].str); } foreach (FmgString line in linesList) { binwr.Write(Encoding.Unicode.GetBytes(line.str)); } fileSize = (uint)binwr.BaseStream.Length; binwr.BaseStream.Position = 0; binwr.Write(idk); binwr.Write(fileSize); binwr.Write(idk2); binwr.Write(idRangeCount); binwr.Write(stringOffsetCount); binwr.Write(idk3); binwr.Write(stringOffsetsOffset); binwr.Write(idk4); binwr.Write(idk5); fmgByteData = data.ToArray(); } Console.Write("."); //string fil = Path.GetFileName(fileName.Substring(0,fileName.Length-1)); //File.WriteAllBytes(@"C:\Users\Burk\Desktop\darksoulsShit\BinderTool v0.4.3\data1\msg\engUS\" + fil, fmgByteData); }
public void Read(string where) { excelPath = where; ExcelPackage pck = new ExcelPackage(File.Open(where, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); ExcelWorksheet ws = pck.Workbook.Worksheets["Satirlar"]; Dictionary <string, FmgFile> fmgDic = new Dictionary <string, FmgFile>(); for (int col = 2; col < ws.Dimension.Rows; col++) { string orgStr = Tools.HandleCellValue(ws.Cells["A" + col].Value); string trStr = Tools.HandleCellValue(ws.Cells["B" + col].Value); uint id = uint.Parse(ws.Cells["C" + col].Value.ToString()); int fol = int.Parse(ws.Cells["D" + col].Value.ToString()); string fileName = ws.Cells["E" + col].Value.ToString(); uint fileId = uint.Parse(ws.Cells["F" + col].Value.ToString()); if (!fmgDic.ContainsKey(fileName)) { FmgFile fmgFile = new FmgFile(); fmgFile.fileName = fileName + "\0"; fmgFile.fileId = fileId; fmgDic.Add(fileName, fmgFile); } FmgString fmgStr = new FmgString(); string selectedStr = trStr; if (trStr == null || trStr == "") { selectedStr = orgStr; } selectedStr = selectedStr.Replace("\\n", "\n").Replace("\\r", "\r").Replace("\\t", "\t") + "\0"; fmgStr.str = selectedStr; fmgStr.id = id; fmgStr.firstorLast = fol; fmgDic[fileName].linesList.Add(fmgStr); } fmgBlocks = fmgDic.Values.ToList(); foreach (var fmg in fmgBlocks) { FmgIdRange idrange; for (int i = 0; i < fmg.linesList.Count; i++) { FmgString fstr = fmg.linesList[i]; if (fstr.firstorLast == 1) { idrange = new FmgIdRange(); idrange.firstId = fstr.id; idrange.offsetIndex = (uint)i; idrange.lastId = fstr.id; fmg.idRangesList.Add(idrange); } else if (fstr.firstorLast == -1) { fmg.idRangesList.Last().lastId = fstr.id; } } } Console.Write("."); }