summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-24 18:41:39 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-24 18:41:39 +0000
commit424d353923933ea786ce682a811f700852af08d5 (patch)
tree87d40fb512385d1c2027c3e9541f24c95876f2b5 /src/map/mob.c
parente6115fa3fdbe0e8bbdf0e55634232af1c0fd1a74 (diff)
downloadhercules-424d353923933ea786ce682a811f700852af08d5.tar.gz
hercules-424d353923933ea786ce682a811f700852af08d5.tar.bz2
hercules-424d353923933ea786ce682a811f700852af08d5.tar.xz
hercules-424d353923933ea786ce682a811f700852af08d5.zip
- The autoloot range check is no longer done unless AUTOLOOT_DISTANCE is defined (by default it is no longer defined)
- Ganbantein now deletes individual skill cells instead of the whole skill in the area it is casted. - Modified the mob total damage code to prevent overflows when mobs receive over 2kM damage. - Made the dmg structure of the damage log an unsigned int rather than signed. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10343 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 63bd76d91..9ed6f99f3 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1513,8 +1513,10 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
}
if (dlist->first_sd && dlist->first_sd->state.autoloot &&
- drop_rate <= dlist->first_sd->state.autoloot &&
- check_distance_blxy(&dlist->first_sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE)
+ drop_rate <= dlist->first_sd->state.autoloot
+#ifdef AUTOLOOT_DISTANCE
+ && check_distance_blxy(&dlist->first_sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE)
+#endif
) { //Autoloot.
if (party_share_loot(
dlist->first_sd->status.party_id?
@@ -1617,7 +1619,14 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage)
if (damage > 0)
{ //Store total damage...
- md->tdmg+=damage;
+ if (UINT_MAX - (unsigned int)damage > md->tdmg)
+ md->tdmg+=damage;
+ else if (md->tdmg == UINT_MAX)
+ damage = 0; //Stop recording damage once the cap has been reached.
+ else { //Cap damage log...
+ damage = (int)(UINT_MAX - md->tdmg);
+ md->tdmg = UINT_MAX;
+ }
if (md->state.aggressive)
{ //No longer aggressive, change to retaliate AI.
md->state.aggressive = 0;
@@ -1688,8 +1697,9 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage)
}
//Log damage...
if (char_id && damage > 0) {
- int i,minpos,mindmg;
- for(i=0,minpos=DAMAGELOG_SIZE-1,mindmg=INT_MAX;i<DAMAGELOG_SIZE;i++){
+ int i,minpos;
+ unsigned int mindmg;
+ for(i=0,minpos=DAMAGELOG_SIZE-1,mindmg=UINT_MAX;i<DAMAGELOG_SIZE;i++){
if(md->dmglog[i].id==char_id &&
md->dmglog[i].flag==flag)
break;
@@ -1811,7 +1821,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
tmpsd[i] = NULL;
continue;
}
- if(mvp_damage<(unsigned int)md->dmglog[i].dmg){
+ if(mvp_damage<md->dmglog[i].dmg){
third_sd = second_sd;
second_sd = mvp_sd;
mvp_sd=tmpsd[i];
@@ -1822,8 +1832,13 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if(!battle_config.exp_calc_type && count > 1)
{ //Apply first-attacker 200% exp share bonus
//TODO: Determine if this should go before calculating the MVP player instead of after.
- md->tdmg += md->dmglog[0].dmg;
- md->dmglog[0].dmg<<=1;
+ if (UINT_MAX - md->dmglog[0].dmg > md->tdmg) {
+ md->tdmg += md->dmglog[0].dmg;
+ md->dmglog[0].dmg<<=1;
+ } else {
+ md->dmglog[0].dmg+= UINT_MAX - md->tdmg;
+ md->tdmg = UINT_MAX;
+ }
}
if(!(type&2) && //No exp