mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
62d08d7c30
split some methods with optional parameters=null add more xmldoc replace some magic numbers -> enum/const references consolidate common array operations (span soon maybe?)
21 lines
No EOL
653 B
C#
21 lines
No EOL
653 B
C#
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Utility logic for dealing with bitflags in a byte array.
|
|
/// </summary>
|
|
public static class FlagUtil
|
|
{
|
|
public static bool GetFlag(byte[] arr, int offset, int bitIndex)
|
|
{
|
|
bitIndex &= 7; // ensure bit access is 0-7
|
|
return (arr[offset] >> bitIndex & 1) != 0;
|
|
}
|
|
|
|
public static void SetFlag(byte[] arr, int offset, int bitIndex, bool value)
|
|
{
|
|
bitIndex &= 7; // ensure bit access is 0-7
|
|
arr[offset] &= (byte)~(1 << bitIndex);
|
|
arr[offset] |= (byte)((value ? 1 : 0) << bitIndex);
|
|
}
|
|
}
|
|
} |