Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            NetAttribute.LoadXml("attributes.xml");

            XDocument doc = XDocument.Load("typedescriptors.xml");
            int       protocolHash;
            var       descriptors = TypeDescriptor.LoadXml(doc.Root, out protocolHash);

            var structs = TypeDescriptor.FilterGameMessageStructures(descriptors);

            var writer = new StreamWriter("classgenerator-output.cs");

            foreach (var s in structs)
            {
                var b = new StringBuilder();
                s.GenerateClass(b, 4);
                writer.WriteLine(b.ToString());
            }

            writer.Close();

            writer = new StreamWriter("attributes-output.cs");
            var builder = new StringBuilder();

            NetAttribute.GenerateClass(builder);
            writer.WriteLine(builder.ToString());
            writer.Close();

            Console.WriteLine("done");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void DumpAttributes(Mem32 mem)
        {
            // could get the max num from descriptor
            var attribList = mem[AttributesAddress];

            NetAttribute.Attributes = new NetAttribute[AttributeCount];
            for (int i = 0; i < AttributeCount; i++)
            {
                var attrib = attribList[i * 40];

                int id = attrib.Int32;
                int u2 = attrib[4].Int32;
                int u3 = attrib[8].Int32;
                int u4 = attrib[12].Int32;
                int u5 = attrib[16].Int32;

                string scriptA = attrib[20].CStringPtr;
                string scriptB = attrib[24].CStringPtr;
                string name    = attrib[28].CStringPtr;
                var    decoder = attrib[32].Ptr;
                byte   u10     = attrib[36].Byte;
                switch (decoder.Int32)
                {
                case Attribute_Int:
                {
                    int bitCount = decoder[12].Int32;
                    NetAttribute.Attributes[id] = new NetAttribute(id, u2, u3, u4, u5, scriptA, scriptB, name, NetAttributeEncoding.Int, u10, 0, 0, bitCount);
                    break;
                }

                case Attribute_IntMinMax:
                {
                    int bitCount = decoder[20].Int32;
                    int min      = decoder[12].Int32;
                    int max      = decoder[16].Int32;
                    NetAttribute.Attributes[id] = new NetAttribute(id, u2, u3, u4, u5, scriptA, scriptB, name, NetAttributeEncoding.IntMinMax, u10, min, max, bitCount);
                    break;
                }

                case Attribute_Float16:     // Decode16BitFloat(bits)
                {
                    int bitCount = decoder[12].Int32;
                    NetAttribute.Attributes[id] = new NetAttribute(id, u2, u3, u4, u5, scriptA, scriptB, name, NetAttributeEncoding.Float16, u10, 0, 0, bitCount);
                }
                break;

                case Attribute_Float16Or32:
                {
                    NetAttribute.Attributes[id] = new NetAttribute(id, u2, u3, u4, u5, scriptA, scriptB, name, NetAttributeEncoding.Float16Or32, u10, 0, 0, 0);
                }
                break;

                case Attribute_FloatMinMax:     // DecodeFloatMinMax
                    throw new Exception("FloatMinMax used");

                default:
                    throw new Exception("Unknown decoder used");
                }
            }
            NetAttribute.SaveXml("attributes.xml");
        }