Crossfire Server, Branch 1.12
R12190
|
00001 /*****************************************************************************/ 00002 /* CFPython - A Python module for Crossfire RPG. */ 00003 /* Version: 2.0beta8 (also known as "Alexander") */ 00004 /* Contact: yann.chachkoff@myrealbox.com */ 00005 /*****************************************************************************/ 00006 /* That code is placed under the GNU General Public Licence (GPL) */ 00007 /* (C)2001-2005 by Chachkoff Yann (Feel free to deliver your complaints) */ 00008 /*****************************************************************************/ 00009 /* CrossFire, A Multiplayer game for X-windows */ 00010 /* */ 00011 /* Copyright (C) 2000 Mark Wedel */ 00012 /* Copyright (C) 1992 Frank Tore Johansen */ 00013 /* */ 00014 /* This program is free software; you can redistribute it and/or modify */ 00015 /* it under the terms of the GNU General Public License as published by */ 00016 /* the Free Software Foundation; either version 2 of the License, or */ 00017 /* (at your option) any later version. */ 00018 /* */ 00019 /* This program is distributed in the hope that it will be useful, */ 00020 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 00021 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 00022 /* GNU General Public License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU General Public License */ 00025 /* along with this program; if not, write to the Free Software */ 00026 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 00027 /* */ 00028 /*****************************************************************************/ 00029 #ifndef PLUGIN_PYTHON_H 00030 #define PLUGIN_PYTHON_H 00031 00032 /* First the required header files - only the CF module interface and Python */ 00033 #ifdef WIN32 00034 #ifdef _DEBUG 00035 #undef _DEBUG 00036 #include <Python.h> 00037 #define _DEBUG 00038 #else 00039 #include <Python.h> 00040 #endif 00041 #else /* WIN32 */ 00042 #include <Python.h> 00043 #endif 00044 00045 /* This is for allowing both python 3 and python 2. 00046 * We also use some warnings and such with python 2.6 (and later 2.x). 00047 */ 00048 #if PY_MAJOR_VERSION >= 3 00049 # define IS_PY3K 00050 #else /* Python 2.x */ 00051 # if PY_MINOR_VERSION >= 6 /* 2.6 or later */ 00052 # define IS_PY26 00053 # else 00054 # define IS_PY_LEGACY /* Pre-2.6 lack forward compat. changes for Py3 */ 00055 # endif 00056 # if PY_MINOR_VERSION >= 5 /* PyNumberMethods changed in 2.5 */ 00057 # define IS_PY25 00058 # endif 00059 #endif 00060 00061 /* Python 2.5 or older doesn't define these. */ 00062 #ifndef Py_SIZE 00063 # define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) 00064 #endif 00065 #ifndef Py_TYPE 00066 # define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) 00067 #endif 00068 00069 /* Python 2.6 and later use PyObject_HashNotImplemented to indicate no support 00070 * for hash. 00071 */ 00072 #ifdef IS_PY_LEGACY 00073 # define PyObject_HashNotImplemented NULL 00074 #endif 00075 00076 /* Handle Bytes vs. String */ 00077 #ifdef IS_PY3K 00078 # define CF_IS_PYSTR(cfpy_obj) (PyUnicode_Check(cfpy_obj)) 00079 #else 00080 # define CF_IS_PYSTR(cfpy_obj) (PyString_Check(cfpy_obj) || PyUnicode_Check(cfpy_obj)) 00081 #endif 00082 00083 /* Python can define HAVE_GETTIMEOFDAY, but we have our own later on. */ 00084 #ifdef HAVE_GETTIMEOFDAY 00085 #undef HAVE_GETTIMEOFDAY 00086 #endif 00087 00088 /* include compile.h from python. Python.h doesn't pull it in with versions 00089 * 2.3 and older, and it does have protection from double-imports. 00090 */ 00091 #include <compile.h> 00092 #include <plugin.h> 00093 00094 #undef MODULEAPI 00095 #ifdef WIN32 00096 #ifdef PYTHON_PLUGIN_EXPORTS 00097 #define MODULEAPI __declspec(dllexport) 00098 #else 00099 #define MODULEAPI __declspec(dllimport) 00100 #endif 00101 00102 #else 00103 #define MODULEAPI 00104 #endif 00105 00106 #define PLUGIN_NAME "Python" 00107 #define PLUGIN_VERSION "CFPython Plugin 2.0a13 (Fido)" 00108 00109 #include <plugin_common.h> 00110 #include <cfpython_object.h> 00111 #include <cfpython_map.h> 00112 #include <cfpython_archetype.h> 00113 #include <cfpython_party.h> 00114 #include <cfpython_region.h> 00115 00116 typedef struct _cfpcontext { 00117 struct _cfpcontext *down; 00118 PyObject *who; 00119 PyObject *activator; 00120 PyObject *third; 00121 PyObject *event; 00122 char message[1024]; 00123 int fix; 00124 int event_code; 00125 char script[1024]; 00126 char options[1024]; 00127 int returnvalue; 00128 int parms[5]; 00129 } CFPContext; 00130 00131 extern f_plug_api gethook; 00132 00133 extern CFPContext *context_stack; 00134 00135 extern CFPContext *current_context; 00136 00137 /* This structure is used to define one python-implemented crossfire command.*/ 00138 typedef struct PythonCmdStruct { 00139 char *name; /* The name of the command, as known in the game. */ 00140 char *script; /* The name of the script file to bind. */ 00141 double speed; /* The speed of the command execution. */ 00142 } PythonCmd; 00143 00144 /* This plugin allows up to 1024 custom commands. */ 00145 #define NR_CUSTOM_CMD 1024 00146 #include <cfpython_proto.h> 00147 00148 #endif /* PLUGIN_PYTHON_H */