1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-04-28 07:09:06 +02:00

don't allow adding a flag with value 0 using AddFlag

This commit is contained in:
Ell 2021-09-22 21:32:34 +02:00
parent 81dcbfb9a1
commit e620ed0d87

View file

@ -146,9 +146,9 @@ namespace MLEM.Data {
/// <typeparam name="T">The type to add this value to</typeparam>
/// <returns>The newly created enum value</returns>
public static T AddFlag<T>(string name) where T : DynamicEnum {
BigInteger value = 0;
BigInteger value = 1;
while (GetStorage(typeof(T)).Values.ContainsKey(value))
value = value != 0 ? value << 1 : 1;
value <<= 1;
return Add<T>(name, value);
}