From 5524938f8650e659b3c838df44212de56bf72584 Mon Sep 17 00:00:00 2001 From: ultramage Date: Thu, 1 May 2008 12:14:06 +0000 Subject: Implemented get_percentage() for compact and safe calculation of percentual values. Fixed integer arithmetic overflows that were occuring in several supernovice checks (bugreport:1135). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12679 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/common/utils.h') diff --git a/src/common/utils.h b/src/common/utils.h index 21e8e090c..93563dc34 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -18,6 +18,9 @@ void findfile(const char *p, const char *pat, void (func)(const char*)); //Caps values to min/max #define cap_value(a, min, max) ((a >= max) ? max : (a <= min) ? min : a) +/// calculates the value of A / B, in percent (rounded down) +unsigned int get_percentage(const unsigned int A, const unsigned int B); + ////////////////////////////////////////////////////////////////////////// // byte word dword access [Shinomori] ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3-60-g2f50