summaryrefslogtreecommitdiff
path: root/src/map/skill.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/skill.c')
-rw-r--r--src/map/skill.c65
1 files changed, 45 insertions, 20 deletions
diff --git a/src/map/skill.c b/src/map/skill.c
index 8cb82e3a6..4bd27f578 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -64,20 +64,6 @@ static struct eri *skill_timer_ers = NULL; //For handling skill_timerskills [Sko
DBMap* skillunit_db = NULL; // int id -> struct skill_unit*
/**
- * Skill Cool Down Delay Saving
- * Struct skill_cd is not a member of struct map_session_data
- * to keep cooldowns in memory between player log-ins.
- * All cooldowns are reset when server is restarted.
- **/
-DBMap* skillcd_db = NULL; // char_id -> struct skill_cd
-struct skill_cd {
- int duration[MAX_SKILL_TREE];//milliseconds
- short skidx[MAX_SKILL_TREE];//the skill index entries belong to
- short nameid[MAX_SKILL_TREE];//skill id
- unsigned char cursor;
-};
-
-/**
* Skill Unit Persistency during endack routes (mostly for songs see bugreport:4574)
**/
DBMap* skillusave_db = NULL; // char_id -> struct skill_usave
@@ -8050,9 +8036,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
else if(bl->type == BL_PC) rate += 20 + 10 * skill_lv; // On Players, (20 + 10 * Skill Level) %
else rate += 40 + 10 * skill_lv; // On Monsters, (40 + 10 * Skill Level) %
- if( sd )
- skill->blockpc_start(sd,skill_id,4000, false);
-
if( !(tsc && tsc->data[type]) ){
i = sc_start2(bl,type,rate,skill_lv,src->id,(src == bl)?5000:(bl->type == BL_PC)?skill->get_time(skill_id,skill_lv):skill->get_time2(skill_id, skill_lv));
clif->skill_nodamage(src,bl,skill_id,skill_lv,i);
@@ -16888,16 +16871,24 @@ int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data) {
int i,cursor;
ARR_FIND( 0, cd->cursor+1, cursor, cd->skidx[cursor] == data );
cd->duration[cursor] = 0;
+#if PACKETVER >= 20120604
+ cd->total[cursor] = 0;
+#endif
cd->skidx[cursor] = 0;
cd->nameid[cursor] = 0;
+ cd->started[cursor] = 0;
// compact the cool down list
for( i = 0, cursor = 0; i < cd->cursor; i++ ) {
if( cd->duration[i] == 0 )
continue;
if( cursor != i ) {
cd->duration[cursor] = cd->duration[i];
+#if PACKETVER >= 20120604
+ cd->total[cursor] = cd->total[i];
+#endif
cd->skidx[cursor] = cd->skidx[i];
cd->nameid[cursor] = cd->nameid[i];
+ cd->started[cursor] = cd->started[i];
}
cursor++;
}
@@ -16933,7 +16924,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick,
return -1;
}
- if( battle_config.display_status_timers )
+ if( !load && battle_config.display_status_timers )
clif->skill_cooldown(sd, skill_id, tick);
if( !load ) {// not being loaded initially so ensure the skill delay is recorded
@@ -16944,8 +16935,12 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick,
// record the skill duration in the database map
cd->duration[cd->cursor] = tick;
+#if PACKETVER >= 20120604
+ cd->total[cd->cursor] = tick;
+#endif
cd->skidx[cd->cursor] = idx;
cd->nameid[cd->cursor] = skill_id;
+ cd->started[cd->cursor] = iTimer->gettick();
cd->cursor++;
}
@@ -17438,13 +17433,37 @@ int skill_get_elemental_type( uint16 skill_id , uint16 skill_lv ) {
}
/**
+ * update stored skill cooldowns for player logout
+ * @param sd the affected player structure
+ */
+void skill_cooldown_save(struct map_session_data * sd) {
+ int i;
+ struct skill_cd* cd = NULL;
+ unsigned int now = 0;
+
+ // 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;
+ }
+
+ now = iTimer->gettick();
+
+ // process each individual cooldown associated with the character
+ for( i = 0; i < cd->cursor; i++ ) {
+ cd->duration[i] = DIFF_TICK(cd->started[i]+cd->duration[i],now);
+ }
+}
+
+/**
* reload stored skill cooldowns when a player logs in.
* @param sd the affected player structure
*/
-void skill_cooldown_load(struct map_session_data * sd)
-{
+void skill_cooldown_load(struct map_session_data * sd) {
int i;
struct skill_cd* cd = NULL;
+ unsigned int now = 0;
// always check to make sure the session properly exists
nullpo_retv(sd);
@@ -17453,8 +17472,13 @@ void skill_cooldown_load(struct map_session_data * sd)
return;
}
+ clif->cooldown_list(sd->fd,cd);
+
+ now = iTimer->gettick();
+
// process each individual cooldown associated with the character
for( i = 0; i < cd->cursor; i++ ) {
+ cd->started[i] = now;
// block the skill from usage but ensure it is not recorded (load = true)
skill->blockpc_start( sd, cd->nameid[i], cd->duration[i], true );
}
@@ -18145,5 +18169,6 @@ void skill_defaults(void) {
skill->elementalanalysis = skill_elementalanalysis;
skill->changematerial = skill_changematerial;
skill->get_elemental_type = skill_get_elemental_type;
+ skill->cooldown_save = skill_cooldown_save;
}