public d_msgFile() { _header = null; _entry_list = null; }
public d_msgEntryFormat(BinaryReader _bfile, d_msgHeaderFormat _header) { if (_bfile.BaseStream.Position == _bfile.BaseStream.Length) return; // Loader for the new way as of April 2007 long start_of_data_block = _bfile.BaseStream.Position; long saved_pos = _bfile.BaseStream.Position; UInt32 string_count; if (_header.ToCSize == 0) // no ToC, use EntrySize { #region if _header.ToCSize == 0 (Use EntrySize) start_of_data_block = _bfile.BaseStream.Position; if (_header.AreBitsFlipped) string_count = ~(_bfile.ReadUInt32()); else string_count = _bfile.ReadUInt32(); if ((string_count < 1) || (string_count > 100)) { _bfile.BaseStream.Position = start_of_data_block + _header.EntrySize; return; } data = new String[string_count]; byte[] b; UInt32 type = 0; for (int str_cnt = 0; str_cnt < string_count; str_cnt++) { data[str_cnt] = String.Empty; if (_header.AreBitsFlipped) { offset = ~(_bfile.ReadUInt32()); length = ~(_bfile.ReadUInt32()); // Use "length" for flags } else { offset = _bfile.ReadUInt32(); length = _bfile.ReadUInt32(); // Use "length" for flags } saved_pos = _bfile.BaseStream.Position; _bfile.BaseStream.Position = start_of_data_block + offset; type = _bfile.ReadUInt32(); if (_header.AreBitsFlipped) type = ~type; b = new byte[4]; if ((length == 1) && (str_cnt == 0) && (string_count > 3)) // It's not a String. { // Hack right now for Key Items. MessageID = (byte)(type & 0x00FF); // already converted. GroupID = (byte)((type & 0xFF00) >> 8); _bfile.BaseStream.Position = saved_pos; continue; } else if (length == 1) { _bfile.BaseStream.Position = saved_pos; continue; } _bfile.BaseStream.Position += 24; // add 24 bytes to get to actual text. byte[] b_xfer = null; do { b[0] = _bfile.ReadByte(); b[1] = _bfile.ReadByte(); b[2] = _bfile.ReadByte(); b[3] = _bfile.ReadByte(); if (_header.AreBitsFlipped) { b[0] = (byte)(~((uint)b[0])); b[1] = (byte)(~((uint)b[1])); b[2] = (byte)(~((uint)b[2])); b[3] = (byte)(~((uint)b[3])); } if (b_xfer == null) b_xfer = new byte[4]; else Array.Resize(ref b_xfer, b_xfer.Length + 4); b_xfer[b_xfer.Length - 4] = b[0]; b_xfer[b_xfer.Length - 3] = b[1]; b_xfer[b_xfer.Length - 2] = b[2]; b_xfer[b_xfer.Length - 1] = b[3]; if (b[3] == 0x00) break; } while (true); data[str_cnt] = System.Text.Encoding.GetEncoding(932).GetString(b_xfer).Trim('\0'); _bfile.BaseStream.Position = saved_pos; } _bfile.BaseStream.Position = start_of_data_block + _header.EntrySize; #endregion } else if (_header.EntrySize == 0) // use ToCSize { #region if _header.EntrySize == 0 (Use ToCSize) start_of_data_block = _header.HeaderSize + _header.ToCSize; offset = _bfile.ReadUInt32(); length = _bfile.ReadUInt32(); if (_header.AreBitsFlipped) { offset = ~offset; length = ~length; } saved_pos = _bfile.BaseStream.Position; _bfile.BaseStream.Position = start_of_data_block + offset + 40; data = new String[1]; if (_header.AreBitsFlipped) data[0] = System.Text.Encoding.GetEncoding(932).GetString(Fix(_bfile.ReadBytes((int)length - 40))).Trim('\0'); else data[0] = System.Text.Encoding.GetEncoding(932).GetString(_bfile.ReadBytes((int)length - 40)).Trim('\0'); _bfile.BaseStream.Position = saved_pos; #endregion } else return; }
public d_msgFile(BinaryReader _bfile) : this() { if (_bfile == null) return; _header = new d_msgHeaderFormat(_bfile); if (_bfile.BaseStream.Length != _header.FileSize || !_header.Marker.StartsWith("d_msg")) { _header = null; return; } _entry_list = new d_msgEntryFormat[_header.EntryCount]; for (int counter = 0; counter < _header.EntryCount; counter++) _entry_list[counter] = new d_msgEntryFormat(_bfile, _header); _bfile.Close(); _bfile = null; }
public d_msgFile(BinaryReader _bfile, FFXIEncoding FFXIConvert) : this() { if (_bfile == null) return; _header = new d_msgHeaderFormat(_bfile); if (_bfile.BaseStream.Length != _header.FileSize) { _header = null; return; } _entry_list = new d_msgEntryFormat[_header.EntryCount]; for (int counter = 0; counter < _header.EntryCount; counter++) _entry_list[counter] = new d_msgEntryFormat(_bfile, _header, FFXIConvert); _bfile.Close(); _bfile = null; }