Crossfire Server, Branches 1.12
R18729
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
cfpython.h
Go to the documentation of this file.
1
/*****************************************************************************/
2
/* CFPython - A Python module for Crossfire RPG. */
3
/* Version: 2.0beta8 (also known as "Alexander") */
4
/* Contact: yann.chachkoff@myrealbox.com */
5
/*****************************************************************************/
6
/* That code is placed under the GNU General Public Licence (GPL) */
7
/* (C)2001-2005 by Chachkoff Yann (Feel free to deliver your complaints) */
8
/*****************************************************************************/
9
/* CrossFire, A Multiplayer game for X-windows */
10
/* */
11
/* Copyright (C) 2000 Mark Wedel */
12
/* Copyright (C) 1992 Frank Tore Johansen */
13
/* */
14
/* This program is free software; you can redistribute it and/or modify */
15
/* it under the terms of the GNU General Public License as published by */
16
/* the Free Software Foundation; either version 2 of the License, or */
17
/* (at your option) any later version. */
18
/* */
19
/* This program is distributed in the hope that it will be useful, */
20
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
21
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
22
/* GNU General Public License for more details. */
23
/* */
24
/* You should have received a copy of the GNU General Public License */
25
/* along with this program; if not, write to the Free Software */
26
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
27
/* */
28
/*****************************************************************************/
29
#ifndef PLUGIN_PYTHON_H
30
#define PLUGIN_PYTHON_H
31
32
/* First the required header files - only the CF module interface and Python */
33
#ifdef WIN32
34
#ifdef _DEBUG
35
#undef _DEBUG
36
#include <Python.h>
37
#define _DEBUG
38
#else
39
#include <Python.h>
40
#endif
41
#else
/* WIN32 */
42
#include <Python.h>
43
#endif
44
45
/* This is for allowing both python 3 and python 2.
46
* We also use some warnings and such with python 2.6 (and later 2.x).
47
*/
48
#if PY_MAJOR_VERSION >= 3
49
# define IS_PY3K
50
#else
/* Python 2.x */
51
# if PY_MINOR_VERSION >= 6
/* 2.6 or later */
52
# define IS_PY26
53
# else
54
# define IS_PY_LEGACY
/* Pre-2.6 lack forward compat. changes for Py3 */
55
# endif
56
# if PY_MINOR_VERSION >= 5
/* PyNumberMethods changed in 2.5 */
57
# define IS_PY25
58
# endif
59
#endif
60
61
/* Python 2.5 or older doesn't define these. */
62
#ifndef Py_SIZE
63
# define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
64
#endif
65
#ifndef Py_TYPE
66
# define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
67
#endif
68
69
/* Python 2.6 and later use PyObject_HashNotImplemented to indicate no support
70
* for hash.
71
*/
72
#ifdef IS_PY_LEGACY
73
# define PyObject_HashNotImplemented NULL
74
#endif
75
76
/* Handle Bytes vs. String */
77
#ifdef IS_PY3K
78
# define CF_IS_PYSTR(cfpy_obj) (PyUnicode_Check(cfpy_obj))
79
#else
80
# define CF_IS_PYSTR(cfpy_obj) (PyString_Check(cfpy_obj) || PyUnicode_Check(cfpy_obj))
81
#endif
82
83
/* Python can define HAVE_GETTIMEOFDAY, but we have our own later on. */
84
#ifdef HAVE_GETTIMEOFDAY
85
#undef HAVE_GETTIMEOFDAY
86
#endif
87
88
/* include compile.h from python. Python.h doesn't pull it in with versions
89
* 2.3 and older, and it does have protection from double-imports.
90
*/
91
#include <compile.h>
92
#include <
plugin.h
>
93
94
#undef MODULEAPI
95
#ifdef WIN32
96
#ifdef PYTHON_PLUGIN_EXPORTS
97
#define MODULEAPI __declspec(dllexport)
98
#else
99
#define MODULEAPI __declspec(dllimport)
100
#endif
101
102
#else
103
#define MODULEAPI
104
#endif
105
106
#define PLUGIN_NAME "Python"
107
#define PLUGIN_VERSION "CFPython Plugin 2.0a13 (Fido)"
108
109
#include <
plugin_common.h
>
110
#include <
cfpython_object.h
>
111
#include <
cfpython_map.h
>
112
#include <
cfpython_archetype.h
>
113
#include <
cfpython_party.h
>
114
#include <
cfpython_region.h
>
115
116
typedef
struct
_cfpcontext
{
117
struct
_cfpcontext
*
down
;
118
PyObject *
who
;
119
PyObject *
activator
;
120
PyObject *
third
;
121
PyObject *
event
;
122
char
message
[1024];
123
int
fix
;
124
int
event_code
;
125
char
script
[1024];
126
char
options
[1024];
127
int
returnvalue
;
128
int
parms
[5];
129
}
CFPContext
;
130
131
extern
f_plug_api
gethook
;
132
133
extern
CFPContext
*
context_stack
;
134
135
extern
CFPContext
*
current_context
;
136
137
/* This structure is used to define one python-implemented crossfire command.*/
138
typedef
struct
PythonCmdStruct
{
139
char
*
name
;
/* The name of the command, as known in the game. */
140
char
*
script
;
/* The name of the script file to bind. */
141
double
speed
;
/* The speed of the command execution. */
142
}
PythonCmd
;
143
144
/* This plugin allows up to 1024 custom commands. */
145
#define NR_CUSTOM_CMD 1024
146
#include <
cfpython_proto.h
>
147
148
#endif
/* PLUGIN_PYTHON_H */
context_stack
CFPContext * context_stack
Definition:
cfpython.c:184
_cfpcontext::third
PyObject * third
Definition:
cfpython.h:120
_cfpcontext::event_code
int event_code
Definition:
cfpython.h:124
cfpython_object.h
_cfpcontext::activator
PyObject * activator
Definition:
cfpython.h:119
_cfpcontext::options
char options[1024]
Definition:
cfpython.h:126
plugin.h
f_plug_api
void *(* f_plug_api)(int *type,...)
Definition:
plugin.h:121
_cfpcontext::message
char message[1024]
Definition:
cfpython.h:122
_cfpcontext::fix
int fix
Definition:
cfpython.h:123
gethook
f_plug_api gethook
Definition:
cfnewspaper.c:38
_cfpcontext::script
char script[1024]
Definition:
cfpython.h:125
PythonCmdStruct::speed
double speed
Definition:
cfpython.h:141
_cfpcontext::event
PyObject * event
Definition:
cfpython.h:121
cfpython_map.h
cfpython_region.h
cfpython_proto.h
PythonCmdStruct::script
char * script
Definition:
cfpython.h:140
PythonCmdStruct::name
char * name
Definition:
cfpython.h:139
_cfpcontext::who
PyObject * who
Definition:
cfpython.h:118
PythonCmdStruct
Definition:
cfpython.h:138
_cfpcontext::parms
int parms[5]
Definition:
cfpython.h:128
plugin_common.h
cfpython_party.h
_cfpcontext
Definition:
cfpython.h:116
_cfpcontext::down
struct _cfpcontext * down
Definition:
cfpython.h:117
cfpython_archetype.h
_cfpcontext::returnvalue
int returnvalue
Definition:
cfpython.h:127
CFPContext
struct _cfpcontext CFPContext
PythonCmd
struct PythonCmdStruct PythonCmd
current_context
CFPContext * current_context
Definition:
cfpython.c:186
crossfire-code
server
branches
1.12
plugins
cfpython
include
cfpython.h
Generated on Sun Nov 18 2018 02:40:29 for Crossfire Server, Branches 1.12 by
1.8.6