/// <summary> /// The over write. /// </summary> /// <param name="map">The map.</param> /// <param name="tagIndex">Index of the tag.</param> /// <param name="newMeta">The new meta.</param> /// <remarks></remarks> public static void OverWrite(Map map, int tagIndex, ref Meta newMeta) { TagIndex = tagIndex; if (map.MetaInfo.TagType[tagIndex] == "sbsp") { MessageBox.Show("Can't OverWrite The Bsp"); return; } newMeta.RelinkReferences(); ArrayList metas = new ArrayList(0); map.OpenMap(MapTypes.Internal); for (int x = 0; x < map.IndexHeader.metaCount; x++) { if (tagIndex == x) { newMeta.type = map.MetaInfo.TagType[x]; newMeta.name = map.FileNames.Name[x]; SizeOfShift = newMeta.size - map.MetaInfo.Size[x]; metas.Add(newMeta); continue; } Meta m = new Meta(map); m.ReadMetaFromMap(x, true); try { IFPIO ifpx = IFPHashMap.GetIfp(m.type, map.HaloVersion); m.headersize = ifpx.headerSize; m.scanner.ScanWithIFP(ref ifpx); // metaScanner.ScanManually(ref m, ref map); metas.Add(m); } catch (System.Exception ex) { Globals.Global.ShowErrorMsg(string.Empty, ex); } } FixReflexives(metas, map); map.CloseMap(); }
/// <summary> /// The build meta. /// </summary> /// <param name="metasplit">The metasplit.</param> /// <param name="map">The map.</param> /// <returns></returns> /// <remarks></remarks> public static Meta BuildMeta(MetaSplitter metasplit, Map map) { metasize = 0; MetaStream = new MemoryStream(metasplit.Header.chunksize); BinaryWriter BW = new BinaryWriter(MetaStream); // BW.BaseStream.Position = 0; // BW.Write(metasplit.Header.MS.ToArray(), 0, metasplit.Header.chunksize); metasize += metasplit.Header.chunksize; TagIndex = metasplit.TagIndex; Meta m = new Meta(map); List<Meta.Item> NewItems = new List<Meta.Item>(); // Major error here! Size is not calculated right! RecursivelyAddPiecesToMeta(metasplit.Header, ref NewItems, ref BW); m.items = NewItems; if (MetaStream.Length % 4 != 0) { metasize += (int)MetaStream.Length % 4; MetaStream.SetLength(MetaStream.Length + MetaStream.Length % 4); } m.MS = MetaStream; m.size = metasize; m.type = metasplit.type; m.name = metasplit.name; m.rawType = metasplit.rawtype; m.raw = metasplit.raw; m.magic = metasplit.magic; m.offset = metasplit.offset; m.TagIndex = TagIndex; m.RelinkReferences(); m.WriteReferences(); // m.items.Clear(); // MetaScanner Ms = new MetaScanner(); if (m.rawType != RawDataContainerType.Empty) { map.OpenMap(MapTypes.Internal); m.raw = map.Functions.ForMeta.ReadRaw(m.TagIndex, false); map.CloseMap(); } // map.OpenMap(MapTypes.Internal); // IFPIO ifp=IFP.IFPHashMap.GetIfp(m.type); // m.parsed = true; // Ms.ScanWithIFP(ref ifp, ref m, map) ; // map.CloseMap(); return m; }