| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#ifndef PLUGIN_H |
| 17 |
#define PLUGIN_H |
| 18 |
|
| 19 |
|
| 20 |
|
| 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 |
|
| 51 |
|
| 52 |
#ifndef WIN32 |
| 53 |
#include <dirent.h> |
| 54 |
#endif |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
#define EVENT_NONE 0 |
| 64 |
#define EVENT_APPLY 1 |
| 65 |
#define EVENT_ATTACKED 2 |
| 66 |
#define EVENT_ATTACKS 33 |
| 67 |
#define EVENT_BOUGHT 34 |
| 68 |
#define EVENT_CLOSE 11 |
| 69 |
#define EVENT_DEATH 3 |
| 70 |
#define EVENT_DESTROY 13 |
| 71 |
#define EVENT_DROP 4 |
| 72 |
#define EVENT_PICKUP 5 |
| 73 |
#define EVENT_SAY 6 |
| 74 |
#define EVENT_SELLING 32 |
| 75 |
#define EVENT_STOP 7 |
| 76 |
#define EVENT_TIME 8 |
| 77 |
#define EVENT_THROW 9 |
| 78 |
#define EVENT_TRIGGER 10 |
| 79 |
#define EVENT_TIMER 12 |
| 80 |
#define EVENT_USER 31 |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
#define EVENT_BORN 14 |
| 85 |
#define EVENT_CLOCK 15 |
| 86 |
#define EVENT_CRASH 16 |
| 87 |
#define EVENT_GKILL 18 |
| 88 |
#define EVENT_KICK 28 |
| 89 |
#define EVENT_LOGIN 19 |
| 90 |
#define EVENT_LOGOUT 20 |
| 91 |
#define EVENT_MAPENTER 21 |
| 92 |
#define EVENT_MAPLEAVE 22 |
| 93 |
#define EVENT_MAPLOAD 30 |
| 94 |
#define EVENT_MAPRESET 23 |
| 95 |
#define EVENT_MAPUNLOAD 29 |
| 96 |
#define EVENT_MUZZLE 27 |
| 97 |
#define EVENT_PLAYER_DEATH 17 |
| 98 |
#define EVENT_REMOVE 24 |
| 99 |
#define EVENT_SHOUT 25 |
| 100 |
#define EVENT_TELL 26 |
| 101 |
#define NR_EVENTS 35 |
| 102 |
|
| 103 |
#include <stdarg.h> |
| 104 |
|
| 105 |
#define CFAPI_NONE 0 |
| 106 |
#define CFAPI_INT 1 |
| 107 |
#define CFAPI_LONG 2 |
| 108 |
#define CFAPI_CHAR 3 |
| 109 |
#define CFAPI_STRING 4 |
| 110 |
#define CFAPI_POBJECT 5 |
| 111 |
#define CFAPI_PMAP 6 |
| 112 |
#define CFAPI_FLOAT 7 |
| 113 |
#define CFAPI_DOUBLE 8 |
| 114 |
#define CFAPI_PARCH 9 |
| 115 |
#define CFAPI_FUNC 10 |
| 116 |
#define CFAPI_PPLAYER 11 |
| 117 |
#define CFAPI_PPARTY 12 |
| 118 |
#define CFAPI_PREGION 13 |
| 119 |
#define CFAPI_INT16 14 |
| 120 |
#define CFAPI_TIME 15 |
| 121 |
#define CFAPI_SINT64 16 |
| 122 |
#define CFAPI_SSTRING 17 |
| 123 |
#define CFAPI_MOVETYPE 18 |
| 124 |
|
| 125 |
|
| 126 |
typedef void (*f_plug_api)(int *type, ...); |
| 127 |
|
| 128 |
typedef int (*f_plug_postinit)(void); |
| 129 |
|
| 130 |
typedef int (*f_plug_init)(const char *iversion, f_plug_api gethooksptr); |
| 131 |
|
| 132 |
typedef int (*f_plug_event)(int *type, ...); |
| 133 |
|
| 134 |
typedef void *(*f_plug_property)(int *type, ...); |
| 135 |
|
| 136 |
#ifndef WIN32 |
| 137 |
#define LIBPTRTYPE void * |
| 138 |
#else |
| 139 |
|
| 140 |
#define LIBPTRTYPE HMODULE |
| 141 |
#endif |
| 142 |
|
| 143 |
|
| 144 |
typedef struct _crossfire_plugin { |
| 145 |
f_plug_event eventfunc; |
| 146 |
f_plug_property propfunc; |
| 147 |
f_plug_postinit closefunc; |
| 148 |
LIBPTRTYPE libptr; |
| 149 |
char id[MAX_BUF]; |
| 150 |
char fullname[MAX_BUF]; |
| 151 |
f_plug_event gevent[NR_EVENTS]; |
| 152 |
struct _crossfire_plugin *next; |
| 153 |
struct _crossfire_plugin *prev; |
| 154 |
} crossfire_plugin; |
| 155 |
|
| 156 |
#ifdef WIN32 |
| 157 |
|
| 158 |
#define plugins_dlopen(fname) LoadLibrary(fname) |
| 159 |
#define plugins_dlclose(lib) FreeLibrary(lib) |
| 160 |
#define plugins_dlsym(lib, name) GetProcAddress(lib, name) |
| 161 |
|
| 162 |
#else |
| 163 |
|
| 164 |
#define plugins_dlopen(fname) dlopen(fname, RTLD_NOW|RTLD_GLOBAL) |
| 165 |
#define plugins_dlclose(lib) dlclose(lib) |
| 166 |
#define plugins_dlsym(lib, name) dlsym(lib, name) |
| 167 |
#define plugins_dlerror() dlerror() |
| 168 |
#endif |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
#define CFAPI_OBJECT_PROP_OB_ABOVE 1 |
| 173 |
#define CFAPI_OBJECT_PROP_OB_BELOW 2 |
| 174 |
#define CFAPI_OBJECT_PROP_NEXT_ACTIVE_OB 3 |
| 175 |
#define CFAPI_OBJECT_PROP_PREV_ACTIVE_OB 4 |
| 176 |
#define CFAPI_OBJECT_PROP_INVENTORY 5 |
| 177 |
#define CFAPI_OBJECT_PROP_ENVIRONMENT 6 |
| 178 |
#define CFAPI_OBJECT_PROP_HEAD 7 |
| 179 |
#define CFAPI_OBJECT_PROP_CONTAINER 8 |
| 180 |
#define CFAPI_OBJECT_PROP_MAP 9 |
| 181 |
#define CFAPI_OBJECT_PROP_COUNT 10 |
| 182 |
#define CFAPI_OBJECT_PROP_NAME 12 |
| 183 |
#define CFAPI_OBJECT_PROP_NAME_PLURAL 13 |
| 184 |
#define CFAPI_OBJECT_PROP_TITLE 14 |
| 185 |
#define CFAPI_OBJECT_PROP_RACE 15 |
| 186 |
#define CFAPI_OBJECT_PROP_SLAYING 16 |
| 187 |
#define CFAPI_OBJECT_PROP_SKILL 17 |
| 188 |
#define CFAPI_OBJECT_PROP_MESSAGE 18 |
| 189 |
#define CFAPI_OBJECT_PROP_LORE 19 |
| 190 |
#define CFAPI_OBJECT_PROP_X 20 |
| 191 |
#define CFAPI_OBJECT_PROP_Y 21 |
| 192 |
#define CFAPI_OBJECT_PROP_SPEED 22 |
| 193 |
#define CFAPI_OBJECT_PROP_SPEED_LEFT 23 |
| 194 |
#define CFAPI_OBJECT_PROP_NROF 24 |
| 195 |
#define CFAPI_OBJECT_PROP_DIRECTION 25 |
| 196 |
#define CFAPI_OBJECT_PROP_FACING 26 |
| 197 |
#define CFAPI_OBJECT_PROP_TYPE 27 |
| 198 |
#define CFAPI_OBJECT_PROP_SUBTYPE 28 |
| 199 |
#define CFAPI_OBJECT_PROP_CLIENT_TYPE 29 |
| 200 |
#define CFAPI_OBJECT_PROP_RESIST 30 |
| 201 |
#define CFAPI_OBJECT_PROP_ATTACK_TYPE 31 |
| 202 |
#define CFAPI_OBJECT_PROP_PATH_ATTUNED 32 |
| 203 |
#define CFAPI_OBJECT_PROP_PATH_REPELLED 33 |
| 204 |
#define CFAPI_OBJECT_PROP_PATH_DENIED 34 |
| 205 |
#define CFAPI_OBJECT_PROP_MATERIAL 35 |
| 206 |
#define CFAPI_OBJECT_PROP_MATERIAL_NAME 36 |
| 207 |
#define CFAPI_OBJECT_PROP_MAGIC 37 |
| 208 |
#define CFAPI_OBJECT_PROP_VALUE 38 |
| 209 |
#define CFAPI_OBJECT_PROP_LEVEL 39 |
| 210 |
#define CFAPI_OBJECT_PROP_LAST_HEAL 40 |
| 211 |
#define CFAPI_OBJECT_PROP_LAST_SP 41 |
| 212 |
#define CFAPI_OBJECT_PROP_LAST_GRACE 42 |
| 213 |
#define CFAPI_OBJECT_PROP_LAST_EAT 43 |
| 214 |
#define CFAPI_OBJECT_PROP_INVISIBLE_TIME 44 |
| 215 |
#define CFAPI_OBJECT_PROP_PICK_UP 45 |
| 216 |
#define CFAPI_OBJECT_PROP_ITEM_POWER 46 |
| 217 |
#define CFAPI_OBJECT_PROP_GEN_SP_ARMOUR 47 |
| 218 |
#define CFAPI_OBJECT_PROP_WEIGHT 48 |
| 219 |
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT 49 |
| 220 |
#define CFAPI_OBJECT_PROP_CARRYING 50 |
| 221 |
#define CFAPI_OBJECT_PROP_GLOW_RADIUS 51 |
| 222 |
#define CFAPI_OBJECT_PROP_TOTAL_EXP 52 |
| 223 |
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON 53 |
| 224 |
#define CFAPI_OBJECT_PROP_ENEMY 54 |
| 225 |
#define CFAPI_OBJECT_PROP_ATTACKED_BY 55 |
| 226 |
#define CFAPI_OBJECT_PROP_RUN_AWAY 56 |
| 227 |
#define CFAPI_OBJECT_PROP_CHOSEN_SKILL 57 |
| 228 |
#define CFAPI_OBJECT_PROP_HIDDEN 58 |
| 229 |
#define CFAPI_OBJECT_PROP_MOVE_STATUS 59 |
| 230 |
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT 60 |
| 231 |
#define CFAPI_OBJECT_PROP_SPELL_ITEM 61 |
| 232 |
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER 62 |
| 233 |
#define CFAPI_OBJECT_PROP_ARCHETYPE 63 |
| 234 |
#define CFAPI_OBJECT_PROP_OTHER_ARCH 64 |
| 235 |
#define CFAPI_OBJECT_PROP_CUSTOM_NAME 65 |
| 236 |
#define CFAPI_OBJECT_PROP_ANIM_SPEED 66 |
| 237 |
#define CFAPI_OBJECT_PROP_FRIENDLY 67 |
| 238 |
#define CFAPI_OBJECT_PROP_SHORT_NAME 68 |
| 239 |
#define CFAPI_OBJECT_PROP_BASE_NAME 69 |
| 240 |
#define CFAPI_OBJECT_PROP_MAGICAL 70 |
| 241 |
#define CFAPI_OBJECT_PROP_LUCK 71 |
| 242 |
#define CFAPI_OBJECT_PROP_EXP 72 |
| 243 |
#define CFAPI_OBJECT_PROP_OWNER 73 |
| 244 |
#define CFAPI_OBJECT_PROP_PRESENT 74 |
| 245 |
#define CFAPI_OBJECT_PROP_CHEATER 75 |
| 246 |
#define CFAPI_OBJECT_PROP_MERGEABLE 76 |
| 247 |
#define CFAPI_OBJECT_PROP_PICKABLE 77 |
| 248 |
#define CFAPI_OBJECT_PROP_FLAGS 78 |
| 249 |
#define CFAPI_OBJECT_PROP_STR 79 |
| 250 |
#define CFAPI_OBJECT_PROP_DEX 80 |
| 251 |
#define CFAPI_OBJECT_PROP_CON 81 |
| 252 |
#define CFAPI_OBJECT_PROP_WIS 82 |
| 253 |
#define CFAPI_OBJECT_PROP_INT 83 |
| 254 |
#define CFAPI_OBJECT_PROP_POW 84 |
| 255 |
#define CFAPI_OBJECT_PROP_CHA 85 |
| 256 |
#define CFAPI_OBJECT_PROP_WC 86 |
| 257 |
#define CFAPI_OBJECT_PROP_AC 87 |
| 258 |
#define CFAPI_OBJECT_PROP_HP 88 |
| 259 |
#define CFAPI_OBJECT_PROP_SP 89 |
| 260 |
#define CFAPI_OBJECT_PROP_GP 90 |
| 261 |
#define CFAPI_OBJECT_PROP_FP 91 |
| 262 |
#define CFAPI_OBJECT_PROP_MAXHP 92 |
| 263 |
#define CFAPI_OBJECT_PROP_MAXSP 93 |
| 264 |
#define CFAPI_OBJECT_PROP_MAXGP 94 |
| 265 |
#define CFAPI_OBJECT_PROP_DAM 95 |
| 266 |
#define CFAPI_OBJECT_PROP_GOD 96 |
| 267 |
#define CFAPI_OBJECT_PROP_ARCH_NAME 97 |
| 268 |
#define CFAPI_OBJECT_PROP_INVISIBLE 98 |
| 269 |
#define CFAPI_OBJECT_PROP_FACE 99 |
| 270 |
#define CFAPI_OBJECT_PROP_ANIMATION 100 |
| 271 |
|
| 272 |
#define CFAPI_OBJECT_PROP_MOVE_TYPE 102 |
| 273 |
#define CFAPI_OBJECT_PROP_MOVE_BLOCK 103 |
| 274 |
#define CFAPI_OBJECT_PROP_MOVE_ALLOW 104 |
| 275 |
#define CFAPI_OBJECT_PROP_MOVE_ON 105 |
| 276 |
#define CFAPI_OBJECT_PROP_MOVE_OFF 106 |
| 277 |
#define CFAPI_OBJECT_PROP_MOVE_SLOW 107 |
| 278 |
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY 108 |
| 279 |
#define CFAPI_OBJECT_PROP_DURATION 109 |
| 280 |
#define CFAPI_OBJECT_PROP_RAW_NAME 110 |
| 281 |
|
| 282 |
#define CFAPI_PLAYER_PROP_IP 150 |
| 283 |
#define CFAPI_PLAYER_PROP_MARKED_ITEM 151 |
| 284 |
#define CFAPI_PLAYER_PROP_PARTY 152 |
| 285 |
#define CFAPI_PLAYER_PROP_BED_MAP 153 |
| 286 |
#define CFAPI_PLAYER_PROP_BED_X 154 |
| 287 |
#define CFAPI_PLAYER_PROP_BED_Y 155 |
| 288 |
#define CFAPI_PLAYER_PROP_NEXT 156 |
| 289 |
#define CFAPI_PLAYER_PROP_TITLE 157 |
| 290 |
|
| 291 |
#define CFAPI_PLAYER_QUEST_START 0 |
| 292 |
#define CFAPI_PLAYER_QUEST_GET_STATE 1 |
| 293 |
#define CFAPI_PLAYER_QUEST_SET_STATE 2 |
| 294 |
#define CFAPI_PLAYER_QUEST_WAS_COMPLETED 3 |
| 295 |
|
| 296 |
#define CFAPI_MAP_PROP_FLAGS 0 |
| 297 |
#define CFAPI_MAP_PROP_DIFFICULTY 1 |
| 298 |
#define CFAPI_MAP_PROP_PATH 2 |
| 299 |
#define CFAPI_MAP_PROP_TMPNAME 3 |
| 300 |
#define CFAPI_MAP_PROP_NAME 4 |
| 301 |
#define CFAPI_MAP_PROP_RESET_TIME 5 |
| 302 |
#define CFAPI_MAP_PROP_RESET_TIMEOUT 6 |
| 303 |
#define CFAPI_MAP_PROP_PLAYERS 7 |
| 304 |
#define CFAPI_MAP_PROP_LIGHT 8 |
| 305 |
#define CFAPI_MAP_PROP_DARKNESS 9 |
| 306 |
#define CFAPI_MAP_PROP_WIDTH 10 |
| 307 |
#define CFAPI_MAP_PROP_HEIGHT 11 |
| 308 |
#define CFAPI_MAP_PROP_ENTER_X 12 |
| 309 |
#define CFAPI_MAP_PROP_ENTER_Y 13 |
| 310 |
#define CFAPI_MAP_PROP_MESSAGE 22 |
| 311 |
#define CFAPI_MAP_PROP_NEXT 23 |
| 312 |
#define CFAPI_MAP_PROP_REGION 24 |
| 313 |
#define CFAPI_MAP_PROP_UNIQUE 25 |
| 314 |
|
| 315 |
#define CFAPI_ARCH_PROP_NAME 0 |
| 316 |
#define CFAPI_ARCH_PROP_NEXT 1 |
| 317 |
#define CFAPI_ARCH_PROP_HEAD 2 |
| 318 |
#define CFAPI_ARCH_PROP_MORE 3 |
| 319 |
#define CFAPI_ARCH_PROP_CLONE 4 |
| 320 |
|
| 321 |
#define CFAPI_PARTY_PROP_NAME 0 |
| 322 |
#define CFAPI_PARTY_PROP_NEXT 1 |
| 323 |
#define CFAPI_PARTY_PROP_PASSWORD 2 |
| 324 |
#define CFAPI_PARTY_PROP_PLAYER 3 |
| 325 |
|
| 326 |
#define CFAPI_REGION_PROP_NAME 0 |
| 327 |
#define CFAPI_REGION_PROP_NEXT 1 |
| 328 |
#define CFAPI_REGION_PROP_PARENT 2 |
| 329 |
#define CFAPI_REGION_PROP_LONGNAME 3 |
| 330 |
#define CFAPI_REGION_PROP_MESSAGE 4 |
| 331 |
#define CFAPI_REGION_PROP_JAIL_X 5 |
| 332 |
#define CFAPI_REGION_PROP_JAIL_Y 6 |
| 333 |
#define CFAPI_REGION_PROP_JAIL_PATH 7 |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
typedef struct _hook_entry { |
| 352 |
f_plug_api func; |
| 353 |
int fid; |
| 354 |
const char fname[256]; |
| 355 |
} hook_entry; |
| 356 |
|
| 357 |
#endif |