summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorgepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-01-17 18:06:34 +0000
committergepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-01-17 18:06:34 +0000
commit95548cb1caad95933e2b36df9a13af070b733b04 (patch)
treeb9ce67cc8b45c6956528e5bb2935900b6d8ad441 /src/map/pc.c
parenta09cc2371ac0a2534f514a35a5637614c11f6a37 (diff)
downloadhercules-95548cb1caad95933e2b36df9a13af070b733b04.tar.gz
hercules-95548cb1caad95933e2b36df9a13af070b733b04.tar.bz2
hercules-95548cb1caad95933e2b36df9a13af070b733b04.tar.xz
hercules-95548cb1caad95933e2b36df9a13af070b733b04.zip
Enabled Mersenne Twister MT19937 as random number generator instead of standard `rand()` function (follow-up to r14865, r14870).
- It fixes issues caused by RAND_MAX being only 32k in Windows system (bugreport:1927, bugreport:86). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15483 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 52141c913..398a77b65 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -5,6 +5,7 @@
#include "../common/core.h" // get_svn_revision()
#include "../common/malloc.h"
#include "../common/nullpo.h"
+#include "../common/random.h"
#include "../common/showmsg.h"
#include "../common/socket.h" // session[]
#include "../common/strlib.h" // safestrncpy()
@@ -4201,7 +4202,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int lv)
// Try dropping one item, in the order from first to last possible slot.
// Droprate is affected by the skill success rate.
for( i = 0; i < MAX_STEAL_DROP; i++ )
- if( md->db->dropitem[i].nameid > 0 && itemdb_exists(md->db->dropitem[i].nameid) && rand() % 10000 < md->db->dropitem[i].p * rate/100. )
+ if( md->db->dropitem[i].nameid > 0 && itemdb_exists(md->db->dropitem[i].nameid) && rnd() % 10000 < md->db->dropitem[i].p * rate/100. )
break;
if( i == MAX_STEAL_DROP )
return 0;
@@ -4258,8 +4259,8 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *target)
skill = pc_checkskill(sd,RG_STEALCOIN)*10;
rate = skill + (sd->status.base_level - md->level)*3 + sd->battle_status.dex*2 + sd->battle_status.luk*2;
- if(rand()%1000 < rate) {
- pc_getzeny(sd,md->level*10 + rand()%100);
+ if(rnd()%1000 < rate) {
+ pc_getzeny(sd,md->level*10 + rnd()%100);
md->state.steal_coin_flag = 1;
return 1;
}
@@ -4371,8 +4372,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
if( x == 0 && y == 0 )
{// pick a random walkable cell
do {
- x=rand()%(map[m].xs-2)+1;
- y=rand()%(map[m].ys-2)+1;
+ x=rnd()%(map[m].xs-2)+1;
+ y=rnd()%(map[m].ys-2)+1;
} while(map_getcell(m,x,y,CELL_CHKNOPASS));
}
@@ -4438,8 +4439,8 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type)
return 0;
do{
- x=rand()%(map[m].xs-2)+1;
- y=rand()%(map[m].ys-2)+1;
+ x=rnd()%(map[m].xs-2)+1;
+ y=rnd()%(map[m].ys-2)+1;
}while(map_getcell(m,x,y,CELL_CHKNOPASS) && (i++)<1000 );
if (i < 1000)
@@ -6177,8 +6178,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
}
}
if(eq_num > 0){
- int n = eq_n[rand()%eq_num];
- if(rand()%10000 < per){
+ int n = eq_n[rnd()%eq_num];
+ if(rnd()%10000 < per){
if(sd->status.inventory[n].equip)
pc_unequipitem(sd,n,3);
pc_dropitem(sd,n,1);
@@ -6188,7 +6189,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
else if(id > 0){
for(i=0;i<MAX_INVENTORY;i++){
if(sd->status.inventory[i].nameid == id
- && rand()%10000 < per
+ && rnd()%10000 < per
&& ((type == 1 && !sd->status.inventory[i].equip)
|| (type == 2 && sd->status.inventory[i].equip)
|| type == 3) ){