ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/cfperl.h
Revision: 1.2
Committed: Thu Aug 24 17:29:30 2006 UTC (17 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.1: +45 -0 lines
Log Message:
- fix extmap protocol
- lay foundation for new event interface (not used, not tested)
- "slow down" in-game time specials

File Contents

# Content
1 //
2 // cfperl.h perl interface
3 //
4 #ifndef CFPERL_H__
5 #define CFPERL_H__
6
7 // could have used templates, but a more traditional C api
8 // uses more explicit typing which is ok for this purpose.
9 enum data_type {
10 DT_END, // no further arguments
11 DT_INT,
12 DT_LONG,
13 DT_DOUBLE,
14 DT_STRING, // 0-terminated string
15 DT_DATA, // string + length
16 DT_OBJECT,
17 DT_MAP,
18 DT_PLAYER,
19 DT_ARCH,
20 DT_PARTY,
21 DT_REGION,
22 };
23
24 enum event_type {
25 # define def(name) EV_ ## name,
26 # include "eventinc.h"
27 # undef def
28 };
29
30 #define DT_INT(v) DT_INT , (int)(v)
31 #define DT_LONG(v) DT_LONG , (long)(v)
32 #define DT_DOUBLE(v) DT_DOUBLE, (double)(v)
33 #define DT_STRING(v) DT_STRING, (char *)(v)
34 #define DT_DATA(s,l) DT_DATA , (void *)(s), (l)
35 #define DT_OBJECT(o) DT_OBJECT, (object *)(o)
36 #define DT_MAP(o) DT_MAP , (map *)(o)
37 #define DT_PLAYER(o) DT_PLAYER, (player *)(o)
38 #define DT_ARCH(o) DT_ARCH , (archetype *)(o)
39 #define DT_PARTY(o) DT_PARTY , (party *)(o)
40 #define DT_REGION(o) DT_REGION, (region *)(o)
41
42 #define INVOKE(event, ...) cfperl_invoke ("cf::invoke" , EV_ # event, __VA_ARGS__, DT_END)
43 // should be called on all objects, should be optimised
44 #define INVOKE_ON(object,event, ...) cfperl_invoke ("cf::invoke_on" , EV_ # event, DT_OBJECT(object), __VA_ARGS__, DT_END)
45
46 int cfperl_invoke (const char *klass, event_type event, ...);
47
48 void cfperl_main ();
49
50 #endif