| 1 |
root |
1.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 |
|
|
static PyObject* Map_GetDifficulty(Crossfire_Map* whoptr, void* closure); |
| 29 |
|
|
static PyObject* Map_GetPath(Crossfire_Map* whoptr, void* closure); |
| 30 |
|
|
static PyObject* Map_GetTempName(Crossfire_Map* whoptr, void* closure); |
| 31 |
|
|
static PyObject* Map_GetName(Crossfire_Map* whoptr, void* closure); |
| 32 |
|
|
static PyObject* Map_GetResetTime(Crossfire_Map* whoptr, void* closure); |
| 33 |
|
|
static PyObject* Map_GetResetTimeout(Crossfire_Map* whoptr, void* closure); |
| 34 |
|
|
static PyObject* Map_GetPlayers(Crossfire_Map* whoptr, void* closure); |
| 35 |
|
|
static PyObject* Map_GetLight(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_GetTemperature(Crossfire_Map* whoptr, void* closure); |
| 42 |
|
|
static PyObject* Map_GetPressure(Crossfire_Map* whoptr, void* closure); |
| 43 |
|
|
static PyObject* Map_GetHumidity(Crossfire_Map* whoptr, void* closure); |
| 44 |
|
|
static PyObject* Map_GetWindSpeed(Crossfire_Map* whoptr, void* closure); |
| 45 |
|
|
static PyObject* Map_GetWindDir(Crossfire_Map* whoptr, void* closure); |
| 46 |
|
|
static PyObject* Map_GetSky(Crossfire_Map* whoptr, void* closure); |
| 47 |
|
|
static PyObject* Map_GetWPartX(Crossfire_Map* whoptr, void* closure); |
| 48 |
|
|
static PyObject* Map_GetWPartY(Crossfire_Map* whoptr, void* closure); |
| 49 |
|
|
static PyObject* Map_GetMessage(Crossfire_Map* whoptr, void* closure); |
| 50 |
|
|
static PyObject* Map_GetRegion(Crossfire_Map* whoptr, void* closure); |
| 51 |
|
|
|
| 52 |
|
|
static PyObject* Map_Message(Crossfire_Map* map, PyObject* args); |
| 53 |
|
|
static PyObject* Map_GetFirstObjectAt(Crossfire_Map* map, PyObject* args); |
| 54 |
|
|
static PyObject* Map_CreateObject(Crossfire_Map* map, PyObject* args); |
| 55 |
|
|
static PyObject* Map_Check(Crossfire_Map* map, PyObject* args); |
| 56 |
|
|
static PyObject* Map_Next(Crossfire_Map* map, PyObject* args); |
| 57 |
|
|
|
| 58 |
|
|
static int Map_InternalCompare(Crossfire_Map* left, Crossfire_Map* right); |
| 59 |
|
|
|
| 60 |
|
|
static PyObject* Crossfire_Map_Long( PyObject* obj ); |
| 61 |
|
|
static PyObject* Crossfire_Map_Int( PyObject* obj ); |
| 62 |
|
|
static PyObject *Crossfire_Map_new(PyTypeObject *type, PyObject *args, PyObject *kwds); |
| 63 |
|
|
|
| 64 |
|
|
/* Python binding */ |
| 65 |
|
|
static PyGetSetDef Map_getseters[] = { |
| 66 |
|
|
{"Difficulty", (getter)Map_GetDifficulty, NULL, NULL, NULL }, |
| 67 |
|
|
{"Path", (getter)Map_GetPath, NULL, NULL, NULL }, |
| 68 |
|
|
{"TempName", (getter)Map_GetTempName, NULL, NULL, NULL }, |
| 69 |
|
|
{"Name", (getter)Map_GetName, NULL, NULL, NULL }, |
| 70 |
|
|
{"ResetTime", (getter)Map_GetResetTime, NULL, NULL, NULL }, |
| 71 |
|
|
{"ResetTimeout", (getter)Map_GetResetTimeout,NULL, NULL, NULL }, |
| 72 |
|
|
{"Players", (getter)Map_GetPlayers, NULL, NULL, NULL }, |
| 73 |
|
|
{"Light", (getter)Map_GetLight, NULL, NULL, NULL }, |
| 74 |
|
|
{"Darkness", (getter)Map_GetDarkness, NULL, NULL, NULL }, |
| 75 |
|
|
{"Width", (getter)Map_GetWidth, NULL, NULL, NULL }, |
| 76 |
|
|
{"Height", (getter)Map_GetHeight, NULL, NULL, NULL }, |
| 77 |
|
|
{"EnterX", (getter)Map_GetEnterX, NULL, NULL, NULL }, |
| 78 |
|
|
{"EnterY", (getter)Map_GetEnterY, NULL, NULL, NULL }, |
| 79 |
|
|
{"Temperature", (getter)Map_GetTemperature, NULL, NULL, NULL }, |
| 80 |
|
|
{"Pressure", (getter)Map_GetPressure, NULL, NULL, NULL }, |
| 81 |
|
|
{"Humidity", (getter)Map_GetHumidity, NULL, NULL, NULL }, |
| 82 |
|
|
{"WindSpeed", (getter)Map_GetWindSpeed, NULL, NULL, NULL }, |
| 83 |
|
|
{"WindDirection", (getter)Map_GetWindDir, NULL, NULL, NULL }, |
| 84 |
|
|
{"Sky", (getter)Map_GetSky, NULL, NULL, NULL }, |
| 85 |
|
|
{"WPartX", (getter)Map_GetWPartX, NULL, NULL, NULL }, |
| 86 |
|
|
{"WPartY", (getter)Map_GetWPartY, NULL, NULL, NULL }, |
| 87 |
|
|
{"Message", (getter)Map_GetMessage, NULL, NULL, NULL }, |
| 88 |
|
|
{"Region", (getter)Map_GetRegion, NULL, NULL, NULL }, |
| 89 |
|
|
{ NULL, NULL, NULL, NULL, NULL } |
| 90 |
|
|
}; |
| 91 |
|
|
|
| 92 |
|
|
static PyMethodDef MapMethods[] = { |
| 93 |
|
|
{ "Print", (PyCFunction)Map_Message, METH_VARARGS}, |
| 94 |
|
|
{ "ObjectAt", (PyCFunction)Map_GetFirstObjectAt, METH_VARARGS}, |
| 95 |
|
|
{ "CreateObject", (PyCFunction)Map_CreateObject, METH_VARARGS}, |
| 96 |
|
|
{ "Check", (PyCFunction)Map_Check, METH_VARARGS}, |
| 97 |
|
|
{ "Next", (PyCFunction)Map_Next, METH_VARARGS}, |
| 98 |
|
|
{NULL, NULL, 0} |
| 99 |
|
|
}; |
| 100 |
|
|
|
| 101 |
|
|
static PyNumberMethods MapConvert[ ] = { |
| 102 |
|
|
0, /* binaryfunc nb_add; */ /* __add__ */ |
| 103 |
|
|
0, /* binaryfunc nb_subtract; */ /* __sub__ */ |
| 104 |
|
|
0, /* binaryfunc nb_multiply; */ /* __mul__ */ |
| 105 |
|
|
0, /* binaryfunc nb_divide; */ /* __div__ */ |
| 106 |
|
|
0, /* binaryfunc nb_remainder; */ /* __mod__ */ |
| 107 |
|
|
0, /* binaryfunc nb_divmod; */ /* __divmod__ */ |
| 108 |
|
|
0, /* ternaryfunc nb_power; */ /* __pow__ */ |
| 109 |
|
|
0, /* unaryfunc nb_negative; */ /* __neg__ */ |
| 110 |
|
|
0, /* unaryfunc nb_positive; */ /* __pos__ */ |
| 111 |
|
|
0, /* unaryfunc nb_absolute; */ /* __abs__ */ |
| 112 |
|
|
0, /* inquiry nb_nonzero; */ /* __nonzero__ */ |
| 113 |
|
|
0, /* unaryfunc nb_invert; */ /* __invert__ */ |
| 114 |
|
|
0, /* binaryfunc nb_lshift; */ /* __lshift__ */ |
| 115 |
|
|
0, /* binaryfunc nb_rshift; */ /* __rshift__ */ |
| 116 |
|
|
0, /* binaryfunc nb_and; */ /* __and__ */ |
| 117 |
|
|
0, /* binaryfunc nb_xor; */ /* __xor__ */ |
| 118 |
|
|
0, /* binaryfunc nb_or; */ /* __or__ */ |
| 119 |
|
|
0, /* coercion nb_coerce; */ /* __coerce__ */ |
| 120 |
|
|
Crossfire_Map_Int, /* unaryfunc nb_int; */ /* __int__ */ |
| 121 |
|
|
Crossfire_Map_Long, /* unaryfunc nb_long; */ /* __long__ */ |
| 122 |
|
|
0 |
| 123 |
|
|
}; |
| 124 |
|
|
|
| 125 |
|
|
/* Our actual Python MapType */ |
| 126 |
|
|
PyTypeObject Crossfire_MapType = { |
| 127 |
|
|
PyObject_HEAD_INIT(NULL) |
| 128 |
|
|
0, /* ob_size*/ |
| 129 |
|
|
"Crossfire.Map", /* tp_name*/ |
| 130 |
|
|
sizeof(Crossfire_Map), /* tp_basicsize*/ |
| 131 |
|
|
0, /* tp_itemsize*/ |
| 132 |
|
|
0, /* tp_dealloc*/ |
| 133 |
|
|
0, /* tp_print*/ |
| 134 |
|
|
0, /* tp_getattr*/ |
| 135 |
|
|
0, /* tp_setattr*/ |
| 136 |
|
|
(cmpfunc)Map_InternalCompare, /* tp_compare*/ |
| 137 |
|
|
0, /* tp_repr*/ |
| 138 |
|
|
MapConvert, /* tp_as_number*/ |
| 139 |
|
|
0, /* tp_as_sequence*/ |
| 140 |
|
|
0, /* tp_as_mapping*/ |
| 141 |
|
|
0, /* tp_hash */ |
| 142 |
|
|
0, /* tp_call*/ |
| 143 |
|
|
0, /* tp_str*/ |
| 144 |
|
|
PyObject_GenericGetAttr, /* tp_getattro*/ |
| 145 |
|
|
PyObject_GenericSetAttr, /* tp_setattro*/ |
| 146 |
|
|
0, /* tp_as_buffer*/ |
| 147 |
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags*/ |
| 148 |
|
|
"Crossfire maps", /* tp_doc */ |
| 149 |
|
|
0, /* tp_traverse */ |
| 150 |
|
|
0, /* tp_clear */ |
| 151 |
|
|
0, /* tp_richcompare */ |
| 152 |
|
|
0, /* tp_weaklistoffset */ |
| 153 |
|
|
0, /* tp_iter */ |
| 154 |
|
|
0, /* tp_iternext */ |
| 155 |
|
|
MapMethods, /* tp_methods */ |
| 156 |
|
|
0, /* tp_members */ |
| 157 |
|
|
Map_getseters, /* tp_getset */ |
| 158 |
|
|
0, /* tp_base */ |
| 159 |
|
|
0, /* tp_dict */ |
| 160 |
|
|
0, /* tp_descr_get */ |
| 161 |
|
|
0, /* tp_descr_set */ |
| 162 |
|
|
0, /* tp_dictoffset */ |
| 163 |
|
|
0, /* tp_init */ |
| 164 |
|
|
0, /* tp_alloc */ |
| 165 |
|
|
Crossfire_Map_new, /* tp_new */ |
| 166 |
|
|
}; |