Crossfire Server, Trunk
timers.h
Go to the documentation of this file.
1
/*****************************************************************************/
2
/* Crossfire timers support - (C) 2001 by Yann Chachkoff. */
3
/* This code is placed under the GPL. */
4
/*****************************************************************************/
5
12
#ifndef TIMERS_H
13
#define TIMERS_H
14
15
#include <
global.h
>
16
#include <
object.h
>
17
18
#include <time.h>
19
20
/*****************************************************************************/
21
/* A timer is a kind of "clock" associated with an object. When the counter */
22
/* of a timer reaches 0, it is removed from the list of active timers and an */
23
/* EVENT_TIMER is generated for the target object. */
24
/* Important note: don't confuse "EVENT_TIMER" and "EVENT_TIME" - the first */
25
/* one is called when a timer delay has reached 0 while EVENT_TIME is */
26
/* triggered each time the object gets the opportunity to move. */
27
/*****************************************************************************/
28
/* Timer counting methods. */
29
/* You can either count the time in seconds or in "crossfire cycles". */
30
/* If mode = TIMER_MODE_SECONDS, delay will store the "time to reach" in sec.*/
31
/* For example, if a timer is created at t=2044s to be triggered 10 seconds */
32
/* later, delay = 2054. */
33
/* If mode = TIMER_MODE_CYCLES, delay will store the "time remaining", given */
34
/* in crossfire cycles. For example, if a timer is to be triggered 10 seconds*/
35
/* later, delay = 10. */
36
/*****************************************************************************/
37
/* Timer limits. */
38
/* You can't create more than 1000 timers (I created the timers table as a */
39
/* static one not (only) because I was too lazy/incompetent to implement is */
40
/* as a dynamic linked-list, but because 1) 1000 should be quite enough, 2) */
41
/* 1000 does not use a lot of memory, 3) it would be easier to adapt to some */
42
/* form of multithreading support with a static list. */
43
/* Anyway, if you think 1000 is not enough, you can safely increase this - */
44
/* memory should not be a problem in that case, given the size of a cftimer. */
45
/*****************************************************************************/
46
47
#define TIMER_MODE_DEAD 0
48
#define TIMER_MODE_SECONDS 1
49
#define TIMER_MODE_CYCLES 2
54
struct cftimer {
55
int
mode
;
56
long
delay
;
57
tag_t
ob_tag
;
58
};
59
61
#define MAX_TIMERS 1000
62
64
extern
cftimer
timers_table
[
MAX_TIMERS
];
65
66
#define TIMER_ERR_NONE 0
67
#define TIMER_ERR_ID -1
68
#define TIMER_ERR_OBJ -2
69
#define TIMER_ERR_MODE -3
71
#endif
/* TIMERS_H */
global.h
MAX_TIMERS
#define MAX_TIMERS
Definition:
timers.h:61
timers_table
cftimer timers_table[MAX_TIMERS]
Definition:
timers.cpp:37
cftimer::delay
long delay
Definition:
timers.h:56
cftimer::ob_tag
tag_t ob_tag
Definition:
timers.h:57
tag_t
uint32_t tag_t
Definition:
object.h:14
cftimer
Definition:
timers.h:54
cftimer::mode
int mode
Definition:
timers.h:55
object.h
crossfire-crossfire-server
include
timers.h
Generated by
1.8.17