/// <summary> /// このレスが参照しているレス番号の配列を作成 /// </summary> /// <returns></returns> private int[] Createrefidx() { List <int> indices = new List <int>(); foreach (Match m in ResReference.RefAnchor.Matches(body)) { string text = m.Groups["num"].Value; int[] indexArray = ResReference.GetArray(text); indices.AddRange(indexArray); } return(indices.ToArray()); }
public MacMapSet(FileInfo macBin) { MacBin = macBin; using (var reader = new BinaryReader(MacBin.OpenRead())) { var resHeader = new ResHeader(); resHeader.ResourceOffset = reader.ReadUInt32BE(); resHeader.MapOffset = reader.ReadUInt32BE(); resHeader.ResourceLength = reader.ReadUInt32BE(); resHeader.MapLength = reader.ReadUInt32BE(); reader.BaseStream.Seek(resHeader.MapOffset, SeekOrigin.Current); var mapHeader = new MapHeader(); mapHeader.ReservedHandle = reader.ReadUInt32BE(); mapHeader.ReferenceNumber = reader.ReadUInt16BE(); mapHeader.ForkAttributes = reader.ReadUInt16BE(); mapHeader.TypeListOffset = reader.ReadUInt16BE(); mapHeader.NameListOffset = reader.ReadUInt16BE(); mapHeader.NumTypesMinusOne = reader.ReadUInt16BE(); reader.BaseStream.Seek(resHeader.MapOffset + mapHeader.TypeListOffset, SeekOrigin.Begin); var numTypes = reader.ReadUInt16BE() + 1; var resTypes = new ResType[numTypes]; var brgrIdx = -1; for (var i = 0; i < numTypes; i++) { var resType = new ResType(); resType.Type = Encoding.ASCII.GetString(reader.ReadBytes(4)); resType.NumResourcesMinusOne = reader.ReadUInt16BE(); resType.Offset = reader.ReadUInt16BE(); if (resType.Type == "BRGR") { brgrIdx = i; } resTypes[i] = resType; } if (brgrIdx < 0) { throw new Exception("No map resource found."); } reader.BaseStream.Seek(resHeader.MapOffset + mapHeader.TypeListOffset + resTypes[brgrIdx].Offset, SeekOrigin.Begin); var brgrRefs = new ResReference[resTypes[brgrIdx].NumResourcesMinusOne + 1]; for (var i = 0; i < resTypes[brgrIdx].NumResourcesMinusOne + 1; i++) { var resRef = new ResReference(); var refData = new ResReference.RefData(); refData.ResId = reader.ReadUInt16BE(); refData.NameOffset = reader.ReadUInt16BE(); refData.Attributes = reader.ReadByte(); refData.HiDataOffset = reader.ReadByte(); refData.LoDataOffset = reader.ReadUInt16BE(); refData.ReservedHandle = reader.ReadUInt32BE(); resRef.Ref = refData; resRef.DataOffset = (uint)((refData.HiDataOffset << 16) | (refData.LoDataOffset)); brgrRefs[i] = resRef; } // get names for (var i = 0; i < brgrRefs.Length; i++) { if (brgrRefs[i].Ref.NameOffset == 0xFFFF) { continue; } reader.BaseStream.Seek(resHeader.MapOffset + mapHeader.NameListOffset + brgrRefs[i].Ref.NameOffset, SeekOrigin.Begin); var nameLen = reader.ReadByte(); brgrRefs[i].Name = Encoding.ASCII.GetString(reader.ReadBytes(nameLen)); } // get data for (var i = 0; i < brgrRefs.Length; i++) { reader.BaseStream.Seek(brgrRefs[i].DataOffset + resHeader.ResourceOffset, SeekOrigin.Begin); var dataLen = reader.ReadUInt32BE(); var data = reader.ReadBytes((int)dataLen); } } }