Crossfire Server, Branch 1.12  R12190
cfpython_region.c
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 
00030 #include <cfpython.h>
00031 #include <cfpython_region_private.h>
00032 
00033 static PyObject *Crossfire_Region_GetName(Crossfire_Region *regionptr, void *closure) {
00034     return Py_BuildValue("s", cf_region_get_name(regionptr->reg));
00035 }
00036 
00037 static PyObject *Crossfire_Region_GetLongname(Crossfire_Region *regionptr, void *closure) {
00038     return Py_BuildValue("s", cf_region_get_longname(regionptr->reg));
00039 }
00040 
00041 static PyObject *Crossfire_Region_GetMessage(Crossfire_Region *regionptr, void *closure) {
00042     return Py_BuildValue("s", cf_region_get_message(regionptr->reg));
00043 }
00044 
00045 static PyObject *Crossfire_Region_GetNext(Crossfire_Region *party, void *closure) {
00046     return Crossfire_Region_wrap(cf_region_get_next(party->reg));
00047 }
00048 
00049 static PyObject *Crossfire_Region_GetParent(Crossfire_Region *party, PyObject *args) {
00050     return Crossfire_Region_wrap(cf_region_get_parent(party->reg));
00051 }
00052 
00053 PyObject *Crossfire_Region_wrap(region *what) {
00054     Crossfire_Region *wrapper;
00055 
00056     /* return None if no object was to be wrapped */
00057     if (what == NULL) {
00058         Py_INCREF(Py_None);
00059         return Py_None;
00060     }
00061 
00062     wrapper = PyObject_NEW(Crossfire_Region, &Crossfire_RegionType);
00063     if (wrapper != NULL)
00064         wrapper->reg = what;
00065     return (PyObject *)wrapper;
00066 }
00067 
00068 static int Crossfire_Region_InternalCompare(Crossfire_Region *left, Crossfire_Region *right) {
00069     return (left->reg < right->reg ? -1 : (left->reg == right->reg ? 0 : 1));
00070 }