internal int GetItemCount() { int itemCount = 0; if (_stream.CanRead) { _stream.Position = 0; } _header = (SSEHeader)BinaryFileHelper.Read(_stream, typeof(SSEHeader)); if (_header.ItemCount > 0) { return itemCount = Convert.ToInt32(_header.ItemCount); } return itemCount; }
/// <summary> /// Verify whether file items_730.bin is valid /// </summary> /// <param name="stream" type="System.IO.Stream"> /// <para> /// Stream of items_730.bin /// </para> /// </param> /// /// <returns> /// True if file is valid, false otherwise /// </returns> internal bool VerifyHeader(Stream file) { try { using (file) { _header = (SSEHeader)BinaryFileHelper.Read(file, typeof(SSEHeader)); } if (_header.FileHeader.Equals("SSEItem", StringComparison.CurrentCulture) && _header.ItemCount > 0) { return true; } else { return false; } } catch (Exception e) { return false; } }
public static void WriteDefaultValues() { SSEHeader header = new SSEHeader(); ItemData dataHeader = new ItemData(); header.FileHeader = "SSEItem"; header.ItemCount = 4; List<ItemAttribute> attribsWeapon1 = new List<ItemAttribute>(); ItemAttribute attribWeapon1 = new ItemAttribute(); attribWeapon1.Id = 6; attribWeapon1.ValueByte = 266.0f; attribsWeapon1.Add(attribWeapon1); attribWeapon1 = new ItemAttribute(); attribWeapon1.Id = 80; attribWeapon1.ValueByte = 0; attribsWeapon1.Add(attribWeapon1); attribWeapon1 = new ItemAttribute(); attribWeapon1.Id = 81; attribWeapon1.ValueByte = 0; attribsWeapon1.Add(attribWeapon1); List<ItemAttribute> attribsWeapon2 = new List<ItemAttribute>(); ItemAttribute attribWeapon2 = new ItemAttribute(); attribWeapon2.Id = 6; attribWeapon2.ValueByte = BitConverter.ToSingle(new byte[] { 0x00, 0x00, 0x16, 0x42 }, 0); attribsWeapon2.Add(attribWeapon2); attribWeapon2 = new ItemAttribute(); attribWeapon2.Id = 80; attribWeapon2.ValueByte = 0; attribsWeapon2.Add(attribWeapon2); attribWeapon2 = new ItemAttribute(); attribWeapon2.Id = 82; attribWeapon2.ValueByte = 0; attribsWeapon2.Add(attribWeapon2); List<ItemAttribute> attribsMusic = new List<ItemAttribute>(); ItemAttribute attribMusic = new ItemAttribute(); attribMusic.Id = 113; attribMusic.ValueByte = 5; attribsMusic.Add(attribMusic); List<ItemAttribute> attribsSticker = new List<ItemAttribute>(); ItemAttribute attribSticker = new ItemAttribute(); attribSticker.Id = 166; attribSticker.ValueByte = 3; attribsSticker.Add(attribSticker); using (Stream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { // id, inventory, quality, rarity, level, def_index, {attrs} Write(stream, header); // weapons 0 0 4 2 1 4 6=00008543 80=00000000 81=00000000 CreateItem(4, 4, 2, 1, attribsWeapon1, stream, dataHeader); // weapon 0 0 4 2 1 16 6=00001642 80=00000000 81=00000000 CreateItem(16, 4, 2, 1, attribsWeapon2, stream, dataHeader); // sticker 0 0 0 0 0 1209 113=02000000 CreateItem(1209, 0, 0, 0, attribsMusic, stream, dataHeader); // music kit 0 0 0 0 0 1314 166=03000000 CreateItem(1314, 0, 0, 0, attribsSticker, stream, dataHeader); } }