Crossfire Server, Trunk
1.75.0
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
#undef MODULEAPI
20
#ifdef WIN32__
21
# ifdef PYTHON_PLUGIN_EXPORTS
22
# define MODULEAPI __declspec(dllexport)
23
# else
24
# define MODULEAPI __declspec(dllimport)
25
# endif
26
#else
27
#ifdef HAVE_VISIBILITY
28
# define MODULEAPI __attribute__((visibility("default")))
29
#else
30
# define MODULEAPI
31
#endif
32
#endif
33
34
#include <
global.h
>
35
36
/*****************************************************************************/
37
/* This one does not exist under Win32. */
38
/*****************************************************************************/
39
#ifndef WIN32
40
#include <dlfcn.h>
41
#endif
42
43
#include "
random_maps/random_map.h
"
44
#include "
random_maps/rproto.h
"
45
46
/*******************************************************************************/
47
/* This one does not exist under Win32. */
48
/*******************************************************************************/
49
#ifndef WIN32
50
#include <dirent.h>
51
#endif
52
53
#define CFAPI_NONE 0
54
#define CFAPI_INT 1
55
#define CFAPI_LONG 2
56
#define CFAPI_CHAR 3
57
#define CFAPI_STRING 4
/* String with a length that must be given too. */
58
#define CFAPI_POBJECT 5
59
#define CFAPI_PMAP 6
60
#define CFAPI_FLOAT 7
61
#define CFAPI_DOUBLE 8
62
#define CFAPI_PARCH 9
63
#define CFAPI_FUNC 10
64
#define CFAPI_PPLAYER 11
65
#define CFAPI_PPARTY 12
66
#define CFAPI_PREGION 13
67
#define CFAPI_INT16 14
68
#define CFAPI_TIME 15
69
#define CFAPI_SINT64 16
70
#define CFAPI_SSTRING 17
/* Shared string that shouldn't be changed, or const char* */
71
#define CFAPI_MOVETYPE 18
/* MoveType */
72
#define CFAPI_OBJECT_VECTOR 19
73
#define CFAPI_MAP_VECTOR 20
74
#define CFAPI_ARCHETYPE_VECTOR 21
75
#define CFAPI_REGION_VECTOR 22
76
#define CFAPI_PARTY_VECTOR 23
79
typedef void (*f_plug_api)(int *type, ...);
80
81
typedef
int (*
f_plug_postinit
)(void);
83
typedef
int (*
f_plug_init
)(
const
char
*iversion,
f_plug_api
gethooksptr);
85
typedef
void
*(*f_plug_property)(
int
*
type
, ...);
86
87
#ifndef WIN32
88
#define LIBPTRTYPE void *
89
#else
90
91
#define LIBPTRTYPE HMODULE
92
#endif
93
95
struct
crossfire_plugin
{
96
f_plug_property
propfunc
;
97
f_plug_postinit
closefunc
;
98
LIBPTRTYPE
libptr
;
99
char
id
[
MAX_BUF
];
100
char
fullname
[
MAX_BUF
];
101
event_registration
global_registration
[
NR_EVENTS
];
102
} ;
103
104
#ifdef WIN32
105
106
#define plugins_dlopen(fname) LoadLibraryA(fname)
107
#define plugins_dlclose(lib) FreeLibrary(lib)
108
#define plugins_dlsym(lib, name) GetProcAddress(lib, name)
109
110
#else
/*WIN32 */
111
112
#define plugins_dlopen(fname) dlopen(fname, RTLD_NOW|RTLD_GLOBAL)
113
#define plugins_dlclose(lib) dlclose(lib)
114
#define plugins_dlsym(lib, name) dlsym(lib, name)
115
#define plugins_dlerror() dlerror()
116
#endif
/* WIN32 */
117
118
/* OBJECT-RELATED HOOKS */
119
120
#define CFAPI_OBJECT_PROP_OB_ABOVE 1
121
#define CFAPI_OBJECT_PROP_OB_BELOW 2
122
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB 3
123
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB 4
124
#define CFAPI_OBJECT_PROP_INVENTORY 5
125
#define CFAPI_OBJECT_PROP_ENVIRONMENT 6
126
#define CFAPI_OBJECT_PROP_HEAD 7
127
#define CFAPI_OBJECT_PROP_CONTAINER 8
128
#define CFAPI_OBJECT_PROP_MAP 9
129
#define CFAPI_OBJECT_PROP_COUNT 10
130
#define CFAPI_OBJECT_PROP_NAME 12
131
#define CFAPI_OBJECT_PROP_NAME_PLURAL 13
132
#define CFAPI_OBJECT_PROP_TITLE 14
133
#define CFAPI_OBJECT_PROP_RACE 15
134
#define CFAPI_OBJECT_PROP_SLAYING 16
135
#define CFAPI_OBJECT_PROP_SKILL 17
136
#define CFAPI_OBJECT_PROP_MESSAGE 18
137
#define CFAPI_OBJECT_PROP_LORE 19
138
#define CFAPI_OBJECT_PROP_X 20
139
#define CFAPI_OBJECT_PROP_Y 21
140
#define CFAPI_OBJECT_PROP_SPEED 22
141
#define CFAPI_OBJECT_PROP_SPEED_LEFT 23
142
#define CFAPI_OBJECT_PROP_NROF 24
143
#define CFAPI_OBJECT_PROP_DIRECTION 25
144
#define CFAPI_OBJECT_PROP_FACING 26
145
#define CFAPI_OBJECT_PROP_TYPE 27
146
#define CFAPI_OBJECT_PROP_SUBTYPE 28
147
#define CFAPI_OBJECT_PROP_CLIENT_TYPE 29
148
#define CFAPI_OBJECT_PROP_RESIST 30
149
#define CFAPI_OBJECT_PROP_ATTACK_TYPE 31
150
#define CFAPI_OBJECT_PROP_PATH_ATTUNED 32
151
#define CFAPI_OBJECT_PROP_PATH_REPELLED 33
152
#define CFAPI_OBJECT_PROP_PATH_DENIED 34
153
#define CFAPI_OBJECT_PROP_MATERIAL 35
154
#define CFAPI_OBJECT_PROP_MATERIAL_NAME 36
155
#define CFAPI_OBJECT_PROP_MAGIC 37
156
#define CFAPI_OBJECT_PROP_VALUE 38
157
#define CFAPI_OBJECT_PROP_LEVEL 39
158
#define CFAPI_OBJECT_PROP_LAST_HEAL 40
159
#define CFAPI_OBJECT_PROP_LAST_SP 41
160
#define CFAPI_OBJECT_PROP_LAST_GRACE 42
161
#define CFAPI_OBJECT_PROP_LAST_EAT 43
162
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME 44
163
#define CFAPI_OBJECT_PROP_PICK_UP 45
164
#define CFAPI_OBJECT_PROP_ITEM_POWER 46
165
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR 47
166
#define CFAPI_OBJECT_PROP_WEIGHT 48
167
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT 49
168
#define CFAPI_OBJECT_PROP_CARRYING 50
169
#define CFAPI_OBJECT_PROP_GLOW_RADIUS 51
170
#define CFAPI_OBJECT_PROP_TOTAL_EXP 52
171
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON 53
172
#define CFAPI_OBJECT_PROP_ENEMY 54
173
#define CFAPI_OBJECT_PROP_ATTACKED_BY 55
174
#define CFAPI_OBJECT_PROP_RUN_AWAY 56
175
#define CFAPI_OBJECT_PROP_CHOSEN_SKILL 57
176
#define CFAPI_OBJECT_PROP_HIDDEN 58
177
#define CFAPI_OBJECT_PROP_MOVE_STATUS 59
178
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT 60
179
#define CFAPI_OBJECT_PROP_SPELL_ITEM 61
180
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER 62
181
#define CFAPI_OBJECT_PROP_ARCHETYPE 63
182
#define CFAPI_OBJECT_PROP_OTHER_ARCH 64
183
#define CFAPI_OBJECT_PROP_CUSTOM_NAME 65
184
#define CFAPI_OBJECT_PROP_ANIM_SPEED 66
185
#define CFAPI_OBJECT_PROP_FRIENDLY 67
186
#define CFAPI_OBJECT_PROP_SHORT_NAME 68
187
#define CFAPI_OBJECT_PROP_BASE_NAME 69
188
#define CFAPI_OBJECT_PROP_MAGICAL 70
189
#define CFAPI_OBJECT_PROP_LUCK 71
190
#define CFAPI_OBJECT_PROP_EXP 72
191
#define CFAPI_OBJECT_PROP_OWNER 73
192
#define CFAPI_OBJECT_PROP_PRESENT 74
193
#define CFAPI_OBJECT_PROP_CHEATER 75
194
#define CFAPI_OBJECT_PROP_MERGEABLE 76
195
#define CFAPI_OBJECT_PROP_PICKABLE 77
196
#define CFAPI_OBJECT_PROP_FLAGS 78
197
#define CFAPI_OBJECT_PROP_STR 79
198
#define CFAPI_OBJECT_PROP_DEX 80
199
#define CFAPI_OBJECT_PROP_CON 81
200
#define CFAPI_OBJECT_PROP_WIS 82
201
#define CFAPI_OBJECT_PROP_INT 83
202
#define CFAPI_OBJECT_PROP_POW 84
203
#define CFAPI_OBJECT_PROP_CHA 85
204
#define CFAPI_OBJECT_PROP_WC 86
205
#define CFAPI_OBJECT_PROP_AC 87
206
#define CFAPI_OBJECT_PROP_HP 88
207
#define CFAPI_OBJECT_PROP_SP 89
208
#define CFAPI_OBJECT_PROP_GP 90
209
#define CFAPI_OBJECT_PROP_FP 91
210
#define CFAPI_OBJECT_PROP_MAXHP 92
211
#define CFAPI_OBJECT_PROP_MAXSP 93
212
#define CFAPI_OBJECT_PROP_MAXGP 94
213
#define CFAPI_OBJECT_PROP_DAM 95
214
#define CFAPI_OBJECT_PROP_GOD 96
215
#define CFAPI_OBJECT_PROP_ARCH_NAME 97
216
#define CFAPI_OBJECT_PROP_INVISIBLE 98
217
#define CFAPI_OBJECT_PROP_FACE 99
218
#define CFAPI_OBJECT_PROP_ANIMATION 100
219
/*#define CFAPI_OBJECT_PROP_NO_SAVE 101*/
220
#define CFAPI_OBJECT_PROP_MOVE_TYPE 102
221
#define CFAPI_OBJECT_PROP_MOVE_BLOCK 103
222
#define CFAPI_OBJECT_PROP_MOVE_ALLOW 104
223
#define CFAPI_OBJECT_PROP_MOVE_ON 105
224
#define CFAPI_OBJECT_PROP_MOVE_OFF 106
225
#define CFAPI_OBJECT_PROP_MOVE_SLOW 107
226
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY 108
227
#define CFAPI_OBJECT_PROP_DURATION 109
228
#define CFAPI_OBJECT_PROP_RAW_NAME 110
229
230
#define CFAPI_PLAYER_PROP_IP 150
231
#define CFAPI_PLAYER_PROP_MARKED_ITEM 151
232
#define CFAPI_PLAYER_PROP_PARTY 152
233
#define CFAPI_PLAYER_PROP_BED_MAP 153
234
#define CFAPI_PLAYER_PROP_BED_X 154
235
#define CFAPI_PLAYER_PROP_BED_Y 155
236
#define CFAPI_PLAYER_PROP_NEXT 156
237
#define CFAPI_PLAYER_PROP_TITLE 157
238
#define CFAPI_PLAYER_PROP_TRANSPORT 158
239
#define CFAPI_PLAYER_PROP_COUNT 159
240
241
#define CFAPI_PLAYER_QUEST_START 0
242
#define CFAPI_PLAYER_QUEST_GET_STATE 1
243
#define CFAPI_PLAYER_QUEST_SET_STATE 2
244
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED 3
245
246
#define CFAPI_MAP_PROP_FLAGS 0
247
#define CFAPI_MAP_PROP_DIFFICULTY 1
248
#define CFAPI_MAP_PROP_PATH 2
249
#define CFAPI_MAP_PROP_TMPNAME 3
250
#define CFAPI_MAP_PROP_NAME 4
251
#define CFAPI_MAP_PROP_RESET_TIME 5
252
#define CFAPI_MAP_PROP_RESET_TIMEOUT 6
253
#define CFAPI_MAP_PROP_PLAYERS 7
254
#define CFAPI_MAP_PROP_LIGHT 8
255
#define CFAPI_MAP_PROP_DARKNESS 9
256
#define CFAPI_MAP_PROP_WIDTH 10
257
#define CFAPI_MAP_PROP_HEIGHT 11
258
#define CFAPI_MAP_PROP_ENTER_X 12
259
#define CFAPI_MAP_PROP_ENTER_Y 13
260
#define CFAPI_MAP_PROP_MESSAGE 22
261
#define CFAPI_MAP_PROP_NEXT 23
262
#define CFAPI_MAP_PROP_REGION 24
263
#define CFAPI_MAP_PROP_UNIQUE 25
264
265
#define CFAPI_ARCH_PROP_NAME 0
266
#define CFAPI_ARCH_PROP_NEXT 1
267
#define CFAPI_ARCH_PROP_HEAD 2
268
#define CFAPI_ARCH_PROP_MORE 3
269
#define CFAPI_ARCH_PROP_CLONE 4
270
271
#define CFAPI_PARTY_PROP_NAME 0
272
#define CFAPI_PARTY_PROP_NEXT 1
273
#define CFAPI_PARTY_PROP_PASSWORD 2
274
#define CFAPI_PARTY_PROP_PLAYER 3
275
276
#define CFAPI_REGION_PROP_NAME 0
277
#define CFAPI_REGION_PROP_NEXT 1
278
#define CFAPI_REGION_PROP_PARENT 2
279
#define CFAPI_REGION_PROP_LONGNAME 3
280
#define CFAPI_REGION_PROP_MESSAGE 4
281
#define CFAPI_REGION_PROP_JAIL_X 5
282
#define CFAPI_REGION_PROP_JAIL_Y 6
283
#define CFAPI_REGION_PROP_JAIL_PATH 7
284
285
#define CFAPI_SYSTEM_MAPS 200
286
#define CFAPI_SYSTEM_PLAYERS 201
287
#define CFAPI_SYSTEM_ARCHETYPES 202
288
#define CFAPI_SYSTEM_REGIONS 203
289
#define CFAPI_SYSTEM_PARTIES 204
290
#define CFAPI_SYSTEM_FRIENDLY_LIST 205
291
292
/*****************************************************************************/
293
/* Exportable functions. Any plugin should define all those. */
294
/* initPlugin is called when the plugin initialization process starts.*/
295
/* endPlugin is called before the plugin gets unloaded from memory. */
296
/* getPluginProperty is currently unused. */
297
/* registerHook is used to transmit hook pointers from server to plugin.*/
298
/* triggerEvent is called whenever an event occurs. */
299
/*****************************************************************************/
300
/*extern MODULEAPI CFParm *initPlugin(CFParm *PParm);
301
extern MODULEAPI CFParm *endPlugin(CFParm *PParm);
302
extern MODULEAPI CFParm *getPluginProperty(CFParm *PParm);
303
extern MODULEAPI CFParm *registerHook(CFParm *PParm);
304
extern MODULEAPI CFParm *triggerEvent(CFParm *PParm);
305
*/
306
308
struct
hook_entry
{
309
f_plug_api
func
;
310
int
fid
;
311
const
char
fname
[256];
312
};
313
314
#endif
/* PLUGIN_H */
crossfire_plugin::propfunc
f_plug_property propfunc
Plugin getProperty function
Definition:
plugin.h:96
global.h
random_map.h
f_plug_postinit
int(* f_plug_postinit)(void)
Function called after the plugin was initialized.
Definition:
plugin.h:81
NR_EVENTS
#define NR_EVENTS
Number of events, maximum code + 1.
Definition:
events.h:61
hook_entry
One function the server exposes to plugins.
Definition:
plugin.h:308
crossfire_plugin::fullname
char fullname[MAX_BUF]
Plugin full name
Definition:
plugin.h:100
hook_entry::fname
const char fname[256]
Function name.
Definition:
plugin.h:311
f_plug_init
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
First function called in a plugin.
Definition:
plugin.h:83
crossfire_plugin::libptr
LIBPTRTYPE libptr
Pointer to the plugin library
Definition:
plugin.h:98
hook_entry::func
f_plug_api func
Function itself.
Definition:
plugin.h:309
f_plug_api
void(* f_plug_api)(int *type,...)
General API function.
Definition:
plugin.h:79
crossfire_plugin::closefunc
f_plug_postinit closefunc
Plugin Termination function
Definition:
plugin.h:97
rproto.h
crossfire_plugin::global_registration
event_registration global_registration[NR_EVENTS]
Global event registration identifiers.
Definition:
plugin.h:101
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition:
define.h:35
event_registration
unsigned long event_registration
Registration identifier type.
Definition:
events.h:71
LIBPTRTYPE
#define LIBPTRTYPE
Definition:
plugin.h:88
crossfire_plugin
One loaded plugin.
Definition:
plugin.h:95
hook_entry::fid
int fid
Function identifier.
Definition:
plugin.h:310
f_plug_property
void *(* f_plug_property)(int *type,...)
Get various plugin properties.
Definition:
plugin.h:85
is_valid_types_gen.type
list type
Definition:
is_valid_types_gen.py:25
crossfire-crossfire-server
include
plugin.h
Generated on Thu Jun 12 2025 17:03:20 for Crossfire Server, Trunk by
1.8.17