Crossfire Server, Trunk
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 
99  char id[MAX_BUF];
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 
240 #define CFAPI_PLAYER_QUEST_START 0
241 #define CFAPI_PLAYER_QUEST_GET_STATE 1
242 #define CFAPI_PLAYER_QUEST_SET_STATE 2
243 #define CFAPI_PLAYER_QUEST_WAS_COMPLETED 3
244 
245 #define CFAPI_MAP_PROP_FLAGS 0
246 #define CFAPI_MAP_PROP_DIFFICULTY 1
247 #define CFAPI_MAP_PROP_PATH 2
248 #define CFAPI_MAP_PROP_TMPNAME 3
249 #define CFAPI_MAP_PROP_NAME 4
250 #define CFAPI_MAP_PROP_RESET_TIME 5
251 #define CFAPI_MAP_PROP_RESET_TIMEOUT 6
252 #define CFAPI_MAP_PROP_PLAYERS 7
253 #define CFAPI_MAP_PROP_LIGHT 8
254 #define CFAPI_MAP_PROP_DARKNESS 9
255 #define CFAPI_MAP_PROP_WIDTH 10
256 #define CFAPI_MAP_PROP_HEIGHT 11
257 #define CFAPI_MAP_PROP_ENTER_X 12
258 #define CFAPI_MAP_PROP_ENTER_Y 13
259 #define CFAPI_MAP_PROP_MESSAGE 22
260 #define CFAPI_MAP_PROP_NEXT 23
261 #define CFAPI_MAP_PROP_REGION 24
262 #define CFAPI_MAP_PROP_UNIQUE 25
263 
264 #define CFAPI_ARCH_PROP_NAME 0
265 #define CFAPI_ARCH_PROP_NEXT 1
266 #define CFAPI_ARCH_PROP_HEAD 2
267 #define CFAPI_ARCH_PROP_MORE 3
268 #define CFAPI_ARCH_PROP_CLONE 4
269 
270 #define CFAPI_PARTY_PROP_NAME 0
271 #define CFAPI_PARTY_PROP_NEXT 1
272 #define CFAPI_PARTY_PROP_PASSWORD 2
273 #define CFAPI_PARTY_PROP_PLAYER 3
274 
275 #define CFAPI_REGION_PROP_NAME 0
276 #define CFAPI_REGION_PROP_NEXT 1
277 #define CFAPI_REGION_PROP_PARENT 2
278 #define CFAPI_REGION_PROP_LONGNAME 3
279 #define CFAPI_REGION_PROP_MESSAGE 4
280 #define CFAPI_REGION_PROP_JAIL_X 5
281 #define CFAPI_REGION_PROP_JAIL_Y 6
282 #define CFAPI_REGION_PROP_JAIL_PATH 7
283 
284 #define CFAPI_SYSTEM_MAPS 200
285 #define CFAPI_SYSTEM_PLAYERS 201
286 #define CFAPI_SYSTEM_ARCHETYPES 202
287 #define CFAPI_SYSTEM_REGIONS 203
288 #define CFAPI_SYSTEM_PARTIES 204
289 #define CFAPI_SYSTEM_FRIENDLY_LIST 205
290 
291 /*****************************************************************************/
292 /* Exportable functions. Any plugin should define all those. */
293 /* initPlugin is called when the plugin initialization process starts.*/
294 /* endPlugin is called before the plugin gets unloaded from memory. */
295 /* getPluginProperty is currently unused. */
296 /* registerHook is used to transmit hook pointers from server to plugin.*/
297 /* triggerEvent is called whenever an event occurs. */
298 /*****************************************************************************/
299 /*extern MODULEAPI CFParm *initPlugin(CFParm *PParm);
300 extern MODULEAPI CFParm *endPlugin(CFParm *PParm);
301 extern MODULEAPI CFParm *getPluginProperty(CFParm *PParm);
302 extern MODULEAPI CFParm *registerHook(CFParm *PParm);
303 extern MODULEAPI CFParm *triggerEvent(CFParm *PParm);
304 */
305 
307 struct hook_entry {
309  int fid;
310  const char fname[256];
311 };
312 
313 #endif /* PLUGIN_H */
crossfire_plugin::propfunc
f_plug_property propfunc
Definition: plugin.h:96
global.h
random_map.h
f_plug_postinit
int(* f_plug_postinit)(void)
Definition: plugin.h:81
NR_EVENTS
#define NR_EVENTS
Definition: events.h:59
hook_entry
Definition: plugin.h:307
crossfire_plugin::fullname
char fullname[MAX_BUF]
Definition: plugin.h:100
hook_entry::fname
const char fname[256]
Definition: plugin.h:310
f_plug_init
int(* f_plug_init)(const char *iversion, f_plug_api gethooksptr)
Definition: plugin.h:83
crossfire_plugin::libptr
LIBPTRTYPE libptr
Definition: plugin.h:98
hook_entry::func
f_plug_api func
Definition: plugin.h:308
f_plug_api
void(* f_plug_api)(int *type,...)
Definition: plugin.h:79
crossfire_plugin::closefunc
f_plug_postinit closefunc
Definition: plugin.h:97
rproto.h
crossfire_plugin::global_registration
event_registration global_registration[NR_EVENTS]
Definition: plugin.h:101
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
MAX_BUF
#define MAX_BUF
Definition: define.h:35
event_registration
unsigned long event_registration
Definition: events.h:69
LIBPTRTYPE
#define LIBPTRTYPE
Definition: plugin.h:88
crossfire_plugin
Definition: plugin.h:95
make_face_from_files.int
int
Definition: make_face_from_files.py:32
hook_entry::fid
int fid
Definition: plugin.h:309
f_plug_property
void *(* f_plug_property)(int *type,...)
Definition: plugin.h:85
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25