ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/plugin.h
(Generate patch)

Comparing deliantra/server/include/plugin.h (file contents):
Revision 1.8 by elmex, Sat Jul 15 11:57:01 2006 UTC vs.
Revision 1.17 by root, Sun Jul 1 05:00:18 2007 UTC

1/*****************************************************************************/ 1/*
2/* Crossfire plugin support - (C) 2001 by Yann Chachkoff. */ 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3/* This code is placed under the GPL. */ 3 *
4/*****************************************************************************/ 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 *
8 * Crossfire TRT 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 3 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, see <http://www.gnu.org/licenses/>.
20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
22 */
5 23
6/*****************************************************************************/ 24/*****************************************************************************/
7/* Headers needed. */ 25/* Headers needed. */
8/*****************************************************************************/ 26/*****************************************************************************/
9 27
11#define PLUGIN_H_ 29#define PLUGIN_H_
12 30
13/*****************************************************************************/ 31/*****************************************************************************/
14/* This one does not exist under Win32. */ 32/* This one does not exist under Win32. */
15/*****************************************************************************/ 33/*****************************************************************************/
16#ifndef WIN32
17#include <dlfcn.h> 34#include <dlfcn.h>
18#endif
19 35
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 36#define MODULEAPI
29#endif
30 37
31#include <global.h> 38#include <global.h>
32#include <object.h> 39#include <object.h>
33 40
34#ifdef HAVE_TIME_H 41#ifdef HAVE_TIME_H
39 46
40 47
41/*****************************************************************************/ 48/*****************************************************************************/
42/* This one does not exist under Win32. */ 49/* This one does not exist under Win32. */
43/*****************************************************************************/ 50/*****************************************************************************/
44#ifndef WIN32
45#include <dirent.h> 51#include <dirent.h>
46#endif
47 52
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 /* Player or monster dead. */
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_BORN 13 /* A new character has been created. */
74#define EVENT_CLOCK 14 /* Global time event. */
75#define EVENT_CRASH 15 /* Triggered when the server crashes. Not recursive*/
76#define EVENT_PLAYER_DEATH 16 /* Global Death event */
77#define EVENT_GKILL 17 /* Triggered when anything got killed by anyone. */
78#define EVENT_LOGIN 18 /* Player login. */
79#define EVENT_LOGOUT 19 /* Player logout. */
80#define EVENT_MAPENTER 20 /* A player entered a map. */
81#define EVENT_MAPLEAVE 21 /* A player left a map. */
82#define EVENT_MAPRESET 22 /* A map is resetting. */
83#define EVENT_REMOVE 23 /* A Player character has been removed. */
84#define EVENT_SHOUT 24 /* A player 'shout' something. */
85#define EVENT_TELL 25 /* A player 'tell' something. */
86#define EVENT_MUZZLE 26 /* A player was Muzzled (no_shout set). */
87#define EVENT_KICK 27 /* A player was Kicked by a DM */
88#define EVENT_FREE_OB 29 /* Object destroyed */
89#define EVENT_MAPLOAD 30 /* Original map has been loaded */
90#define EVENT_MAPOUT 31 /* Map has been swapped out */
91#define EVENT_MAPIN 32 /* Temporary map has been swapped in */
92#define EVENT_MAPCLEAN 33 /* Temporary map will be deleted */
93#define EVENT_PLAYER_LOAD 34 /* Player was just loaded from disk */
94#define EVENT_PLAYER_SAVE 35 /* Player was just saved to disk */
95#define EVENT_PLAYER_USE_SKILL 36 /* player was just trying to use a skill */
96#define EVENT_MONSTER_USE_SKILL 37 /* monster was just trying to use a skill */
97#define EVENT_FIND_UNARMED_SKILL 38 /* lets a plugin find the unarmed skill */
98#define EVENT_EXTCMD 39 /* Low-Level socket command */
99/* should add FREE_MAP, FREE_PLAYER */
100
101#define NR_EVENTS 40 53#define NR_EVENTS 42
102 54
103#include <stdarg.h> 55#include <stdarg.h>
104 56
105#define CFAPI_NONE 0 57#define CFAPI_NONE 0
106#define CFAPI_INT 1 58#define CFAPI_INT 1
120 72
121typedef void* (*f_plug_api) (int* type, ...); 73typedef void* (*f_plug_api) (int* type, ...);
122typedef int (*f_plug_postinit) (void); 74typedef int (*f_plug_postinit) (void);
123typedef int (*f_plug_init)(const char* iversion, f_plug_api gethooksptr); 75typedef int (*f_plug_init)(const char* iversion, f_plug_api gethooksptr);
124 76
125#ifndef WIN32
126#define LIBPTRTYPE void* 77#define LIBPTRTYPE void*
127#else
128#define LIBPTRTYPE HMODULE
129#endif
130 78
131typedef struct _crossfire_plugin 79typedef struct _crossfire_plugin
132{ 80{
133 f_plug_api eventfunc; /* Event Handler function */ 81 f_plug_api eventfunc; /* Event Handler function */
134 f_plug_api propfunc; /* Plugin getProperty function */ 82 f_plug_api propfunc; /* Plugin getProperty function */
142} crossfire_plugin; 90} crossfire_plugin;
143 91
144extern int plugin_number; 92extern int plugin_number;
145extern crossfire_plugin* plugins_list; 93extern crossfire_plugin* plugins_list;
146 94
147#ifdef WIN32
148
149#define plugins_dlopen(fname) LoadLibrary(fname)
150#define plugins_dlclose(lib) FreeLibrary(lib)
151#define plugins_dlsym(lib,name) GetProcAddress(lib,name)
152
153#else /*WIN32 */
154
155#define plugins_dlopen(fname) dlopen(fname,RTLD_NOW|RTLD_GLOBAL) 95#define plugins_dlopen(fname) dlopen(fname,RTLD_NOW|RTLD_GLOBAL)
156#define plugins_dlclose(lib) dlclose(lib) 96#define plugins_dlclose(lib) dlclose(lib)
157#define plugins_dlsym(lib,name) dlsym(lib,name) 97#define plugins_dlsym(lib,name) dlsym(lib,name)
158#define plugins_dlerror() dlerror() 98#define plugins_dlerror() dlerror()
159#endif /* WIN32 */
160 99
161 100
162/* OBJECT-RELATED HOOKS */ 101/* OBJECT-RELATED HOOKS */
163 102
164#define CFAPI_OBJECT_PROP_OB_ABOVE 1 103#define CFAPI_OBJECT_PROP_OB_ABOVE 1

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines