Crossfire Server, Branches 1.12  R18729
cfpython_party.c
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 
30 #include <cfpython.h>
31 #include <cfpython_party_private.h>
32 
33 static PyObject *Crossfire_Party_GetName(Crossfire_Party *partyptr, void *closure) {
34  return Py_BuildValue("s", cf_party_get_name(partyptr->party));
35 }
36 
37 static PyObject *Crossfire_Party_GetPassword(Crossfire_Party *partyptr, void *closure) {
38  return Py_BuildValue("s", cf_party_get_password(partyptr->party));
39 }
40 
41 static PyObject *Crossfire_Party_GetNext(Crossfire_Party *party, void *closure) {
43 }
44 
45 static PyObject *Crossfire_Party_GetPlayers(Crossfire_Party *party, PyObject *args) {
46  PyObject *list;
47  player *pl;
48 
49  list = PyList_New(0);
50  pl = cf_party_get_first_player(party->party);
51  while (pl) {
52  PyList_Append(list, Crossfire_Object_wrap(pl->ob));
53  pl = cf_party_get_next_player(party->party, pl);
54  }
55  return list;
56 }
57 
58 PyObject *Crossfire_Party_wrap(partylist *what) {
59  Crossfire_Party *wrapper;
60 
61  /* return None if no object was to be wrapped */
62  if (what == NULL) {
63  Py_INCREF(Py_None);
64  return Py_None;
65  }
66 
67  wrapper = PyObject_NEW(Crossfire_Party, &Crossfire_PartyType);
68  if (wrapper != NULL)
69  wrapper->party = what;
70  return (PyObject *)wrapper;
71 }
72 
74  return (left->party < right->party ? -1 : (left->party == right->party ? 0 : 1));
75 }
Definition: player.h:146
PyObject * Crossfire_Party_wrap(partylist *what)
PyObject_HEAD partylist * party
static PyObject * Crossfire_Party_GetNext(Crossfire_Party *party, void *closure)
const char * cf_party_get_name(partylist *party)
static PyObject * Crossfire_Party_GetPassword(Crossfire_Party *partyptr, void *closure)
static PyObject * Crossfire_Party_GetPlayers(Crossfire_Party *party, PyObject *args)
partylist * cf_party_get_next(partylist *party)
static PyObject * Crossfire_Party_GetName(Crossfire_Party *partyptr, void *closure)
const char * cf_party_get_password(partylist *party)
PyObject * Crossfire_Object_wrap(object *what)
PyTypeObject Crossfire_PartyType
object * ob
Definition: player.h:207
player * cf_party_get_next_player(partylist *party, player *op)
player * cf_party_get_first_player(partylist *party)
static int Crossfire_Party_InternalCompare(Crossfire_Party *left, Crossfire_Party *right)