version 1.8 | | version 1.9 |
---|
| | |
#include <sproto.h> | | #include <sproto.h> |
#endif | | #endif |
| | |
static void cftimer_process_event(object* ob); | | static void cftimer_process_event(tag_t ob_tag); |
| | |
/*****************************************************************************/ | | /*****************************************************************************/ |
/* Processes all timers. */ | | /* Processes all timers. */ |
| | |
{ | | { |
/* Call object timer event */ | | /* Call object timer event */ |
timers_table[i].mode = TIMER_MODE_DEAD; | | timers_table[i].mode = TIMER_MODE_DEAD; |
cftimer_process_event(timers_table[i].ob); | | cftimer_process_event(timers_table[i].ob_tag); |
} | | } |
} | | } |
else if (timers_table[i].mode == TIMER_MODE_SECONDS) | | else if (timers_table[i].mode == TIMER_MODE_SECONDS) |
| | |
{ | | { |
/* Call object timer event */ | | /* Call object timer event */ |
timers_table[i].mode = TIMER_MODE_DEAD; | | timers_table[i].mode = TIMER_MODE_DEAD; |
cftimer_process_event(timers_table[i].ob); | | cftimer_process_event(timers_table[i].ob_tag); |
} | | } |
} | | } |
} | | } |
| | |
/*****************************************************************************/ | | /*****************************************************************************/ |
/* Triggers the EVENT_TIMER of the given object */ | | /* Triggers the EVENT_TIMER of the given object */ |
/*****************************************************************************/ | | /*****************************************************************************/ |
static void cftimer_process_event(object* ob) | | static void cftimer_process_event(tag_t ob_tag) |
{ | | { |
| | object* ob = find_object(ob_tag); |
| | if ( ob ) |
execute_event(ob, EVENT_TIMER,NULL,NULL,NULL,SCRIPT_FIX_ALL); | | execute_event(ob, EVENT_TIMER,NULL,NULL,NULL,SCRIPT_FIX_ALL); |
} | | } |
| | |
| | |
return TIMER_ERR_MODE; | | return TIMER_ERR_MODE; |
if (ob == NULL) | | if (ob == NULL) |
return TIMER_ERR_OBJ; | | return TIMER_ERR_OBJ; |
if (find_event(ob, EVENT_TIMER) == NULL) | | if (find_obj_by_type_subtype(ob, EVENT_CONNECTOR, EVENT_TIMER) == NULL) |
return TIMER_ERR_OBJ; | | return TIMER_ERR_OBJ; |
timers_table[id].mode = mode; | | timers_table[id].mode = mode; |
timers_table[id].ob = ob; | | timers_table[id].ob_tag = ob->count; |
if (mode == TIMER_MODE_CYCLES) | | if (mode == TIMER_MODE_CYCLES) |
timers_table[id].delay = delay; | | timers_table[id].delay = delay; |
else | | else |
| | |
return TIMER_ERR_ID; | | return TIMER_ERR_ID; |
} | | } |
| | |
| | void cftimer_init() |
| | { |
| | memset(&timers_table[0], 0, sizeof(cftimer) * MAX_TIMERS); |
| | } |