void prim_timer_stop(PRIM_PROTOTYPE) { CHECKOP(1); oper1 = POP(); /* string: timer id */ if (oper1->type != PROG_STRING) abort_interp("Expected a string timer id. (2)"); dequeue_timers(fr->pid, DoNullInd(oper1->data.string)); CLEAR(oper1); }
void prim_timer_start(PRIM_PROTOTYPE) { CHECKOP(2); oper2 = POP(); /* string: timer id */ oper1 = POP(); /* int: delay length in seconds */ if (fr->timercount > tp_process_timer_limit) abort_interp("Too many timers!"); if (oper1->type != PROG_INTEGER) abort_interp("Expected an integer delay time. (1)"); if (oper2->type != PROG_STRING) abort_interp("Expected a string timer id. (2)"); dequeue_timers(fr->pid, DoNullInd(oper2->data.string)); add_muf_timer_event(fr->descr, player, program, fr, oper1->data.number, DoNullInd(oper2->data.string)); CLEAR(oper1); CLEAR(oper2); }
/* clean up the stack. */ void prog_clean(struct frame *fr) { int i; struct frame *ptr; if (!fr) { log_status("WARNING: prog_clean(): Tried to free a NULL frame ! Ignored."); return; } for (ptr = free_frames_list; ptr; ptr = ptr->next) { if (ptr == fr) { log_status("WARNING: prog_clean(): tried to free an already freed program frame ! Ignored."); return; } } watchpid_process (fr); fr->system.top = 0; for (i = 0; i < fr->argument.top; i++){ CLEAR(&fr->argument.st[i]); } DEBUGPRINT("prog_clean: fr->caller.top=%d\n",fr->caller.top,0); for (i = 1; i <= fr->caller.top; i++) { DEBUGPRINT("Decreasing instances of fr->caller.st[%d](#%d)\n", i, fr->caller.st[i]); PROGRAM_DEC_INSTANCES(fr->caller.st[i]); } for (i = 0; i < MAX_VAR; i++) CLEAR(&fr->variables[i]); localvar_freeall(fr); scopedvar_freeall(fr); if (fr->fors.st) { struct forvars **loop = &(fr->fors.st); while (*loop) { CLEAR(&((*loop)->cur)); CLEAR(&((*loop)->end)); loop = &((*loop)->next); } *loop = for_pool; if (last_for == &for_pool) { last_for = loop; } for_pool = fr->fors.st; fr->fors.st = NULL; fr->fors.top = 0; } if (fr->trys.st) { struct tryvars **loop = &(fr->trys.st); while (*loop) { loop = &((*loop)->next); } *loop = try_pool; if (last_try == &try_pool) { last_try = loop; } try_pool = fr->trys.st; fr->trys.st = NULL; fr->trys.top = 0; } fr->argument.top = 0; fr->pc = 0; if (fr->brkpt.lastcmd) free(fr->brkpt.lastcmd); if (fr->brkpt.proglines) { free_prog_text(fr->brkpt.proglines); fr->brkpt.proglines = NULL; } if (fr->rndbuf) delete_seed(fr->rndbuf); muf_dlog_purge(fr); dequeue_timers(fr->pid, NULL); muf_event_purge(fr); fr->next = free_frames_list; free_frames_list = fr; err = 0; }