From 2b33dc09080f94873bbae55dca364fdd1db92a3d Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Mon, 5 Jan 2026 01:00:53 -0500 Subject: [PATCH] Add hp_mana_units.hpp helper --- Source/utils/hp_mana_units.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Source/utils/hp_mana_units.hpp diff --git a/Source/utils/hp_mana_units.hpp b/Source/utils/hp_mana_units.hpp new file mode 100644 index 000000000..d20ed8af2 --- /dev/null +++ b/Source/utils/hp_mana_units.hpp @@ -0,0 +1,23 @@ +#pragma once + +namespace devilution { + +constexpr int HpManaFracBits = 6; +constexpr int HpManaScale = 1 << HpManaFracBits; + +constexpr int HpManaToFrac(int whole) +{ + return whole * HpManaScale; +} + +constexpr int HpManaToWhole(int frac) +{ + return frac / HpManaScale; +} + +constexpr int HpManaFromParts(int whole, int frac) +{ + return HpManaToFrac(whole) + frac; +} + +} // namespace devilution