Crossfire Server, Branch 1.12
R12190
|
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_party_private.h> 00032 00033 static PyObject *Crossfire_Party_GetName(Crossfire_Party *partyptr, void *closure) { 00034 return Py_BuildValue("s", cf_party_get_name(partyptr->party)); 00035 } 00036 00037 static PyObject *Crossfire_Party_GetPassword(Crossfire_Party *partyptr, void *closure) { 00038 return Py_BuildValue("s", cf_party_get_password(partyptr->party)); 00039 } 00040 00041 static PyObject *Crossfire_Party_GetNext(Crossfire_Party *party, void *closure) { 00042 return Crossfire_Party_wrap(cf_party_get_next(party->party)); 00043 } 00044 00045 static PyObject *Crossfire_Party_GetPlayers(Crossfire_Party *party, PyObject *args) { 00046 PyObject *list; 00047 player *pl; 00048 00049 list = PyList_New(0); 00050 pl = cf_party_get_first_player(party->party); 00051 while (pl) { 00052 PyList_Append(list, Crossfire_Object_wrap(pl->ob)); 00053 pl = cf_party_get_next_player(party->party, pl); 00054 } 00055 return list; 00056 } 00057 00058 PyObject *Crossfire_Party_wrap(partylist *what) { 00059 Crossfire_Party *wrapper; 00060 00061 /* return None if no object was to be wrapped */ 00062 if (what == NULL) { 00063 Py_INCREF(Py_None); 00064 return Py_None; 00065 } 00066 00067 wrapper = PyObject_NEW(Crossfire_Party, &Crossfire_PartyType); 00068 if (wrapper != NULL) 00069 wrapper->party = what; 00070 return (PyObject *)wrapper; 00071 } 00072 00073 static int Crossfire_Party_InternalCompare(Crossfire_Party *left, Crossfire_Party *right) { 00074 return (left->party < right->party ? -1 : (left->party == right->party ? 0 : 1)); 00075 }