示例#1
0
 private void SetRemake()
 {
     var ofs = Player.Personal.Offsets.ItemRemakeCollectBit;
     var data = Player.Personal.Data;
     for (int i = 0; i < CLB_Remake.Items.Count; i++)
         FlagUtil.SetFlag(data, ofs, i, CLB_Remake.GetItemChecked(i));
 }
示例#2
0
 public override byte[] Write()
 {
     for (int i = 0; i < SpecialTutors[0].Length; i++)
     {
         FlagUtil.SetFlag(Data, 0xA8 + (i >> 3), i, SpecialTutors[0][i]);
     }
     return(Data);
 }
示例#3
0
        private void B_Save_Click(object sender, EventArgs e)
        {
            var ofs  = Player.Personal.Offsets.ReceivedItems;
            var data = Player.Personal.Data;

            for (int i = 0; i < CLB_Items.Items.Count; i++)
            {
                FlagUtil.SetFlag(data, ofs, i, CLB_Items.GetItemChecked(i));
            }
            Close();
        }
示例#4
0
    public void GetSetFlag(uint raw, int byteIndex, int bitIndex)
    {
        Span <byte> data = stackalloc byte[4];

        WriteUInt32LittleEndian(data, raw);
        var value = FlagUtil.GetFlag(data, byteIndex, bitIndex);

        value.Should().Be(true);

        Span <byte> copy = stackalloc byte[data.Length];

        FlagUtil.SetFlag(copy, byteIndex, bitIndex, true);
        data.SequenceEqual(copy).Should().BeTrue();
    }
示例#5
0
 public override byte[] Write()
 {
     for (var i = 0; i < CountTR; i++)
     {
         FlagUtil.SetFlag(Data, 0x28 + (i >> 3), i, TMHM[i]);
         FlagUtil.SetFlag(Data, 0x3C + (i >> 3), i, TMHM[i + CountTM]);
     }
     for (int i = 0; i < TypeTutors.Length; i++)
     {
         FlagUtil.SetFlag(Data, 0x38, i, TypeTutors[i]);
     }
     for (int i = 0; i < SpecialTutors[0].Length; i++)
     {
         FlagUtil.SetFlag(Data, 0xA8 + (i >> 3), i, SpecialTutors[0][i]);
     }
     return(Data);
 }
示例#6
0
    private static void SaveFavorites(IEnumerable <InventoryItem> items, Span <byte> favorites)
    {
        foreach (var z in items)
        {
            var item   = (InventoryItem8a)z;
            var itemID = item.Index;
            var ofs    = itemID >> 3;
            if ((uint)ofs >= favorites.Length)
            {
                continue;
            }

            var bit   = itemID & 7;
            var value = FlagUtil.GetFlag(favorites, ofs, bit);
            value |= item.IsFavorite;
            FlagUtil.SetFlag(favorites, ofs, bit, value);
        }
    }
示例#7
0
    public void ClearFlag(uint raw, int byteIndex, int bitIndex)
    {
        Span <byte> data = stackalloc byte[4];

        WriteUInt32LittleEndian(data, raw);
        var value = FlagUtil.GetFlag(data, byteIndex, bitIndex);

        value.Should().Be(false);

        // does nothing on empty
        Span <byte> copy = stackalloc byte[data.Length];

        FlagUtil.SetFlag(copy, byteIndex, bitIndex, false);
        copy.Count((byte)0).Should().Be(copy.Length);

        // doesn't clear any other flag
        data.CopyTo(copy);
        FlagUtil.SetFlag(copy, byteIndex, bitIndex, false);
        data.SequenceEqual(copy).Should().BeTrue();
    }
示例#8
0
 public sealed override void SetFlag(int offset, int bitIndex, bool value) => FlagUtil.SetFlag(General, offset, bitIndex, value);
示例#9
0
    public void SetFlag(int index, bool value = true)
    {
        var offset = Offset + FlagStart + (index >> 3);

        FlagUtil.SetFlag(Data, offset, index, value);
    }