summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-07-27 19:06:40 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-07-27 19:06:40 +0000
commitbba15f5d17900a5e9cb85c796555f8ed1591ea2a (patch)
tree37842cee4078170b560984ffb540a1ec329e1419 /src
parente82df73e8a0d6c1757ef10a8532545ab0cd80ac4 (diff)
downloadhercules-bba15f5d17900a5e9cb85c796555f8ed1591ea2a.tar.gz
hercules-bba15f5d17900a5e9cb85c796555f8ed1591ea2a.tar.bz2
hercules-bba15f5d17900a5e9cb85c796555f8ed1591ea2a.tar.xz
hercules-bba15f5d17900a5e9cb85c796555f8ed1591ea2a.zip
* Simplified exp gain equations (now more FPU-friendly and precise), also fixes the uninitialized variable problem
* Corrected one exp calculation overflow (mainly affected high-rate pk servers) * Fixed Neuralizer item script typo git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10921 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/mob.c25
-rw-r--r--src/map/pc.c13
2 files changed, 8 insertions, 30 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 07fd60642..222f0130a 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1813,9 +1813,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
for(i = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++)
{
int flag=1,zeny=0;
- unsigned int base_exp,job_exp;
+ unsigned int base_exp, job_exp;
double per; //Your share of the mob's exp
- double jper; //For the job-exp
int bonus; //Bonus on top of your share.
if (!tmpsd[i]) continue;
@@ -1856,28 +1855,16 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if(md->db->mexp > 0)
zeny*=rand()%250;
}
- jper = per;
if (map[m].flag.nobaseexp || !md->db->base_exp)
base_exp = 0;
- else {
- if (map[m].bexp != 100)
- temp = map[m].bexp*bonus/100;
- if (temp != 100)
- per = per*temp/100.;
-
- base_exp = (unsigned int)cap_value(md->db->base_exp * per, 1, UINT_MAX);
- }
+ else
+ base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * map[m].bexp/100., 1, UINT_MAX);
+
if (map[m].flag.nojobexp || !md->db->job_exp || md->dmglog[i].flag) //Homun earned job-exp is always lost.
job_exp = 0;
- else {
- if (map[m].jexp != 100)
- temp = map[m].jexp*bonus/100;
- if (temp != 100)
- jper = jper*temp/100.;
-
- job_exp = (unsigned int)cap_value(md->db->job_exp * jper, 1, UINT_MAX);
- }
+ else
+ job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * map[m].jexp/100., 1, UINT_MAX);
if((temp = tmpsd[i]->status.party_id )>0 && !md->dmglog[i].flag) //Homun-done damage (flag 1) is not given to party
{
diff --git a/src/map/pc.c b/src/map/pc.c
index 49d880767..ad57ef809 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4230,17 +4230,8 @@ static void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsi
if (!bonus)
return;
- temp = *base_exp*bonus/100;
- if (*base_exp > UINT_MAX - temp)
- *base_exp = UINT_MAX;
- else
- *base_exp += temp;
-
- temp = *job_exp*bonus/100;
- if (*job_exp > UINT_MAX - temp)
- *job_exp = UINT_MAX;
- else
- *job_exp += temp;
+ *base_exp += (unsigned int) cap_value((double)*base_exp * bonus/100., 1, UINT_MAX);
+ *job_exp += (unsigned int) cap_value((double)*job_exp * bonus/100., 1, UINT_MAX);
return;
}