… | |
… | |
11 | #define PLUGIN_H_ |
11 | #define PLUGIN_H_ |
12 | |
12 | |
13 | /*****************************************************************************/ |
13 | /*****************************************************************************/ |
14 | /* This one does not exist under Win32. */ |
14 | /* This one does not exist under Win32. */ |
15 | /*****************************************************************************/ |
15 | /*****************************************************************************/ |
16 | #ifndef WIN32 |
|
|
17 | #include <dlfcn.h> |
16 | #include <dlfcn.h> |
18 | #endif |
|
|
19 | |
17 | |
20 | #undef MODULEAPI |
|
|
21 | #ifdef WIN32 |
|
|
22 | #ifdef PYTHON_PLUGIN_EXPORTS |
|
|
23 | #define MODULEAPI __declspec(dllexport) |
|
|
24 | #else |
|
|
25 | #define MODULEAPI __declspec(dllimport) |
|
|
26 | #endif |
|
|
27 | #else |
|
|
28 | #define MODULEAPI |
18 | #define MODULEAPI |
29 | #endif |
|
|
30 | |
19 | |
31 | #include <global.h> |
20 | #include <global.h> |
32 | #include <object.h> |
21 | #include <object.h> |
33 | |
22 | |
34 | #ifdef HAVE_TIME_H |
23 | #ifdef HAVE_TIME_H |
… | |
… | |
39 | |
28 | |
40 | |
29 | |
41 | /*****************************************************************************/ |
30 | /*****************************************************************************/ |
42 | /* This one does not exist under Win32. */ |
31 | /* This one does not exist under Win32. */ |
43 | /*****************************************************************************/ |
32 | /*****************************************************************************/ |
44 | #ifndef WIN32 |
|
|
45 | #include <dirent.h> |
33 | #include <dirent.h> |
46 | #endif |
|
|
47 | |
|
|
48 | /*****************************************************************************/ |
|
|
49 | /* Event ID codes. I sorted them to present local events first, but it is */ |
|
|
50 | /* just a 'cosmetic' thing. */ |
|
|
51 | /*****************************************************************************/ |
|
|
52 | /*****************************************************************************/ |
|
|
53 | /* Local events. Those are always linked to a specific object. */ |
|
|
54 | /*****************************************************************************/ |
|
|
55 | // how about making this an enum |
|
|
56 | #define EVENT_NONE 0 /* No event. This exists only to reserve the "0". */ |
|
|
57 | #define EVENT_APPLY 1 /* Object applied-unapplied. */ |
|
|
58 | #define EVENT_ATTACK 2 /* Monster attacked or Scripted Weapon used. */ |
|
|
59 | #define EVENT_DEATH 3 |
|
|
60 | #define EVENT_DROP 4 /* Object dropped on the floor. */ |
|
|
61 | #define EVENT_PICKUP 5 /* Object picked up. */ |
|
|
62 | #define EVENT_SAY 6 /* Someone speaks. */ |
|
|
63 | #define EVENT_STOP 7 /* Thrown object stopped. */ |
|
|
64 | #define EVENT_TIME 8 /* Triggered each time the object can react/move. */ |
|
|
65 | #define EVENT_THROW 9 /* Object is thrown. */ |
|
|
66 | #define EVENT_TRIGGER 10 /* Button pushed, lever pulled, etc. */ |
|
|
67 | #define EVENT_CLOSE 11 /* Container closed. */ |
|
|
68 | #define EVENT_TIMER 12 /* Timer connected triggered it. */ |
|
|
69 | #define EVENT_MOVE 28 /* Monster move */ |
|
|
70 | /*****************************************************************************/ |
|
|
71 | /* Global events. Those are never linked to a specific object. */ |
|
|
72 | /*****************************************************************************/ |
|
|
73 | #define EVENT_CLOCK 14 /* Global time event. */ |
|
|
74 | #define EVENT_CRASH 15 /* Triggered when the server crashes. Not recursive*/ |
|
|
75 | #define EVENT_GKILL 17 /* Triggered when anything got killed by anyone. */ |
|
|
76 | #define EVENT_SHOUT 24 /* A player 'shout' something. */ |
|
|
77 | #define EVENT_TELL 25 /* A player 'tell' something. */ |
|
|
78 | #define EVENT_MUZZLE 26 /* A player was Muzzled (no_shout set). */ |
|
|
79 | #define EVENT_KICK 27 /* A player was Kicked by a DM */ |
|
|
80 | #define EVENT_PLAYER_USE_SKILL 36 /* player was just trying to use a skill */ |
|
|
81 | #define EVENT_MONSTER_USE_SKILL 37 /* monster was just trying to use a skill*/ |
|
|
82 | #define EVENT_FIND_UNARMED_SKILL 38 /* lets a plugin find the unarmed skill */ |
|
|
83 | #define EVENT_EXTCMD 39 /* Low-Level socket command */ |
|
|
84 | #define EVENT_CAST_SPELL 40 /* Something successfully casted a spell */ |
|
|
85 | #define EVENT_DROP_ON 41 /* Something was dropped on this (floor) */ |
|
|
86 | /* should add FREE_MAP, FREE_PLAYER */ |
|
|
87 | |
34 | |
88 | #define NR_EVENTS 42 |
35 | #define NR_EVENTS 42 |
89 | |
36 | |
90 | #include <stdarg.h> |
37 | #include <stdarg.h> |
91 | |
38 | |
… | |
… | |
107 | |
54 | |
108 | typedef void* (*f_plug_api) (int* type, ...); |
55 | typedef void* (*f_plug_api) (int* type, ...); |
109 | typedef int (*f_plug_postinit) (void); |
56 | typedef int (*f_plug_postinit) (void); |
110 | typedef int (*f_plug_init)(const char* iversion, f_plug_api gethooksptr); |
57 | typedef int (*f_plug_init)(const char* iversion, f_plug_api gethooksptr); |
111 | |
58 | |
112 | #ifndef WIN32 |
|
|
113 | #define LIBPTRTYPE void* |
59 | #define LIBPTRTYPE void* |
114 | #else |
|
|
115 | #define LIBPTRTYPE HMODULE |
|
|
116 | #endif |
|
|
117 | |
60 | |
118 | typedef struct _crossfire_plugin |
61 | typedef struct _crossfire_plugin |
119 | { |
62 | { |
120 | f_plug_api eventfunc; /* Event Handler function */ |
63 | f_plug_api eventfunc; /* Event Handler function */ |
121 | f_plug_api propfunc; /* Plugin getProperty function */ |
64 | f_plug_api propfunc; /* Plugin getProperty function */ |
… | |
… | |
129 | } crossfire_plugin; |
72 | } crossfire_plugin; |
130 | |
73 | |
131 | extern int plugin_number; |
74 | extern int plugin_number; |
132 | extern crossfire_plugin* plugins_list; |
75 | extern crossfire_plugin* plugins_list; |
133 | |
76 | |
134 | #ifdef WIN32 |
|
|
135 | |
|
|
136 | #define plugins_dlopen(fname) LoadLibrary(fname) |
|
|
137 | #define plugins_dlclose(lib) FreeLibrary(lib) |
|
|
138 | #define plugins_dlsym(lib,name) GetProcAddress(lib,name) |
|
|
139 | |
|
|
140 | #else /*WIN32 */ |
|
|
141 | |
|
|
142 | #define plugins_dlopen(fname) dlopen(fname,RTLD_NOW|RTLD_GLOBAL) |
77 | #define plugins_dlopen(fname) dlopen(fname,RTLD_NOW|RTLD_GLOBAL) |
143 | #define plugins_dlclose(lib) dlclose(lib) |
78 | #define plugins_dlclose(lib) dlclose(lib) |
144 | #define plugins_dlsym(lib,name) dlsym(lib,name) |
79 | #define plugins_dlsym(lib,name) dlsym(lib,name) |
145 | #define plugins_dlerror() dlerror() |
80 | #define plugins_dlerror() dlerror() |
146 | #endif /* WIN32 */ |
|
|
147 | |
81 | |
148 | |
82 | |
149 | /* OBJECT-RELATED HOOKS */ |
83 | /* OBJECT-RELATED HOOKS */ |
150 | |
84 | |
151 | #define CFAPI_OBJECT_PROP_OB_ABOVE 1 |
85 | #define CFAPI_OBJECT_PROP_OB_ABOVE 1 |