Exemple #1
0
        public SendTable(IBitStream bitstream)
        {
            DP.FastNetmessages.SendTable dataTable = new DP.FastNetmessages.SendTable();

            foreach (var prop in dataTable.Parse(bitstream))
            {
                SendTableProperty property = new SendTableProperty()
                {
                    DataTableName    = prop.DtName,
                    HighValue        = prop.HighValue,
                    LowValue         = prop.LowValue,
                    Name             = prop.VarName,
                    NumberOfBits     = prop.NumBits,
                    NumberOfElements = prop.NumElements,
                    Priority         = prop.Priority,
                    RawFlags         = prop.Flags,
                    RawType          = prop.Type
                };

                properties.Add(property);
            }

            this.Name  = dataTable.NetTableName;
            this.IsEnd = dataTable.IsEnd;
        }
        void FlattenDataTable(int serverClassIndex)
        {
            SendTable table = DataTables[ServerClasses[serverClassIndex].DataTableID];

            CurrentExcludes.Clear();
            CurrentBaseclasses = new List <ServerClass> ();            //NOT .clear because we use *this* reference
            //LITERALLY 3 lines later. @main--, this is warning for you.

            GatherExcludesAndBaseclasses(table, true);

            ServerClasses [serverClassIndex].BaseClasses = CurrentBaseclasses;

            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.HasFlagFast(SendPropertyFlags.ChangesOften)))
                        {
                            if (start != currentProp)
                            {
                                FlattenedPropEntry temp = flattenedProps[start];
                                flattenedProps[start]       = flattenedProps[currentProp];
                                flattenedProps[currentProp] = temp;
                            }

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

                    if (currentProp == flattenedProps.Count)
                    {
                        break;
                    }
                }
            }
        }
        void GatherProps_IterateProps(SendTable table, int ServerClassIndex, List <FlattenedPropEntry> flattenedProps, string prefix)
        {
            for (int i = 0; i < table.Properties.Count; i++)
            {
                SendTableProperty property = table.Properties[i];

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

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

                    if (property.Flags.HasFlagFast(SendPropertyFlags.Collapsible))
                    {
                        //we don't prefix Collapsible stuff, since it is just derived mostly
                        GatherProps_IterateProps(subTable, ServerClassIndex, flattenedProps, prefix);
                    }
                    else
                    {
                        //We do however prefix everything else

                        string nfix = prefix + ((property.Name.Length > 0) ? property.Name + "." : "");

                        GatherProps(subTable, ServerClassIndex, nfix);
                    }
                }
                else
                {
                    if (property.Type == SendPropertyType.Array)
                    {
                        flattenedProps.Add(new FlattenedPropEntry(prefix + property.Name, property, table.Properties[i - 1]));
                    }
                    else
                    {
                        flattenedProps.Add(new FlattenedPropEntry(prefix + property.Name, property, null));
                    }
                }
            }
        }
 bool IsPropExcluded(SendTable table, SendTableProperty prop)
 {
     return(CurrentExcludes.Exists(a => table.Name == a.DTName && prop.Name == a.VarName));
 }
Exemple #5
0
 public FlattenedPropEntry(string propertyName, SendTableProperty prop, SendTableProperty arrayElementProp)
 {
     this.Prop             = prop;
     this.ArrayElementProp = arrayElementProp;
     this.PropertyName     = propertyName;
 }