/// <summary> /// For deserializing from playerskilltable.tbl. /// </summary> public DataSection(BinaryReader reader, SkillModes game) { // Reduce ths ize of Values by 1 if we're dealing with a game with "level 0." We can just auto-write level 1 to the dummy level slot instead of needing the user to manually specify it. int numberOfValues = DataSectionTypeLookup[game] == DataSectionTypes.DummyLevel ? NumberOfLevelsLookup[game] - 1 : NumberOfLevelsLookup[game]; Type = reader.ReadInt32(); for (int valueIndex = 0; valueIndex < numberOfValues; valueIndex += 1) { Values.Add(reader.ReadInt32()); } }
public void Serialize(BinaryWriter writer, SkillModes game) { foreach (var section in this) { section.Serialize(writer); } int numberOfNullSections = DataSection.NumberOfDataSectionsLookup[game] - Count; for (int nullSection = 0; nullSection < numberOfNullSections; nullSection += 1) { for (int place = 0; place < 1 + DataSection.NumberOfLevelsLookup[game]; place += 1) { writer.Write(0); } } }
/// <summary> /// For deserializing data sections from playerskilltable.tbl. /// </summary> public DataSections(BinaryReader reader, SkillModes game) { for (int dataSectionIndex = 0; dataSectionIndex < DataSection.NumberOfDataSectionsLookup[game]; dataSectionIndex += 1) { int type = reader.ReadInt32(); // Skip over the rest of this if this is a null data section. if (type == 0x0) { reader.ReadBytes(4 * DataSection.NumberOfLevelsLookup[game]); } else { // Jump the reader back to where we were, and construct a new data section. reader.BaseStream.Position -= 4; Add(new DataSection(reader, game)); } } }