/// <summary> /// The read meta from map. /// </summary> /// <param name="tagIndex">The tagIndex.</param> /// <param name="dontreadraw">The dontreadraw.</param> /// <remarks></remarks> public void ReadMetaFromMap(int tagIndex, bool dontReadRaw) { // set meta properties this.Map = Map; this.TagIndex = tagIndex; this.type = Map.MetaInfo.TagType[tagIndex]; this.name = Map.FileNames.Name[tagIndex]; this.offset = Map.MetaInfo.Offset[tagIndex]; this.size = Map.MetaInfo.Size[tagIndex]; this.ident = Map.MetaInfo.Ident[tagIndex]; string temps = this.offset.ToString("X"); char[] tempc = temps.ToCharArray(); int xxx = tempc.Length; this.padding = tempc[xxx - 1]; // THIS = Currently Selected Tag // Find current Tag Meta and read into memory stream (MS) this.MS = new MemoryStream(this.size); Map.BR.BaseStream.Position = this.offset; this.MS.Write(Map.BR.ReadBytes(this.size), 0, this.size); // Checks if type has raw data this.rawType = Map.Functions.ForMeta.CheckForRaw(this.type); if (dontReadRaw == false) { if (rawType != RawDataContainerType.Empty) { this.raw = Map.Functions.ForMeta.ReadRaw(this.TagIndex, dontReadRaw); } } if (this.type == "sbsp") { int h = Map.BSP.FindBSPNumberByBSPIdent(this.ident); this.magic = Map.BSP.sbsp[h].magic; } else if (this.type == "ltmp") { int h = Map.BSP.FindBSPNumberByLightMapIdent(this.ident); this.magic = Map.BSP.sbsp[h].magic; } else { // Not "sbsp" or "ltmp" // For Halo 1 or Halo CE if (Map.HaloVersion == HaloVersionEnum.HaloCE || Map.HaloVersion == HaloVersionEnum.Halo1) { this.magic = Map.PrimaryMagic; } else { // For Halo 2 this.magic = Map.SecondaryMagic; } } }
/// <summary> /// The find by type. /// </summary> /// <param name="type">The type.</param> /// <returns>The find by type.</returns> /// <remarks></remarks> public int FindByType(RawDataContainerType type) { for (int x = 0; x < chunks.Count; x++) { LayOutChunk c = (LayOutChunk)chunks[x]; if (c.rawType == type) { return(x); } } return(-1); }
public int FindLastByType(RawDataContainerType type) { int index = -1; for (int x = 0; x < chunks.Count; x++) { LayOutChunk c = (LayOutChunk)chunks[x]; if (c.rawType == type) { index = x; } } return(index); }
/// <summary> /// The split with ifp. /// </summary> /// <param name="ifp">The ifp.</param> /// <param name="meta">The meta.</param> /// <param name="map">The map.</param> /// <remarks></remarks> public void SplitWithIFP(ref IFPIO ifp, ref Meta meta, Map map) { this.type = meta.type; this.TagIndex = meta.TagIndex; this.name = meta.name; this.offset = meta.offset; this.magic = meta.magic; this.raw = meta.raw; this.rawtype = meta.rawType; map.OpenMap(MapTypes.Internal); if (ifp.items != null) { map.BR.BaseStream.Position = meta.offset; Header = new SplitReflexive(); Header.offset = 0; Header.Chunks = new List <SplitReflexive>(); Header.translation = 0; // Header.MS = new MemoryStream(ifp.headerSize); // Header.MS.Write(map.BR.ReadBytes(ifp.headerSize), 0, ifp.headerSize); Header.chunksize = ifp.headerSize; Header.chunkcount = 1; Header.splitReflexiveType = SplitReflexive.SplitReflexiveType.Container; Header.realtranslation = meta.offset; if (meta.type == "sbsp") { int p = map.BSP.FindBSPNumberByBSPIdent(meta.ident); CycleElements( ref Header, ifp.items, ref meta, meta.offset, map, meta.TagIndex, map.BSP.sbsp[p].magic); } else if (meta.type == "ltmp") { int p = map.BSP.FindBSPNumberByLightMapIdent(meta.ident); CycleElements( ref Header, ifp.items, ref meta, meta.offset, map, meta.TagIndex, map.BSP.sbsp[p].magic); } else { // not "sbsp" or "ltmp" CycleElements(ref Header, ifp.items, ref meta, meta.offset, map, meta.TagIndex, map.SecondaryMagic); } } map.CloseMap(); }
/// <summary> /// The find by type. /// </summary> /// <param name="type">The type.</param> /// <param name="index">The index.</param> /// <returns>The find by type.</returns> /// <remarks></remarks> public int FindByType(RawDataContainerType type, int index) { int tempc = 0; for (int x = 0; x < chunks.Count; x++) { LayOutChunk c = (LayOutChunk)chunks[x]; if (c.rawType == type) { tempc += 1; if (tempc == index) { return(x); } } } return(-1); }
/// <summary> /// The find by type. /// </summary> /// <param name="type">The type.</param> /// <param name="index">The index.</param> /// <returns>The find by type.</returns> /// <remarks></remarks> public int FindByType(RawDataContainerType type, int index) { int tempc = 0; for (int x = 0; x < chunks.Count; x++) { LayOutChunk c = (LayOutChunk)chunks[x]; if (c.rawType == type) { tempc += 1; if (tempc == index) { return x; } } } return -1; }
/// <summary> /// The find by type. /// </summary> /// <param name="type">The type.</param> /// <returns>The find by type.</returns> /// <remarks></remarks> public int FindByType(RawDataContainerType type) { for (int x = 0; x < chunks.Count; x++) { LayOutChunk c = (LayOutChunk)chunks[x]; if (c.rawType == type) { return x; } } return -1; }
/// <summary> /// Load meta from an XML file. /// </summary> /// <param name="inputFileName">The XML file name.</param> /// <remarks></remarks> public void LoadMetaFromFile(string inputFileName) { // write memorysteam of meta to file FileStream FS = new FileStream(inputFileName, FileMode.Open); BinaryReader BR = new BinaryReader(FS); this.size = (int)FS.Length; this.MS = new MemoryStream(this.size); BR.BaseStream.Position = 0; this.MS.Write(BR.ReadBytes(this.size), 0, this.size); BR.Close(); FS.Close(); // write idents,strings,reflexives XmlTextReader xtr = new XmlTextReader(inputFileName + ".xml"); xtr.WhitespaceHandling = WhitespaceHandling.None; while (xtr.Read()) { // MessageBox.Show(xtr.Name); switch (xtr.NodeType) { case XmlNodeType.Element: if (xtr.Name == "Meta") { this.type = xtr.GetAttribute("TagType"); this.name = xtr.GetAttribute("TagName"); this.parsed = xtr.GetAttribute("Parsed") == "True" ? true : false; this.size = Convert.ToInt32(xtr.GetAttribute("Size")); this.magic = Convert.ToInt32(xtr.GetAttribute("Magic")); this.padding = Convert.ToChar(xtr.GetAttribute("Padding")); this.offset = Convert.ToInt32(xtr.GetAttribute("Offset")); } else if (xtr.Name == "Reflexive") { Reflexive r = new Reflexive(); r.description = xtr.GetAttribute("Description"); r.offset = Convert.ToInt32(xtr.GetAttribute("Offset")); r.chunkcount = Convert.ToInt32(xtr.GetAttribute("ChunkCount")); r.chunksize = Convert.ToInt32(xtr.GetAttribute("ChunkSize")); r.translation = Convert.ToInt32(xtr.GetAttribute("Translation")); r.pointstotagtype = xtr.GetAttribute("PointsToTagType"); r.pointstotagname = xtr.GetAttribute("PointsToTagName"); r.pointstoTagIndex = Map.Functions.ForMeta.FindByNameAndTagType( r.pointstotagtype, r.pointstotagname); r.intagtype = xtr.GetAttribute("TagType"); r.intagname = xtr.GetAttribute("TagName"); r.intag = Map.Functions.ForMeta.FindByNameAndTagType(r.intagtype, r.intagname); this.items.Add(r); } else if (xtr.Name == "Ident") { Ident id = new Ident(); id.description = xtr.GetAttribute("Description"); id.offset = Convert.ToInt32(xtr.GetAttribute("Offset")); id.pointstotagtype = xtr.GetAttribute("PointsToTagType"); id.pointstotagname = xtr.GetAttribute("PointsToTagName"); id.pointstoTagIndex = Map.Functions.ForMeta.FindByNameAndTagType( id.pointstotagtype, id.pointstotagname); id.intagtype = xtr.GetAttribute("TagType"); id.intagname = xtr.GetAttribute("TagName"); id.intag = Map.Functions.ForMeta.FindByNameAndTagType(id.intagtype, id.intagname); this.items.Add(id); } else if (xtr.Name == "String") { String s = new String(); s.description = xtr.GetAttribute("Description"); s.offset = Convert.ToInt32(xtr.GetAttribute("Offset")); s.name = xtr.GetAttribute("StringName"); s.intagtype = xtr.GetAttribute("TagType"); s.intagname = xtr.GetAttribute("TagName"); s.intag = Map.Functions.ForMeta.FindByNameAndTagType(s.intagtype, s.intagname); this.items.Add(s); } break; default: break; } } xtr.Close(); // ///check for raw this.rawType = Map.Functions.ForMeta.CheckForRaw(this.type); if (this.rawType != RawDataContainerType.Empty) { this.raw = new RawDataContainer(); this.raw = this.raw.LoadRawFromFile(inputFileName, this); } }
/// <summary> /// The split with ifp. /// </summary> /// <param name="ifp">The ifp.</param> /// <param name="meta">The meta.</param> /// <param name="map">The map.</param> /// <remarks></remarks> public void SplitWithIFP(ref IFPIO ifp, ref Meta meta, Map map) { this.type = meta.type; this.TagIndex = meta.TagIndex; this.name = meta.name; this.offset = meta.offset; this.magic = meta.magic; this.raw = meta.raw; this.rawtype = meta.rawType; map.OpenMap(MapTypes.Internal); if (ifp.items != null) { map.BR.BaseStream.Position = meta.offset; Header = new SplitReflexive(); Header.offset = 0; Header.Chunks = new List<SplitReflexive>(); Header.translation = 0; // Header.MS = new MemoryStream(ifp.headerSize); // Header.MS.Write(map.BR.ReadBytes(ifp.headerSize), 0, ifp.headerSize); Header.chunksize = ifp.headerSize; Header.chunkcount = 1; Header.splitReflexiveType = SplitReflexive.SplitReflexiveType.Container; Header.realtranslation = meta.offset; if (meta.type == "sbsp") { int p = map.BSP.FindBSPNumberByBSPIdent(meta.ident); CycleElements( ref Header, ifp.items, ref meta, meta.offset, map, meta.TagIndex, map.BSP.sbsp[p].magic); } else if (meta.type == "ltmp") { int p = map.BSP.FindBSPNumberByLightMapIdent(meta.ident); CycleElements( ref Header, ifp.items, ref meta, meta.offset, map, meta.TagIndex, map.BSP.sbsp[p].magic); } else { // not "sbsp" or "ltmp" CycleElements(ref Header, ifp.items, ref meta, meta.offset, map, meta.TagIndex, map.SecondaryMagic); } } map.CloseMap(); }
public int FindLastByType(RawDataContainerType type) { int index = -1; for (int x = 0; x < chunks.Count; x++) { LayOutChunk c = (LayOutChunk)chunks[x]; if (c.rawType == type) index = x; } return index; }