Crossfire Server, Branch 1.12
R12190
|
00001 /*****************************************************************************/ 00002 /* Crossfire plugin support - (C) 2001 by Yann Chachkoff. */ 00003 /* This code is placed under the GPL. */ 00004 /*****************************************************************************/ 00005 00012 /*****************************************************************************/ 00013 /* Headers needed. */ 00014 /*****************************************************************************/ 00015 00016 #ifndef PLUGIN_H 00017 #define PLUGIN_H 00018 00019 /*****************************************************************************/ 00020 /* This one does not exist under Win32. */ 00021 /*****************************************************************************/ 00022 #ifndef WIN32 00023 #include <dlfcn.h> 00024 #endif 00025 00026 #undef MODULEAPI 00027 #ifdef WIN32 00028 #ifdef PYTHON_PLUGIN_EXPORTS 00029 #define MODULEAPI __declspec(dllexport) 00030 #else 00031 #define MODULEAPI __declspec(dllimport) 00032 #endif 00033 #else 00034 #define MODULEAPI 00035 #endif 00036 00037 #include <global.h> 00038 #include <object.h> 00039 #include <logger.h> 00040 00041 #ifdef HAVE_TIME_H 00042 #include <time.h> 00043 #endif 00044 #include <../random_maps/random_map.h> 00045 #include <../random_maps/rproto.h> 00046 00047 /*******************************************************************************/ 00048 /* This one does not exist under Win32. */ 00049 /*******************************************************************************/ 00050 #ifndef WIN32 00051 #include <dirent.h> 00052 #endif 00053 00054 /*******************************************************************************/ 00055 /* Event ID codes. I sorted them to present local events first, but it is */ 00056 /* just a 'cosmetic' thing. */ 00057 /*******************************************************************************/ 00058 /*******************************************************************************/ 00059 /* Local events. Those are always linked to a specific object. */ 00060 /*******************************************************************************/ 00061 #define EVENT_NONE 0 00062 #define EVENT_APPLY 1 00063 #define EVENT_ATTACK 2 00064 #define EVENT_DEATH 3 00065 #define EVENT_DROP 4 00066 #define EVENT_PICKUP 5 00067 #define EVENT_SAY 6 00068 #define EVENT_STOP 7 00069 #define EVENT_TIME 8 00070 #define EVENT_THROW 9 00071 #define EVENT_TRIGGER 10 00072 #define EVENT_CLOSE 11 00073 #define EVENT_TIMER 12 00074 #define EVENT_DESTROY 13 00075 #define EVENT_USER 31 00076 /*******************************************************************************/ 00077 /* Global events. Those are never linked to a specific object. */ 00078 /*******************************************************************************/ 00079 #define EVENT_BORN 14 00080 #define EVENT_CLOCK 15 00081 #define EVENT_CRASH 16 00082 #define EVENT_PLAYER_DEATH 17 00083 #define EVENT_GKILL 18 00084 #define EVENT_LOGIN 19 00085 #define EVENT_LOGOUT 20 00086 #define EVENT_MAPENTER 21 00087 #define EVENT_MAPLEAVE 22 00088 #define EVENT_MAPRESET 23 00089 #define EVENT_REMOVE 24 00090 #define EVENT_SHOUT 25 00091 #define EVENT_TELL 26 00092 #define EVENT_MUZZLE 27 00093 #define EVENT_KICK 28 00094 #define EVENT_MAPUNLOAD 29 00095 #define EVENT_MAPLOAD 30 00096 #define NR_EVENTS 32 00097 00098 #include <stdarg.h> 00099 00100 #define CFAPI_NONE 0 00101 #define CFAPI_INT 1 00102 #define CFAPI_LONG 2 00103 #define CFAPI_CHAR 3 00104 #define CFAPI_STRING 4 /* String with a length that must be given too. */ 00105 #define CFAPI_POBJECT 5 00106 #define CFAPI_PMAP 6 00107 #define CFAPI_FLOAT 7 00108 #define CFAPI_DOUBLE 8 00109 #define CFAPI_PARCH 9 00110 #define CFAPI_FUNC 10 00111 #define CFAPI_PPLAYER 11 00112 #define CFAPI_PPARTY 12 00113 #define CFAPI_PREGION 13 00114 #define CFAPI_INT16 14 00115 #define CFAPI_TIME 15 00116 #define CFAPI_SINT64 16 00117 #define CFAPI_SSTRING 17 /* Shared string that shouldn't be changed, or const char* */ 00118 #define CFAPI_MOVETYPE 18 /* MoveType */ 00119 00121 typedef void *(*f_plug_api)(int *type, ...); 00123 typedef int (*f_plug_postinit)(void); 00125 typedef int (*f_plug_init)(const char *iversion, f_plug_api gethooksptr); 00126 00127 #ifndef WIN32 00128 #define LIBPTRTYPE void * 00129 #else 00130 00131 #define LIBPTRTYPE HMODULE 00132 #endif 00133 00135 typedef struct _crossfire_plugin { 00136 f_plug_api eventfunc; 00137 f_plug_api propfunc; 00138 f_plug_postinit closefunc; 00139 LIBPTRTYPE libptr; 00140 char id[MAX_BUF]; 00141 char fullname[MAX_BUF]; 00142 f_plug_api gevent[NR_EVENTS]; 00143 struct _crossfire_plugin *next; 00144 struct _crossfire_plugin *prev; 00145 } crossfire_plugin; 00146 00147 extern int plugin_number; 00148 extern crossfire_plugin *plugins_list; 00149 00150 #ifdef WIN32 00151 00152 #define plugins_dlopen(fname) LoadLibrary(fname) 00153 #define plugins_dlclose(lib) FreeLibrary(lib) 00154 #define plugins_dlsym(lib, name) GetProcAddress(lib, name) 00155 00156 #else /*WIN32 */ 00157 00158 #define plugins_dlopen(fname) dlopen(fname, RTLD_NOW|RTLD_GLOBAL) 00159 #define plugins_dlclose(lib) dlclose(lib) 00160 #define plugins_dlsym(lib, name) dlsym(lib, name) 00161 #define plugins_dlerror() dlerror() 00162 #endif /* WIN32 */ 00163 00164 /* OBJECT-RELATED HOOKS */ 00165 00166 #define CFAPI_OBJECT_PROP_OB_ABOVE 1 00167 #define CFAPI_OBJECT_PROP_OB_BELOW 2 00168 #define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB 3 00169 #define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB 4 00170 #define CFAPI_OBJECT_PROP_INVENTORY 5 00171 #define CFAPI_OBJECT_PROP_ENVIRONMENT 6 00172 #define CFAPI_OBJECT_PROP_HEAD 7 00173 #define CFAPI_OBJECT_PROP_CONTAINER 8 00174 #define CFAPI_OBJECT_PROP_MAP 9 00175 #define CFAPI_OBJECT_PROP_COUNT 10 00176 #define CFAPI_OBJECT_PROP_NAME 12 00177 #define CFAPI_OBJECT_PROP_NAME_PLURAL 13 00178 #define CFAPI_OBJECT_PROP_TITLE 14 00179 #define CFAPI_OBJECT_PROP_RACE 15 00180 #define CFAPI_OBJECT_PROP_SLAYING 16 00181 #define CFAPI_OBJECT_PROP_SKILL 17 00182 #define CFAPI_OBJECT_PROP_MESSAGE 18 00183 #define CFAPI_OBJECT_PROP_LORE 19 00184 #define CFAPI_OBJECT_PROP_X 20 00185 #define CFAPI_OBJECT_PROP_Y 21 00186 #define CFAPI_OBJECT_PROP_SPEED 22 00187 #define CFAPI_OBJECT_PROP_SPEED_LEFT 23 00188 #define CFAPI_OBJECT_PROP_NROF 24 00189 #define CFAPI_OBJECT_PROP_DIRECTION 25 00190 #define CFAPI_OBJECT_PROP_FACING 26 00191 #define CFAPI_OBJECT_PROP_TYPE 27 00192 #define CFAPI_OBJECT_PROP_SUBTYPE 28 00193 #define CFAPI_OBJECT_PROP_CLIENT_TYPE 29 00194 #define CFAPI_OBJECT_PROP_RESIST 30 00195 #define CFAPI_OBJECT_PROP_ATTACK_TYPE 31 00196 #define CFAPI_OBJECT_PROP_PATH_ATTUNED 32 00197 #define CFAPI_OBJECT_PROP_PATH_REPELLED 33 00198 #define CFAPI_OBJECT_PROP_PATH_DENIED 34 00199 #define CFAPI_OBJECT_PROP_MATERIAL 35 00200 #define CFAPI_OBJECT_PROP_MATERIAL_NAME 36 00201 #define CFAPI_OBJECT_PROP_MAGIC 37 00202 #define CFAPI_OBJECT_PROP_VALUE 38 00203 #define CFAPI_OBJECT_PROP_LEVEL 39 00204 #define CFAPI_OBJECT_PROP_LAST_HEAL 40 00205 #define CFAPI_OBJECT_PROP_LAST_SP 41 00206 #define CFAPI_OBJECT_PROP_LAST_GRACE 42 00207 #define CFAPI_OBJECT_PROP_LAST_EAT 43 00208 #define CFAPI_OBJECT_PROP_INVISIBLE_TIME 44 00209 #define CFAPI_OBJECT_PROP_PICK_UP 45 00210 #define CFAPI_OBJECT_PROP_ITEM_POWER 46 00211 #define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR 47 00212 #define CFAPI_OBJECT_PROP_WEIGHT 48 00213 #define CFAPI_OBJECT_PROP_WEIGHT_LIMIT 49 00214 #define CFAPI_OBJECT_PROP_CARRYING 50 00215 #define CFAPI_OBJECT_PROP_GLOW_RADIUS 51 00216 #define CFAPI_OBJECT_PROP_PERM_EXP 52 00217 #define CFAPI_OBJECT_PROP_CURRENT_WEAPON 53 00218 #define CFAPI_OBJECT_PROP_ENEMY 54 00219 #define CFAPI_OBJECT_PROP_ATTACKED_BY 55 00220 #define CFAPI_OBJECT_PROP_RUN_AWAY 56 00221 #define CFAPI_OBJECT_PROP_CHOSEN_SKILL 57 00222 #define CFAPI_OBJECT_PROP_HIDDEN 58 00223 #define CFAPI_OBJECT_PROP_MOVE_STATUS 59 00224 #define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT 60 00225 #define CFAPI_OBJECT_PROP_SPELL_ITEM 61 00226 #define CFAPI_OBJECT_PROP_EXP_MULTIPLIER 62 00227 #define CFAPI_OBJECT_PROP_ARCHETYPE 63 00228 #define CFAPI_OBJECT_PROP_OTHER_ARCH 64 00229 #define CFAPI_OBJECT_PROP_CUSTOM_NAME 65 00230 #define CFAPI_OBJECT_PROP_ANIM_SPEED 66 00231 #define CFAPI_OBJECT_PROP_FRIENDLY 67 00232 #define CFAPI_OBJECT_PROP_SHORT_NAME 68 00233 #define CFAPI_OBJECT_PROP_BASE_NAME 69 00234 #define CFAPI_OBJECT_PROP_MAGICAL 70 00235 #define CFAPI_OBJECT_PROP_LUCK 71 00236 #define CFAPI_OBJECT_PROP_EXP 72 00237 #define CFAPI_OBJECT_PROP_OWNER 73 00238 #define CFAPI_OBJECT_PROP_PRESENT 74 00239 #define CFAPI_OBJECT_PROP_CHEATER 75 00240 #define CFAPI_OBJECT_PROP_MERGEABLE 76 00241 #define CFAPI_OBJECT_PROP_PICKABLE 77 00242 #define CFAPI_OBJECT_PROP_FLAGS 78 00243 #define CFAPI_OBJECT_PROP_STR 79 00244 #define CFAPI_OBJECT_PROP_DEX 80 00245 #define CFAPI_OBJECT_PROP_CON 81 00246 #define CFAPI_OBJECT_PROP_WIS 82 00247 #define CFAPI_OBJECT_PROP_INT 83 00248 #define CFAPI_OBJECT_PROP_POW 84 00249 #define CFAPI_OBJECT_PROP_CHA 85 00250 #define CFAPI_OBJECT_PROP_WC 86 00251 #define CFAPI_OBJECT_PROP_AC 87 00252 #define CFAPI_OBJECT_PROP_HP 88 00253 #define CFAPI_OBJECT_PROP_SP 89 00254 #define CFAPI_OBJECT_PROP_GP 90 00255 #define CFAPI_OBJECT_PROP_FP 91 00256 #define CFAPI_OBJECT_PROP_MAXHP 92 00257 #define CFAPI_OBJECT_PROP_MAXSP 93 00258 #define CFAPI_OBJECT_PROP_MAXGP 94 00259 #define CFAPI_OBJECT_PROP_DAM 95 00260 #define CFAPI_OBJECT_PROP_GOD 96 00261 #define CFAPI_OBJECT_PROP_ARCH_NAME 97 00262 #define CFAPI_OBJECT_PROP_INVISIBLE 98 00263 #define CFAPI_OBJECT_PROP_FACE 99 00264 #define CFAPI_OBJECT_PROP_ANIMATION 100 00265 #define CFAPI_OBJECT_PROP_NO_SAVE 101 00266 #define CFAPI_OBJECT_PROP_MOVE_TYPE 102 00267 #define CFAPI_OBJECT_PROP_MOVE_BLOCK 103 00268 #define CFAPI_OBJECT_PROP_MOVE_ALLOW 104 00269 #define CFAPI_OBJECT_PROP_MOVE_ON 105 00270 #define CFAPI_OBJECT_PROP_MOVE_OFF 106 00271 #define CFAPI_OBJECT_PROP_MOVE_SLOW 107 00272 #define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY 108 00273 #define CFAPI_OBJECT_PROP_DURATION 109 00274 00275 #define CFAPI_PLAYER_PROP_IP 150 00276 #define CFAPI_PLAYER_PROP_MARKED_ITEM 151 00277 #define CFAPI_PLAYER_PROP_PARTY 152 00278 #define CFAPI_PLAYER_PROP_BED_MAP 153 00279 #define CFAPI_PLAYER_PROP_BED_X 154 00280 #define CFAPI_PLAYER_PROP_BED_Y 155 00281 #define CFAPI_PLAYER_PROP_NEXT 156 00282 #define CFAPI_PLAYER_PROP_TITLE 157 00283 00284 #define CFAPI_MAP_PROP_FLAGS 0 00285 #define CFAPI_MAP_PROP_DIFFICULTY 1 00286 #define CFAPI_MAP_PROP_PATH 2 00287 #define CFAPI_MAP_PROP_TMPNAME 3 00288 #define CFAPI_MAP_PROP_NAME 4 00289 #define CFAPI_MAP_PROP_RESET_TIME 5 00290 #define CFAPI_MAP_PROP_RESET_TIMEOUT 6 00291 #define CFAPI_MAP_PROP_PLAYERS 7 00292 #define CFAPI_MAP_PROP_LIGHT 8 00293 #define CFAPI_MAP_PROP_DARKNESS 9 00294 #define CFAPI_MAP_PROP_WIDTH 10 00295 #define CFAPI_MAP_PROP_HEIGHT 11 00296 #define CFAPI_MAP_PROP_ENTER_X 12 00297 #define CFAPI_MAP_PROP_ENTER_Y 13 00298 #define CFAPI_MAP_PROP_MESSAGE 22 00299 #define CFAPI_MAP_PROP_NEXT 23 00300 #define CFAPI_MAP_PROP_REGION 24 00301 #define CFAPI_MAP_PROP_UNIQUE 25 00302 00303 #define CFAPI_ARCH_PROP_NAME 0 00304 #define CFAPI_ARCH_PROP_NEXT 1 00305 #define CFAPI_ARCH_PROP_HEAD 2 00306 #define CFAPI_ARCH_PROP_MORE 3 00307 #define CFAPI_ARCH_PROP_CLONE 4 00308 00309 #define CFAPI_PARTY_PROP_NAME 0 00310 #define CFAPI_PARTY_PROP_NEXT 1 00311 #define CFAPI_PARTY_PROP_PASSWORD 2 00312 #define CFAPI_PARTY_PROP_PLAYER 3 00313 00314 #define CFAPI_REGION_PROP_NAME 0 00315 #define CFAPI_REGION_PROP_NEXT 1 00316 #define CFAPI_REGION_PROP_PARENT 2 00317 #define CFAPI_REGION_PROP_LONGNAME 3 00318 #define CFAPI_REGION_PROP_MESSAGE 4 00319 00320 /*****************************************************************************/ 00321 /* Exportable functions. Any plugin should define all those. */ 00322 /* initPlugin is called when the plugin initialization process starts.*/ 00323 /* endPlugin is called before the plugin gets unloaded from memory. */ 00324 /* getPluginProperty is currently unused. */ 00325 /* registerHook is used to transmit hook pointers from server to plugin.*/ 00326 /* triggerEvent is called whenever an event occurs. */ 00327 /*****************************************************************************/ 00328 /*extern MODULEAPI CFParm *initPlugin(CFParm *PParm); 00329 extern MODULEAPI CFParm *endPlugin(CFParm *PParm); 00330 extern MODULEAPI CFParm *getPluginProperty(CFParm *PParm); 00331 extern MODULEAPI CFParm *registerHook(CFParm *PParm); 00332 extern MODULEAPI CFParm *triggerEvent(CFParm *PParm); 00333 */ 00334 00336 typedef struct _hook_entry { 00337 f_plug_api func; 00338 int fid; 00339 const char fname[256]; 00340 } hook_entry; 00341 00342 #endif /* PLUGIN_H */