summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-02-13 08:46:52 +0100
committerHaru <haru@dotalux.com>2020-04-05 21:20:35 +0200
commit3bdf77ae814ae0c15cba32acfcb82f591fa848c2 (patch)
tree520cfe2b63c9642c4312c32c75a76e223201e1d7
parent09e291009156002e83566afe7a10b6509f5463f5 (diff)
downloadhercules-3bdf77ae814ae0c15cba32acfcb82f591fa848c2.tar.gz
hercules-3bdf77ae814ae0c15cba32acfcb82f591fa848c2.tar.bz2
hercules-3bdf77ae814ae0c15cba32acfcb82f591fa848c2.tar.xz
hercules-3bdf77ae814ae0c15cba32acfcb82f591fa848c2.zip
Add value capping to pet_set_intimate() function
-rw-r--r--src/map/pc.c2
-rw-r--r--src/map/pet.c14
2 files changed, 4 insertions, 12 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 33deb780b..eb71ccfe4 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -8046,8 +8046,6 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src)
struct pet_data *pd = sd->pd;
if( !map->list[sd->bl.m].flag.noexppenalty ) {
pet->set_intimate(pd, pd->pet.intimate - pd->petDB->die);
- if (pd->pet.intimate < PET_INTIMACY_NONE)
- pd->pet.intimate = PET_INTIMACY_NONE;
clif->send_petdata(sd,sd->pd,1,pd->pet.intimate);
}
if( sd->pd->target_id ) // Unlock all targets...
diff --git a/src/map/pet.c b/src/map/pet.c
index 592a25d3e..9384b3134 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -85,13 +85,13 @@ static void pet_set_intimate(struct pet_data *pd, int value)
intimate = pd->pet.intimate;
sd = pd->msd;
- pd->pet.intimate = value;
+ pd->pet.intimate = cap_value(value, PET_INTIMACY_NONE, PET_INTIMACY_MAX);
if( (intimate >= battle_config.pet_equip_min_friendly && pd->pet.intimate < battle_config.pet_equip_min_friendly) || (intimate < battle_config.pet_equip_min_friendly && pd->pet.intimate >= battle_config.pet_equip_min_friendly) )
status_calc_pc(sd,SCO_NONE);
/* Pet is lost, delete the egg */
- if (value <= PET_INTIMACY_NONE) {
+ if (pd->pet.intimate == PET_INTIMACY_NONE) {
int i;
ARR_FIND(0, sd->status.inventorySize, i, sd->status.inventory[i].card[0] == CARD0_PET &&
@@ -262,11 +262,8 @@ static int pet_hungry(int tid, int64 tick, int id, intptr_t data)
pet_stop_attack(pd);
pd->pet.hungry = PET_HUNGER_STARVING;
pet->set_intimate(pd, pd->pet.intimate - battle_config.pet_hungry_friendly_decrease);
- if (pd->pet.intimate <= PET_INTIMACY_NONE)
- {
- pd->pet.intimate = PET_INTIMACY_NONE;
+ if (pd->pet.intimate == PET_INTIMACY_NONE)
pd->status.speed = pd->db->status.speed;
- }
status_calc_pet(pd, SCO_NONE);
clif->send_petdata(sd,pd,1,pd->pet.intimate);
}
@@ -858,12 +855,9 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
}
pet->set_intimate(pd, pd->pet.intimate + add_intimate);
}
- if (pd->pet.intimate <= PET_INTIMACY_NONE) {
- pd->pet.intimate = PET_INTIMACY_NONE;
+ if (pd->pet.intimate == PET_INTIMACY_NONE) {
pet_stop_attack(pd);
pd->status.speed = pd->db->status.speed;
- } else if (pd->pet.intimate > PET_INTIMACY_MAX) {
- pd->pet.intimate = PET_INTIMACY_MAX;
}
status_calc_pet(pd, SCO_NONE);
pd->pet.hungry += pd->petDB->fullness;