diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-01-07 17:59:25 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-01-07 17:59:25 +0000 |
commit | 8fd7ea9e4f38bd02b99e4fa42fc2003390a25adc (patch) | |
tree | 3298beebedd59756a671560128b7ce1e4d9b78ea /src/map/script.c | |
parent | f11b8f4bb3b1c047e0b1dfc9585f5b6c49ee8f65 (diff) | |
download | hercules-8fd7ea9e4f38bd02b99e4fa42fc2003390a25adc.tar.gz hercules-8fd7ea9e4f38bd02b99e4fa42fc2003390a25adc.tar.bz2 hercules-8fd7ea9e4f38bd02b99e4fa42fc2003390a25adc.tar.xz hercules-8fd7ea9e4f38bd02b99e4fa42fc2003390a25adc.zip |
- Fixed the sleep timers not being removed when the an npc was being unloaded and when reloading scripts.
Ref: http://www.eathena.ws/board/index.php?showtopic=131464
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9629 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/map/script.c b/src/map/script.c index 4b84f6c72..3efa8dbc0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6,18 +6,6 @@ //#define DEBUG_DISASM //#define DEBUG_RUN -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <math.h> - -#ifndef _WIN32 - #include <sys/time.h> -#endif -#include <time.h> -#include <setjmp.h> - #include "../common/cbasetypes.h" #include "../common/socket.h" #include "../common/timer.h" @@ -53,6 +41,18 @@ #include "irc.h" #include "pet.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <math.h> +#ifndef WIN32 + #include <sys/time.h> +#endif +#include <time.h> +#include <setjmp.h> + + /////////////////////////////////////////////////////////////////////////////// /// Returns the stack_data at the target index @@ -2683,6 +2683,21 @@ void run_script(struct script_code *rootscript,int pos,int rid,int oid) run_script_main(st); } +void script_stop_sleeptimers(int id) +{ + struct script_state* st; + for(;;) + { + st = (struct script_state*)linkdb_erase(&sleep_db,(void*)id); + if( st == NULL ) + break; // no more sleep timers + if( st->sleep.timer != INVALID_TIMER ) + delete_timer(st->sleep.timer, run_script_timer); + script_free_stack(st->stack); + aFree(st); + } +} + /*========================================== * 指定ノードをsleep_dbから削除 *------------------------------------------ @@ -3439,6 +3454,8 @@ int script_reload() struct linkdb_node *n = (struct linkdb_node *)sleep_db; while(n) { struct script_state *st = (struct script_state *)n->data; + if( st->sleep.timer != INVALID_TIMER ) + delete_timer(st->sleep.timer, run_script_timer); script_free_stack(st->stack); aFree(st); n = n->next; |