Crossfire Server, Branch 1.12  R12190
cfpython_map_private.h
Go to the documentation of this file.
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 static PyObject *Map_GetDifficulty(Crossfire_Map *whoptr, void *closure);
00030 static PyObject *Map_GetPath(Crossfire_Map *whoptr, void *closure);
00031 static PyObject *Map_GetTempName(Crossfire_Map *whoptr, void *closure);
00032 static PyObject *Map_GetName(Crossfire_Map *whoptr, void *closure);
00033 static PyObject *Map_GetResetTime(Crossfire_Map *whoptr, void *closure);
00034 static PyObject *Map_GetResetTimeout(Crossfire_Map *whoptr, void *closure);
00035 static PyObject *Map_GetPlayers(Crossfire_Map *whoptr, void *closure);
00036 static PyObject *Map_GetDarkness(Crossfire_Map *whoptr, void *closure);
00037 static PyObject *Map_GetWidth(Crossfire_Map *whoptr, void *closure);
00038 static PyObject *Map_GetHeight(Crossfire_Map *whoptr, void *closure);
00039 static PyObject *Map_GetEnterX(Crossfire_Map *whoptr, void *closure);
00040 static PyObject *Map_GetEnterY(Crossfire_Map *whoptr, void *closure);
00041 static PyObject *Map_GetMessage(Crossfire_Map *whoptr, void *closure);
00042 static PyObject *Map_GetRegion(Crossfire_Map *whoptr, void *closure);
00043 static PyObject *Map_GetUnique(Crossfire_Map *whoptr, void *closure);
00044 
00045 static int Map_SetPath(Crossfire_Map *whoptr, PyObject *value, void *closure);
00046 
00047 static PyObject *Map_Message(Crossfire_Map *map, PyObject *args);
00048 static PyObject *Map_GetFirstObjectAt(Crossfire_Map *map, PyObject *args);
00049 static PyObject *Map_CreateObject(Crossfire_Map *map, PyObject *args);
00050 static PyObject *Map_Check(Crossfire_Map *map, PyObject *args);
00051 static PyObject *Map_Next(Crossfire_Map *map, PyObject *args);
00052 static PyObject *Map_Insert(Crossfire_Map *map, PyObject *args);
00053 static PyObject *Map_ChangeLight(Crossfire_Map *map, PyObject *args);
00054 static PyObject *Map_TriggerConnected(Crossfire_Map *map, PyObject *args);
00055 
00056 static int Map_InternalCompare(Crossfire_Map *left, Crossfire_Map *right);
00057 
00058 static PyObject *Crossfire_Map_Long(PyObject *obj);
00059 #ifndef IS_PY3K
00060 static PyObject *Crossfire_Map_Int(PyObject *obj);
00061 #endif
00062 static void Crossfire_Map_dealloc(PyObject *obj);
00063 static PyObject *Crossfire_Map_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
00064 
00065 /* Python binding */
00066 static PyGetSetDef Map_getseters[] = {
00067     { "Difficulty",      (getter)Map_GetDifficulty,  NULL, NULL, NULL },
00068     { "Path",            (getter)Map_GetPath,        (setter)Map_SetPath, NULL, NULL },
00069     { "TempName",        (getter)Map_GetTempName,    NULL, NULL, NULL },
00070     { "Name",            (getter)Map_GetName,        NULL, NULL, NULL },
00071     { "ResetTime",       (getter)Map_GetResetTime,   NULL, NULL, NULL },
00072     { "ResetTimeout",    (getter)Map_GetResetTimeout, NULL, NULL, NULL },
00073     { "Players",         (getter)Map_GetPlayers,     NULL, NULL, NULL },
00074     { "Light",           (getter)Map_GetDarkness,    NULL, NULL, NULL },
00075     { "Darkness",        (getter)Map_GetDarkness,    NULL, NULL, NULL },
00076     { "Width",           (getter)Map_GetWidth,       NULL, NULL, NULL },
00077     { "Height",          (getter)Map_GetHeight,      NULL, NULL, NULL },
00078     { "EnterX",          (getter)Map_GetEnterX,      NULL, NULL, NULL },
00079     { "EnterY",          (getter)Map_GetEnterY,      NULL, NULL, NULL },
00080     { "Message",         (getter)Map_GetMessage,     NULL, NULL, NULL },
00081     { "Region",          (getter)Map_GetRegion,      NULL, NULL, NULL },
00082     { "Unique",          (getter)Map_GetUnique,      NULL, NULL, NULL },
00083     {  NULL, NULL, NULL, NULL, NULL }
00084 };
00085 
00086 static PyMethodDef MapMethods[] = {
00087     { "Print",            (PyCFunction)Map_Message,          METH_VARARGS, NULL },
00088     { "ObjectAt",         (PyCFunction)Map_GetFirstObjectAt, METH_VARARGS, NULL },
00089     { "CreateObject",     (PyCFunction)Map_CreateObject,     METH_VARARGS, NULL },
00090     { "Check",            (PyCFunction)Map_Check,            METH_VARARGS, NULL },
00091     { "Next",             (PyCFunction)Map_Next,             METH_NOARGS,  NULL },
00092     { "Insert",           (PyCFunction)Map_Insert,           METH_VARARGS, NULL },
00093     { "ChangeLight",      (PyCFunction)Map_ChangeLight,      METH_VARARGS, NULL },
00094     { "TriggerConnected", (PyCFunction)Map_TriggerConnected, METH_VARARGS, NULL },
00095     { NULL, NULL, 0, NULL }
00096 };
00097 
00098 static PyNumberMethods MapConvert = {
00099     NULL,            /* binaryfunc nb_add; */        /* __add__ */
00100     NULL,            /* binaryfunc nb_subtract; */   /* __sub__ */
00101     NULL,            /* binaryfunc nb_multiply; */   /* __mul__ */
00102 #ifndef IS_PY3K
00103     NULL,            /* binaryfunc nb_divide; */     /* __div__ */
00104 #endif
00105     NULL,            /* binaryfunc nb_remainder; */  /* __mod__ */
00106     NULL,            /* binaryfunc nb_divmod; */     /* __divmod__ */
00107     NULL,            /* ternaryfunc nb_power; */     /* __pow__ */
00108     NULL,            /* unaryfunc nb_negative; */    /* __neg__ */
00109     NULL,            /* unaryfunc nb_positive; */    /* __pos__ */
00110     NULL,            /* unaryfunc nb_absolute; */    /* __abs__ */
00111 #ifdef IS_PY3K
00112     NULL,            /* inquiry nb_bool; */          /* __bool__ */
00113 #else
00114     NULL,            /* inquiry nb_nonzero; */       /* __nonzero__ */
00115 #endif
00116     NULL,            /* unaryfunc nb_invert; */      /* __invert__ */
00117     NULL,            /* binaryfunc nb_lshift; */     /* __lshift__ */
00118     NULL,            /* binaryfunc nb_rshift; */     /* __rshift__ */
00119     NULL,            /* binaryfunc nb_and; */        /* __and__ */
00120     NULL,            /* binaryfunc nb_xor; */        /* __xor__ */
00121     NULL,            /* binaryfunc nb_or; */         /* __or__ */
00122 #ifndef IS_PY3K
00123     NULL,            /* coercion nb_coerce; */       /* __coerce__ */
00124 #endif
00125 #ifdef IS_PY3K
00126     /* This is not a typo. For Py3k it should be Crossfire_Map_Long
00127      * and NOT Crossfire_Map_Int.
00128      */
00129     Crossfire_Map_Long, /* unaryfunc nb_int; */      /* __int__ */
00130     NULL,               /* void *nb_reserved; */
00131 #else
00132     Crossfire_Map_Int,  /* unaryfunc nb_int; */      /* __int__ */
00133     Crossfire_Map_Long, /* unaryfunc nb_long; */     /* __long__ */
00134 #endif
00135     NULL,            /* unaryfunc nb_float; */       /* __float__ */
00136 #ifndef IS_PY3K
00137     NULL,            /* unaryfunc nb_oct; */         /* __oct__ */
00138     NULL,            /* unaryfunc nb_hex; */         /* __hex__ */
00139 #endif
00140     NULL,            /* binaryfunc nb_inplace_add; */
00141     NULL,            /* binaryfunc nb_inplace_subtract; */
00142     NULL,            /* binaryfunc nb_inplace_multiply; */
00143 #ifndef IS_PY3K
00144     NULL,            /* binaryfunc nb_inplace_divide; */
00145 #endif
00146     NULL,            /* binaryfunc nb_inplace_remainder; */
00147     NULL,            /* ternaryfunc nb_inplace_power; */
00148     NULL,            /* binaryfunc nb_inplace_lshift; */
00149     NULL,            /* binaryfunc nb_inplace_rshift; */
00150     NULL,            /* binaryfunc nb_inplace_and; */
00151     NULL,            /* binaryfunc nb_inplace_xor; */
00152     NULL,            /* binaryfunc nb_inplace_or; */
00153 
00154     NULL,            /* binaryfunc nb_floor_divide; */
00155     NULL,            /* binaryfunc nb_true_divide; */
00156     NULL,            /* binaryfunc nb_inplace_floor_divide; */
00157     NULL,            /* binaryfunc nb_inplace_true_divide; */
00158 #if defined(IS_PY25) || defined(IS_PY3K)
00159     NULL             /* unaryfunc nb_index; */
00160 #endif
00161 };
00162 
00163 /* Our actual Python MapType */
00164 PyTypeObject Crossfire_MapType = {
00165     PyObject_HEAD_INIT(NULL)
00166 #ifndef IS_PY3K
00167     0,                         /* ob_size*/
00168 #endif
00169     "Crossfire.Map",           /* tp_name*/
00170     sizeof(Crossfire_Map),     /* tp_basicsize*/
00171     0,                         /* tp_itemsize*/
00172     Crossfire_Map_dealloc,     /* tp_dealloc*/
00173     NULL,                      /* tp_print*/
00174     NULL,                      /* tp_getattr*/
00175     NULL,                      /* tp_setattr*/
00176     (cmpfunc)Map_InternalCompare, /* tp_compare*/
00177     NULL,                      /* tp_repr*/
00178     &MapConvert,               /* tp_as_number*/
00179     NULL,                      /* tp_as_sequence*/
00180     NULL,                      /* tp_as_mapping*/
00181     PyObject_HashNotImplemented, /* tp_hash */
00182     NULL,                      /* tp_call*/
00183     NULL,                      /* tp_str*/
00184     PyObject_GenericGetAttr,   /* tp_getattro*/
00185     PyObject_GenericSetAttr,   /* tp_setattro*/
00186     NULL,                      /* tp_as_buffer*/
00187     Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags*/
00188     "Crossfire maps",          /* tp_doc */
00189     NULL,                      /* tp_traverse */
00190     NULL,                      /* tp_clear */
00191     NULL,                      /* tp_richcompare */
00192     0,                         /* tp_weaklistoffset */
00193     NULL,                      /* tp_iter */
00194     NULL,                      /* tp_iternext */
00195     MapMethods,                /* tp_methods */
00196     NULL,                      /* tp_members */
00197     Map_getseters,             /* tp_getset */
00198     NULL,                      /* tp_base */
00199     NULL,                      /* tp_dict */
00200     NULL,                      /* tp_descr_get */
00201     NULL,                      /* tp_descr_set */
00202     0,                         /* tp_dictoffset */
00203     NULL,                      /* tp_init */
00204     NULL,                      /* tp_alloc */
00205     Crossfire_Map_new,         /* tp_new */
00206     NULL,                      /* tp_free */
00207     NULL,                      /* tp_is_gc */
00208     NULL,                      /* tp_bases */
00209     NULL,                      /* tp_mro */
00210     NULL,                      /* tp_cache */
00211     NULL,                      /* tp_subclasses */
00212     NULL,                      /* tp_weaklist */
00213     NULL,                      /* tp_del */
00214 };