summaryrefslogtreecommitdiff
path: root/src/map/battle.c
diff options
context:
space:
mode:
authorDastgir <dastgirpojee@rocketmail.com>2016-03-29 19:08:01 +0530
committerDastgir <dastgirp@gmail.com>2018-08-04 10:55:07 +0530
commitdef9450e64bf13878a4ecb1650278e48e15ded20 (patch)
treec041d4cbe604200971270139a6dc3e4aa5b82763 /src/map/battle.c
parentf3b156edbdf8a09afa95c65085e4e32df3884e07 (diff)
downloadhercules-def9450e64bf13878a4ecb1650278e48e15ded20.tar.gz
hercules-def9450e64bf13878a4ecb1650278e48e15ded20.tar.bz2
hercules-def9450e64bf13878a4ecb1650278e48e15ded20.tar.xz
hercules-def9450e64bf13878a4ecb1650278e48e15ded20.zip
Fixed defense overflow exploit
* The defense penalty for being attacked by many enemies at the same time can no longer make DEF go negative * Fixed two potential overflow exploits When being hit by a lot of monsters, your DEF will become negative and then eventually overflow, making you almost invincible. On official servers the simultaneous attacker count is limited to 22. So at max, your def is reduced by ((22-2)*5%) = 100%. So it should neither be able to make your DEF negative nor cause an overflow. Merge from https://github.com/rathena/rathena/commit/590f42cd15c58de78cff8be6053109852375bce1#diff-d96b6365b4bdad78139e676d6e7e3295R4589
Diffstat (limited to 'src/map/battle.c')
-rw-r--r--src/map/battle.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index fceb30be1..16b503e9d 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -1382,6 +1382,7 @@ static int64 battle_calc_defense(int attack_type, struct block_list *src, struct
#ifndef RENEWAL
if(skill_id == AM_ACIDTERROR) def1 = 0; //Acid Terror ignores only armor defense. [Skotlex]
#endif
+ def1 = max(def1, 0);
if(def2 < 1) def2 = 1;
}
//Vitality reduction from rodatazone: http://rodatazone.simgaming.net/mechanics/substats.php#def