Crossfire Server, Branches 1.12  R18729
cfpython_map_private.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 static PyObject *Map_GetDifficulty(Crossfire_Map *whoptr, void *closure);
30 static PyObject *Map_GetPath(Crossfire_Map *whoptr, void *closure);
31 static PyObject *Map_GetTempName(Crossfire_Map *whoptr, void *closure);
32 static PyObject *Map_GetName(Crossfire_Map *whoptr, void *closure);
33 static PyObject *Map_GetResetTime(Crossfire_Map *whoptr, void *closure);
34 static PyObject *Map_GetResetTimeout(Crossfire_Map *whoptr, void *closure);
35 static PyObject *Map_GetPlayers(Crossfire_Map *whoptr, void *closure);
36 static PyObject *Map_GetDarkness(Crossfire_Map *whoptr, void *closure);
37 static PyObject *Map_GetWidth(Crossfire_Map *whoptr, void *closure);
38 static PyObject *Map_GetHeight(Crossfire_Map *whoptr, void *closure);
39 static PyObject *Map_GetEnterX(Crossfire_Map *whoptr, void *closure);
40 static PyObject *Map_GetEnterY(Crossfire_Map *whoptr, void *closure);
41 static PyObject *Map_GetMessage(Crossfire_Map *whoptr, void *closure);
42 static PyObject *Map_GetRegion(Crossfire_Map *whoptr, void *closure);
43 static PyObject *Map_GetUnique(Crossfire_Map *whoptr, void *closure);
44 
45 static int Map_SetPath(Crossfire_Map *whoptr, PyObject *value, void *closure);
46 
47 static PyObject *Map_Message(Crossfire_Map *map, PyObject *args);
48 static PyObject *Map_GetFirstObjectAt(Crossfire_Map *map, PyObject *args);
49 static PyObject *Map_CreateObject(Crossfire_Map *map, PyObject *args);
50 static PyObject *Map_Check(Crossfire_Map *map, PyObject *args);
51 static PyObject *Map_Next(Crossfire_Map *map, PyObject *args);
52 static PyObject *Map_Insert(Crossfire_Map *map, PyObject *args);
53 static PyObject *Map_ChangeLight(Crossfire_Map *map, PyObject *args);
54 static PyObject *Map_TriggerConnected(Crossfire_Map *map, PyObject *args);
55 
56 static int Map_InternalCompare(Crossfire_Map *left, Crossfire_Map *right);
57 
58 static PyObject *Crossfire_Map_Long(PyObject *obj);
59 #ifndef IS_PY3K
60 static PyObject *Crossfire_Map_Int(PyObject *obj);
61 #endif
62 static void Crossfire_Map_dealloc(PyObject *obj);
63 static PyObject *Crossfire_Map_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
64 
65 /* Python binding */
66 static PyGetSetDef Map_getseters[] = {
67  { "Difficulty", (getter)Map_GetDifficulty, NULL, NULL, NULL },
68  { "Path", (getter)Map_GetPath, (setter)Map_SetPath, NULL, NULL },
69  { "TempName", (getter)Map_GetTempName, NULL, NULL, NULL },
70  { "Name", (getter)Map_GetName, NULL, NULL, NULL },
71  { "ResetTime", (getter)Map_GetResetTime, NULL, NULL, NULL },
72  { "ResetTimeout", (getter)Map_GetResetTimeout, NULL, NULL, NULL },
73  { "Players", (getter)Map_GetPlayers, NULL, NULL, NULL },
74  { "Light", (getter)Map_GetDarkness, NULL, NULL, NULL },
75  { "Darkness", (getter)Map_GetDarkness, NULL, NULL, NULL },
76  { "Width", (getter)Map_GetWidth, NULL, NULL, NULL },
77  { "Height", (getter)Map_GetHeight, NULL, NULL, NULL },
78  { "EnterX", (getter)Map_GetEnterX, NULL, NULL, NULL },
79  { "EnterY", (getter)Map_GetEnterY, NULL, NULL, NULL },
80  { "Message", (getter)Map_GetMessage, NULL, NULL, NULL },
81  { "Region", (getter)Map_GetRegion, NULL, NULL, NULL },
82  { "Unique", (getter)Map_GetUnique, NULL, NULL, NULL },
83  { NULL, NULL, NULL, NULL, NULL }
84 };
85 
86 static PyMethodDef MapMethods[] = {
87  { "Print", (PyCFunction)Map_Message, METH_VARARGS, NULL },
88  { "ObjectAt", (PyCFunction)Map_GetFirstObjectAt, METH_VARARGS, NULL },
89  { "CreateObject", (PyCFunction)Map_CreateObject, METH_VARARGS, NULL },
90  { "Check", (PyCFunction)Map_Check, METH_VARARGS, NULL },
91  { "Next", (PyCFunction)Map_Next, METH_NOARGS, NULL },
92  { "Insert", (PyCFunction)Map_Insert, METH_VARARGS, NULL },
93  { "ChangeLight", (PyCFunction)Map_ChangeLight, METH_VARARGS, NULL },
94  { "TriggerConnected", (PyCFunction)Map_TriggerConnected, METH_VARARGS, NULL },
95  { NULL, NULL, 0, NULL }
96 };
97 
98 static PyNumberMethods MapConvert = {
99  NULL, /* binaryfunc nb_add; */ /* __add__ */
100  NULL, /* binaryfunc nb_subtract; */ /* __sub__ */
101  NULL, /* binaryfunc nb_multiply; */ /* __mul__ */
102 #ifndef IS_PY3K
103  NULL, /* binaryfunc nb_divide; */ /* __div__ */
104 #endif
105  NULL, /* binaryfunc nb_remainder; */ /* __mod__ */
106  NULL, /* binaryfunc nb_divmod; */ /* __divmod__ */
107  NULL, /* ternaryfunc nb_power; */ /* __pow__ */
108  NULL, /* unaryfunc nb_negative; */ /* __neg__ */
109  NULL, /* unaryfunc nb_positive; */ /* __pos__ */
110  NULL, /* unaryfunc nb_absolute; */ /* __abs__ */
111 #ifdef IS_PY3K
112  NULL, /* inquiry nb_bool; */ /* __bool__ */
113 #else
114  NULL, /* inquiry nb_nonzero; */ /* __nonzero__ */
115 #endif
116  NULL, /* unaryfunc nb_invert; */ /* __invert__ */
117  NULL, /* binaryfunc nb_lshift; */ /* __lshift__ */
118  NULL, /* binaryfunc nb_rshift; */ /* __rshift__ */
119  NULL, /* binaryfunc nb_and; */ /* __and__ */
120  NULL, /* binaryfunc nb_xor; */ /* __xor__ */
121  NULL, /* binaryfunc nb_or; */ /* __or__ */
122 #ifndef IS_PY3K
123  NULL, /* coercion nb_coerce; */ /* __coerce__ */
124 #endif
125 #ifdef IS_PY3K
126  /* This is not a typo. For Py3k it should be Crossfire_Map_Long
127  * and NOT Crossfire_Map_Int.
128  */
129  Crossfire_Map_Long, /* unaryfunc nb_int; */ /* __int__ */
130  NULL, /* void *nb_reserved; */
131 #else
132  Crossfire_Map_Int, /* unaryfunc nb_int; */ /* __int__ */
133  Crossfire_Map_Long, /* unaryfunc nb_long; */ /* __long__ */
134 #endif
135  NULL, /* unaryfunc nb_float; */ /* __float__ */
136 #ifndef IS_PY3K
137  NULL, /* unaryfunc nb_oct; */ /* __oct__ */
138  NULL, /* unaryfunc nb_hex; */ /* __hex__ */
139 #endif
140  NULL, /* binaryfunc nb_inplace_add; */
141  NULL, /* binaryfunc nb_inplace_subtract; */
142  NULL, /* binaryfunc nb_inplace_multiply; */
143 #ifndef IS_PY3K
144  NULL, /* binaryfunc nb_inplace_divide; */
145 #endif
146  NULL, /* binaryfunc nb_inplace_remainder; */
147  NULL, /* ternaryfunc nb_inplace_power; */
148  NULL, /* binaryfunc nb_inplace_lshift; */
149  NULL, /* binaryfunc nb_inplace_rshift; */
150  NULL, /* binaryfunc nb_inplace_and; */
151  NULL, /* binaryfunc nb_inplace_xor; */
152  NULL, /* binaryfunc nb_inplace_or; */
153 
154  NULL, /* binaryfunc nb_floor_divide; */
155  NULL, /* binaryfunc nb_true_divide; */
156  NULL, /* binaryfunc nb_inplace_floor_divide; */
157  NULL, /* binaryfunc nb_inplace_true_divide; */
158 #if defined(IS_PY25) || defined(IS_PY3K)
159  NULL /* unaryfunc nb_index; */
160 #endif
161 };
162 
163 /* Our actual Python MapType */
164 PyTypeObject Crossfire_MapType = {
165  PyObject_HEAD_INIT(NULL)
166 #ifndef IS_PY3K
167  0, /* ob_size*/
168 #endif
169  "Crossfire.Map", /* tp_name*/
170  sizeof(Crossfire_Map), /* tp_basicsize*/
171  0, /* tp_itemsize*/
172  Crossfire_Map_dealloc, /* tp_dealloc*/
173  NULL, /* tp_print*/
174  NULL, /* tp_getattr*/
175  NULL, /* tp_setattr*/
176  (cmpfunc)Map_InternalCompare, /* tp_compare*/
177  NULL, /* tp_repr*/
178  &MapConvert, /* tp_as_number*/
179  NULL, /* tp_as_sequence*/
180  NULL, /* tp_as_mapping*/
181  PyObject_HashNotImplemented, /* tp_hash */
182  NULL, /* tp_call*/
183  NULL, /* tp_str*/
184  PyObject_GenericGetAttr, /* tp_getattro*/
185  PyObject_GenericSetAttr, /* tp_setattro*/
186  NULL, /* tp_as_buffer*/
187  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags*/
188  "Crossfire maps", /* tp_doc */
189  NULL, /* tp_traverse */
190  NULL, /* tp_clear */
191  NULL, /* tp_richcompare */
192  0, /* tp_weaklistoffset */
193  NULL, /* tp_iter */
194  NULL, /* tp_iternext */
195  MapMethods, /* tp_methods */
196  NULL, /* tp_members */
197  Map_getseters, /* tp_getset */
198  NULL, /* tp_base */
199  NULL, /* tp_dict */
200  NULL, /* tp_descr_get */
201  NULL, /* tp_descr_set */
202  0, /* tp_dictoffset */
203  NULL, /* tp_init */
204  NULL, /* tp_alloc */
205  Crossfire_Map_new, /* tp_new */
206  NULL, /* tp_free */
207  NULL, /* tp_is_gc */
208  NULL, /* tp_bases */
209  NULL, /* tp_mro */
210  NULL, /* tp_cache */
211  NULL, /* tp_subclasses */
212  NULL, /* tp_weaklist */
213  NULL, /* tp_del */
214 };
Definition: object.h:132
static PyObject * Map_TriggerConnected(Crossfire_Map *map, PyObject *args)
static PyObject * Map_Insert(Crossfire_Map *map, PyObject *args)
static PyObject * Map_GetEnterY(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_Next(Crossfire_Map *map, PyObject *args)
static PyObject * Map_GetUnique(Crossfire_Map *whoptr, void *closure)
static int Map_SetPath(Crossfire_Map *whoptr, PyObject *value, void *closure)
static PyObject * Map_GetDarkness(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_GetFirstObjectAt(Crossfire_Map *map, PyObject *args)
static PyObject * Crossfire_Map_Int(PyObject *obj)
static int Map_InternalCompare(Crossfire_Map *left, Crossfire_Map *right)
static PyObject * Map_GetRegion(Crossfire_Map *whoptr, void *closure)
static void Crossfire_Map_dealloc(PyObject *obj)
static PyObject * Map_CreateObject(Crossfire_Map *map, PyObject *args)
#define PyObject_HashNotImplemented
Definition: cfpython.h:73
static PyObject * Map_GetPlayers(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_GetWidth(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_GetPath(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_GetMessage(Crossfire_Map *whoptr, void *closure)
PyTypeObject Crossfire_MapType
static PyObject * Crossfire_Map_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Map_GetDifficulty(Crossfire_Map *whoptr, void *closure)
static PyNumberMethods MapConvert
static PyObject * Map_ChangeLight(Crossfire_Map *map, PyObject *args)
static PyObject * Map_GetResetTimeout(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_GetTempName(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_Check(Crossfire_Map *map, PyObject *args)
static PyMethodDef MapMethods[]
static PyObject * Map_GetResetTime(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_GetHeight(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_GetEnterX(Crossfire_Map *whoptr, void *closure)
static PyObject * Map_Message(Crossfire_Map *map, PyObject *args)
static PyGetSetDef Map_getseters[]
static PyObject * Map_GetName(Crossfire_Map *whoptr, void *closure)
static PyObject * Crossfire_Map_Long(PyObject *obj)