summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2019-09-04 20:20:55 +0300
committerAndrei Karas <akaras@inbox.ru>2019-09-18 22:31:51 +0300
commit79c2a4b11f5f05eed9ae5535395205236f73b1e4 (patch)
tree4ef36136b8bdeec7c435b45a62619e175cfd8543 /src/map
parentcd303fb60f2ac5d4fde55dccdd01050397b1bb7e (diff)
downloadhercules-79c2a4b11f5f05eed9ae5535395205236f73b1e4.tar.gz
hercules-79c2a4b11f5f05eed9ae5535395205236f73b1e4.tar.bz2
hercules-79c2a4b11f5f05eed9ae5535395205236f73b1e4.tar.xz
hercules-79c2a4b11f5f05eed9ae5535395205236f73b1e4.zip
Extract code for really gain homun exp to separate function
Also replace hardcoded message to message string.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/homunculus.c28
-rw-r--r--src/map/homunculus.h1
2 files changed, 20 insertions, 9 deletions
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);