Crossfire Server, Branches 1.12  R18729
plugin.h
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* Crossfire plugin support - (C) 2001 by Yann Chachkoff. */
3 /* This code is placed under the GPL. */
4 /*****************************************************************************/
5 
12 /*****************************************************************************/
13 /* Headers needed. */
14 /*****************************************************************************/
15 
16 #ifndef PLUGIN_H
17 #define PLUGIN_H
18 
19 /*****************************************************************************/
20 /* This one does not exist under Win32. */
21 /*****************************************************************************/
22 #ifndef WIN32
23 #include <dlfcn.h>
24 #endif
25 
26 #undef MODULEAPI
27 #ifdef WIN32
28 #ifdef PYTHON_PLUGIN_EXPORTS
29 #define MODULEAPI __declspec(dllexport)
30 #else
31 #define MODULEAPI __declspec(dllimport)
32 #endif
33 #else
34 #define MODULEAPI
35 #endif
36 
37 #include <global.h>
38 #include <object.h>
39 #include <logger.h>
40 
41 #ifdef HAVE_TIME_H
42 #include <time.h>
43 #endif
44 #include <../random_maps/random_map.h>
45 #include <../random_maps/rproto.h>
46 
47 /*******************************************************************************/
48 /* This one does not exist under Win32. */
49 /*******************************************************************************/
50 #ifndef WIN32
51 #include <dirent.h>
52 #endif
53 
54 /*******************************************************************************/
55 /* Event ID codes. I sorted them to present local events first, but it is */
56 /* just a 'cosmetic' thing. */
57 /*******************************************************************************/
58 /*******************************************************************************/
59 /* Local events. Those are always linked to a specific object. */
60 /*******************************************************************************/
61 #define EVENT_NONE 0
62 #define EVENT_APPLY 1
63 #define EVENT_ATTACK 2
64 #define EVENT_DEATH 3
65 #define EVENT_DROP 4
66 #define EVENT_PICKUP 5
67 #define EVENT_SAY 6
68 #define EVENT_STOP 7
69 #define EVENT_TIME 8
70 #define EVENT_THROW 9
71 #define EVENT_TRIGGER 10
72 #define EVENT_CLOSE 11
73 #define EVENT_TIMER 12
74 #define EVENT_DESTROY 13
75 #define EVENT_USER 31
76 /*******************************************************************************/
77 /* Global events. Those are never linked to a specific object. */
78 /*******************************************************************************/
79 #define EVENT_BORN 14
80 #define EVENT_CLOCK 15
81 #define EVENT_CRASH 16
82 #define EVENT_PLAYER_DEATH 17
83 #define EVENT_GKILL 18
84 #define EVENT_LOGIN 19
85 #define EVENT_LOGOUT 20
86 #define EVENT_MAPENTER 21
87 #define EVENT_MAPLEAVE 22
88 #define EVENT_MAPRESET 23
89 #define EVENT_REMOVE 24
90 #define EVENT_SHOUT 25
91 #define EVENT_TELL 26
92 #define EVENT_MUZZLE 27
93 #define EVENT_KICK 28
94 #define EVENT_MAPUNLOAD 29
95 #define EVENT_MAPLOAD 30
96 #define NR_EVENTS 32
97 
98 #include <stdarg.h>
99 
100 #define CFAPI_NONE 0
101 #define CFAPI_INT 1
102 #define CFAPI_LONG 2
103 #define CFAPI_CHAR 3
104 #define CFAPI_STRING 4 /* String with a length that must be given too. */
105 #define CFAPI_POBJECT 5
106 #define CFAPI_PMAP 6
107 #define CFAPI_FLOAT 7
108 #define CFAPI_DOUBLE 8
109 #define CFAPI_PARCH 9
110 #define CFAPI_FUNC 10
111 #define CFAPI_PPLAYER 11
112 #define CFAPI_PPARTY 12
113 #define CFAPI_PREGION 13
114 #define CFAPI_INT16 14
115 #define CFAPI_TIME 15
116 #define CFAPI_SINT64 16
117 #define CFAPI_SSTRING 17 /* Shared string that shouldn't be changed, or const char* */
118 #define CFAPI_MOVETYPE 18 /* MoveType */
119 
121 typedef void *(*f_plug_api)(int *type, ...);
123 typedef int (*f_plug_postinit)(void);
125 typedef int (*f_plug_init)(const char *iversion, f_plug_api gethooksptr);
126 
127 #ifndef WIN32
128 #define LIBPTRTYPE void *
129 #else
130 
131 #define LIBPTRTYPE HMODULE
132 #endif
133 
135 typedef struct _crossfire_plugin {
140  char id[MAX_BUF];
146 
147 extern int plugin_number;
149 
150 #ifdef WIN32
151 
152 #define plugins_dlopen(fname) LoadLibrary(fname)
153 #define plugins_dlclose(lib) FreeLibrary(lib)
154 #define plugins_dlsym(lib, name) GetProcAddress(lib, name)
155 
156 #else /*WIN32 */
157 
158 #define plugins_dlopen(fname) dlopen(fname, RTLD_NOW|RTLD_GLOBAL)
159 #define plugins_dlclose(lib) dlclose(lib)
160 #define plugins_dlsym(lib, name) dlsym(lib, name)
161 #define plugins_dlerror() dlerror()
162 #endif /* WIN32 */
163 
164 /* OBJECT-RELATED HOOKS */
165 
166 #define CFAPI_OBJECT_PROP_OB_ABOVE 1
167 #define CFAPI_OBJECT_PROP_OB_BELOW 2
168 #define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB 3
169 #define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB 4
170 #define CFAPI_OBJECT_PROP_INVENTORY 5
171 #define CFAPI_OBJECT_PROP_ENVIRONMENT 6
172 #define CFAPI_OBJECT_PROP_HEAD 7
173 #define CFAPI_OBJECT_PROP_CONTAINER 8
174 #define CFAPI_OBJECT_PROP_MAP 9
175 #define CFAPI_OBJECT_PROP_COUNT 10
176 #define CFAPI_OBJECT_PROP_NAME 12
177 #define CFAPI_OBJECT_PROP_NAME_PLURAL 13
178 #define CFAPI_OBJECT_PROP_TITLE 14
179 #define CFAPI_OBJECT_PROP_RACE 15
180 #define CFAPI_OBJECT_PROP_SLAYING 16
181 #define CFAPI_OBJECT_PROP_SKILL 17
182 #define CFAPI_OBJECT_PROP_MESSAGE 18
183 #define CFAPI_OBJECT_PROP_LORE 19
184 #define CFAPI_OBJECT_PROP_X 20
185 #define CFAPI_OBJECT_PROP_Y 21
186 #define CFAPI_OBJECT_PROP_SPEED 22
187 #define CFAPI_OBJECT_PROP_SPEED_LEFT 23
188 #define CFAPI_OBJECT_PROP_NROF 24
189 #define CFAPI_OBJECT_PROP_DIRECTION 25
190 #define CFAPI_OBJECT_PROP_FACING 26
191 #define CFAPI_OBJECT_PROP_TYPE 27
192 #define CFAPI_OBJECT_PROP_SUBTYPE 28
193 #define CFAPI_OBJECT_PROP_CLIENT_TYPE 29
194 #define CFAPI_OBJECT_PROP_RESIST 30
195 #define CFAPI_OBJECT_PROP_ATTACK_TYPE 31
196 #define CFAPI_OBJECT_PROP_PATH_ATTUNED 32
197 #define CFAPI_OBJECT_PROP_PATH_REPELLED 33
198 #define CFAPI_OBJECT_PROP_PATH_DENIED 34
199 #define CFAPI_OBJECT_PROP_MATERIAL 35
200 #define CFAPI_OBJECT_PROP_MATERIAL_NAME 36
201 #define CFAPI_OBJECT_PROP_MAGIC 37
202 #define CFAPI_OBJECT_PROP_VALUE 38
203 #define CFAPI_OBJECT_PROP_LEVEL 39
204 #define CFAPI_OBJECT_PROP_LAST_HEAL 40
205 #define CFAPI_OBJECT_PROP_LAST_SP 41
206 #define CFAPI_OBJECT_PROP_LAST_GRACE 42
207 #define CFAPI_OBJECT_PROP_LAST_EAT 43
208 #define CFAPI_OBJECT_PROP_INVISIBLE_TIME 44
209 #define CFAPI_OBJECT_PROP_PICK_UP 45
210 #define CFAPI_OBJECT_PROP_ITEM_POWER 46
211 #define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR 47
212 #define CFAPI_OBJECT_PROP_WEIGHT 48
213 #define CFAPI_OBJECT_PROP_WEIGHT_LIMIT 49
214 #define CFAPI_OBJECT_PROP_CARRYING 50
215 #define CFAPI_OBJECT_PROP_GLOW_RADIUS 51
216 #define CFAPI_OBJECT_PROP_PERM_EXP 52
217 #define CFAPI_OBJECT_PROP_CURRENT_WEAPON 53
218 #define CFAPI_OBJECT_PROP_ENEMY 54
219 #define CFAPI_OBJECT_PROP_ATTACKED_BY 55
220 #define CFAPI_OBJECT_PROP_RUN_AWAY 56
221 #define CFAPI_OBJECT_PROP_CHOSEN_SKILL 57
222 #define CFAPI_OBJECT_PROP_HIDDEN 58
223 #define CFAPI_OBJECT_PROP_MOVE_STATUS 59
224 #define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT 60
225 #define CFAPI_OBJECT_PROP_SPELL_ITEM 61
226 #define CFAPI_OBJECT_PROP_EXP_MULTIPLIER 62
227 #define CFAPI_OBJECT_PROP_ARCHETYPE 63
228 #define CFAPI_OBJECT_PROP_OTHER_ARCH 64
229 #define CFAPI_OBJECT_PROP_CUSTOM_NAME 65
230 #define CFAPI_OBJECT_PROP_ANIM_SPEED 66
231 #define CFAPI_OBJECT_PROP_FRIENDLY 67
232 #define CFAPI_OBJECT_PROP_SHORT_NAME 68
233 #define CFAPI_OBJECT_PROP_BASE_NAME 69
234 #define CFAPI_OBJECT_PROP_MAGICAL 70
235 #define CFAPI_OBJECT_PROP_LUCK 71
236 #define CFAPI_OBJECT_PROP_EXP 72
237 #define CFAPI_OBJECT_PROP_OWNER 73
238 #define CFAPI_OBJECT_PROP_PRESENT 74
239 #define CFAPI_OBJECT_PROP_CHEATER 75
240 #define CFAPI_OBJECT_PROP_MERGEABLE 76
241 #define CFAPI_OBJECT_PROP_PICKABLE 77
242 #define CFAPI_OBJECT_PROP_FLAGS 78
243 #define CFAPI_OBJECT_PROP_STR 79
244 #define CFAPI_OBJECT_PROP_DEX 80
245 #define CFAPI_OBJECT_PROP_CON 81
246 #define CFAPI_OBJECT_PROP_WIS 82
247 #define CFAPI_OBJECT_PROP_INT 83
248 #define CFAPI_OBJECT_PROP_POW 84
249 #define CFAPI_OBJECT_PROP_CHA 85
250 #define CFAPI_OBJECT_PROP_WC 86
251 #define CFAPI_OBJECT_PROP_AC 87
252 #define CFAPI_OBJECT_PROP_HP 88
253 #define CFAPI_OBJECT_PROP_SP 89
254 #define CFAPI_OBJECT_PROP_GP 90
255 #define CFAPI_OBJECT_PROP_FP 91
256 #define CFAPI_OBJECT_PROP_MAXHP 92
257 #define CFAPI_OBJECT_PROP_MAXSP 93
258 #define CFAPI_OBJECT_PROP_MAXGP 94
259 #define CFAPI_OBJECT_PROP_DAM 95
260 #define CFAPI_OBJECT_PROP_GOD 96
261 #define CFAPI_OBJECT_PROP_ARCH_NAME 97
262 #define CFAPI_OBJECT_PROP_INVISIBLE 98
263 #define CFAPI_OBJECT_PROP_FACE 99
264 #define CFAPI_OBJECT_PROP_ANIMATION 100
265 #define CFAPI_OBJECT_PROP_NO_SAVE 101
266 #define CFAPI_OBJECT_PROP_MOVE_TYPE 102
267 #define CFAPI_OBJECT_PROP_MOVE_BLOCK 103
268 #define CFAPI_OBJECT_PROP_MOVE_ALLOW 104
269 #define CFAPI_OBJECT_PROP_MOVE_ON 105
270 #define CFAPI_OBJECT_PROP_MOVE_OFF 106
271 #define CFAPI_OBJECT_PROP_MOVE_SLOW 107
272 #define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY 108
273 #define CFAPI_OBJECT_PROP_DURATION 109
274 
275 #define CFAPI_PLAYER_PROP_IP 150
276 #define CFAPI_PLAYER_PROP_MARKED_ITEM 151
277 #define CFAPI_PLAYER_PROP_PARTY 152
278 #define CFAPI_PLAYER_PROP_BED_MAP 153
279 #define CFAPI_PLAYER_PROP_BED_X 154
280 #define CFAPI_PLAYER_PROP_BED_Y 155
281 #define CFAPI_PLAYER_PROP_NEXT 156
282 #define CFAPI_PLAYER_PROP_TITLE 157
283 
284 #define CFAPI_MAP_PROP_FLAGS 0
285 #define CFAPI_MAP_PROP_DIFFICULTY 1
286 #define CFAPI_MAP_PROP_PATH 2
287 #define CFAPI_MAP_PROP_TMPNAME 3
288 #define CFAPI_MAP_PROP_NAME 4
289 #define CFAPI_MAP_PROP_RESET_TIME 5
290 #define CFAPI_MAP_PROP_RESET_TIMEOUT 6
291 #define CFAPI_MAP_PROP_PLAYERS 7
292 #define CFAPI_MAP_PROP_LIGHT 8
293 #define CFAPI_MAP_PROP_DARKNESS 9
294 #define CFAPI_MAP_PROP_WIDTH 10
295 #define CFAPI_MAP_PROP_HEIGHT 11
296 #define CFAPI_MAP_PROP_ENTER_X 12
297 #define CFAPI_MAP_PROP_ENTER_Y 13
298 #define CFAPI_MAP_PROP_MESSAGE 22
299 #define CFAPI_MAP_PROP_NEXT 23
300 #define CFAPI_MAP_PROP_REGION 24
301 #define CFAPI_MAP_PROP_UNIQUE 25
302 
303 #define CFAPI_ARCH_PROP_NAME 0
304 #define CFAPI_ARCH_PROP_NEXT 1
305 #define CFAPI_ARCH_PROP_HEAD 2
306 #define CFAPI_ARCH_PROP_MORE 3
307 #define CFAPI_ARCH_PROP_CLONE 4
308 
309 #define CFAPI_PARTY_PROP_NAME 0
310 #define CFAPI_PARTY_PROP_NEXT 1
311 #define CFAPI_PARTY_PROP_PASSWORD 2
312 #define CFAPI_PARTY_PROP_PLAYER 3
313 
314 #define CFAPI_REGION_PROP_NAME 0
315 #define CFAPI_REGION_PROP_NEXT 1
316 #define CFAPI_REGION_PROP_PARENT 2
317 #define CFAPI_REGION_PROP_LONGNAME 3
318 #define CFAPI_REGION_PROP_MESSAGE 4
319 
320 /*****************************************************************************/
321 /* Exportable functions. Any plugin should define all those. */
322 /* initPlugin is called when the plugin initialization process starts.*/
323 /* endPlugin is called before the plugin gets unloaded from memory. */
324 /* getPluginProperty is currently unused. */
325 /* registerHook is used to transmit hook pointers from server to plugin.*/
326 /* triggerEvent is called whenever an event occurs. */
327 /*****************************************************************************/
328 /*extern MODULEAPI CFParm *initPlugin(CFParm *PParm);
329 extern MODULEAPI CFParm *endPlugin(CFParm *PParm);
330 extern MODULEAPI CFParm *getPluginProperty(CFParm *PParm);
331 extern MODULEAPI CFParm *registerHook(CFParm *PParm);
332 extern MODULEAPI CFParm *triggerEvent(CFParm *PParm);
333 */
334 
336 typedef struct _hook_entry {
338  int fid;
339  const char fname[256];
340 } hook_entry;
341 
342 #endif /* PLUGIN_H */
struct _crossfire_plugin crossfire_plugin
#define NR_EVENTS
Definition: plugin.h:96
f_plug_api func
Definition: plugin.h:337
void *(* f_plug_api)(int *type,...)
Definition: plugin.h:121
f_plug_api propfunc
Definition: plugin.h:137
struct _hook_entry hook_entry
int(* f_plug_postinit)(void)
Definition: plugin.h:123
int fid
Definition: plugin.h:338
Definition: plugin.h:336
struct _crossfire_plugin * next
Definition: plugin.h:143
LIBPTRTYPE libptr
Definition: plugin.h:139
f_plug_api eventfunc
Definition: plugin.h:136
f_plug_api gevent[NR_EVENTS]
Definition: plugin.h:142
f_plug_postinit closefunc
Definition: plugin.h:138
#define LIBPTRTYPE
Definition: plugin.h:128
const char fname[256]
Definition: plugin.h:339
char fullname[MAX_BUF]
Definition: plugin.h:141
#define MAX_BUF
Definition: define.h:81
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:125
int plugin_number
Definition: plugins.c:154
crossfire_plugin * plugins_list
Definition: plugins.c:156
struct _crossfire_plugin * prev
Definition: plugin.h:144