summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/map/mob.c25
-rw-r--r--src/map/script.c2
-rw-r--r--src/map/skill.c6
4 files changed, 28 insertions, 7 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 933896a76..007638d80 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -6,6 +6,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2009/02/23
* Made mob_delayspawn check the spawn_timer in the mob. [FlavioJS]
* Added missing delete_timer's every time spawn_timer is being set. (except when allocating)
+ * Made mob_timer_delete check the deletetimer in the mob.
+ * Added missing delete_timer's every time deletetimer is being set. (except when allocating)
2009/02/20
* Increased variable size for status/skill points to remove the 65k cap (bugreport:1579) [ultramage]
* Modified WFIFOSET to trigger a fatal error when trying to send a packet that is too big. [FlavioJS]
diff --git a/src/map/mob.c b/src/map/mob.c
index e69f504e3..2691dc45f 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1705,13 +1705,20 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
int mob_timer_delete(int tid, unsigned int tick, int id, intptr data)
{
- struct block_list *bl=map_id2bl(id);
- nullpo_retr(0, bl);
- if (bl->type != BL_MOB)
- return 0; //??
- //for Alchemist CANNIBALIZE [Lupus]
- ((TBL_MOB*)bl)->deletetimer = INVALID_TIMER;
- unit_free(bl,3);
+ struct block_list* bl = map_id2bl(id);
+ struct mob_data* md = BL_CAST(BL_MOB, bl);
+
+ if( md )
+ {
+ if( md->deletetimer != tid )
+ {
+ ShowError("mob_timer_delete: Timer mismatch: %d != %d\n", tid, md->deletetimer);
+ return 0;
+ }
+ //for Alchemist CANNIBALIZE [Lupus]
+ md->deletetimer = INVALID_TIMER;
+ unit_free(bl, 3);
+ }
return 0;
}
@@ -3227,7 +3234,11 @@ int mob_clone_spawn(struct map_session_data *sd, int m, int x, int y, const char
if (master_id) //Attach to Master
md->master_id = master_id;
if (duration) //Auto Delete after a while.
+ {
+ if( md->deletetimer != INVALID_TIMER )
+ delete_timer(md->deletetimer, mob_timer_delete);
md->deletetimer = add_timer (gettick() + duration, mob_timer_delete, md->bl.id, 0);
+ }
}
mob_spawn(md);
diff --git a/src/map/script.c b/src/map/script.c
index e38672e16..fc65a3d7e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -11330,6 +11330,8 @@ BUILDIN_FUNC(summon)
if (md) {
md->master_id=sd->bl.id;
md->special_state.ai=1;
+ if( md->deletetimer != INVALID_TIMER )
+ delete_timer(md->deletetimer, mob_timer_delete);
md->deletetimer = add_timer(tick+(timeout>0?timeout*1000:60000),mob_timer_delete,md->bl.id,0);
mob_spawn (md); //Now it is ready for spawning.
clif_misceffect2(&md->bl,344);
diff --git a/src/map/skill.c b/src/map/skill.c
index 9d03be3d9..a1fe80c06 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -6002,6 +6002,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int sk
if (md) {
md->master_id = src->id;
md->special_state.ai = skillid==AM_SPHEREMINE?2:3;
+ if( md->deletetimer != INVALID_TIMER )
+ delete_timer(md->deletetimer, mob_timer_delete);
md->deletetimer = add_timer (gettick() + skill_get_time(skillid,skilllv), mob_timer_delete, md->bl.id, 0);
mob_spawn (md); //Now it is ready for spawning.
}
@@ -6104,7 +6106,11 @@ int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int sk
TBL_MOB* md = mob_once_spawn_sub(src, src->m, x, y, "--ja--",(skilllv < 2 ? 1084+rand()%2 : 1078+rand()%6),"");
if (!md) break;
if ((i = skill_get_time(skillid, skilllv)) > 0)
+ {
+ if( md->deletetimer != INVALID_TIMER )
+ delete_timer(md->deletetimer, mob_timer_delete);
md->deletetimer = add_timer (tick + i, mob_timer_delete, md->bl.id, 0);
+ }
mob_spawn (md);
}
}