mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 14:08:34 +01:00
don't allow adding a flag with value 0 using AddFlag
This commit is contained in:
parent
81dcbfb9a1
commit
e620ed0d87
1 changed files with 2 additions and 2 deletions
|
@ -146,9 +146,9 @@ namespace MLEM.Data {
|
||||||
/// <typeparam name="T">The type to add this value to</typeparam>
|
/// <typeparam name="T">The type to add this value to</typeparam>
|
||||||
/// <returns>The newly created enum value</returns>
|
/// <returns>The newly created enum value</returns>
|
||||||
public static T AddFlag<T>(string name) where T : DynamicEnum {
|
public static T AddFlag<T>(string name) where T : DynamicEnum {
|
||||||
BigInteger value = 0;
|
BigInteger value = 1;
|
||||||
while (GetStorage(typeof(T)).Values.ContainsKey(value))
|
while (GetStorage(typeof(T)).Values.ContainsKey(value))
|
||||||
value = value != 0 ? value << 1 : 1;
|
value <<= 1;
|
||||||
return Add<T>(name, value);
|
return Add<T>(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue