diff options
author | malufett <malufett.eat.my.binaries@gmail.com> | 2013-02-22 02:12:01 +0800 |
---|---|---|
committer | malufett <malufett.eat.my.binaries@gmail.com> | 2013-02-22 02:12:01 +0800 |
commit | 84926b94e869a19f08a7a25df15b4c677316cd32 (patch) | |
tree | c5cbb9b292d4a4224570aad9b7bda9fb4ada3be4 /src | |
parent | 064dad8c094d9c694a73a0110189932c9ab4f257 (diff) | |
download | hercules-84926b94e869a19f08a7a25df15b4c677316cd32.tar.gz hercules-84926b94e869a19f08a7a25df15b4c677316cd32.tar.bz2 hercules-84926b94e869a19f08a7a25df15b4c677316cd32.tar.xz hercules-84926b94e869a19f08a7a25df15b4c677316cd32.zip |
Fixed Bug #6708
-Where leveling homunculus causes map server to crash due to infinite loop.
Signed-off-by: malufett <malufett.eat.my.binaries@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 11 | ||||
-rw-r--r-- | src/map/homunculus.c | 13 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0d56ce9bf..dbf66b6aa 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6884,7 +6884,7 @@ ACMD_FUNC(showmobs) ACMD_FUNC(homlevel) { TBL_HOM * hd; - int level = 0, i = 0; + int level = 0; nullpo_retr(-1, sd); @@ -6900,10 +6900,13 @@ ACMD_FUNC(homlevel) hd = sd->hd; - for (i = 1; i <= level && hd->exp_next; i++){ + if ( battle_config.hom_max_level == hd->homunculus.level ) // Already reach maximum level + return 0; + + do{ hd->homunculus.exp += hd->exp_next; - merc_hom_levelup(hd); - } + }while( hd->homunculus.level < level && merc_hom_levelup(hd) ); + status_calc_homunculus(hd,0); status_percent_heal(&hd->bl, 100, 100); clif_specialeffect(&hd->bl,568,AREA); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 9a0a1c898..4dc30934d 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -503,11 +503,7 @@ int merc_hom_gainexp(struct homun_data *hd,int exp) } //levelup - do - { - merc_hom_levelup(hd) ; - } - while(hd->homunculus.exp > hd->exp_next && hd->exp_next != 0 ); + while( hd->homunculus.exp > hd->exp_next && merc_hom_levelup(hd) ); if( hd->exp_next == 0 ) hd->homunculus.exp = 0 ; @@ -983,7 +979,7 @@ void merc_reset_stats(struct homun_data *hd) int merc_hom_shuffle(struct homun_data *hd) { struct map_session_data *sd; - int lv, i, skillpts; + int lv, skillpts; unsigned int exp; struct s_skill b_skill[MAX_HOMUNSKILL]; @@ -998,10 +994,9 @@ int merc_hom_shuffle(struct homun_data *hd) //Reset values to level 1. merc_reset_stats(hd); //Level it back up - for (i = 1; i < lv && hd->exp_next; i++){ + do{ hd->homunculus.exp += hd->exp_next; - merc_hom_levelup(hd); - } + }while( hd->homunculus.level < lv && merc_hom_levelup(hd) ); if(hd->homunculus.class_ == hd->homunculusDB->evo_class) { //Evolved bonuses |