Page 1 of 1

Plugins

Posted: Thu Feb 21, 2008 12:49 pm
by grimdoomer
Well I have every nodetype done except enums, bitmasks, and structs. The only problem im having is getting my xmltextreader to read the contense, ex options etc. Can any one help me?

Posted: Thu Feb 21, 2008 1:46 pm
by Supermodder911
Maybe you can show us your reading code?

Posted: Thu Feb 21, 2008 2:01 pm
by grimdoomer
Ok, I wrote it my self, Ill only put the enum part, because bitmasks are similar and so are structs.

Code: Select all

case "enum8":
                                    {
                                        ItemTag += 1;
                                        string Name = XR.GetAttribute("name");
                                        int Offset = System.Convert.ToInt32(XR.GetAttribute("offset"));
                                        bool Visible = bool.Parse(XR.GetAttribute("visible"));
                                        List<string> Temp = new List<string>(0);
                                        while (XR.Read())
                                        {
                                            switch (XR.NodeType)
                                            {
                                                case XmlNodeType.Element:
                                                    {
                                                        do
                                                        {
                                                            Temp.Capacity += 1;
                                                            Temp.Add(XR.GetAttribute("name"));
                                                        }
                                                        while (XR.Name.ToLower() == "option");
                                                        break;
                                                    }
                                                case XmlNodeType.EndElement:
                                                    {
                                                        break;
                                                    }
                                                default:
                                                    {
                                                        break;
                                                    }
                                            }
                                        }
                                        string[] Options = Temp.ToArray();
                                        Map.BR.BaseStream.Position = Offset;
                                        int Value = Map.BR.ReadByte();
                                        Plugin.Add(new ENTEnum(Map, Name, Offset, Visible, (int)Value, Options, typeof(byte), ItemTag));
                                        break;
                                    }
                                case "enum16":
                                    {
                                        ItemTag += 1;
                                        string Name = XR.GetAttribute("name");
                                        int Offset = System.Convert.ToInt32(XR.GetAttribute("offset"));
                                        bool Visible = bool.Parse(XR.GetAttribute("visible"));
                                        List<string> Temp = new List<string>();
                                        while (XR.Name.ToLower() == "option")
                                        {
                                            Temp.Add(XR.GetAttribute("name"));
                                        }
                                        string[] Options = Temp.ToArray();
                                        Map.BR.BaseStream.Position = Offset;
                                        int Value = Map.BR.ReadInt16();
                                        Plugin.Add(new ENTEnum(Map, Name, Offset, Visible, (int)Value, Options, typeof(short), ItemTag));
                                        break;
                                    }
                                case "enum32":
                                    {
                                        ItemTag += 1;
                                        string Name = XR.GetAttribute("name");
                                        int Offset = System.Convert.ToInt32(XR.GetAttribute("offset"));
                                        bool Visible = bool.Parse(XR.GetAttribute("visible"));
                                        List<string> Temp = new List<string>();
                                        while (XR.Name.ToLower() == "option")
                                        {
                                            Temp.Add(XR.GetAttribute("name"));
                                        }
                                        string[] Options = Temp.ToArray();
                                        Map.BR.BaseStream.Position = Offset;
                                        int Value = Map.BR.ReadInt32();
                                        Plugin.Add(new ENTEnum(Map, Name, Offset, Visible, Value, Options, typeof(int), ItemTag));
                                        break;
                                    }
I tryed many things the code in the enum8 was my last attempt. And sorry about the spacing.

Posted: Thu Feb 21, 2008 2:11 pm
by LuxuriousMeat
The method 'XmlTextReader.ReadSubtree' returns a new XmlReader that just has the child elements of the current element, you can try to use that or you can download entity's source and look how they did it.

Posted: Thu Feb 21, 2008 2:12 pm
by grimdoomer
Ill try that, I did look at entitys source and when I tried it it didn't work the way I wanted it to.