From 380db44583df7abdafb2dfa18d89017dae88d39b Mon Sep 17 00:00:00 2001 From: Spp Date: Tue, 2 Oct 2012 12:17:42 +0200 Subject: Core/Utilities: Use generic templates with AddPct, ApplyPct and CalculatePct --- src/server/shared/Utilities/Util.h | 54 +++++++------------------------------- 1 file changed, 9 insertions(+), 45 deletions(-) (limited to 'src/server/shared/Utilities/Util.h') diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index a574020f878..1785df70a05 100755 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -114,58 +114,22 @@ inline void ApplyPercentModFloatVar(float& var, float val, bool apply) } // Percentage calculation -template -inline T CalculatePctF(T base, float pct) -{ - return T(base * pct / 100.0f); -} - -template -inline T CalculatePctN(T base, int32 pct) -{ - return T(base * float(pct) / 100.0f); -} - -template -inline T CalculatePctU(T base, uint32 pct) +template +inline T CalculatePct(T base, U pct) { - return T(base * float(pct) / 100.0f); + return T(base * static_cast(pct) / 100.0f); } -template -inline T AddPctF(T& base, float pct) -{ - return base += CalculatePctF(base, pct); -} - -template -inline T AddPctN(T& base, int32 pct) +template +inline T AddPct(T &base, U pct) { - return base += CalculatePctN(base, pct); + return base += CalculatePct(base, pct); } -template -inline T AddPctU(T& base, uint32 pct) -{ - return base += CalculatePctU(base, pct); -} - -template -inline T ApplyPctF(T& base, float pct) -{ - return base = CalculatePctF(base, pct); -} - -template -inline T ApplyPctN(T& base, int32 pct) -{ - return base = CalculatePctN(base, pct); -} - -template -inline T ApplyPctU(T& base, uint32 pct) +template +inline T ApplyPct(T &base, U pct) { - return base = CalculatePctU(base, pct); + return base = CalculatePct(base, pct); } template -- cgit v1.2.3