From 95548cb1caad95933e2b36df9a13af070b733b04 Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Tue, 17 Jan 2012 18:06:34 +0000 Subject: 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 --- src/map/pet.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/map/pet.c') diff --git a/src/map/pet.c b/src/map/pet.c index d067b133f..43c3bcb5c 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -5,6 +5,7 @@ #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/malloc.h" +#include "../common/random.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/utils.h" @@ -109,7 +110,7 @@ int pet_attackskill(struct pet_data *pd, int target_id) if (DIFF_TICK(pd->ud.canact_tick, gettick()) > 0) return 0; - if (rand()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000)) + if (rnd()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000)) { //Skotlex: Use pet's skill bl=map_id2bl(target_id); if(bl == NULL || pd->bl.m != bl->m || bl->prev == NULL || status_isdead(bl) || @@ -159,9 +160,9 @@ int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type) if(pd->petDB->defence_attack_rate > 0 && rate <= 0) rate = 1; } - if(rand()%10000 < rate) + if(rnd()%10000 < rate) { - if(pd->target_id == 0 || rand()%10000 < pd->petDB->change_target_rate) + if(pd->target_id == 0 || rnd()%10000 < pd->petDB->change_target_rate) pd->target_id = bl->id; } @@ -283,7 +284,7 @@ static int pet_performance(struct map_session_data *sd, struct pet_data *pd) val = 1; pet_stop_walking(pd,2000<<8); - clif_pet_performance(pd, rand()%val + 1); + clif_pet_performance(pd, rnd()%val + 1); pet_lootitem_drop(pd,NULL); return 1; } @@ -521,7 +522,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) if(battle_config.pet_catch_rate != 100) pet_catch_rate = (pet_catch_rate*battle_config.pet_catch_rate)/100; - if(rand()%10000 < pet_catch_rate) + if(rnd()%10000 < pet_catch_rate) { unit_remove_map(&md->bl,CLR_OUTSIGHT); status_kill(&md->bl); @@ -787,7 +788,7 @@ static int pet_randomwalk(struct pet_data *pd,unsigned int tick) int i,x,y,c,d=12-pd->move_fail_count; if(d<5) d=5; for(i=0;ibl.x+r%(d*2+1)-d; y=pd->bl.y+r/(d*2+1)%(d*2+1)-d; if(map_getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit_walktoxy(&pd->bl,x,y,0)){ @@ -810,7 +811,7 @@ static int pet_randomwalk(struct pet_data *pd,unsigned int tick) else c+=pd->status.speed; } - pd->next_walktime = tick+rand()%3000+3000+c; + pd->next_walktime = tick+rnd()%3000+3000+c; return 1; } -- cgit v1.2.3-70-g09d2