summaryrefslogtreecommitdiff
path: root/src/map/homunculus.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/homunculus.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/homunculus.c')
-rw-r--r--src/map/homunculus.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 31cb5b012..d7f1c5f0c 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -7,6 +7,7 @@
#include "../common/timer.h"
#include "../common/nullpo.h"
#include "../common/mmo.h"
+#include "../common/random.h"
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/utils.h"
@@ -38,10 +39,6 @@
#include <string.h>
#include <math.h>
-
-//Better equiprobability than rand()% [orn]
-#define rand(a, b) (a+(int) ((float)(b-a+1)*rand()/(RAND_MAX+1.0)))
-
struct s_homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS]; //[orn]
struct skill_tree_entry hskill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE];
@@ -233,14 +230,14 @@ int merc_hom_levelup(struct homun_data *hd)
max = &hd->homunculusDB->gmax;
min = &hd->homunculusDB->gmin;
- growth_max_hp = rand(min->HP, max->HP);
- growth_max_sp = rand(min->SP, max->SP);
- growth_str = rand(min->str, max->str);
- growth_agi = rand(min->agi, max->agi);
- growth_vit = rand(min->vit, max->vit);
- growth_dex = rand(min->dex, max->dex);
- growth_int = rand(min->int_,max->int_);
- growth_luk = rand(min->luk, max->luk);
+ growth_max_hp = rnd_value(min->HP, max->HP);
+ growth_max_sp = rnd_value(min->SP, max->SP);
+ growth_str = rnd_value(min->str, max->str);
+ growth_agi = rnd_value(min->agi, max->agi);
+ growth_vit = rnd_value(min->vit, max->vit);
+ growth_dex = rnd_value(min->dex, max->dex);
+ growth_int = rnd_value(min->int_,max->int_);
+ growth_luk = rnd_value(min->luk, max->luk);
//Aegis discards the decimals in the stat growth values!
growth_str-=growth_str%10;
@@ -308,14 +305,14 @@ int merc_hom_evolution(struct homun_data *hd)
hom = &hd->homunculus;
max = &hd->homunculusDB->emax;
min = &hd->homunculusDB->emin;
- hom->max_hp += rand(min->HP, max->HP);
- hom->max_sp += rand(min->SP, max->SP);
- hom->str += 10*rand(min->str, max->str);
- hom->agi += 10*rand(min->agi, max->agi);
- hom->vit += 10*rand(min->vit, max->vit);
- hom->int_+= 10*rand(min->int_,max->int_);
- hom->dex += 10*rand(min->dex, max->dex);
- hom->luk += 10*rand(min->luk, max->luk);
+ hom->max_hp += rnd_value(min->HP, max->HP);
+ hom->max_sp += rnd_value(min->SP, max->SP);
+ hom->str += 10*rnd_value(min->str, max->str);
+ hom->agi += 10*rnd_value(min->agi, max->agi);
+ hom->vit += 10*rnd_value(min->vit, max->vit);
+ hom->int_+= 10*rnd_value(min->int_,max->int_);
+ hom->dex += 10*rnd_value(min->dex, max->dex);
+ hom->luk += 10*rnd_value(min->luk, max->luk);
hom->intimacy = 500;
unit_remove_map(&hd->bl, CLR_OUTSIGHT);
@@ -651,7 +648,7 @@ int merc_call_homunculus(struct map_session_data *sd)
struct homun_data *hd;
if (!sd->status.hom_id) //Create a new homun.
- return merc_create_homunculus_request(sd, HM_CLASS_BASE + rand(0, 7)) ;
+ return merc_create_homunculus_request(sd, HM_CLASS_BASE + rnd_value(0, 7)) ;
// If homunc not yet loaded, load it
if (!sd->hd)
@@ -859,14 +856,14 @@ int merc_hom_shuffle(struct homun_data *hd)
//Evolved bonuses
struct s_homunculus *hom = &hd->homunculus;
struct h_stats *max = &hd->homunculusDB->emax, *min = &hd->homunculusDB->emin;
- hom->max_hp += rand(min->HP, max->HP);
- hom->max_sp += rand(min->SP, max->SP);
- hom->str += 10*rand(min->str, max->str);
- hom->agi += 10*rand(min->agi, max->agi);
- hom->vit += 10*rand(min->vit, max->vit);
- hom->int_+= 10*rand(min->int_,max->int_);
- hom->dex += 10*rand(min->dex, max->dex);
- hom->luk += 10*rand(min->luk, max->luk);
+ hom->max_hp += rnd_value(min->HP, max->HP);
+ hom->max_sp += rnd_value(min->SP, max->SP);
+ hom->str += 10*rnd_value(min->str, max->str);
+ hom->agi += 10*rnd_value(min->agi, max->agi);
+ hom->vit += 10*rnd_value(min->vit, max->vit);
+ hom->int_+= 10*rnd_value(min->int_,max->int_);
+ hom->dex += 10*rnd_value(min->dex, max->dex);
+ hom->luk += 10*rnd_value(min->luk, max->luk);
}
hd->homunculus.exp = exp;