public uiStringID(mStringID stringID, List <string> SID) { ipath = ""; components = null; InitializeComponent(); String_Data = stringID; lblValueName.Text = String_Data.Name; labelEntry = SID; }
private void ParseRecursively(List <mValue> ValueList, int chunkOffset, int chunkNumber) { for (int i = 0; i < ValueList.Count; i++) { object name; switch (ValueList[i].Attributes) { case mValue.ObjectAttributes.TagBlock: { if ((chunkOffset + ValueList[i].Offset) <= ((int)Map.IO.In.BaseStream.Length)) { break; } continue; } case mValue.ObjectAttributes.TagData: { if ((chunkOffset + ValueList[i].Offset) <= ((int)Map.IO.In.BaseStream.Length)) { goto Label_0224; } continue; } case mValue.ObjectAttributes.TagReference: { if ((chunkOffset + ValueList[i].Offset) <= ((int)Map.IO.In.BaseStream.Length)) { goto Label_03B7; } continue; } case mValue.ObjectAttributes.StringID: { if ((chunkOffset + ValueList[i].Offset) <= ((int)Map.IO.In.BaseStream.Length)) { goto Label_05E5; } continue; } default: { continue; } } Map.IO.In.BaseStream.Position = chunkOffset + ValueList[i].Offset; mTagBlock block = (mTagBlock)ValueList[i]; Structure item = new Structure { Name = block.Name }; if (chunkNumber != -1) { name = item.Name; item.Name = string.Concat(new object[] { name, " [", chunkNumber, "]" }); } item.Size = block.Size; item.Count = Map.IO.In.ReadInt32(); item.Pointer = Map.IO.In.ReadInt32() - Map.Map_Header.mapMagic; if (!(((item.Count <= 0) | (item.Pointer <= 0)) | (item.Count > 0x186a0))) { item.Offset = chunkOffset + block.Offset; Structures.Add(item); for (int j = 0; j < item.Count; j++) { ParseRecursively(block.Values, item.Pointer + (j * item.Size), j); } } continue; Label_0224: Map.IO.In.BaseStream.Position = chunkOffset + ValueList[i].Offset; mTagData data = (mTagData)ValueList[i]; TagData data2 = new TagData { Name = data.Name }; if (chunkNumber != -1) { name = data2.Name; data2.Name = string.Concat(new object[] { name, " [", chunkNumber, "]" }); } data2.Size = Map.IO.In.ReadInt32(); Stream baseStream = Map.IO.In.BaseStream; baseStream.Position += 8L; data2.Pointer = Map.IO.In.ReadInt32() - Map.Map_Header.mapMagic; if (!((data2.Size <= 0) | (data2.Pointer <= 0))) { data2.Offset = chunkOffset + data.Offset; Tag_Data_Blocks.Add(data2); } continue; Label_03B7: Map.IO.In.BaseStream.Position = (chunkOffset + ValueList[i].Offset) + 12; mTagReference reference = (mTagReference)ValueList[i]; Ident ident = new Ident { Name = reference.Name }; if (chunkNumber != -1) { name = ident.Name; ident.Name = string.Concat(new object[] { name, " [", chunkNumber, "]" }); } ident.Offset = chunkOffset + reference.Offset; ident.ID = Map.IO.In.ReadInt32(); int tagIndexByIdent = Map.GetTagIndexByIdent(ident.ID); if (tagIndexByIdent != -1) { ident.TagClass = Map.Index_Items[tagIndexByIdent].Class; } else { ident.TagClass = "Null"; } if (tagIndexByIdent != -1) { int key = Map.Index_Items[tagIndexByIdent].Ident; string str = Map.Index_Items[tagIndexByIdent].Name; if (Map.tagNameList.TagPaths.ContainsKey(key)) { try { str = Map.tagNameList.TagPaths[key]; } catch { } } ident.TagName = str + "." + Map.Index_Items[tagIndexByIdent].Class; } else { ident.TagName = "Null"; } Idents.Add(ident); continue; Label_05E5: Map.IO.In.BaseStream.Position = chunkOffset + ValueList[i].Offset; mStringID gid = (mStringID)ValueList[i]; StringIdentifier identifier = new StringIdentifier { Name = gid.Name }; if (chunkNumber != -1) { name = identifier.Name; identifier.Name = string.Concat(new object[] { name, " [", chunkNumber, "]" }); } identifier.Offset = chunkOffset + gid.Offset; identifier.Identifier = Map.IO.In.ReadInt32(); tagIndexByIdent = Map.String_Table.GetStringItemIndexByID(Map, identifier.Identifier); identifier.StringIndex = tagIndexByIdent; try { identifier.StringName = Map.String_Table.StringItems[tagIndexByIdent].Name; } catch { identifier.StringName = "<<invalid sid>>"; } Strings.Add(identifier); } }
private mValue ReadNode(XmlNode xmlNode) { //Indiciate what type of value this is. switch (xmlNode.Name.ToLower()) { case "reflexive": case "structure": case "reflex": case "struct": { //Initialize our instance of a reflexive. mReflexive reflexive = new mReflexive(); //Retrieve the structure's name. reflexive.Name = xmlNode.Attributes["name"].Value; //Retrieve its offset within its parent. reflexive.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Retrieve its chunk size. reflexive.Size = int.Parse(xmlNode.Attributes["size"].Value); //Retrieve its visibility flag. reflexive.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //Initialize the value list for the reflexive reflexive.Values = new List <mValue>(); //Recursively add any nodes that belong to it. for (int i = 0; i < xmlNode.ChildNodes.Count; i++) { //Get our returned value. mValue returnedVal = ReadNode(xmlNode.ChildNodes[i]); //If its not some unknown node that couldnt be read... if (returnedVal.Attributes != mValue.ObjectAttributes.None) { //Then add it to this reflexive value list. reflexive.Values.Add(returnedVal); } } //Return our reflexive return(reflexive); } case "tagref": case "tag": { //Initialize our instance of TagRef mTagRef tagRef = new mTagRef(); //Assign the name tagRef.Name = xmlNode.Attributes["name"].Value; //Assign the offset tagRef.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag tagRef.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(tagRef); } case "ident": case "id": case "tagid": { //Initialize our instance of ident mIdent ident = new mIdent(); //Assign the name ident.Name = xmlNode.Attributes["name"].Value; //Assign the offset ident.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag ident.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(ident); } case "sid": case "stringid": case "stringidentifier": { //Initialize our instance of string mStringID stringID = new mStringID(); //Assign the name stringID.Name = xmlNode.Attributes["name"].Value; //Assign the offset stringID.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag stringID.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(stringID); } case "bitmask8": case "bit8": { //Initialize our instance of bitmask8 mBitmask8 bitmask8 = new mBitmask8(); //Assign the name bitmask8.Name = xmlNode.Attributes["name"].Value; //Assign the offset bitmask8.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag bitmask8.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //Initialize the bitOption list. bitmask8.Options = new List <mBitOption>(); //Loop through the children nodes for options. for (int i = 0; i < xmlNode.ChildNodes.Count; i++) { //if its an option... if (xmlNode.ChildNodes[i].Name.ToLower() == "option") { //then initialize a new instance of option mBitOption bitOption = new mBitOption(); //Get the name of the bit bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value; //Get the bit value bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value); //Add it to the bitList bitmask8.Options.Add(bitOption); } } //return the value return(bitmask8); } case "bitmask16": case "bit16": { //Initialize our instance of bitmask16 mBitmask16 bitmask16 = new mBitmask16(); //Assign the name bitmask16.Name = xmlNode.Attributes["name"].Value; //Assign the offset bitmask16.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag bitmask16.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //Initialize the bitOption list. bitmask16.Options = new List <mBitOption>(); //Loop through the children nodes for options. for (int i = 0; i < xmlNode.ChildNodes.Count; i++) { //if its an option... if (xmlNode.ChildNodes[i].Name.ToLower() == "option") { //then initialize a new instance of option mBitOption bitOption = new mBitOption(); //Get the name of the bit bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value; //Get the bit value bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value); //Add it to the bitList bitmask16.Options.Add(bitOption); } } //return the value return(bitmask16); } case "bitmask32": case "bit32": { //Initialize our instance of bitmask32 mBitmask32 bitmask32 = new mBitmask32(); //Assign the name bitmask32.Name = xmlNode.Attributes["name"].Value; //Assign the offset bitmask32.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag bitmask32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //Initialize the bitOption list. bitmask32.Options = new List <mBitOption>(); //Loop through the children nodes for options. for (int i = 0; i < xmlNode.ChildNodes.Count; i++) { //if its an option... if (xmlNode.ChildNodes[i].Name.ToLower() == "option") { //then initialize a new instance of option mBitOption bitOption = new mBitOption(); //Get the name of the bit bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value; //Get the bit value bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value); //Add it to the bitList bitmask32.Options.Add(bitOption); } } //return the value return(bitmask32); } case "enum8": { //Initialize our instance of enum8 mEnum8 enum8 = new mEnum8(); //Assign the name enum8.Name = xmlNode.Attributes["name"].Value; //Assign the offset enum8.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag enum8.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //Initialize the enumOption list. enum8.Options = new List <mEnumOption>(); //Loop through the children nodes for options. for (int i = 0; i < xmlNode.ChildNodes.Count; i++) { //if its an option... if (xmlNode.ChildNodes[i].Name.ToLower() == "option") { //then initialize a new instance of option mEnumOption enumOption = new mEnumOption(); //Get the name of the bit enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value; //Get the bit value enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value); //Add it to the bitList enum8.Options.Add(enumOption); } } //return the value return(enum8); } case "enum16": { //Initialize our instance of enum16 mEnum16 enum16 = new mEnum16(); //Assign the name enum16.Name = xmlNode.Attributes["name"].Value; //Assign the offset enum16.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag enum16.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //Initialize the enumOption list. enum16.Options = new List <mEnumOption>(); //Loop through the children nodes for options. for (int i = 0; i < xmlNode.ChildNodes.Count; i++) { //if its an option... if (xmlNode.ChildNodes[i].Name.ToLower() == "option") { //then initialize a new instance of option mEnumOption enumOption = new mEnumOption(); //Get the name of the bit enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value; //Get the bit value enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value); //Add it to the bitList enum16.Options.Add(enumOption); } } //return the value return(enum16); } case "enum32": { //Initialize our instance of enum32 mEnum32 enum32 = new mEnum32(); //Assign the name enum32.Name = xmlNode.Attributes["name"].Value; //Assign the offset enum32.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag enum32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //Initialize the enumOption list. enum32.Options = new List <mEnumOption>(); //Loop through the children nodes for options. for (int i = 0; i < xmlNode.ChildNodes.Count; i++) { //if its an option... if (xmlNode.ChildNodes[i].Name.ToLower() == "option") { //then initialize a new instance of option mEnumOption enumOption = new mEnumOption(); //Get the name of the bit enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value; //Get the bit value enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value); //Add it to the bitList enum32.Options.Add(enumOption); } } //return the value return(enum32); } case "int8": case "byte": { //Initialize our instance of byte mByte byteVal = new mByte(); //Assign the name byteVal.Name = xmlNode.Attributes["name"].Value; //Assign the offset byteVal.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag byteVal.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(byteVal); } case "int16": case "short": { //Initialize our instance of int16 mInt16 int16Val = new mInt16(); //Assign the name int16Val.Name = xmlNode.Attributes["name"].Value; //Assign the offset int16Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag int16Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(int16Val); } case "uint16": case "ushort": { //Initialize our instance of uint16 mUInt16 uint16Val = new mUInt16(); //Assign the name uint16Val.Name = xmlNode.Attributes["name"].Value; //Assign the offset uint16Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag uint16Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(uint16Val); } case "int32": case "long": case "int": { //Initialize our instance of int32 mInt32 int32Val = new mInt32(); //Assign the name int32Val.Name = xmlNode.Attributes["name"].Value; //Assign the offset int32Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag int32Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(int32Val); } case "uint32": case "ulong": case "uint": { //Initialize our instance of uint32 mUInt32 uint32Val = new mUInt32(); //Assign the name uint32Val.Name = xmlNode.Attributes["name"].Value; //Assign the offset uint32Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag uint32Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(uint32Val); } case "single": case "float": { //Initialize our instance of float mFloat floatVal = new mFloat(); //Assign the name floatVal.Name = xmlNode.Attributes["name"].Value; //Assign the offset floatVal.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag floatVal.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(floatVal); } case "string32": case "32string": { //Initialize our instance of string32 mString32 string32 = new mString32(); //Assign the name string32.Name = xmlNode.Attributes["name"].Value; //Assign the offset string32.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag string32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(string32); } case "string256": case "256string": { //Initialize our instance of string32 mString256 string256 = new mString256(); //Assign the name string256.Name = xmlNode.Attributes["name"].Value; //Assign the offset string256.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag string256.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(string256); } case "unic64": case "unicode64": case "64unic": case "64unicode": { //Initialize our instance of unicode64 mUnicode64 unicode64 = new mUnicode64(); //Assign the name unicode64.Name = xmlNode.Attributes["name"].Value; //Assign the offset unicode64.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag unicode64.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(unicode64); } case "unic256": case "unicode256": case "256unic": case "256unicode": { //Initialize our instance of unicode64 mUnicode256 unicode256 = new mUnicode256(); //Assign the name unicode256.Name = xmlNode.Attributes["name"].Value; //Assign the offset unicode256.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag unicode256.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(unicode256); } case "undefined": case "unknown": { //Initialize our instance of undefined mUndefined undefined = new mUndefined(); //Assign the name undefined.Name = xmlNode.Attributes["name"].Value; //Assign the offset undefined.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag undefined.Visible = bool.Parse(xmlNode.Attributes["visible"].Value); //return the value return(undefined); } case "unused": case "blank": { //Initialize our instance of undefined mUnused unused = new mUnused(); //Assign the offset unused.Offset = int.Parse(xmlNode.Attributes["offset"].Value); //Assign the visibility flag unused.Size = int.Parse(xmlNode.Attributes["size"].Value); //return the value return(unused); } } //If all else fails, make a 'none' value. mValue blankVal = new mValue(); blankVal.Attributes = mValue.ObjectAttributes.None; return(blankVal); }
private void ParseRecursively(List <mValue> ValueList, int chunkOffset, int chunkNumber) { //Loop through values for (int i = 0; i < ValueList.Count; i++) { //Determine the value type switch (ValueList[i].Attributes) { case mValue.ObjectAttributes.Reflexive: { //If the offset is rediculous.. if (chunkOffset + ValueList[i].Offset > (int)Map.IO.In.BaseStream.Length) { break; } //Go to the reflexive offset Map.IO.In.BaseStream.Position = chunkOffset + ValueList[i].Offset; //Get the reflexive mReflexive mreflexive = (mReflexive)ValueList[i]; //Initialize our instance of structure Structure structure = new Structure(); //Assign the name structure.Name = mreflexive.Name; //Add chunk modifier if (chunkNumber != -1) { structure.Name += " [" + chunkNumber + "]"; } //Assign the size structure.Size = mreflexive.Size; //Read the count structure.Count = Map.IO.In.ReadInt32(); //Read the pointer structure.Pointer = Map.IO.In.ReadInt32() - Map.MapHeader.mapMagic; //If the count or pointer are bad, break out and dont add it to the list if (structure.Count <= 0 | structure.Pointer <= 0 | structure.Count > 100000) { break; } //Assign the offset structure.Offset = chunkOffset + mreflexive.Offset; //Add it to the list Structures.Add(structure); //Loop through all the chunks for (int z = 0; z < structure.Count; z++) { //Parse recursively ParseRecursively(mreflexive.Values, structure.Pointer + (z * structure.Size), z); } break; } case mValue.ObjectAttributes.Ident: { //If the offset is rediculous.. if (chunkOffset + ValueList[i].Offset > (int)Map.IO.In.BaseStream.Length) { break; } //Go to the ident offset Map.IO.In.BaseStream.Position = chunkOffset + ValueList[i].Offset; //Get the ident instance mIdent mident = (mIdent)ValueList[i]; //Initialize our instance of the ident Ident ident = new Ident(); //Assign the name ident.Name = mident.Name; if (chunkNumber != -1) { ident.Name += " [" + chunkNumber + "]"; } //Assign the offset ident.Offset = chunkOffset + mident.Offset - 12; //Assign the Ident ident.ID = Map.IO.In.ReadInt32(); //Get the tag index int index = Map.GetTagIndexByIdent(ident.ID); //Assign the class if (index != -1) { ident.TagClass = Map.IndexItems[index].Class; } else { ident.TagClass = "Null"; } //Assign the name if (index != -1) { ident.TagName = Map.IndexItems[index].Name; } else { ident.TagName = "Null"; } //Add to the ident to the list Idents.Add(ident); break; } case mValue.ObjectAttributes.StringID: { //If the offset is rediculous.. if (chunkOffset + ValueList[i].Offset > (int)Map.IO.In.BaseStream.Length) { break; } //Go to the ident offset Map.IO.In.BaseStream.Position = chunkOffset + ValueList[i].Offset; //Get the ident instance mStringID mstringid = (mStringID)ValueList[i]; //Initialize our instance of the string id. StringIdentifier str = new StringIdentifier(); //Assign the name str.Name = mstringid.Name; if (chunkNumber != -1) { str.Name += " [" + chunkNumber + "]"; } //Assign the offset str.Offset = chunkOffset + mstringid.Offset; //Assign the Ident str.Identifier = Map.IO.In.ReadInt32(); //Get the string index int index = Map.StringTable.GetStringItemIndexByID(Map, str.Identifier); //Assign the string index str.StringIndex = index; //Try to.. try { //Assign the string name str.StringName = Map.StringTable.StringItems[index].Name; } catch { //Assign our invalid name str.StringName = "<<invalid sid>>"; } //Add to the string to the list Strings.Add(str); break; } } } }