diff options
author | shennetsind <ind@henn.et> | 2013-06-23 17:41:46 -0300 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-06-23 17:41:46 -0300 |
commit | ef51dc8087edee3346c9ac9f61c69bcbb3a8d86f (patch) | |
tree | 9d61c8fb1dd306e30ccf50858a69e08d262c2cf1 | |
parent | c1d8f1010cb12e65d49000c29699523a0c1c9263 (diff) | |
download | hercules-ef51dc8087edee3346c9ac9f61c69bcbb3a8d86f.tar.gz hercules-ef51dc8087edee3346c9ac9f61c69bcbb3a8d86f.tar.bz2 hercules-ef51dc8087edee3346c9ac9f61c69bcbb3a8d86f.tar.xz hercules-ef51dc8087edee3346c9ac9f61c69bcbb3a8d86f.zip |
Fixed Bug #7420
http://hercules.ws/board/tracker/issue-7420-killing-the-npc/
Special Thanks to kyeme, frost, ossi0110
Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r-- | src/map/script.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/map/script.c b/src/map/script.c index 481cb5870..a61487332 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2783,28 +2783,31 @@ struct script_state* script_alloc_state(struct script_code* rootscript, int pos, /// Frees a script state. /// /// @param st Script state -void script_free_state(struct script_state* st) -{ - if(st->bk_st) {// backup was not restored - ShowDebug("script_free_state: Previous script state lost (rid=%d, oid=%d, state=%d, bk_npcid=%d).\n", st->bk_st->rid, st->bk_st->oid, st->bk_st->state, st->bk_npcid); - } - - if( st->sleep.timer != INVALID_TIMER ) - iTimer->delete_timer(st->sleep.timer, run_script_timer); - script_free_vars(st->stack->var_function); - script->pop_stack(st, 0, st->stack->sp); - aFree(st->stack->stack_data); - ers_free(script->stack_ers, st->stack); - if( st->script && st->script->script_vars && !db_size(st->script->script_vars) ) { - script_free_vars(st->script->script_vars); - st->script->script_vars = NULL; - } - st->stack = NULL; - st->pos = -1; - idb_remove(script->st_db, st->id); - ers_free(script->st_ers, st); - if( --script->active_scripts == 0 ) { - script->next_id = 0; +void script_free_state(struct script_state* st) { + if( idb_exists(script->st_db,st->id) ) { + if(st->bk_st) {// backup was not restored + ShowDebug("script_free_state: Previous script state lost (rid=%d, oid=%d, state=%d, bk_npcid=%d).\n", st->bk_st->rid, st->bk_st->oid, st->bk_st->state, st->bk_npcid); + } + + if( st->sleep.timer != INVALID_TIMER ) + iTimer->delete_timer(st->sleep.timer, run_script_timer); + if( st->stack ) { + script_free_vars(st->stack->var_function); + script->pop_stack(st, 0, st->stack->sp); + aFree(st->stack->stack_data); + ers_free(script->stack_ers, st->stack); + st->stack = NULL; + } + if( st->script && st->script->script_vars && !db_size(st->script->script_vars) ) { + script_free_vars(st->script->script_vars); + st->script->script_vars = NULL; + } + st->pos = -1; + idb_remove(script->st_db, st->id); + ers_free(script->st_ers, st); + if( --script->active_scripts == 0 ) { + script->next_id = 0; + } } } |