Explorar o código

Changed `rnd()` to return signed number to avoid possible negative-signed to unsigned comparisons (caused by r15483, bugreport:5254).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15498 54d463be-8e91-2dee-dedb-b68131a5f0ec
gepard1984 %!s(int64=13) %!d(string=hai) anos
pai
achega
5e32b5948b
Modificáronse 2 ficheiros con 4 adicións e 4 borrados
  1. 3 3
      src/common/random.c
  2. 1 1
      src/common/random.h

+ 3 - 3
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();
 }
 
 

+ 1 - 1
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)