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