Crossfire Server, Trunk  R20513
Functions | Variables
timers.c File Reference

This handles custom timers. More...

#include <string.h>
#include "timers.h"
#include "sproto.h"
Include dependency graph for timers.c:

Go to the source code of this file.

Functions

int cftimer_create (int id, long delay, object *ob, int mode)
 Creates a new timer. More...
 
int cftimer_destroy (int id)
 Destroys an existing timer. More...
 
int cftimer_find_free_id (void)
 Finds a free ID for a new timer. More...
 
void cftimer_init (void)
 Initialize timers. More...
 
static void cftimer_process_event (tag_t ob_tag)
 Triggers the EVENT_TIMER of the given object. More...
 
void cftimer_process_timers (void)
 Processes all timers. More...
 

Variables

cftimer timers_table [MAX_TIMERS]
 The actual timers. More...
 

Detailed Description

This handles custom timers.

See Custom timers.

Definition in file timers.c.

Function Documentation

int cftimer_create ( int  id,
long  delay,
object ob,
int  mode 
)

Creates a new timer.

Parameters
iddesired timer identifier.
delaydesired timer delay.
obobject that will be linked to this timer. Should have an EVENT_TIMER handler.
modeunit for delay, should be TIMER_MODE_SECONDS or TIMER_MODE_CYCLES. See timers.h.
Return values
TIMER_ERR_NONEtimer was successfully created.
TIMER_ERR_IDinvalid ID.
TIMER_ERR_MODEinvalid mode.
TIMER_ERR_OBJob is NULL or has no EVENT_TIMER handler.

Definition at line 97 of file timers.c.

References obj::count, _cftimer::delay, EVENT_CONNECTOR, EVENT_TIMER, MAX_TIMERS, _cftimer::mode, _cftimer::ob_tag, object_find_by_type_subtype(), seconds(), TIMER_ERR_ID, TIMER_ERR_MODE, TIMER_ERR_NONE, TIMER_ERR_OBJ, TIMER_MODE_CYCLES, TIMER_MODE_DEAD, and TIMER_MODE_SECONDS.

Referenced by cfapi_timer_create().

Here is the call graph for this function:

Here is the caller graph for this function:

int cftimer_destroy ( int  id)

Destroys an existing timer.

Parameters
ididentifier of the timer to destroy.
Return values
TIMER_ERR_NONEno problem encountered.
TIMER_ERR_IDunknown id - timer not found or invalid.

Definition at line 128 of file timers.c.

References MAX_TIMERS, _cftimer::mode, TIMER_ERR_ID, TIMER_ERR_NONE, and TIMER_MODE_DEAD.

Referenced by cfapi_timer_destroy().

Here is the caller graph for this function:

int cftimer_find_free_id ( void  )

Finds a free ID for a new timer.

Return values
TIMER_ERR_IDno free ID available.
>=0an available ID.

Definition at line 144 of file timers.c.

References MAX_TIMERS, TIMER_ERR_ID, and TIMER_MODE_DEAD.

Referenced by cfapi_timer_create().

Here is the caller graph for this function:

void cftimer_init ( void  )

Initialize timers.

Definition at line 157 of file timers.c.

References MAX_TIMERS.

Referenced by init().

Here is the caller graph for this function:

static void cftimer_process_event ( tag_t  ob_tag)
static

Triggers the EVENT_TIMER of the given object.

Parameters
ob_tagobject tag to use.

Definition at line 71 of file timers.c.

References EVENT_TIMER, execute_event(), object_find_by_tag_global(), and SCRIPT_FIX_ALL.

Referenced by cftimer_process_timers().

Here is the call graph for this function:

Here is the caller graph for this function:

void cftimer_process_timers ( void  )

Processes all timers.

Definition at line 44 of file timers.c.

References cftimer_process_event(), _cftimer::delay, MAX_TIMERS, _cftimer::mode, seconds(), TIMER_MODE_CYCLES, TIMER_MODE_DEAD, and TIMER_MODE_SECONDS.

Referenced by server_main().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

cftimer timers_table[MAX_TIMERS]

The actual timers.

Definition at line 37 of file timers.c.