public List<ServerClass> GetBaseClasses(DataTable dataTable) { List<ServerClass> baseClasses = new List<ServerClass>(); for (int i = 0; i < dataTable.Properties.Count; i++) { DataTableProperty dataTableProperty = dataTable.Properties[i]; if (dataTableProperty.Name == "baseclass") { ServerClass baseClass = m_Values.Values.Single(a => a.DataTableName == dataTableProperty.DataTableName); baseClasses.Add(baseClass); } } return baseClasses; }
private List<ExcludedDataTableProperty> GetExcludedDataTableProperties(DataTable dataTable) { List<ExcludedDataTableProperty> excludedDataTableProperties = new List<ExcludedDataTableProperty>(); for (int i = 0; i < dataTable.Properties.Count; i++) { DataTableProperty dataTableProperty = dataTable.Properties[i]; if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Exclude)) { ExcludedDataTableProperty excludedDataTableProperty = new ExcludedDataTableProperty(dataTableProperty.Name, dataTableProperty.DataTableName, dataTable.Name); excludedDataTableProperties.Add(excludedDataTableProperty); } } for (int i = 0; i < dataTable.Properties.Count; i++) { DataTableProperty dataTableProperty = dataTable.Properties[i]; if (dataTableProperty.Type.HasFlag(DataTablePropertyType.DataTable)) { DataTable dataTablePropertyDataTable = m_Demo.DataTables.GetDataTable(dataTableProperty.DataTableName); List<ExcludedDataTableProperty> dataTablePropertyExcludedDataTableProperties = GetExcludedDataTableProperties(dataTablePropertyDataTable); excludedDataTableProperties.AddRange(dataTablePropertyExcludedDataTableProperties); } } return excludedDataTableProperties; }
private void SetServerClassProperties(ServerClass serverClass, DataTable dataTable, List<ServerClassProperty> serverClassProperties, string propertyNamePrefix, List<ExcludedDataTableProperty> currentExcludes) { for (int i = 0; i < dataTable.Properties.Count; i++) { DataTableProperty dataTableProperty = dataTable.Properties[i]; if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.InsideArray) || dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Exclude) || IsPropertyExcluded(dataTable, dataTableProperty, currentExcludes)) { continue; } if (dataTableProperty.Type == DataTablePropertyType.DataTable) { DataTable linkedDataTable = m_Demo.DataTables.GetDataTable(dataTableProperty.DataTableName); if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Collapsible)) { SetServerClassProperties(serverClass, linkedDataTable, serverClassProperties, propertyNamePrefix, currentExcludes); } else { string prefix = String.Format("{0}{1}", propertyNamePrefix, (dataTableProperty.Name.Length > 0) ? dataTableProperty.Name + "." : ""); SetServerClassProperties(serverClass, linkedDataTable, prefix, currentExcludes); } } else { ServerClassProperty serverClassProperty; if (dataTableProperty.Type == DataTablePropertyType.Array) { serverClassProperty = new ServerClassProperty(propertyNamePrefix + dataTableProperty.Name, dataTableProperty, dataTable.Properties[i - 1]); } else { serverClassProperty = new ServerClassProperty(propertyNamePrefix + dataTableProperty.Name, dataTableProperty, null); } serverClassProperties.Add(serverClassProperty); } } }
private void SetServerClassProperties(ServerClass serverClass, DataTable table, string propertyNamePrefix, List<ExcludedDataTableProperty> currentExcludes) { List<ServerClassProperty> newServerClassProperties = new List<ServerClassProperty>(); SetServerClassProperties(serverClass, table, newServerClassProperties, propertyNamePrefix, currentExcludes); List<ServerClassProperty> currentServerClassProperties = serverClass.Properties; currentServerClassProperties.AddRange(newServerClassProperties); }
private bool IsPropertyExcluded(DataTable dataTable, DataTableProperty dataTableProperty, List<ExcludedDataTableProperty> currentExcludes) { return currentExcludes.Exists(a => dataTable.Name == a.DataTableName && dataTableProperty.Name == a.Name); }
public void Add(DataTable dataTable) { m_Values.Add(dataTable); }
private bool ProcessTick() { DemoCommand demoCommand = (DemoCommand)m_BitStream.ReadByte(); int tickNumber = m_BitStream.ReadInt32(); int playerSlot = m_BitStream.ReadByte(); switch (demoCommand) { case DemoCommand.DataTables: { int length = m_BitStream.ReadInt32(); byte[] data = m_BitStream.ReadBytes(length); BitStream bitStream = new BitStream(data); while (true) { int dataTableType = bitStream.ReadVarint32(); int dataTablelength = bitStream.ReadVarint32(); byte[] dataTableData = bitStream.ReadBytes(dataTablelength); DataTable dataTable = new DataTable(this.DataTables.Count, dataTableData); if (dataTable.IsEnd) { break; } else { this.DataTables.Add(dataTable); } } int count = bitStream.ReadShort(); for (int i = 0; i < count; i++) { int serverClassID = bitStream.ReadShort(); string serverClassName = bitStream.ReadString(); string dataTableName = bitStream.ReadString(); DataTable dataTable = this.DataTables.GetDataTable(dataTableName); ServerClass serverClass = new ServerClass(serverClassID, serverClassName, dataTable.ID, dataTable.Name); this.ServerClasses.Add(serverClass); } this.ServerClasses.ProcessAllServerClasses(); break; } case DemoCommand.Packet: case DemoCommand.SignOn: { m_BitStream.SeekBytes(160, SeekOrigin.Current); int length = m_BitStream.ReadInt32(); byte[] data = m_BitStream.ReadBytes(length); BitStream packetReader = new BitStream(data); while (packetReader.PositionInBytes < packetReader.LengthInBytes) { int packetID = packetReader.ReadVarint32(); int packetLength = packetReader.ReadVarint32(); byte[] packetData = packetReader.ReadBytes(packetLength); PacketType packetType; if (!Enum.TryParse<PacketType>(packetID.ToString(), out packetType)) { Console.WriteLine("Unknown Packet Type: {0}", packetID); break; } this.PacketHandlers.OnPacketReceived(packetType, packetData); } break; } case DemoCommand.Stop: { return true; } case DemoCommand.StringTables: { int length = m_BitStream.ReadInt32(); byte[] data = m_BitStream.ReadBytes(length); BitStream bitStream = new BitStream(data); int stringTableCount = bitStream.ReadByte(); for (int i = 0; i < stringTableCount; i++) { string stringTableName = bitStream.ReadString(); int entryCount = bitStream.ReadUShort(); for (int j = 0; j < entryCount; j++) { string entryName = bitStream.ReadString(); bool entryHasData = bitStream.ReadBit(); byte[] entryData = null; if (entryHasData) { int entryDataLength = bitStream.ReadShort(); entryData = bitStream.ReadBytes(entryDataLength); } StringTableEntry stringTableEntry = new StringTableEntry(entryName, entryData); this.StringTables.Add(stringTableName, stringTableEntry); } bool hasExtraTableData = bitStream.ReadBit(); if (hasExtraTableData) { int extraTableDataLength = bitStream.ReadShort(); byte[] extraTableData = bitStream.ReadBytes(extraTableDataLength); } } break; } case DemoCommand.SyncTick: { break; } default: { Console.WriteLine("Unknown Demo Command: {0}", demoCommand); break; } } return false; }