Пример #1
0
        void GatherProps(SendTable table, int serverClassIndex)
        {
            List <FlattenedPropEntry> tmpFlattenedProps = new List <FlattenedPropEntry>();

            GatherProps_IterateProps(table, serverClassIndex, tmpFlattenedProps);

            List <FlattenedPropEntry> flattenedProps = ServerClasses[serverClassIndex].flattenedProps;

            flattenedProps.AddRange(tmpFlattenedProps);
        }
Пример #2
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;
                    }
                }
            }
        }
Пример #3
0
        void GatherExcludes(SendTable sendTable)
        {
            CurrentExcludes.AddRange(
                sendTable.Properties
                .Where(a => a.Flags.HasFlag(SendPropertyFlags.Exclude))
                .Select(a => new ExcludeEntry(a.Name, a.DataTableName, sendTable.Name))
                );

            foreach (var prop in sendTable.Properties.Where(a => a.Type == SendPropertyType.DataTable))
            {
                GatherExcludes(GetTableByName(prop.DataTableName));
            }
        }
Пример #4
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));
                    }
                }
            }
        }
Пример #5
0
 bool IsPropExcluded(SendTable table, SendTableProperty prop)
 {
     return(CurrentExcludes.Exists(a => table.Name == a.DTName && prop.Name == a.VarName));
 }