diff options
-rw-r--r-- | src/map/skill.c | 62 | ||||
-rw-r--r-- | src/map/skill.h | 4 |
2 files changed, 49 insertions, 17 deletions
diff --git a/src/map/skill.c b/src/map/skill.c index ff9641451..68769e599 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -13969,10 +13969,19 @@ int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data) return 1; } -int skill_blockpc_start(struct map_session_data *sd, int skillid, int tick) +/** + * flags a singular skill as being blocked from persistent usage. + * @param sd the player the skill delay affects + * @param skillid the skill which should be delayed + * @param tick the length of time the delay should last + * @param load whether this assignment is being loaded upon player login + * @return 0 if successful, -1 otherwise + */ +int skill_blockpc_start_(struct map_session_data *sd, int skillid, int tick, bool load) { - struct skill_cd * cd = NULL; int oskillid = skillid; + struct skill_cd* cd = NULL; + nullpo_retr (-1, sd); skillid = skill_get_index(skillid); @@ -13987,14 +13996,20 @@ int skill_blockpc_start(struct map_session_data *sd, int skillid, int tick) if( battle_config.display_status_timers ) clif_skill_cooldown(sd, skillid, tick); - if( !( cd = idb_get(skillcd_db,sd->status.char_id) ) ) { - CREATE(cd,struct skill_cd,1); - idb_put(skillcd_db, sd->status.char_id, cd); + if( !load ) + {// not being loaded initially so ensure the skill delay is recorded + if( !(cd = idb_get(skillcd_db,sd->status.char_id)) ) + {// create a new skill cooldown object for map storage + CREATE( cd, struct skill_cd, 1 ); + idb_put( skillcd_db, sd->status.char_id, cd ); + } + + // record the skill duration in the database map + cd->duration[cd->cursor] = tick; + cd->skidx[cd->cursor] = skillid; + cd->nameid[cd->cursor] = oskillid; + cd->cursor++; } - cd->duration[cd->cursor] = tick; - cd->skidx[cd->cursor] = skillid; - cd->nameid[cd->cursor] = oskillid; - cd->cursor++; sd->blockskill[skillid] = 0x1|(0xFE&add_timer(gettick()+tick,skill_blockpc_end,sd->bl.id,skillid)); return 0; @@ -14432,17 +14447,32 @@ int skill_stasis_check(struct block_list *bl, int src_id, int skillid) return 0; // Can Cast anything else like Weapon Skills } -void skill_cooldown_load(struct map_session_data * sd) { - struct skill_cd * cd = NULL; + +/** + * reload stored skill cooldowns when a player logs in. + * @param sd the affected player structure + */ +void skill_cooldown_load(struct map_session_data * sd) +{ int i; - if( !( cd = idb_get(skillcd_db,sd->status.char_id) ) ) - return;//nothing for us here + struct skill_cd* cd = NULL; + + // always check to make sure the session properly exists + nullpo_retv(sd); + + if( !(cd = idb_get(skillcd_db, sd->status.char_id)) ) + {// no skill cooldown is associated with this character + return; + } - for( i = 0; i < cd->cursor; i++ ) { - skill_blockpc_start(sd, cd->nameid[i], cd->duration[i]); + // process each individual cooldown associated with the character + for( i = 0; i < cd->cursor; i++ ) + { + // block the skill from usage but ensure it is not recorded (load = true) + skill_blockpc_start_( sd, cd->nameid[i], cd->duration[i], true ); } - return; } + /*========================================== * DB reading. * skill_db.txt diff --git a/src/map/skill.h b/src/map/skill.h index 75eb2a30e..9e087b464 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -345,10 +345,12 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int skillid,int skilllv,unsigned int tick,int flag ); int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skilllv,unsigned int tick,int flag); -int skill_blockpc_start (struct map_session_data*,int,int); +int skill_blockpc_start_(struct map_session_data*, int, int, bool); int skill_blockhomun_start (struct homun_data*,int,int); int skill_blockmerc_start (struct mercenary_data*,int,int); +#define skill_blockpc_start(sd, skillid, tick) skill_blockpc_start_( sd, skillid, tick, false ) + // スキル攻?一括?理 int skill_attack( int attack_type, struct block_list* src, struct block_list *dsrc,struct block_list *bl,int skillid,int skilllv,unsigned int tick,int flag ); |