diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-02-23 15:57:02 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-02-23 15:57:02 +0000 |
commit | 84b6b31d41b988d8f797126474bfcbb54b198545 (patch) | |
tree | f0489ee6fdfb30f4a9d6784cdcb346e0ad41c17f /src/map | |
parent | 63346b0e5fed404dc7becc01b8d829e69865f8cc (diff) | |
download | hercules-84b6b31d41b988d8f797126474bfcbb54b198545.tar.gz hercules-84b6b31d41b988d8f797126474bfcbb54b198545.tar.bz2 hercules-84b6b31d41b988d8f797126474bfcbb54b198545.tar.xz hercules-84b6b31d41b988d8f797126474bfcbb54b198545.zip |
* Made mob_delayspawn check the spawn_timer in the mob.
* Added missing delete_timer's every time spawn_timer is being set. (except when allocating)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13543 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/mob.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index fd5971cb1..e69f504e3 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -722,9 +722,19 @@ int mob_linksearch(struct block_list *bl,va_list ap) *------------------------------------------*/ int mob_delayspawn(int tid, unsigned int tick, int id, intptr data) { - struct block_list *bl = map_id2bl(id); - if (bl && bl->type == BL_MOB && bl->prev == NULL) - mob_spawn((TBL_MOB*)bl); + struct block_list* bl = map_id2bl(id); + struct mob_data* md = BL_CAST(BL_MOB, bl); + + if( md ) + { + if( md->spawn_timer != tid ) + { + ShowError("mob_delayspawn: Timer mismatch: %d != %d\n", tid, md->spawn_timer); + return 0; + } + md->spawn_timer = INVALID_TIMER; + mob_spawn(md); + } return 0; } @@ -745,6 +755,8 @@ int mob_setdelayspawn(struct mob_data *md) if (spawntime < 5000) //Min respawn time (is it needed?) spawntime = 5000; + if( md->spawn_timer != INVALID_TIMER ) + delete_timer(md->spawn_timer, mob_delayspawn); md->spawn_timer = add_timer(gettick()+spawntime, mob_delayspawn, md->bl.id, 0); return 0; } @@ -783,12 +795,16 @@ int mob_spawn (struct mob_data *md) { //Monster can be spawned on an area. if( !map_search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) ) { // retry again later + if( md->spawn_timer != INVALID_TIMER ) + delete_timer(md->spawn_timer, mob_delayspawn); md->spawn_timer = add_timer(tick+5000,mob_delayspawn,md->bl.id,0); return 1; } } else if( battle_config.no_spawn_on_player > 99 && map_foreachinrange(mob_count_sub, &md->bl, AREA_SIZE, BL_PC) ) { // retry again later (players on sight) + if( md->spawn_timer != INVALID_TIMER ) + delete_timer(md->spawn_timer, mob_delayspawn); md->spawn_timer = add_timer(tick+5000,mob_delayspawn,md->bl.id,0); return 1; } @@ -799,7 +815,11 @@ int mob_spawn (struct mob_data *md) md->attacked_id = 0; md->target_id = 0; md->move_fail_count = 0; - md->spawn_timer = INVALID_TIMER; + if( md->spawn_timer != INVALID_TIMER ) + { + delete_timer(md->spawn_timer, mob_delayspawn); + md->spawn_timer = INVALID_TIMER; + } // md->master_id = 0; md->master_dist = 0; |