public reflexiveData() { node = null; reflexive = null; baseOffset = -1; chunkCount = 0; chunkSelected = -1; inTagNumber = -1; }
public reflexiveData(reflexiveData parentReflexive) { this.node = null; this.reflexive = null; this.baseOffset = -1; this.chunkCount = 0; this.chunkSelected = -1; this.inTagNumber = -1; this.parent = parentReflexive; this.children = null; }
/// <summary> /// Initializes a new instance of the <see cref="ReflexiveContainer"/> class. /// </summary> /// <param name="reflexive">The reflexive.</param> /// <remarks></remarks> public ReflexiveContainer(IFPIO.Reflexive reflexive) { type = ContainerType.Reflexive; // Controls. Label templabel = new Label(); templabel.BorderStyle = BorderStyle.FixedSingle; templabel.BackColor = Color.Silver; templabel.Text = "Reflexive (" + reflexive.name + ") • Offset: " + reflexive.offset.ToString("X"); templabel.TextAlign = ContentAlignment.MiddleCenter; templabel.Dock = DockStyle.Fill; templabel.MouseDown += ReflexiveHeader_MouseDown; SelectedChunkComboBox = new ComboBox(); SelectedChunkComboBox.Dock = DockStyle.Right; SelectedChunkComboBox.Width = 50; SelectedChunkComboBox.Height = 25; SelectedChunkComboBox.FlatStyle = FlatStyle.Popup; // container SplitContainer tempsplit = new SplitContainer(); tempsplit.Orientation = Orientation.Horizontal; tempsplit.Panel1MinSize = 0; tempsplit.SplitterDistance = 25; tempsplit.IsSplitterFixed = true; tempsplit.SplitterWidth = 1; tempsplit.Dock = DockStyle.Top; SetMaxSize(0, 25); tempsplit.MaximumSize = this.MaxSize; // panel 1 tempsplit.Panel1.Controls.Add(templabel); tempsplit.Panel1.Controls.Add(SelectedChunkComboBox); // panel 2 tempsplit.Panel2.AutoScroll = true; tempsplit.Panel2.BackColor = Color.Honeydew; Padding prop = new Padding(); prop.All = 10; // prop.Right = 0; tempsplit.Panel2.Padding = prop; tempsplit.Panel2Collapsed = true; tempsplit.BorderStyle = BorderStyle.None; // tempsplit.Visible = true; this.Container = tempsplit; }
/// <summary> /// The make controls. /// </summary> /// <param name="y">The y.</param> /// <param name="ifpobjects">The ifpobjects.</param> /// <param name="reflex">The reflex.</param> /// <remarks></remarks> public void MakeControls(int y, object[] ifpobjects, ref ReflexiveContainer reflex) { foreach (object o in ifpobjects) { IFPIO.BaseObject tempbase = (IFPIO.BaseObject)o; switch (tempbase.ObjectType) { case IFPIO.ObjectEnum.Struct: IFPIO.Reflexive r = (IFPIO.Reflexive)tempbase; // if (r.visible == false) { break; } ReflexiveContainer tempr = new ReflexiveContainer(r); MakeControls(0, r.items, ref tempr); reflex.Controls.Add(tempr); break; case IFPIO.ObjectEnum.Ident: IFPIO.Ident id = (IFPIO.Ident)tempbase; // if (id.visible == false) { break; } IdentContainer tempid = new IdentContainer(id); reflex.Controls.Add(tempid); break; case IFPIO.ObjectEnum.Int: IFPIO.IFPInt int32 = (IFPIO.IFPInt)tempbase; // if (int32.visible == false) { break; } Int32Container tempint = new Int32Container(int32); reflex.Controls.Add(tempint); break; } } }
/// <summary> /// The cycle elements. /// </summary> /// <param name="elements">The elements.</param> /// <param name="offset">The offset.</param> /// <param name="count">The count.</param> /// <param name="TagIndex">The TagIndex.</param> /// <param name="chunksize">The chunksize.</param> /// <param name="magic">The magic.</param> /// <param name="previousparsedtranslation">The previousparsedtranslation.</param> /// <returns></returns> /// <remarks></remarks> private string[] CycleElements( object[] elements, int offset, int count, int TagIndex, int chunksize, int magic, int previousparsedtranslation) { List <string> tempS = new List <string>(); // elements = all the listings in the .ENT file foreach (IFPIO.BaseObject tempbase in elements.Cast <IFPIO.BaseObject>()) { for (int x = 0; x < count; x++) { switch (tempbase.ObjectType) { // AKA Structs case IFPIO.ObjectEnum.Struct: IFPIO.Reflexive tempreflex = (IFPIO.Reflexive)tempbase; XReflex r = new XReflex(); meta.Map.BR.BaseStream.Position = offset + tempreflex.offset + (x * chunksize); r.mapOffset = (int)meta.Map.BR.BaseStream.Position; // Contains how many Reflexives are listed r.chunkcount = meta.Map.BR.ReadInt32(); if (r.chunkcount == 0) { continue; } r.chunksize = tempreflex.chunkSize; int tempshit = meta.Map.BR.ReadInt32(); r.translation = tempshit - meta.magic; r.pointstoTagIndex = meta.Map.Functions.ForMeta.FindMetaByOffset(r.translation); if (meta.type == "sbsp" && r.pointstoTagIndex != -1) { // r.translation = tempshit - magic; r.pointstoTagIndex = meta.TagIndex; } if (tempreflex.HasCount == false) { r.translation = r.chunkcount - magic; r.chunkcount = 1; r.pointstoTagIndex = meta.TagIndex; } r.description = tempreflex.name + " [" + x + "]"; if (r.pointstoTagIndex == -1) { continue; } if (meta.parsed) { meta.Map.BR.BaseStream.Position = r.translation; r.RealTranslation = r.translation - meta.Map.MetaInfo.Offset[r.pointstoTagIndex]; r.RealTagNumber = r.pointstoTagIndex; int messed = 0; // NEVER USED, ONLY INCREMENTED?? bool found = false; for (int h = 0; h < meta.items.Count; h++) { Meta.Item item = meta.items[h]; if (item.type != Meta.ItemType.Reflexive) { continue; } XReflex rr = (XReflex)meta.items[h]; if (r.RealTranslation == rr.RealTranslation && r.RealTagNumber == rr.RealTagNumber) { r.translation = rr.translation; r.pointstoTagIndex = meta.TagIndex; r.pointstotagtype = meta.type; r.pointstotagname = meta.name; r.offset = previousparsedtranslation + tempreflex.offset + (x * chunksize); r.intag = meta.TagIndex; r.intagtype = meta.type; r.intagname = meta.name; meta.items.Add(r); meta.reflexivecount++; found = true; break; } messed++; } if (found == false) { r.translation = meta.size; meta.MS.SetLength(meta.size + (r.chunksize * r.chunkcount)); meta.MS.Write( meta.Map.BR.ReadBytes(r.chunksize * r.chunkcount), 0, r.chunksize * r.chunkcount); /************************************************************/ // Shouldn't this just add the number of added chunks?? meta.size += r.chunksize * r.chunkcount; // if (tempreflex.adding != 0) // { // int temppadsize = meta.Map.Functions.Padding(r.chunksize * r.chunkcount, (int)s.Padding); // meta.MS.SetLength((long)(meta.size + (temppadsize))); // byte[] tempbytes = new byte[temppadsize]; // meta.MS.Write(tempbytes, 0, temppadsize); // meta.size += temppadsize; // } if (tempreflex.paddingAlign != 0) { int temppadsize = meta.size % tempreflex.paddingAlign == 0 ? 0 : tempreflex.paddingAlign - (meta.size % tempreflex.paddingAlign); meta.MS.SetLength((long)(meta.size + temppadsize)); byte[] tempbytes = new byte[temppadsize]; meta.MS.Write(tempbytes, 0, temppadsize); meta.size += temppadsize; } r.pointstoTagIndex = meta.TagIndex; r.pointstotagtype = meta.type; r.pointstotagname = meta.name; r.offset = previousparsedtranslation + tempreflex.offset + (x * chunksize); r.intag = meta.TagIndex; r.intagtype = meta.type; r.intagname = meta.name; meta.items.Add(r); meta.reflexivecount++; this.CycleElements( tempreflex.items, r.RealTranslation + meta.Map.MetaInfo.Offset[r.RealTagNumber], r.chunkcount, r.pointstoTagIndex, tempreflex.chunkSize, magic, r.translation); } else { found = false; } } #region unparsedReflexive else { r.pointstotagtype = meta.Map.MetaInfo.TagType[r.pointstoTagIndex]; r.pointstotagname = meta.Map.FileNames.Name[r.pointstoTagIndex]; r.translation = r.translation - meta.Map.MetaInfo.Offset[r.pointstoTagIndex]; r.offset = offset + tempreflex.offset + (x * chunksize); r.mapOffset = r.offset; r.offset -= meta.Map.MetaInfo.Offset[TagIndex]; r.intag = TagIndex; r.intagtype = meta.Map.MetaInfo.TagType[r.intag]; r.intagname = meta.Map.FileNames.Name[r.intag]; meta.items.Add(r); meta.reflexivecount++; this.CycleElements( tempreflex.items, meta.Map.MetaInfo.Offset[r.pointstoTagIndex] + r.translation, r.chunkcount, r.pointstoTagIndex, tempreflex.chunkSize, magic, 0); } #endregion break; case IFPIO.ObjectEnum.Ident: IFPIO.Ident tempident = (IFPIO.Ident)tempbase; Meta.Ident i = new Meta.Ident(); meta.Map.BR.BaseStream.Position = offset + tempident.offset + (x * chunksize); i.mapOffset = (int)meta.Map.BR.BaseStream.Position; i.ident = meta.Map.BR.ReadInt32(); i.intag = TagIndex; i.intagtype = meta.Map.MetaInfo.TagType[i.intag]; i.intagname = meta.Map.FileNames.Name[i.intag]; i.pointstoTagIndex = meta.Map.Functions.ForMeta.FindMetaByID(i.ident); if (i.pointstoTagIndex != -1) { // i.pointstoTagIndex = meta.Map.Functions.Meta.FindMetaByID(i.ident, meta.Map); i.pointstotagtype = meta.Map.MetaInfo.TagType[i.pointstoTagIndex]; i.pointstotagname = meta.Map.FileNames.Name[i.pointstoTagIndex]; } else { if (i.ident > 0) { int off = i.mapOffset - meta.Map.MetaInfo.Offset[TagIndex]; /********************************************************************* * Save errors to be displayed all at once. *********************************************************************/ tempS.Add( "Tag: [" + meta.Map.MetaInfo.TagType[TagIndex] + "] " + meta.Map.FileNames.Name[TagIndex] + " @ Offset: " + off.ToString().PadLeft(10) + " , Name: \"" + tempident.name + "\""); i.ident = -1; } i.pointstoTagIndex = -1; i.pointstotagname = "Null"; } //i.mapOffset = offset + tempident.offset + (x * chunksize); i.offset = i.mapOffset - meta.Map.MetaInfo.Offset[TagIndex]; if (meta.parsed) { i.offset = previousparsedtranslation + tempident.offset + (x * chunksize); } i.description = tempident.name + " [" + x + "]"; meta.items.Add(i); break; // If our object is a STRING, read the string info from the file, not just offset values case IFPIO.ObjectEnum.StringID: IFPIO.SID tempstringid = (IFPIO.SID)tempbase; Meta.String si = new Meta.String(); meta.Map.BR.BaseStream.Position = offset + tempstringid.offset + (x * chunksize); si.mapOffset = (int)meta.Map.BR.BaseStream.Position; si.id = meta.Map.BR.ReadUInt16(); if (si.id == 0 | si.id >= meta.Map.MapHeader.scriptReferenceCount) { continue; } meta.Map.BR.ReadByte(); int temp = meta.Map.BR.ReadByte(); if (temp != meta.Map.Strings.Length[si.id]) { continue; } // Finds offset for each subsection -> Chunksize = Size of whole Subsection si.mapOffset = offset + tempstringid.offset + (x * chunksize); si.offset = si.mapOffset - meta.Map.MetaInfo.Offset[TagIndex]; if (meta.parsed) { si.offset = previousparsedtranslation + tempstringid.offset + (x * chunksize); } si.name = meta.Map.Strings.Name[si.id]; si.intag = TagIndex; si.intagtype = meta.Map.MetaInfo.TagType[si.intag]; si.intagname = meta.Map.FileNames.Name[si.intag]; si.description = tempstringid.name + " [" + x + "]"; meta.items.Add(si); break; } } } return(tempS.ToArray()); }
public TreeNode[] loadTreeReflexives(BinaryReader BR, int metaOffset, object[] items, bool enabled) { List <TreeNode> tns = new List <TreeNode>(); foreach (object o in items) { TreeNode tn = new TreeNode(((IFPIO.BaseObject)o).name); if (o is IFPIO.Reflexive) { IFPIO.Reflexive IFPR = (IFPIO.Reflexive)o; reflexiveData rd = new reflexiveData(); tn.Tag = rd; rd.node = tn; rd.reflexive = IFPR; tn.ForeColor = Color.LightGray; tn.Name = IFPR.name; tn.ToolTipText = "Offset: " + rd.reflexive.offset.ToString(); if (enabled) { BR.BaseStream.Position = IFPR.offset + metaOffset; rd.chunkCount = BR.ReadInt32(); if (rd.chunkCount > 0) { rd.chunkSelected = 0; tn.ForeColor = Color.Black; rd.baseOffset = BR.ReadInt32() - meta.magic - meta.offset; // Some listings are actually in other tags! // Check [BLOC] "objects\\vehicles\\wraith\\garbage\\wing_boost\\wing_boost" // > attachments[0] = [BLOC] "objects\\vehicles\\ghost\\garbage\\seat\\seat" if (rd.baseOffset < 0 || rd.baseOffset >= memStream.Length) { rd.chunkCount = 0; } else { rd.inTagNumber = meta.TagIndex; } /* * rd.inTagNumber = map.Functions.ForMeta.FindMetaByOffset(rd.baseOffset); * if (rd.inTagNumber == -1) * { * tn.ToolTipText = "DATA ERROR! Possibly corrupt data or incorrect plugin."; * rd.chunkCount = 0; * rd.chunkSelected = -1; * continue; * } * if (rd.inTagNumber == meta.TagIndex) * rd.baseOffset -= meta.offset; * else * { * tn.ForeColor = Color.Red; * tn.ToolTipText = "Data Source Located in:\n[" + map.MetaInfo.TagType[rd.inTagNumber].ToLower() + * "] " + map.FileNames.Name[rd.inTagNumber].ToLower(); * } */ } } tn.Text += " [" + rd.chunkCount.ToString() + "]"; refData.Add(rd); // Add if non-existant, otherwise update Text /* * if (rd.inTagNumber == meta.TagIndex) * tn.Nodes.AddRange(loadTreeReflexives(BR, meta.offset + rd.baseOffset + rd.chunkSelected * rd.reflexive.chunkSize, IFPR.items, rd.chunkCount != 0)); * else */ tn.Nodes.AddRange(loadTreeReflexives(BR, rd.baseOffset + rd.chunkSelected * rd.reflexive.chunkSize, IFPR.items, rd.chunkCount != 0)); if (rd.chunkCount != 0 | !hideUnusedReflexives) { tns.Add(tn); } } else { //tns.Add(tn); } } return(tns.ToArray()); }
/// <summary> /// The cycle elements. /// </summary> /// <param name="reflex">The reflex.</param> /// <param name="elements">The elements.</param> /// <param name="meta">The meta.</param> /// <param name="offset">The offset.</param> /// <param name="map">The map.</param> /// <param name="TagIndex">The TagIndex.</param> /// <param name="magic">The magic.</param> /// <remarks></remarks> private void CycleElements( ref SplitReflexive reflex, object[] elements, ref Meta meta, int offset, Map map, int TagIndex, int magic) { for (int x = 0; x < reflex.chunkcount; x++) { SplitReflexive chunkreflexive = new SplitReflexive(); map.BR.BaseStream.Position = reflex.realtranslation + (x * reflex.chunksize); chunkreflexive.MS = new MemoryStream(reflex.chunksize); chunkreflexive.MS.Write(map.BR.ReadBytes(reflex.chunksize), 0, reflex.chunksize); chunkreflexive.chunksize = reflex.chunksize; chunkreflexive.splitReflexiveType = SplitReflexive.SplitReflexiveType.Chunk; reflex.Chunks.Add(chunkreflexive); for (int xx = 0; xx < elements.Length; xx++) { IFPIO.BaseObject tempbase = (IFPIO.BaseObject)elements[xx]; switch (tempbase.ObjectType) { case IFPIO.ObjectEnum.Struct: IFPIO.Reflexive tempreflex = (IFPIO.Reflexive)tempbase; SplitReflexive r = new SplitReflexive(); map.BR.BaseStream.Position = offset + tempreflex.offset + (x * reflex.chunksize); r.mapOffset = (int)map.BR.BaseStream.Position; r.chunkcount = map.BR.ReadInt32(); if (r.chunkcount == 0) { continue; } r.chunksize = tempreflex.chunkSize; r.translation = map.BR.ReadInt32() - magic; r.pointstoTagIndex = map.Functions.ForMeta.FindMetaByOffset(r.translation); r.description = tempreflex.name; if (r.pointstoTagIndex == -1) { continue; } // r.parent = reflex.description;// parentname; r.realtranslation = r.translation; r.realTagIndex = r.pointstoTagIndex; r.label = tempreflex.label; r.pointstoTagIndex = meta.TagIndex; r.pointstotagtype = meta.type; r.pointstotagname = meta.name; r.offset = tempreflex.offset; r.intag = meta.TagIndex; r.intagtype = meta.type; r.intagname = meta.name; r.translation -= map.MetaInfo.Offset[r.realTagIndex]; r.inchunknumber = x; r.splitReflexiveType = SplitReflexive.SplitReflexiveType.Container; r.Chunks = new List <SplitReflexive>(); CycleElements( ref r, tempreflex.items, ref meta, r.realtranslation, map, r.pointstoTagIndex, magic); reflex.Chunks[x].ChunkResources.Add(r); meta.reflexivecount++; break; case IFPIO.ObjectEnum.Ident: IFPIO.Ident tempident = (IFPIO.Ident)tempbase; SplitIdent i = new SplitIdent(); map.BR.BaseStream.Position = offset + tempident.offset + (x * reflex.chunksize); i.mapOffset = (int)map.BR.BaseStream.Position; i.ident = map.BR.ReadInt32(); if (i.ident != -1) { try { i.pointstoTagIndex = map.Functions.ForMeta.FindMetaByID(i.ident); i.pointstotagtype = map.MetaInfo.TagType[i.pointstoTagIndex]; i.pointstotagname = map.FileNames.Name[i.pointstoTagIndex]; } catch { continue; } } else { continue; } i.mapOffset = offset + tempident.offset + (x * reflex.chunksize); i.offset = tempident.offset; i.inchunknumber = x; i.intag = TagIndex; i.intagtype = map.MetaInfo.TagType[i.intag]; i.intagname = map.FileNames.Name[i.intag]; i.description = tempident.name; reflex.Chunks[x].ChunkResources.Add(i); break; case IFPIO.ObjectEnum.StringID: IFPIO.SID tempstringid = (IFPIO.SID)tempbase; SplitString si = new SplitString(); map.BR.BaseStream.Position = offset + tempstringid.offset + (x * reflex.chunksize); si.mapOffset = (int)map.BR.BaseStream.Position; si.id = map.BR.ReadUInt16(); if (si.id == 0 | si.id >= map.MapHeader.scriptReferenceCount) { continue; } map.BR.ReadByte(); int temp = map.BR.ReadByte(); if (temp != map.Strings.Length[si.id]) { continue; } si.mapOffset = offset + tempstringid.offset + (x * reflex.chunksize); si.offset = si.mapOffset - map.MetaInfo.Offset[TagIndex]; si.offset = tempstringid.offset; si.inchunknumber = x; si.name = map.Strings.Name[si.id]; si.intag = TagIndex; si.intagtype = map.MetaInfo.TagType[si.intag]; si.intagname = map.FileNames.Name[si.intag]; si.description = tempstringid.name; reflex.Chunks[x].ChunkResources.Add(si); break; } } } return; }