public ActiveModifierRow(StringTableRow r, dota2.CDOTAModifierBuffTableEntry mod) { this.Name = r.Name; this.Value = r.Value; this.Modifier = mod; }
/// <summary> /// Parses the string table out of the binary packet /// </summary> /// <param name="stringData"></param> /// <param name="numEntries"></param> /// <returns></returns> private Dictionary <int, StringTableRow> ParseTable(byte[] stringData, int numEntries) { var stream = new BitStream(stringData); var bitsPerIndex = (int)(Math.Log(this.MaxEntries) / Math.Log(2)); var keyHistory = new KeyHistory(); var map = new Dictionary <int, StringTableRow>(); bool mysteryFlag = stream.ReadBool(); int index = -1; while (map.Count < numEntries) { // figure out if we are consecutive indexing or not if (stream.ReadBool()) { index++; } else { index = stream.ReadBits(bitsPerIndex); } var name = ""; if (stream.ReadBool()) { if (mysteryFlag && stream.ReadBool()) { throw new InvalidDataException("There's a problem with the Mystery Flags."); } // check if we're referencing the key history if (stream.ReadBool()) { // the index of the key in history they we're using int basis = stream.ReadBits(5); // the number of characters from the history key to use int length = stream.ReadBits(5); if (basis > keyHistory.Length) { // the key requested is invalid, so just use the data provided name += stream.ReadString(StringTable.MaxNameLength); } else { string s = keyHistory[basis]; if (length > s.Length) { name += s + stream.ReadString(StringTable.MaxNameLength); } else { // just use the first n characters of the history string and get the rest of the string from the stream /* * i.e. * keyHistory[basis] == "cfg/cpu_level_0_pc.txt" * length = 14 * name = "cfg/cpu_level_" + *read stream* (i.e. "1_pc.txt") */ name += s.Substring(0, length) + stream.ReadString(StringTable.MaxNameLength - length); } } } else { name += stream.ReadString(StringTable.MaxNameLength); } // add the key to the history keyHistory.Push(name); } // read the inner value byte[] value = null; if (stream.ReadBool()) { int bitLength; if (this.UserDataFixedSize) { bitLength = this.UserDataSizeBits; } else { bitLength = stream.ReadBits(14) * 8; } value = stream.ReadBytes(bitLength); } map[index] = new StringTableRow(name, value); } return(map); }
public UserInfoRow(StringTableRow r, UserInfo u) { this.Name = r.Name; this.Value = r.Value; this.Info = u; }