diff options
author | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-01-19 16:27:41 +0000 |
---|---|---|
committer | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-01-19 16:27:41 +0000 |
commit | 6fc8fc296c58e7a935fc6ee1d2775d02367edd95 (patch) | |
tree | 26b96b1ebbde9276b7b6d200377eb7b9a84ae61a | |
parent | c017009bbffa6a89ce55bb28387f00164538bfbc (diff) | |
download | hercules-6fc8fc296c58e7a935fc6ee1d2775d02367edd95.tar.gz hercules-6fc8fc296c58e7a935fc6ee1d2775d02367edd95.tar.bz2 hercules-6fc8fc296c58e7a935fc6ee1d2775d02367edd95.tar.xz hercules-6fc8fc296c58e7a935fc6ee1d2775d02367edd95.zip |
Changed `rnd()` to return signed number to avoid possible negative-signed to unsigned comparisons (caused by r15483, bugreport:5254).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15498 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | src/common/random.c | 6 | ||||
-rw-r--r-- | src/common/random.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/common/random.c b/src/common/random.c index 39990f8a7..224b71fdb 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -43,10 +43,10 @@ void rnd_seed(uint32 seed) } -/// Generates a random number in the interval [0, UINT32_MAX] -uint32 rnd(void) +/// Generates a random number in the interval [0, SINT32_MAX] +int32 rnd(void) { - return (uint32)genrand_int32(); + return (int32)genrand_int31(); } diff --git a/src/common/random.h b/src/common/random.h index 59b609464..43dfd36c0 100644 --- a/src/common/random.h +++ b/src/common/random.h @@ -9,7 +9,7 @@ void rnd_init(void); void rnd_seed(uint32); -uint32 rnd(void);// [0, UINT32_MAX] +int32 rnd(void);// [0, SINT32_MAX] uint32 rnd_roll(uint32 dice_faces);// [0, dice_faces) int32 rnd_value(int32 min, int32 max);// [min, max] double rnd_uniform(void);// [0.0, 1.0) |