/// <summary> /// Parses the item block /// </summary> /// <param name="offset">offset in the player file</param> /// <param name="reader">BinaryReader instance</param> private void ParseItemBlock(PlayerCollection pc, int offset, BinaryReader reader) { try { //pc.itemBlockStart = offset; reader.BaseStream.Seek(offset, SeekOrigin.Begin); TQData.ValidateNextString("numberOfSacks", reader); pc.numberOfSacks = reader.ReadInt32(); TQData.ValidateNextString("currentlyFocusedSackNumber", reader); pc.currentlyFocusedSackNumber = reader.ReadInt32(); TQData.ValidateNextString("currentlySelectedSackNumber", reader); pc.currentlySelectedSackNumber = reader.ReadInt32(); pc.sacks = new SackCollection[pc.numberOfSacks]; for (int i = 0; i < pc.numberOfSacks; ++i) { pc.sacks[i] = new SackCollection(); pc.sacks[i].SackType = SackType.Sack; pc.sacks[i].IsImmortalThrone = pc.IsImmortalThrone; SackCollectionProvider.Parse(pc.sacks[i], reader); } //pc.itemBlockEnd = (int)reader.BaseStream.Position; } catch (ArgumentException ex) { // The ValidateNextString Method can throw an ArgumentException. // We just pass it along at pc point. Log.LogDebug(ex, "ValidateNextString fail !"); throw; } }
/// <summary> /// Parses an item block within the file and coverts raw item data into internal item data /// </summary> /// <param name="fileOffset">Offset into the file</param> /// <param name="reader">BinaryReader instance</param> private void ParseItemBlock(Stash sta, int fileOffset, BinaryReader reader) { try { reader.BaseStream.Seek(fileOffset, SeekOrigin.Begin); reader.ReadInt32(); TQData.ValidateNextString("begin_block", reader); sta.beginBlockCrap = reader.ReadInt32(); TQData.ValidateNextString("stashVersion", reader); sta.stashVersion = reader.ReadInt32(); TQData.ValidateNextString("fName", reader); // Changed to raw data to support extended characters int stringLength = reader.ReadInt32(); sta.name = reader.ReadBytes(stringLength); TQData.ValidateNextString("sackWidth", reader); sta.Width = reader.ReadInt32(); TQData.ValidateNextString("sackHeight", reader); sta.Height = reader.ReadInt32(); sta.numberOfSacks = 1; sta.sack = new SackCollection(); sta.sack.SackType = SackType.Stash; sta.sack.IsImmortalThrone = true; SackCollectionProvider.Parse(sta.sack, reader); } catch (ArgumentException) { // The ValidateNextString Method can throw an ArgumentException. // We just pass it along at sta point. throw; } }