- Modified pc_percent_heal to avoid overflow problems.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5718 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2006-03-23 18:21:36 +00:00
parent e2fb7fab5c
commit 6eb8f2196f
2 changed files with 28 additions and 18 deletions

View File

@ -5,6 +5,7 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EV
GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
2006/03/23
* Modified the function pc_percent_heal to prevent overflow problems. [Skotlex]
* Changed the second entry in the water_height.txt listing to specify
directly the .rsw file (instead of .gat). [Skotlex]
* Fixed Potion Pitcher sometimes crashing the server. [Skotlex]

View File

@ -5224,7 +5224,7 @@ int pc_heal(struct map_session_data *sd,int hp,int sp)
// if(sp > 0 && pc_checkoversp(sd))
// sp = 0;
if(sd->sc.count && sd->sc.data[SC_BERSERK].timer!=-1) //バ?サ?ク中は回復させないらしい
if(sd->sc.count && sd->sc.data[SC_BERSERK].timer!=-1 && hp+sp>0)
return 0;
if(hp > sd->status.max_hp - sd->status.hp)
@ -5324,7 +5324,7 @@ int pc_itemheal(struct map_session_data *sd,int hp,int sp)
int pc_percentheal(struct map_session_data *sd,int hp,int sp)
{
nullpo_retr(0, sd);
/* Shouldn't be needed, these functions are proof of bad coding xP
if(pc_checkoverhp(sd)) {
if(hp > 0)
hp = 0;
@ -5333,38 +5333,47 @@ int pc_percentheal(struct map_session_data *sd,int hp,int sp)
if(sp > 0)
sp = 0;
}
*/
if(hp) {
if(hp >= 100) {
if(hp >= 100)
sd->status.hp = sd->status.max_hp;
}
else if(hp <= -100) {
sd->status.hp = 0;
pc_damage(NULL,sd,1);
}
else {
sd->status.hp += sd->status.max_hp*hp/100;
if(sd->status.hp > sd->status.max_hp)
else if (hp > 0) {
hp = sd->status.max_hp*hp/100;
if (sd->status.max_hp - sd->status.hp < hp)
sd->status.hp = sd->status.max_hp;
if(sd->status.hp <= 0) {
else
sd->status.hp += hp;
}
else { //hp < 0
hp = sd->status.max_hp*hp/100;
if (sd->status.hp <= hp) {
sd->status.hp = 0;
pc_damage(NULL,sd,1);
hp = 0;
}
} else
sd->status.hp -= hp;
}
}
if(sp) {
if(sp >= 100) {
if(sp >= 100)
sd->status.sp = sd->status.max_sp;
}
else if(sp <= -100) {
else if(sp <= -100)
sd->status.sp = 0;
}
else {
sd->status.sp += sd->status.max_sp*sp/100;
if(sd->status.sp > sd->status.max_sp)
else if(sp > 0) {
sp = sd->status.max_sp*sp/100;
if (sd->status.max_sp - sd->status.sp < sp)
sd->status.sp = sd->status.max_sp;
if(sd->status.sp < 0)
else
sd->status.sp += sp;
} else { //sp < 0
sp = sd->status.max_sp*sp/100;
if (sd->status.sp <= sp)
sd->status.sp = 0;
else
sd->status.sp -= sp;
}
}
if(hp)