void action_t::execute() { if ( sim -> log && ! dual ) { log_t::output( sim, "%s performs %s (%.0f)", player -> name(), name(), player -> resource_current[ player -> primary_resource() ] ); } if ( observer ) *observer = 0; player_buff(); target_debuff( DMG_DIRECT ); calculate_result(); consume_resource(); if ( result_is_hit() ) { calculate_direct_damage(); if ( direct_dmg > 0 ) { assess_damage( direct_dmg, DMG_DIRECT ); } if ( num_ticks > 0 ) { if ( dot_behavior == DOT_REFRESH ) { current_tick = 0; if ( ! ticking ) schedule_tick(); } else { if ( ticking ) cancel(); snapshot_haste = haste(); schedule_tick(); } } } else { if ( sim -> log ) { log_t::output( sim, "%s avoids %s (%s)", sim -> target -> name(), name(), util_t::result_type_string( result ) ); log_t::miss_event( this ); } } update_ready(); if ( ! dual ) update_stats( DMG_DIRECT ); schedule_travel(); if ( repeating && ! proc ) schedule_execute(); if ( harmful ) player -> in_combat = true; }
void dot_t::start( timespan_t duration ) { current_duration = duration; last_start = sim.current_time(); ticking = true; end_event = new ( sim ) dot_end_event_t( this, current_duration ); if ( sim.debug ) sim.out_debug.printf( "%s starts dot for %s on %s. duration=%.3f", source -> name(), name(), target -> name(), duration.total_seconds() ); state -> original_x = target -> x_position; state -> original_y = target -> y_position; check_tick_zero(); schedule_tick(); source -> add_active_dot( current_action -> internal_id ); if ( current_action && current_action -> need_to_trigger_costs_per_second() ) { current_action -> schedule_cost_tick_event(); } // Only schedule a tick if thre's enough time to tick at least once. // Otherwise, next tick is the last tick, and the end event will handle it if ( current_duration <= time_to_tick ) event_t::cancel( tick_event ); }
/*---------------------------------------------------------------------------*/ void ct_callback_sch_tick(void *ptr) { printf("===========in intterupt=======\n"); //printf("\t\t\t[schedule tick]\n"); schedule_tick(sch_process_current); //printf("<-\"crt\"-> sch[%s]---\n", sch_process_current->old->name); if (is_set_need_resched(sch_process_current)) { //printf("\t\t\t[schedule]\n"); schedule(); } ctimer_reset(&ct_sch_tick); }
static void trap_dispatch(struct frame *tf) { switch(tf->tf_trapno) { case T_PGFLT: { //print_frame(tf); do_page_fault(tf); break; } case T_GPFLT: { panic("GPFLT!\n"); do_exit(curtask); break; } case T_BRKPT : { print_frame(tf); panic("break point handler not implemented!\n"); break; } case T_DIVIDE: { printk("CPU:%d USER T_DIVIDE\n",get_cpuid()); do_exit(curtask); } case T_SYSCALL: { tf->tf_regs.reg_eax = syscall_handler(tf); break; } case IRQ_SPURIOUS: { printk("CPU:%d Spurious interrupt on irq 7\n",get_cpuid()); print_frame(tf); return; } case IRQ_TIMER : { lapic_eoi(); schedule_tick(); break; } case IRQ_KBD : { irq_eoi(); printk("CPU:%d IRQ_KBD \n",get_cpuid()); inb(0x60); break; } case IRQ_SERIAL : { panic("SERIAL handler not implemented!\n"); break; } case IRQ_IDE0 : case IRQ_IDE1 : { irq_eoi(); do_hd_interrupt(tf); break; } case IRQ_ERROR : { print_frame(tf); panic("ERROR handler not implemented!\n"); break; } default: { if (tf->tf_cs == _KERNEL_CS_) panic("unhandled trap in kernel"); else { print_frame(tf); return; } break; } } }