From 57ba23012d78b8bae37953d65831e932d1365283 Mon Sep 17 00:00:00 2001 From: "Guilherme G. Menaldo" Date: Thu, 29 Mar 2018 01:25:50 -0300 Subject: Allow guild skills cooldown to continue when logged out --- src/map/battle.c | 2 +- src/map/guild.c | 4 ++-- src/map/skill.c | 16 ++++++++++------ src/map/skill.h | 4 +--- 4 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src/map') diff --git a/src/map/battle.c b/src/map/battle.c index bd7e31d05..a6ad143d4 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6955,7 +6955,7 @@ static const struct battle_data { { "chase_range_rate", &battle_config.chase_range_rate, 100, 0, INT_MAX, }, { "gtb_sc_immunity", &battle_config.gtb_sc_immunity, 50, 0, INT_MAX, }, { "guild_max_castles", &battle_config.guild_max_castles, 0, 0, INT_MAX, }, - { "guild_skill_relog_delay", &battle_config.guild_skill_relog_delay, 0, 0, 1, }, + { "guild_skill_relog_delay", &battle_config.guild_skill_relog_delay, 0, 0, 2, }, { "emergency_call", &battle_config.emergency_call, 11, 0, 31, }, { "atcommand_spawn_quantity_limit", &battle_config.atc_spawn_quantity_limit, 100, 0, INT_MAX, }, { "atcommand_slave_clone_limit", &battle_config.atc_slave_clone_limit, 25, 0, INT_MAX, }, diff --git a/src/map/guild.c b/src/map/guild.c index 11609ec81..0d6a08e59 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -551,7 +551,7 @@ int guild_recv_info(const struct guild *sg) if ((sd = map->nick2sd(sg->master)) != NULL) { //If the guild master is online the first time the guild_info is received, //that means he was the first to join, so apply guild skill blocking here. - if( battle_config.guild_skill_relog_delay ) + if( battle_config.guild_skill_relog_delay == 1) guild->block_skill(sd, 300000); //Also set the guild master flag. @@ -759,7 +759,7 @@ void guild_member_joined(struct map_session_data *sd) // set the Guild Master flag sd->state.gmaster_flag = 1; // prevent Guild Skills from being used directly after relog - if( battle_config.guild_skill_relog_delay ) + if( battle_config.guild_skill_relog_delay == 1 ) guild->block_skill(sd, 300000); } i = guild->getindex(g, sd->status.account_id, sd->status.char_id); diff --git a/src/map/skill.c b/src/map/skill.c index 3d541bf76..1258e9aaf 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -19032,9 +19032,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) if (DIFF_TICK32(cd->entry[i]->started + cd->entry[i]->duration, now) > tick) return 0; cd->entry[i]->duration = tick; -#if PACKETVER >= 20120604 cd->entry[i]->total = tick; -#endif cd->entry[i]->started = now; if( timer->settick(cd->entry[i]->timer,now+tick) != -1 ) return 0; @@ -19066,9 +19064,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) cd->entry[cd->cursor] = ers_alloc(skill->cd_entry_ers,struct skill_cd_entry); cd->entry[cd->cursor]->duration = tick; -#if PACKETVER >= 20120604 cd->entry[cd->cursor]->total = tick; -#endif cd->entry[cd->cursor]->skidx = idx; cd->entry[cd->cursor]->skill_id = skill_id; cd->entry[cd->cursor]->started = now; @@ -19717,8 +19713,16 @@ void skill_cooldown_load(struct map_session_data * sd) // process each individual cooldown associated with the character for( i = 0; i < cd->cursor; i++ ) { - cd->entry[i]->started = now; - cd->entry[i]->timer = timer->add(timer->gettick()+cd->entry[i]->duration,skill->blockpc_end,sd->bl.id,cd->entry[i]->skidx); + int64 remaining; + + if (battle_config.guild_skill_relog_delay == 2 && cd->entry[i]->skill_id >= GD_SKILLBASE && cd->entry[i]->skill_id < GD_MAX) { + remaining = cd->entry[i]->started + cd->entry[i]->total - now; + remaining = max(1, remaining); // expired cooldowns will be 1, so they'll expire in the normal way just after this. + } else { + cd->entry[i]->started = now; + remaining = cd->entry[i]->duration; + } + cd->entry[i]->timer = timer->add(timer->gettick() + remaining, skill->blockpc_end, sd->bl.id, cd->entry[i]->skidx); sd->blockskill[cd->entry[i]->skidx] = true; } } diff --git a/src/map/skill.h b/src/map/skill.h index d7590921a..3de7f7bdf 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1842,9 +1842,7 @@ struct s_skill_magicmushroom_db { struct skill_cd_entry { int duration;//milliseconds -#if PACKETVER >= 20120604 - int total;/* used for display on newer clients */ -#endif + int total;/* used when reducing offline cooldown and for display on newer clients */ short skidx;//the skill index entries belong to int64 started;/* gettick() of when it started, used vs duration to measure how much left upon logout */ int timer;/* timer id */ -- cgit v1.2.3-60-g2f50