Beispiel #1
0
 public uiTagBlock(mTagBlock mReflex)
 {
     components   = null;
     pnllo        = new Point(0, 0);
     parentoffset = 0;
     SIZE         = 0;
     cnkbxx       = false;
     pnlsize      = 0;
     InitializeComponent();
     ReflexiveData = mReflex;
     foreach (Control control in base.Controls)
     {
         control.ContextMenuStrip = contextMenuStrip1;
     }
     lblStructureText.Text = ReflexiveData.Name.ToUpper();
     pnllo = pnlValues.Location;
     VIZ();
 }
Beispiel #2
0
        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);
            }
        }
 public void MapPluginWithPDBList(List <mValue> mValueList, List <PluginDataBlock> PDBList, int chunkSize, int unknownStructCount)
 {
     for (int i = 0; i < chunkSize; i += 4)
     {
         List <PluginDataBlock> pDBList = new List <PluginDataBlock>();
         foreach (PluginDataBlock block in PDBList)
         {
             foreach (Reflexive_DataBlock block2 in block.Reflexive_Data_Blocks)
             {
                 if (block2.Offset_In_Parent == i)
                 {
                     pDBList.Add(block2);
                 }
             }
         }
         if (pDBList.Count != 0)
         {
             mTagBlock item = new mTagBlock {
                 Name = "Unknown " + unknownStructCount
             };
             unknownStructCount++;
             item.Offset  = i;
             item.Size    = FindMostLikelySizeForChunk(pDBList);
             item.Visible = false;
             mValueList.Add(item);
             MapPluginWithPDBList(item.Values, pDBList, item.Size, unknownStructCount);
             i += 8;
             continue;
         }
         bool flag  = false;
         bool flag2 = false;
         foreach (PluginDataBlock block in PDBList)
         {
             foreach (Tag_Ident ident in block.Tag_Idents)
             {
                 if (ident.Offset_In_Parent == i)
                 {
                     mTagReference reference = new mTagReference {
                         Name    = "Unknown",
                         Offset  = i,
                         Visible = false
                     };
                     mValueList.Add(reference);
                     i   += 12;
                     flag = true;
                     break;
                 }
             }
             if (flag)
             {
                 break;
             }
             foreach (Tag_Void @void in block.Tag_Voids)
             {
                 if (@void.Offset_In_Parent == i)
                 {
                     mTagData data = new mTagData {
                         Name    = "Unknown",
                         Offset  = i,
                         Visible = false
                     };
                     mValueList.Add(data);
                     i    += 0x10;
                     flag2 = true;
                     break;
                 }
             }
             if (flag2)
             {
                 break;
             }
         }
         if (!flag && !flag2)
         {
             if ((chunkSize - i) >= 4)
             {
                 mUndefined undefined = new mUndefined {
                     Name    = "Unknown",
                     Offset  = i,
                     Visible = false
                 };
                 mValueList.Add(undefined);
             }
             else if ((chunkSize - i) >= 2)
             {
                 mInt16 num2 = new mInt16 {
                     Name    = "Unknown",
                     Offset  = i,
                     Visible = false
                 };
                 mValueList.Add(num2);
                 i -= 2;
             }
             else if ((chunkSize - i) == 1)
             {
                 mByte num3 = new mByte {
                     Name    = "Unknown",
                     Offset  = i,
                     Visible = false
                 };
                 mValueList.Add(num3);
             }
         }
     }
 }
