diff options
author | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-01-17 18:06:34 +0000 |
---|---|---|
committer | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-01-17 18:06:34 +0000 |
commit | 95548cb1caad95933e2b36df9a13af070b733b04 (patch) | |
tree | b9ce67cc8b45c6956528e5bb2935900b6d8ad441 /src/map/clif.c | |
parent | a09cc2371ac0a2534f514a35a5637614c11f6a37 (diff) | |
download | hercules-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/clif.c')
-rw-r--r-- | src/map/clif.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 52bd467ec..48aca796d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8,6 +8,7 @@ #include "../common/malloc.h" #include "../common/version.h" #include "../common/nullpo.h" +#include "../common/random.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/utils.h" @@ -2082,7 +2083,7 @@ static void clif_addcards(unsigned char* buf, struct item* item) } //Client only receives four cards.. so randomly send them a set of cards. [Skotlex] if( MAX_SLOTS > 4 && (j = itemdb_slot(item->nameid)) > 4 ) - i = rand()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rand()%3; + i = rnd()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rnd()%3; //Normal items. if( item->card[i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 ) @@ -4088,8 +4089,8 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic sc = status_get_sc(dst); if(sc && sc->count) { if(sc->data[SC_HALLUCINATION]) { - if(damage) damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rand()%100; - if(damage2) damage2 = damage2*(sc->data[SC_HALLUCINATION]->val2) + rand()%100; + if(damage) damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; + if(damage2) damage2 = damage2*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; } } @@ -4744,7 +4745,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int sc = status_get_sc(dst); if(sc && sc->count) { if(sc->data[SC_HALLUCINATION] && damage) - damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rand()%100; + damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; } #if PACKETVER < 3 @@ -4833,7 +4834,7 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in if(sc && sc->count) { if(sc->data[SC_HALLUCINATION] && damage) - damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rand()%100; + damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; } WBUFW(buf,0)=0x115; @@ -9600,7 +9601,7 @@ void clif_parse_Emotion(int fd, struct map_session_data *sd) if(battle_config.client_reshuffle_dice && emoticon>=E_DICE1 && emoticon<=E_DICE6) {// re-roll dice - emoticon = rand()%6+E_DICE1; + emoticon = rnd()%6+E_DICE1; } clif_emotion(&sd->bl, emoticon); @@ -14671,7 +14672,7 @@ void clif_mercenary_updatestatus(struct map_session_data *sd, int type) { case SP_ATK1: { - int atk = rand()%(status->rhw.atk2 - status->rhw.atk + 1) + status->rhw.atk; + int atk = rnd()%(status->rhw.atk2 - status->rhw.atk + 1) + status->rhw.atk; WFIFOL(fd,4) = cap_value(atk, 0, INT16_MAX); } break; @@ -14741,7 +14742,7 @@ void clif_mercenary_info(struct map_session_data *sd) WFIFOL(fd,2) = md->bl.id; // Mercenary shows ATK as a random value between ATK ~ ATK2 - atk = rand()%(status->rhw.atk2 - status->rhw.atk + 1) + status->rhw.atk; + atk = rnd()%(status->rhw.atk2 - status->rhw.atk + 1) + status->rhw.atk; WFIFOW(fd,6) = cap_value(atk, 0, INT16_MAX); WFIFOW(fd,8) = cap_value(status->matk_max, 0, INT16_MAX); WFIFOW(fd,10) = status->hit; |