Fixed a crash due to script's backup state not being stored/restored properly. (follow up to r13846)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13850 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
Inkfish 2009-06-06 00:59:30 +00:00
parent 5589a98314
commit 4e360035fc

View File

@ -3202,18 +3202,18 @@ void run_script_main(struct script_state *st)
}
if(st->sleep.tick > 0) {
//Delay execution
sd = map_id2sd(st->rid); // Refresh sd since script might have attached someone while running. [Inkfish]
st->sleep.charid = sd?sd->status.char_id:0;
st->sleep.timer = add_timer(gettick()+st->sleep.tick,
run_script_timer, st->sleep.charid, (intptr)st);
linkdb_insert(&sleep_db, (void*)st->oid, st);
//Restore previous script
if (sd) {
sd->st = bk_st;
sd->npc_id = bk_npcid;
bk_st = NULL; //Remove tag for removal.
}
//Delay execution
sd = map_id2sd(st->rid); // Refresh sd since script might have attached someone while running. [Inkfish]
st->sleep.charid = sd?sd->status.char_id:0;
st->sleep.timer = add_timer(gettick()+st->sleep.tick,
run_script_timer, st->sleep.charid, (intptr)st);
linkdb_insert(&sleep_db, (void*)st->oid, st);
}
else if(st->state != END && sd){
//Resume later (st is already attached to player).