summaryrefslogtreecommitdiff
path: root/src/map/pet.c
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-02-18 00:42:29 +0100
committerHaru <haru@dotalux.com>2020-04-05 21:27:30 +0200
commit1bea6e9fc13f718dca37125aed3e87bbda6fc160 (patch)
tree176854d4d95fe369d0c4b8444b2ebe615944635b /src/map/pet.c
parent50a477c2b07e73cf5fe7ef4fadb30c3a349561d9 (diff)
downloadhercules-1bea6e9fc13f718dca37125aed3e87bbda6fc160.tar.gz
hercules-1bea6e9fc13f718dca37125aed3e87bbda6fc160.tar.bz2
hercules-1bea6e9fc13f718dca37125aed3e87bbda6fc160.tar.xz
hercules-1bea6e9fc13f718dca37125aed3e87bbda6fc160.zip
Apply code style to pet_skill_bonus_timer() function
Diffstat (limited to 'src/map/pet.c')
-rw-r--r--src/map/pet.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/map/pet.c b/src/map/pet.c
index 097740cca..e877ae011 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -1228,45 +1228,54 @@ static int pet_lootitem_drop(struct pet_data *pd, struct map_session_data *sd)
return 1;
}
-/*==========================================
- * pet bonus giving skills [Valaris] / Rewritten by [Skotlex]
- *------------------------------------------*/
+/**
+ * Applies pet's stat bonuses to its master. (See petskillbonus() script command.)
+ *
+ * @param tid The timer ID
+ * @param tick The base amount of ticks to add to the pet's bonus timer. (The timer's current ticks when calling this fuction.)
+ * @param id The pet's master's account ID.
+ * @param data Unused.
+ * @return 1 on failure, 0 on success.
+ *
+ **/
static int pet_skill_bonus_timer(int tid, int64 tick, int id, intptr_t data)
{
- struct map_session_data *sd=map->id2sd(id);
- struct pet_data *pd;
- int bonus;
- int duration = 0;
+ struct map_session_data *sd = map->id2sd(id);
- if(sd == NULL || sd->pd==NULL || sd->pd->bonus == NULL)
+ if (sd == NULL || sd->pd == NULL || sd->pd->bonus == NULL)
return 1;
- pd=sd->pd;
+ struct pet_data *pd = sd->pd;
- if(pd->bonus->timer != tid) {
- ShowError("pet_skill_bonus_timer %d != %d\n",pd->bonus->timer,tid);
+ if (pd->bonus->timer != tid) {
+ ShowError("pet_skill_bonus_timer %d != %d\n", pd->bonus->timer, tid);
pd->bonus->timer = INVALID_TIMER;
- return 0;
+ return 1;
}
- // determine the time for the next timer
- if (pd->state.skillbonus && pd->bonus->delay > 0) {
+ int bonus;
+ int duration;
+
+ // Determine the time for the next timer.
+ if (pd->state.skillbonus == 1 && pd->bonus->delay > 0) {
bonus = 0;
- duration = pd->bonus->delay*1000; // the duration until pet bonuses will be reactivated again
+ duration = pd->bonus->delay * 1000; // The duration until pet bonuses will be reactivated again.
} else if (pd->pet.intimate > PET_INTIMACY_NONE) {
bonus = 1;
- duration = pd->bonus->duration*1000; // the duration for pet bonuses to be in effect
- } else { //Lost pet...
+ duration = pd->bonus->duration * 1000; // The duration for pet bonuses to be in effect.
+ } else { // Lost pet...
pd->bonus->timer = INVALID_TIMER;
- return 0;
+ return 1;
}
if (pd->state.skillbonus != bonus) {
pd->state.skillbonus = bonus;
status_calc_pc(sd, SCO_NONE);
}
- // wait for the next timer
- pd->bonus->timer=timer->add(tick+duration,pet->skill_bonus_timer,sd->bl.id,0);
+
+ // Wait for the next timer.
+ pd->bonus->timer = timer->add(tick + duration, pet->skill_bonus_timer, sd->bl.id, 0);
+
return 0;
}