Beispiel #4
0
        private mValue ReadNode(XmlNode xmlNode)
        {
            int         num;
            mColorBlock block2;
            mBitOption  option;
            mEnumOption option2;
            string      str3 = xmlNode.Name.ToLower();

            switch (str3)
            {
            case "reflexive":
            case "structure":
            case "reflex":
            case "struct":
            case "tagblock":
            case "block":
            {
                mTagBlock block = new mTagBlock {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Size    = int.Parse(xmlNode.Attributes["size"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Values  = new List <mValue>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    mValue item = ReadNode(xmlNode.ChildNodes[num]);
                    if (item.Attributes != mValue.ObjectAttributes.None)
                    {
                        block.Values.Add(item);
                    }
                }
                return(block);
            }

            case "tagdata":
            case "void":
                return(new mTagData {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "array":
            case "bytearray":
            case "bytes":
                return(new mByteArray {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Length = int.Parse(xmlNode.Attributes["length"].Value)
                });

            case "comment":
            case "note":
                return(new mComment {
                    Title = xmlNode.Attributes["title"].Value,
                    Description = xmlNode.InnerText.Replace(@"\n", "\n").Replace(@"\t", "\t").Replace(@"\'", "\""),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "color8":
            case "color16":
            case "color32":
            case "colorf":
                if (xmlNode.Name.ToLower() != "color8")
                {
                    if (xmlNode.Name.ToLower() == "color16")
                    {
                        block2 = new mColorBlock16();
                    }
                    else if (xmlNode.Name.ToLower() == "color32")
                    {
                        block2 = new mColorBlock32();
                    }
                    else
                    {
                        block2 = new mColorBlockF();
                    }
                    break;
                }
                block2 = new mColorBlock8();
                break;

            case "tagref":
            case "tag":
            case "tagid":
                return(new mTagReference {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "sid":
            case "stringid":
            case "stringidentifier":
                return(new mStringID {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "bitmask8":
            case "bit8":
            {
                mBitmask8 bitmask = new mBitmask8 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mBitOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if ((xmlNode.ChildNodes[num].Name.ToLower() == "bit") | (xmlNode.ChildNodes[num].Name.ToLower() == "option"))
                    {
                        option = new mBitOption {
                            Name = xmlNode.ChildNodes[num].Attributes["name"].Value
                        };
                        try
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["index"].Value);
                        }
                        catch
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value);
                        }
                        bitmask.Options.Add(option);
                    }
                }
                return(bitmask);
            }

            case "bitmask16":
            case "bit16":
            {
                mBitmask16 bitmask2 = new mBitmask16 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mBitOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if ((xmlNode.ChildNodes[num].Name.ToLower() == "bit") | (xmlNode.ChildNodes[num].Name.ToLower() == "option"))
                    {
                        option = new mBitOption {
                            Name = xmlNode.ChildNodes[num].Attributes["name"].Value
                        };
                        try
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["index"].Value);
                        }
                        catch
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value);
                        }
                        bitmask2.Options.Add(option);
                    }
                }
                return(bitmask2);
            }

            case "bitmask32":
            case "bit32":
            {
                mBitmask32 bitmask3 = new mBitmask32 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mBitOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if ((xmlNode.ChildNodes[num].Name.ToLower() == "bit") | (xmlNode.ChildNodes[num].Name.ToLower() == "option"))
                    {
                        option = new mBitOption {
                            Name = xmlNode.ChildNodes[num].Attributes["name"].Value
                        };
                        try
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["index"].Value);
                        }
                        catch
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value);
                        }
                        bitmask3.Options.Add(option);
                    }
                }
                return(bitmask3);
            }

            case "enum8":
            {
                mEnum8 enum2 = new mEnum8 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mEnumOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if (xmlNode.ChildNodes[num].Name.ToLower() == "option")
                    {
                        option2 = new mEnumOption {
                            Name  = xmlNode.ChildNodes[num].Attributes["name"].Value,
                            Value = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value)
                        };
                        enum2.Options.Add(option2);
                    }
                }
                return(enum2);
            }

            case "enum16":
            {
                mEnum16 enum3 = new mEnum16 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mEnumOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if (xmlNode.ChildNodes[num].Name.ToLower() == "option")
                    {
                        option2 = new mEnumOption {
                            Name  = xmlNode.ChildNodes[num].Attributes["name"].Value,
                            Value = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value)
                        };
                        enum3.Options.Add(option2);
                    }
                }
                return(enum3);
            }

            case "enum32":
            {
                mEnum32 enum4 = new mEnum32 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mEnumOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if (xmlNode.ChildNodes[num].Name.ToLower() == "option")
                    {
                        option2 = new mEnumOption {
                            Name  = xmlNode.ChildNodes[num].Attributes["name"].Value,
                            Value = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value)
                        };
                        enum4.Options.Add(option2);
                    }
                }
                return(enum4);
            }

            case "int8":
            case "byte":
                return(new mByte {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "int16":
            case "short":
                return(new mInt16 {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "uint16":
            case "ushort":
                return(new mUInt16 {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "int32":
            case "long":
            case "int":
                return(new mInt32 {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "uint32":
            case "ulong":
            case "uint":
                return(new mUInt32 {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "single":
            case "float":
                return(new mFloat {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "string":
            case "str":
                return(new mString {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Length = int.Parse(xmlNode.Attributes["length"].Value)
                });

            case "unic":
            case "unicode":
                return(new mUnicode {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Length = int.Parse(xmlNode.Attributes["length"].Value)
                });

            case "undefined":
            case "unknown":
                return(new mUndefined {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "unused":
            case "blank":
                return(new mUnused {
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Size = int.Parse(xmlNode.Attributes["size"].Value)
                });

            default:
                return(new mValue {
                    Attributes = mValue.ObjectAttributes.None
                });
            }
            block2.Name       = xmlNode.Attributes["name"].Value;
            block2.Offset     = int.Parse(xmlNode.Attributes["offset"].Value);
            block2.Visible    = bool.Parse(xmlNode.Attributes["visible"].Value);
            block2.Real_Color = bool.Parse(xmlNode.Attributes["real"].Value);
            string str = xmlNode.Attributes["order"].Value;

            foreach (char ch in str)
            {
                str3 = ch.ToString().ToUpper();
                if (str3 != null)
                {
                    if (str3 != "R")
                    {
                        if (str3 == "G")
                        {
                            goto Label_07F1;
                        }
                        if (str3 == "B")
                        {
                            goto Label_0802;
                        }
                        if (str3 == "A")
                        {
                            goto Label_0813;
                        }
                        if (str3 == "N")
                        {
                            goto Label_0824;
                        }
                    }
                    else
                    {
                        block2.Color_Order.Add(ColorBlockPart.Red);
                    }
                }
                continue;
Label_07F1:
                block2.Color_Order.Add(ColorBlockPart.Green);
                continue;
Label_0802:
                block2.Color_Order.Add(ColorBlockPart.Blue);
                continue;
Label_0813:
                block2.Color_Order.Add(ColorBlockPart.Alpha);
                continue;
Label_0824:
                block2.Color_Order.Add(ColorBlockPart.None);
            }
            return(block2);
        }