예제 #1
0
        void FlattenDataTable(int serverClassIndex)
        {
            SendTable table = DataTables[ServerClasses[serverClassIndex].DataTableID];

            CurrentExcludes.Clear();

            GatherExcludes(table);

            GatherProps(table, serverClassIndex);

            var flattenedProps = ServerClasses[serverClassIndex].flattenedProps;

            List <int> priorities = new List <int>();

            priorities.Add(64);
            priorities.AddRange(flattenedProps.Select(a => a.Prop.Priority).Distinct());
            priorities.Sort();

            int start = 0;

            for (int priorityIndex = 0; priorityIndex < priorities.Count; priorityIndex++)
            {
                int priority = priorities[priorityIndex];

                while (true)
                {
                    int currentProp = start;

                    while (currentProp < flattenedProps.Count)
                    {
                        SendTableProperty prop = flattenedProps[currentProp].Prop;

                        if (prop.Priority == priority || (priority == 64 && prop.Flags.HasFlag(SendPropertyFlags.ChangesOften)))
                        {
                            if (start != currentProp)
                            {
                                FlattenedPropEntry temp = flattenedProps[start];
                                flattenedProps[start]       = flattenedProps[currentProp];
                                flattenedProps[currentProp] = temp;
                            }

                            start++;
                            break;
                        }
                        currentProp++;
                    }

                    if (currentProp == flattenedProps.Count)
                    {
                        break;
                    }
                }
            }
        }
예제 #2
0
        private void Parse(Messages.CSVCMsg_SendTable dataTable)
        {
            this.Name = dataTable.net_table_name;

            foreach (var prop in dataTable.props)
            {
                SendTableProperty property = new SendTableProperty()
                {
                    DataTableName    = prop.dt_name,
                    HighValue        = prop.high_value,
                    LowValue         = prop.low_value,
                    Name             = prop.var_name,
                    NumberOfBits     = prop.num_bits,
                    NumberOfElements = prop.num_elements,
                    Priority         = prop.priority,
                    RawFlags         = prop.flags,
                    RawType          = prop.type
                };

                properties.Add(property);
            }
        }
예제 #3
0
        void GatherProps_IterateProps(SendTable table, int ServerClassIndex, List <FlattenedPropEntry> flattenedProps)
        {
            for (int i = 0; i < table.Properties.Count; i++)
            {
                SendTableProperty property = table.Properties[i];

                if (property.Flags.HasFlag(SendPropertyFlags.InsideArray) || property.Flags.HasFlag(SendPropertyFlags.Exclude) || IsPropExcluded(table, property))
                {
                    continue;
                }

                if (property.Type == SendPropertyType.DataTable)
                {
                    SendTable subTable = GetTableByName(property.DataTableName);

                    if (property.Flags.HasFlag(SendPropertyFlags.Collapsible))
                    {
                        GatherProps_IterateProps(subTable, ServerClassIndex, flattenedProps);
                    }
                    else
                    {
                        GatherProps(subTable, ServerClassIndex);
                    }
                }
                else
                {
                    if (property.Type == SendPropertyType.Array)
                    {
                        flattenedProps.Add(new FlattenedPropEntry(property, table.Properties[i - 1]));
                    }
                    else
                    {
                        flattenedProps.Add(new FlattenedPropEntry(property, null));
                    }
                }
            }
        }
예제 #4
0
 public FlattenedPropEntry(SendTableProperty prop, SendTableProperty arrayElementProp)
 {
     this.Prop             = prop;
     this.ArrayElementProp = arrayElementProp;
 }
예제 #5
0
 bool IsPropExcluded(SendTable table, SendTableProperty prop)
 {
     return(CurrentExcludes.Exists(a => table.Name == a.DTName && prop.Name == a.VarName));
 }