summaryrefslogtreecommitdiff
path: root/src/map/skill.c
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-07-09 06:29:03 -0300
committerpanikon <panikon@zoho.com>2014-07-09 07:09:37 -0300
commit1eee0fd015aaca31df67f0cc7fa36105ade366df (patch)
tree1475ccfd8b7c6f3756768d7006afef74dd14f0f7 /src/map/skill.c
parentfc41d1f9fa9f3eff21568c8111f74454793dea9c (diff)
downloadhercules-1eee0fd015aaca31df67f0cc7fa36105ade366df.tar.gz
hercules-1eee0fd015aaca31df67f0cc7fa36105ade366df.tar.bz2
hercules-1eee0fd015aaca31df67f0cc7fa36105ade366df.tar.xz
hercules-1eee0fd015aaca31df67f0cc7fa36105ade366df.zip
Fixed issue with mounts and jobchange, ranger and mechanic mounts weren't being checked and properly removed in pc_setoption
Abstracted running functions into two other methods (unit_run and unit_wugdash) Added checks in skill_dance_switch so it'd be safe to call it whenever it's needed Documented unit_run, unit_run_hit, skill_dance_switch and sc_conf_type
Diffstat (limited to 'src/map/skill.c')
-rw-r--r--src/map/skill.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/map/skill.c b/src/map/skill.c
index 04aee371c..08275ab49 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -10630,14 +10630,22 @@ int skill_dance_overlap(struct skill_unit* su, int flag) {
return map->foreachincell(skill->dance_overlap_sub, su->bl.m,su->bl.x,su->bl.y,BL_SKILL, su,flag);
}
-/*==========================================
+/**
* Converts this group information so that it is handled as a Dissonance or Ugly Dance cell.
- * Flag: 0 - Convert, 1 - Revert.
- *------------------------------------------*/
+ * This function is safe to call even when the unit or the group were freed by other function
+ * previously.
+ * @param su Skill unit data (from BA_DISSONANCE or DC_UGLYDANCE)
+ * @param flag 0 Convert
+ * @param flag 1 Revert
+ * @retval true success
+ **/
bool skill_dance_switch(struct skill_unit* su, int flag) {
static int prevflag = 1; // by default the backup is empty
static struct skill_unit_group backup;
- struct skill_unit_group* group = su->group;
+ struct skill_unit_group* group;
+
+ if( su == NULL || (group = su->group) == NULL )
+ return false;
// val2&UF_ENSEMBLE is a hack to indicate dissonance
if ( !(group->state.song_dance&0x1 && su->val2&UF_ENSEMBLE) )
@@ -16133,9 +16141,6 @@ int skill_unit_move_sub(struct block_list* bl, va_list ap) {
}
}
- //TODO: Normally, this is dangerous since the unit and group could be freed
- //inside the onout/onplace functions. Currently it is safe because we know song/dance
- //cells do not get deleted within them. [Skotlex]
if( dissonance ) skill->dance_switch(su, 1);
if( flag&4 )