Example #1
0
        private void GatherProps(SendTable table, int serverClassIndex, string prefix)
        {
            var tmpFlattenedProps = new List <FlattenedPropEntry>();

            GatherProps_IterateProps(table, serverClassIndex, tmpFlattenedProps, prefix);

            var flattenedProps = ServerClasses[serverClassIndex].FlattenedProps;

            flattenedProps.AddRange(tmpFlattenedProps);
        }
Example #2
0
        public void ParsePacket(IBitStream bitstream)
        {
            while (true)
            {
                var type = (SVC_Messages)bitstream.ReadProtobufVarInt();
                if (type != SVC_Messages.svc_SendTable)
                {
                    throw new Exception("Expected SendTable, got " + type);
                }

                var size = bitstream.ReadProtobufVarInt();
                bitstream.BeginChunk(size * 8);
                var sendTable = new SendTable(bitstream);
                bitstream.EndChunk();

                if (sendTable.IsEnd)
                {
                    break;
                }

                DataTables.Add(sendTable);
            }

            var serverClassCount = checked ((int)bitstream.ReadInt(16));

            for (var i = 0; i < serverClassCount; i++)
            {
                var entry = new ServerClass();
                entry.ClassID = checked ((int)bitstream.ReadInt(16));

                if (entry.ClassID > serverClassCount)
                {
                    throw new Exception("Invalid class index");
                }

                entry.Name   = bitstream.ReadDataTableString();
                entry.DTName = bitstream.ReadDataTableString();

                entry.DataTableID = DataTables.FindIndex(a => a.Name == entry.DTName);

                ServerClasses.Add(entry);
            }

            for (var i = 0; i < serverClassCount; i++)
            {
                FlattenDataTable(i);
            }
        }
Example #3
0
        private void GatherProps_IterateProps(SendTable table, int ServerClassIndex,
                                              List <FlattenedPropEntry> flattenedProps, string prefix)
        {
            for (var i = 0; i < table.Properties.Count; i++)
            {
                var property = table.Properties[i];

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

                if (property.Type == SendPropertyType.DataTable)
                {
                    var 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

                        var 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));
                    }
                }
            }
        }
Example #4
0
        private void GatherExcludesAndBaseclasses(SendTable sendTable, bool collectBaseClasses)
        {
            CurrentExcludes.AddRange(
                sendTable.Properties
                .Where(a => a.Flags.HasFlagFast(SendPropertyFlags.Exclude))
                .Select(a => new ExcludeEntry(a.Name, a.DataTableName, sendTable.Name))
                );

            foreach (var prop in sendTable.Properties.Where(a => a.Type == SendPropertyType.DataTable))
            {
                if (collectBaseClasses && prop.Name == "baseclass")
                {
                    GatherExcludesAndBaseclasses(GetTableByName(prop.DataTableName), true);
                    CurrentBaseclasses.Add(FindByDTName(prop.DataTableName));
                }
                else
                {
                    GatherExcludesAndBaseclasses(GetTableByName(prop.DataTableName), false);
                }
            }
        }
Example #5
0
 private bool IsPropExcluded(SendTable table, SendTableProperty prop)
 {
     return(CurrentExcludes.Exists(a => table.Name == a.DTName && prop.Name == a.VarName));
 }