From 79c2a4b11f5f05eed9ae5535395205236f73b1e4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 4 Sep 2019 20:20:55 +0300 Subject: Extract code for really gain homun exp to separate function Also replace hardcoded message to message string. --- src/map/homunculus.c | 28 +++++++++++++++++++--------- src/map/homunculus.h | 1 + 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'src/map') diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 31744f479..bb940fd44 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -525,6 +525,21 @@ static bool homunculus_mutate(struct homun_data *hd, int homun_id) return true; } +static int homunculus_gainexp_real(struct homun_data *hd, unsigned int exp) +{ + nullpo_ret(hd); + nullpo_ret(hd->master); + + hd->homunculus.exp += exp; + + if (hd->master->state.showexp && hd->exp_next > 0) { + char output[256]; + sprintf(output, msg_fd(hd->master->fd, 449), exp, ((float)exp / (float)hd->exp_next * (float)100)); + clif_disp_onlyself(hd->master, output); + } + return 1; +} + static int homunculus_gainexp(struct homun_data *hd, unsigned int exp) { enum homun_type htype; @@ -550,16 +565,10 @@ static int homunculus_gainexp(struct homun_data *hd, unsigned int exp) break; } - hd->homunculus.exp += exp; - - if (hd->master->state.showexp && hd->exp_next > 0) { - char output[256]; - sprintf(output, "Homunculus Experience Gained Base:%u (%.2f%%)", exp, ((float)exp / (float)hd->exp_next * (float)100)); - clif_disp_onlyself(hd->master, output); - } + homun->gainexp_real(hd, exp); - if(hd->homunculus.exp < hd->exp_next) { - clif->hominfo(hd->master,hd,0); + if (hd->homunculus.exp < hd->exp_next) { + clif->hominfo(hd->master, hd, 0); return 0; } @@ -1439,6 +1448,7 @@ void homunculus_defaults(void) homun->evolve = homunculus_evolve; homun->mutate = homunculus_mutate; homun->gainexp = homunculus_gainexp; + homun->gainexp_real = homunculus_gainexp_real; homun->add_intimacy = homunculus_add_intimacy; homun->consume_intimacy = homunculus_consume_intimacy; homun->healed = homunculus_healed; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 745c7cd84..502fb0b7f 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -178,6 +178,7 @@ struct homunculus_interface { bool (*evolve) (struct homun_data *hd); bool (*mutate) (struct homun_data *hd, int homun_id); int (*gainexp) (struct homun_data *hd, unsigned int exp); + int (*gainexp_real) (struct homun_data *hd, unsigned int exp); unsigned int (*add_intimacy) (struct homun_data * hd, unsigned int value); unsigned int (*consume_intimacy) (struct homun_data *hd, unsigned int value); void (*healed) (struct homun_data *hd); -- cgit v1.2.3-70-g09d2