/// <summary> /// Parses raw character stat data /// </summary> /// <param name="headerBytes">Raw characte stat data found between "gf" and "if" near offset 765 in save file</param> /// <remarks>Bit lengths of stat types are found in the CSvBits column of ItemStatCost.txt</remarks> /// Source: http://phrozenkeep.hugelaser.com/forum/viewtopic.php?f=8&t=9011&start=50 private void ReadStats() { BitStream bs = new BitStream(statsBytes); // Skip header bytes bs.SkipBits(8); bs.SkipBits(8); while (bs.RemainingBits >= 9) { // ID of stat (See ItemStatCost.txt) int statIndex = (int)bs.ReadReversed(9); // Value contains this many bits (See CSvBits in ItemStatCost.txt) int statValueBits = 0; // Value needs to be shifted by this amount int valShift = 0; // Terminating stat index if (statIndex == 0x1ff) { break; } statValueBits = ItemDefs.ItemStatCostsById[statIndex].CSvBits; if (statValueBits == 0) { break; } valShift = ItemDefs.ItemStatCostsById[(int)statIndex].ValShift; int statValue = (int)bs.ReadReversed(statValueBits); if (!statValues.ContainsKey(statIndex)) { statValues.Add(statIndex, (statValue >> valShift)); } } }