public void Remove(TagObject Tag) { if (List.Contains(Tag)) { List.Remove(Tag); } else { throw new Exception("The given tag was not found inside of the array \r\n Error No. 146"); } }
public TagTable(Map Map) { this.Map = Map; bool Go = true; int tmp = 1; Map.Reader.BaseStream.Position = Map.Index.TagStart; while (Go) { if (this.Count == 0) { byte[] Buffer = new byte[] { 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] Buffer1 = Map.Reader.ReadBytes(16); while (Buffer1[0] == Buffer[0] & Buffer1[1] == Buffer[1] & Buffer[2] == Buffer1[2]) { Buffer1 = Map.Reader.ReadBytes(16); tmp += 1; } Map.Reader.BaseStream.Position -= 16; tmp -= 1; } else { byte[] Buffer = new byte[] { 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] Buffer1 = Map.Reader.ReadBytes(16); if (Buffer1[0] == Buffer[0] && Buffer1[1] == Buffer[1] && Buffer1[2] == Buffer[2]) break; else Map.Reader.BaseStream.Position -= 16; } TagObject t = new TagObject(); t.Class = Globals.ReverseStr(new string(Map.Reader.ReadChars(4))); t.Identifier = Map.Reader.ReadInt32(); t.RawMetaOffset = Map.Reader.ReadInt32(); t.MetaSize = Map.Reader.ReadInt32(); t.MetaOffset = t.RawMetaOffset - Map.Index.SecondaryMagic; t.Index = tmp; tmp += 1; if (this.Count < 15065 && (uint)t.Identifier != 0xFFFFFFFF && tmp < 15065) { List.Add(t); if (!this.TagTypes.Contains(t.Class)) this.TagTypes.Add(t.Class); } if (tmp == 15064 || t.Class == "ugh!") Go = false; } Map.Header.TagCount = this.Count; Map.Reader.BaseStream.Position = Map.Header.FileTableOffset; for (int i = 0; i < this.Count; i++) { char c; while ((c = Map.Reader.ReadChar()) != '\0') this[i].Path += c; } }
public void Read(int tagoff, string st, ref Panel Meta, TagObject ST, Map map) { #region Reading string C = st.Replace('*', '!'); C = C.Replace('/', '_'); C = C.Replace('\\', '_'); C = C.Replace('<', '_'); C = C.Replace('>', '_'); string Location = Application.StartupPath + "\\Plugins\\" + C + ".Xml"; if (!File.Exists(Location)) { MessageBox.Show("Can not find plugin!"); } else { xr = new XmlTextReader(new FileStream(Location, FileMode.Open, FileAccess.Read, FileShare.Read)); Controls.Clear(); Meta.Hide(); Meta.Refresh(); Meta.SuspendLayout(); Class = ""; Author = ""; Version = ""; while (xr.Read()) { switch (xr.NodeType) { case XmlNodeType.Element: { switch (xr.Name.ToLower()) { case "plugin": { Class = xr.GetAttribute("class"); Author = xr.GetAttribute("author"); Version = xr.GetAttribute("version"); break; } case "revision": { Revisions.Add(xr.ReadElementString()); break; } case "byte": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Value b = new Value(Description, typeof(byte), 0, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "short": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Value b = new Value(Description, typeof(short), 0, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "ushort": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Value b = new Value(Description, typeof(ushort), 0, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "int": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Value b = new Value(Description, typeof(int), 0, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "uint": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Value b = new Value(Description, typeof(uint), 0, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "float": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Value b = new Value(Description, typeof(float), 0, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "string": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); int Length = Convert.ToInt32(xr.GetAttribute("length")); Value b = new Value(Description, typeof(string), "", Length, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "unknown": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Value b = new Value(Description, typeof(int), 0, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "long": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Value b = new Value(Description, typeof(long), 0, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "ident": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); Ident i = new Ident("Null", 0, tagoff, Offset, Description, map); Controls.Add(i); i.Dock = DockStyle.Top; i.BringToFront(); break; } case "reflexive": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); int Size = Convert.ToInt32(xr.GetAttribute("size")); map.Reader.BaseStream.Position = ((Offset + tagoff) - map.Index.SecondaryMagic); Reflexive b = new Reflexive(map, Description, map.Reader.ReadInt32(), tagoff, Offset, Size, xr.ReadSubtree()); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "stringid": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); StringID b = new StringID(Description, tagoff, Offset, 0, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "enum8": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); //map.Reader.BaseStream.Position = ((Offset+tagoff) - map.Index.SecondaryMagic); //int Index = map.Reader.ReadByte(); List <string> Items = new List <string>(); List <int> Values = new List <int>(); XmlReader x = xr.ReadSubtree(); while (x.Read()) { switch (x.Name.ToLower()) { case "option": { Items.Add(xr.GetAttribute("name")); Values.Add(Convert.ToInt32(xr.GetAttribute("value"))); break; } } } Enum e = new Enum(Description, tagoff, Offset, typeof(byte), Items, Values, 0, map); Controls.Add(e); e.Dock = DockStyle.Top; e.BringToFront(); break; } case "enum16": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); //map.Reader.BaseStream.Position = ((Offset+tagoff) - map.Index.SecondaryMagic); //int Index = map.Reader.ReadInt16(); List <string> Items = new List <string>(); List <int> Values = new List <int>(); XmlReader x = xr.ReadSubtree(); while (x.Read()) { switch (x.Name.ToLower()) { case "option": { Items.Add(xr.GetAttribute("name")); Values.Add(Convert.ToInt32(xr.GetAttribute("value"))); break; } } } Enum e = new Enum(Description, tagoff, Offset, typeof(short), Items, Values, 0, map); Controls.Add(e); e.Dock = DockStyle.Top; e.BringToFront(); break; } case "enum32": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); //map.Reader.BaseStream.Position = ((Offset+tagoff) - map.Index.SecondaryMagic); //int Index = map.Reader.ReadInt32(); List <string> Items = new List <string>(); List <int> Values = new List <int>(); XmlReader x = xr.ReadSubtree(); while (x.Read()) { switch (x.Name.ToLower()) { case "option": { Items.Add(xr.GetAttribute("name")); Values.Add(Convert.ToInt32(xr.GetAttribute("value"))); break; } } } Enum e = new Enum(Description, tagoff, Offset, typeof(int), Items, Values, 0, map); Controls.Add(e); e.Dock = DockStyle.Top; e.BringToFront(); break; } case "bitmask8": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); List <string> Items = new List <string>(); List <int> Values = new List <int>(); XmlReader x = xr.ReadSubtree(); while (x.Read()) { switch (x.Name.ToLower()) { case "option": { Items.Add(xr.GetAttribute("name")); Values.Add(Convert.ToInt32(xr.GetAttribute("value"))); break; } } } Bitmask b = new Bitmask(Description, typeof(byte), Items, Values, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "bitmask16": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); List <string> Items = new List <string>(); List <int> Values = new List <int>(); XmlReader x = xr.ReadSubtree(); while (x.Read()) { switch (x.Name.ToLower()) { case "option": { Items.Add(xr.GetAttribute("name")); Values.Add(Convert.ToInt32(xr.GetAttribute("value"))); break; } } } Bitmask b = new Bitmask(Description, typeof(short), Items, Values, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "bitmask32": { string Description = xr.GetAttribute("name"); int Offset = Convert.ToInt32(xr.GetAttribute("offset")); List <string> Items = new List <string>(); List <int> Values = new List <int>(); XmlReader x = xr.ReadSubtree(); while (x.Read()) { switch (x.Name.ToLower()) { case "option": { Items.Add(xr.GetAttribute("name")); Values.Add(Convert.ToInt32(xr.GetAttribute("value"))); break; } } } Bitmask b = new Bitmask(Description, typeof(int), Items, Values, tagoff, Offset, map); Controls.Add(b); b.Dock = DockStyle.Top; b.BringToFront(); break; } case "string32": { //string Description = xr.GetAttribute("name"); //int Offset = Convert.ToInt32(xr.GetAttribute("offset")) + map.SelectedTag.MetaOffset; //map.br.BaseStream.Position = Offset; //string Value = new string(map.br.ReadChars(32)); //String s = new String(Description, Offset, ValueringType.String32); //Controls.Add(s); //s.Dock = DockStyle.Top; //s.BringToFront(); break; } case "string64": { //string Description = xr.GetAttribute("name"); //int Offset = Convert.ToInt32(xr.GetAttribute("offset")) + map.SelectedTag.MetaOffset; //map.br.BaseStream.Position = Offset; //string Value = new string(map.br.ReadChars(64)); //String s = new String(Description, Offset, ValueringType.String64); //Controls.Add(s); //s.Dock = DockStyle.Top; //s.BringToFront(); break; } case "unicode64": { //string Description = xr.GetAttribute("name"); //int Offset = Convert.ToInt32(xr.GetAttribute("offset")) + map.SelectedTag.MetaOffset; //map.br.BaseStream.Position = Offset; //string Value = ""; //for (int i = 0; i < 32; i++) //{ // Value += Convert.ToChar(map.br.ReadByte()); // map.br.BaseStream.Position++; //} //String s = new String(Description, Offset, ValueringType.Unicode64); //Controls.Add(s); //s.Dock = DockStyle.Top; //s.BringToFront(); break; } case "unicode256": { //string Description = xr.GetAttribute("name"); //int Offset = Convert.ToInt32(xr.GetAttribute("offset")) + map.SelectedTag.MetaOffset; //map.br.BaseStream.Position = Offset; //string Value = ""; //for (int i = 0; i < 128; i++) //{ // Value += Convert.ToChar(map.br.ReadByte()); // map.br.BaseStream.Position++; //} //String s = new String(Description, Offset, ValueringType.Unicode256); //Controls.Add(s); //s.Dock = DockStyle.Top; //s.BringToFront(); break; } } break; } } } xr.Close(); //Load Controls for (int i = Controls.Count - 1; i > -1; i--) { Meta.Controls.Add(Controls[i]); } Meta.ResumeLayout(true); Meta.Show(); } #endregion }
public int IndexOf(TagObject Tag) { return(List.IndexOf(Tag)); }
public TagTable(Map Map) { this.Map = Map; bool Go = true; int tmp = 1; Map.Reader.BaseStream.Position = Map.Index.TagStart; while (Go) { if (this.Count == 0) { byte[] Buffer = new byte[] { 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] Buffer1 = Map.Reader.ReadBytes(16); while (Buffer1[0] == Buffer[0] & Buffer1[1] == Buffer[1] & Buffer[2] == Buffer1[2]) { Buffer1 = Map.Reader.ReadBytes(16); tmp += 1; } Map.Reader.BaseStream.Position -= 16; tmp -= 1; } else { byte[] Buffer = new byte[] { 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] Buffer1 = Map.Reader.ReadBytes(16); if (Buffer1[0] == Buffer[0] && Buffer1[1] == Buffer[1] && Buffer1[2] == Buffer[2]) { break; } else { Map.Reader.BaseStream.Position -= 16; } } TagObject t = new TagObject(); t.Class = Globals.ReverseStr(new string(Map.Reader.ReadChars(4))); t.Identifier = Map.Reader.ReadInt32(); t.RawMetaOffset = Map.Reader.ReadInt32(); t.MetaSize = Map.Reader.ReadInt32(); t.MetaOffset = t.RawMetaOffset - Map.Index.SecondaryMagic; t.Index = tmp; tmp += 1; if (this.Count < 15065 && (uint)t.Identifier != 0xFFFFFFFF && tmp < 15065) { List.Add(t); if (!this.TagTypes.Contains(t.Class)) { this.TagTypes.Add(t.Class); } } if (tmp == 15064 || t.Class == "ugh!") { Go = false; } } Map.Header.TagCount = this.Count; Map.Reader.BaseStream.Position = Map.Header.FileTableOffset; for (int i = 0; i < this.Count; i++) { char c; while ((c = Map.Reader.ReadChar()) != '\0') { this[i].Path += c; } } }
public void Remove(TagObject Tag) { if (List.Contains(Tag)) List.Remove(Tag); else throw new Exception("The given tag was not found inside of the array \r\n Error No. 146"); }
public int IndexOf(TagObject Tag) { return List.IndexOf(Tag); }