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.13 by root, Sat Aug 26 08:44:06 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
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/*NOT GENERATED*/#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_SHOUT 24 /* A player 'shout' something. */
76#define EVENT_TELL 25 /* A player 'tell' something. */
77#define EVENT_MUZZLE 26 /* A player was Muzzled (no_shout set). */
78#define EVENT_KICK 27 /* A player was Kicked by a DM */
79//#define EVENT_PLAYER_USE_SKILL 36 /* player was just trying to use a skill */
80//#define EVENT_MONSTER_USE_SKILL 37 /* monster was just trying to use a skill*/
81#define EVENT_DROP_ON 41 /* Something was dropped on this (floor) */
82/* should add FREE_MAP, FREE_PLAYER */
83 52
84#define NR_EVENTS 42 53#define NR_EVENTS 42
85 54
86#include <stdarg.h> 55#include <stdarg.h>
87 56
103 72
104typedef void* (*f_plug_api) (int* type, ...); 73typedef void* (*f_plug_api) (int* type, ...);
105typedef int (*f_plug_postinit) (void); 74typedef int (*f_plug_postinit) (void);
106typedef int (*f_plug_init)(const char* iversion, f_plug_api gethooksptr); 75typedef int (*f_plug_init)(const char* iversion, f_plug_api gethooksptr);
107 76
108#ifndef WIN32
109#define LIBPTRTYPE void* 77#define LIBPTRTYPE void*
110#else
111#define LIBPTRTYPE HMODULE
112#endif
113 78
114typedef struct _crossfire_plugin 79typedef struct _crossfire_plugin
115{ 80{
116 f_plug_api eventfunc; /* Event Handler function */ 81 f_plug_api eventfunc; /* Event Handler function */
117 f_plug_api propfunc; /* Plugin getProperty function */ 82 f_plug_api propfunc; /* Plugin getProperty function */
125} crossfire_plugin; 90} crossfire_plugin;
126 91
127extern int plugin_number; 92extern int plugin_number;
128extern crossfire_plugin* plugins_list; 93extern crossfire_plugin* plugins_list;
129 94
130#ifdef WIN32
131
132#define plugins_dlopen(fname) LoadLibrary(fname)
133#define plugins_dlclose(lib) FreeLibrary(lib)
134#define plugins_dlsym(lib,name) GetProcAddress(lib,name)
135
136#else /*WIN32 */
137
138#define plugins_dlopen(fname) dlopen(fname,RTLD_NOW|RTLD_GLOBAL) 95#define plugins_dlopen(fname) dlopen(fname,RTLD_NOW|RTLD_GLOBAL)
139#define plugins_dlclose(lib) dlclose(lib) 96#define plugins_dlclose(lib) dlclose(lib)
140#define plugins_dlsym(lib,name) dlsym(lib,name) 97#define plugins_dlsym(lib,name) dlsym(lib,name)
141#define plugins_dlerror() dlerror() 98#define plugins_dlerror() dlerror()
142#endif /* WIN32 */
143 99
144 100
145/* OBJECT-RELATED HOOKS */ 101/* OBJECT-RELATED HOOKS */
146 102
147#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