Atrinik Server  4.0
plugin.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
32 #ifndef PLUGIN_H
33 #define PLUGIN_H
34 
35 #ifndef WIN32
36 #include <dlfcn.h>
37 #endif
38 
39 #undef MODULEAPI
40 
41 #ifdef WIN32
42 #ifdef PYTHON_PLUGIN_EXPORTS
43 #define MODULEAPI __declspec(dllexport)
44 #else
45 #define MODULEAPI __declspec(dllimport)
46 #endif
47 #else
48 #define MODULEAPI
49 #endif
50 
59 #define PLUGIN_EVENT_NORMAL 1
60 
61 #define PLUGIN_EVENT_MAP 2
62 
63 #define PLUGIN_EVENT_GLOBAL 3
64 
65 #define PLUGIN_EVENT_UNIT 4
66 
73 #define EVENT_NONE 0
74 
75 #define EVENT_APPLY 1
76 
77 #define EVENT_ATTACK 2
78 
79 #define EVENT_DEATH 3
80 
81 #define EVENT_DROP 4
82 
83 #define EVENT_PICKUP 5
84 
85 #define EVENT_SAY 6
86 
87 #define EVENT_STOP 7
88 
89 #define EVENT_TIME 8
90 
91 #define EVENT_THROW 9
92 
93 #define EVENT_TRIGGER 10
94 
95 #define EVENT_CLOSE 11
96 
97 #define EVENT_QUEST 13
98 
99 #define EVENT_ASK_SHOW 14
100 
101 #define EVENT_AI 15
102 
109 #define EVENT_AI_RANDOM_MOVE 1
110 
111 #define EVENT_AI_GUARD_STOP 2
112 
119 #define MEVENT_ENTER 1
120 
121 #define MEVENT_LEAVE 2
122 
123 #define MEVENT_RESET 3
124 
125 #define MEVENT_SPELL_CAST 4
126 
127 #define MEVENT_SKILL_USED 5
128 
129 #define MEVENT_DROP 6
130 
131 #define MEVENT_PICK 7
132 
133 #define MEVENT_PUT 8
134 
135 #define MEVENT_APPLY 9
136 
137 #define MEVENT_LOGIN 10
138 
139 #define MEVENT_CMD_DROP 11
140 
141 #define MEVENT_CMD_TAKE 12
142 
143 #define MEVENT_EXAMINE 13
144 
151 #define GEVENT_BORN 0
152 
153 #define GEVENT_LOGIN 1
154 
155 #define GEVENT_LOGOUT 2
156 
157 #define GEVENT_PLAYER_DEATH 3
158 
159 #define GEVENT_CACHE_REMOVED 4
160 
161 #define GEVENT_TICK 5
162 
163 #define GEVENT_NUM 6
164 
170 #define EVENT_FLAG(x) (1U << (x - 1))
171 
179 #define HAS_EVENT(ob, event) (ob->event_flags & EVENT_FLAG(event))
180 
181 struct plugin_hooklist;
182 
184 typedef void *(*f_plug_event)(int *type, ...);
186 typedef void (*f_plug_prop)(int *type, ...);
188 typedef void (*f_plug_init)(struct plugin_hooklist *hooklist);
190 typedef void (*f_plug_pinit)(void);
191 
192 #ifndef WIN32
193 
194 #define LIBPTRTYPE void *
195 
196 #define plugins_dlopen(fname) dlopen(fname, RTLD_NOW | RTLD_GLOBAL)
197 
198 #define plugins_dlclose(lib) dlclose(lib)
199 
200 #define plugins_dlsym(lib, name, type) dlsym(lib, name)
201 
202 #define plugins_dlerror() dlerror()
203 #else
204 #define LIBPTRTYPE HMODULE
205 #define plugins_dlopen(fname) LoadLibrary(fname)
206 #define plugins_dlclose(lib) FreeLibrary(lib)
207 #define plugins_dlsym(lib, name, type) (type) GetProcAddress(lib, name)
208 #endif
209 
211 #define FILENAME_IS_PLUGIN(_path) (strstr((_path), "plugin_") && !strcmp((_path) + strlen((_path)) - strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX))
212 
214 typedef struct atrinik_plugin {
217 
220 
223 
225  char id[MAX_BUF];
226 
228  char fullname[MAX_BUF];
229 
232 
236 
246 extern MODULEAPI void initPlugin(struct plugin_hooklist *hooklist);
247 
256 extern MODULEAPI void getPluginProperty(int *type, ...);
257 
265 extern MODULEAPI void *triggerEvent(int *type, ...);
266 
270 extern MODULEAPI void postinitPlugin(void);
271 
275 extern MODULEAPI void closePlugin(void);
278 #endif
char fullname[MAX_BUF]
Definition: plugin.h:228
uint8_t type
One of operation types.
Definition: sound_ambient.c:45
void(* f_plug_init)(struct plugin_hooklist *hooklist)
Definition: plugin.h:188
void(* f_plug_prop)(int *type,...)
Definition: plugin.h:186
void(* f_plug_pinit)(void)
Definition: plugin.h:190
struct atrinik_plugin atrinik_plugin
MODULEAPI void closePlugin(void)
Definition: plugin_arena.c:167
#define LIBPTRTYPE
Definition: plugin.h:194
MODULEAPI void * triggerEvent(int *type,...)
Definition: plugin_arena.c:605
MODULEAPI void getPluginProperty(int *type,...)
Definition: plugin_arena.c:171
int8_t gevent[GEVENT_NUM]
Definition: plugin.h:231
struct atrinik_plugin * next
Definition: plugin.h:234
LIBPTRTYPE libptr
Definition: plugin.h:222
f_plug_event eventfunc
Definition: plugin.h:216
void *(* f_plug_event)(int *type,...)
Definition: plugin.h:184
MODULEAPI void postinitPlugin(void)
Definition: plugin_arena.c:196
#define GEVENT_NUM
Definition: plugin.h:163
f_plug_pinit closefunc
Definition: plugin.h:219
MODULEAPI void initPlugin(struct plugin_hooklist *hooklist)
Definition: plugin_arena.c:162