Skip to content

Commit 2b33dc0

Browse files
kphoenix137glebm
authored andcommitted
Add hp_mana_units.hpp helper
1 parent 5937734 commit 2b33dc0

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Source/utils/hp_mana_units.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
namespace devilution {
4+
5+
constexpr int HpManaFracBits = 6;
6+
constexpr int HpManaScale = 1 << HpManaFracBits;
7+
8+
constexpr int HpManaToFrac(int whole)
9+
{
10+
return whole * HpManaScale;
11+
}
12+
13+
constexpr int HpManaToWhole(int frac)
14+
{
15+
return frac / HpManaScale;
16+
}
17+
18+
constexpr int HpManaFromParts(int whole, int frac)
19+
{
20+
return HpManaToFrac(whole) + frac;
21+
}
22+
23+
} // namespace devilution

0 commit comments

Comments
 (0)