private MutableStringTable InitNewTable(int id, SvcCreateStringTable creationInfo) { var table = new MutableStringTable(id, creationInfo); _privateTables.Add(table); Tables[creationInfo.TableName] = table; TableReadable[creationInfo.TableName] = true; return(table); }
internal void CreateTablesFromPacket(StringTables tablesPacket) { _privateTables.Clear(); TableReadable.Clear(); bool useCreationLookup = CreationLookup.Any(); try { foreach (StringTable table in tablesPacket.Tables) { MutableStringTable newTable; if (useCreationLookup) { int tableId = CreationLookup.FindIndex(info => info.TableName == table.Name); newTable = InitNewTable(tableId, CreationLookup[tableId]); } else { // create fake creation info SvcCreateStringTable fakeInfo = new SvcCreateStringTable(null) { TableName = table.Name, MaxEntries = -1, Flags = StringTableFlags.Fake, UserDataFixedSize = false, UserDataSize = -1, UserDataSizeBits = -1 }; // SvcServerInfo wasn't parsed correctly, assume i is the proper table ID newTable = CreateStringTable(fakeInfo); } table.MaxEntries = newTable.MaxEntries; if (table.TableEntries != null) { foreach (StringTableEntry entry in table.TableEntries) { AddTableEntry(newTable, entry?.EntryData?.CreateCopy(), entry.Name); } } if (table.Classes != null) { foreach (MutableStringTableClass tableClass in newTable.Classes) { AddTableClass(newTable, tableClass.Name, tableClass.Data); } } } } catch (Exception e) { _demoRef.LogError($"error while converting tables packet to c_tables: {e.Message}"); TableReadable.Keys.ToList().ForEach(s => TableReadable[s] = false); } }
public MutableStringTable(int id, SvcCreateStringTable creationInfo) { Id = id; Name = creationInfo.TableName; MaxEntries = creationInfo.MaxEntries; UserDataFixedSize = creationInfo.UserDataFixedSize; UserDataSize = creationInfo.UserDataSize; UserDataSizeBits = creationInfo.UserDataSizeBits; Flags = creationInfo.Flags; Entries = new List <MutableStringTableEntry>(); EntryToIndex = new Dictionary <string, int>(); Classes = new List <MutableStringTableClass>(); }
internal MutableStringTable CreateStringTable(SvcCreateStringTable creationInfo) { CreationLookup.Add(creationInfo); TableReadable[creationInfo.TableName] = true; return(InitNewTable(_privateTables.Count, creationInfo)); }