예제 #1
0
 public FieldDescriptor(XElement e, int index, Dictionary<int, TypeDescriptor> typesByIndex)
 {
     Index = index;
     _Name = e.OptionalStringAttribute("Name");
     CustomName = e.OptionalStringAttribute("CustomName");
     Type = e.OptionalTypeAttribute("Type", typesByIndex);
     Offset = e.IntAttribute("Offset");
     Min = e.OptionalIntAttribute("Min");
     Max = e.OptionalIntAttribute("Max");
     Flags = e.IntAttribute("Flags");
     SubType = e.OptionalTypeAttribute("SubType", typesByIndex);
     VariableOffset = e.OptionalIntAttribute("VariableOffset");
     ArrayLength = e.OptionalIntAttribute("ArrayLength", -1);
     ArrayLengthOffset = e.OptionalIntAttribute("ArrayLengthOffset");
     EncodedBits = e.OptionalIntAttribute("EncodedBits");
     EncodedBits2 = e.OptionalIntAttribute("EncodedBits2");
     SnoType = e.OptionalIntAttribute("SnoType", -1);
     TagMapRelated = e.OptionalIntAttribute("TagMapRelated");
     var en = e.Element("Enum");
     if (en != null)
         EnumFields = en.Elements().Select(x => new Tuple<string, int>(x.Attribute("Name").Value, int.Parse(x.Attribute("Value").Value))).ToArray();
     FlagIndex = e.OptionalIntAttribute("FlagIndex");
     FuncA = e.OptionalStringAttribute("FuncA");
     FuncB = e.OptionalStringAttribute("FuncB");
     DspIndex = e.OptionalIntAttribute("DspIndex", -1);
 }
예제 #2
0
        public static TypeDescriptor[] FilterGameMessageStructures(TypeDescriptor[] types)
        {
            HashSet<TypeDescriptor> explored = new HashSet<TypeDescriptor>();

            List<GameMessageDescriptor> list = new List<GameMessageDescriptor>();
            foreach (var t in types)
            {
                if(t.IsGameMessage && explored.Add(t))
                    ExploreType((StructureTypeDescriptor)t, explored);
            }
            return explored.ToArray();
        }
예제 #3
0
        public static void DumpOpcodes(TypeDescriptor[] descriptors)
        {
            Dictionary<int, int> messages = new Dictionary<int, int>();
            foreach (var o1 in _gameMessageLookUp)
            {
                foreach (var o2 in o1.Value.Opcodes)
                {
                    messages[o2] = o1.Value.Offset;
                }
            }

            var messages_sorted = messages.OrderBy((o1) => { return o1.Key; });

            var writer = new StreamWriter("opcodes.txt");
            foreach (var message in messages_sorted)
            {
                var descriptor = descriptors.Single((w1) => { return w1.Offset == message.Value; });
                writer.WriteLine("{0} {1}", message.Key, descriptor._Name);
            }
            writer.Close();

            writer = new StreamWriter("opcodes.cs");
            writer.WriteLine("        static public Dictionary<int, Type> tomsg = new Dictionary<int, Type> {");
            foreach (var message in messages_sorted)
            {
                var descriptor = descriptors.Single((w1) => { return w1.Offset == message.Value; });
                writer.WriteLine("            {2}{0}, typeof({1}){3},", message.Key, descriptor.Name, '{', '}');
            }

            writer.WriteLine("};");
            writer.Close();
        }
예제 #4
0
 public static StructureTypeDescriptor[] ToStructures(TypeDescriptor[] elements)
 {
     List<StructureTypeDescriptor> v1 = new  List<StructureTypeDescriptor>();
     foreach(var element in elements)
         v1.Add((StructureTypeDescriptor)element);
     return v1.ToArray();
 }