… | |
… | |
30 | #include <cfpython.h> |
30 | #include <cfpython.h> |
31 | #include <cfpython_party_private.h> |
31 | #include <cfpython_party_private.h> |
32 | |
32 | |
33 | static PyObject* Crossfire_Party_GetName( Crossfire_Party* partyptr, void* closure) |
33 | static PyObject* Crossfire_Party_GetName( Crossfire_Party* partyptr, void* closure) |
34 | { |
34 | { |
35 | return Py_BuildValue("s",cf_party_get_name(partyptr->party)); |
35 | return Py_BuildValue("s",cf_party_get_name(partyptr->party)); |
36 | } |
36 | } |
37 | |
37 | |
38 | static PyObject* Crossfire_Party_GetPassword( Crossfire_Party* partyptr, void* closure) |
38 | static PyObject* Crossfire_Party_GetPassword( Crossfire_Party* partyptr, void* closure) |
39 | { |
39 | { |
40 | return Py_BuildValue("s",cf_party_get_password(partyptr->party)); |
40 | return Py_BuildValue("s",cf_party_get_password(partyptr->party)); |
41 | } |
41 | } |
42 | |
42 | |
43 | static PyObject* Crossfire_Party_GetNext( Crossfire_Party* party, PyObject* args ) |
43 | static PyObject* Crossfire_Party_GetNext( Crossfire_Party* party, PyObject* args ) |
44 | { |
44 | { |
45 | return Crossfire_Party_wrap(cf_party_get_next(party->party)); |
45 | return Crossfire_Party_wrap(cf_party_get_next(party->party)); |
46 | } |
46 | } |
47 | |
47 | |
48 | static PyObject* Crossfire_Party_GetPlayers( Crossfire_Party* party, PyObject* args ) |
48 | static PyObject* Crossfire_Party_GetPlayers( Crossfire_Party* party, PyObject* args ) |
49 | { |
49 | { |
50 | PyObject* list; |
50 | PyObject* list;
|
51 | player* pl; |
51 | player* pl;
|
52 | |
52 |
|
53 | list = PyList_New(0); |
53 | list = PyList_New(0);
|
54 | pl = cf_party_get_first_player(party->party); |
54 | pl = cf_party_get_first_player(party->party);
|
55 | while (pl) |
55 | while (pl)
|
56 | { |
56 | {
|
57 | PyList_Append(list,Crossfire_Object_wrap(pl->ob)); |
57 | PyList_Append(list,Crossfire_Object_wrap(pl->ob));
|
58 | pl = cf_party_get_next_player(party->party,pl); |
58 | pl = cf_party_get_next_player(party->party,pl);
|
59 | } |
59 | }
|
60 | return list; |
60 | return list;
|
61 | } |
61 | } |
62 | |
62 | |
63 | PyObject *Crossfire_Party_wrap(partylist *what) |
63 | PyObject *Crossfire_Party_wrap(partylist *what) |
64 | { |
64 | { |
65 | Crossfire_Party *wrapper; |
65 | Crossfire_Party *wrapper; |
… | |
… | |
76 | return (PyObject *)wrapper; |
76 | return (PyObject *)wrapper; |
77 | } |
77 | } |
78 | |
78 | |
79 | static int Crossfire_Party_InternalCompare(Crossfire_Party* left, Crossfire_Party* right) |
79 | static int Crossfire_Party_InternalCompare(Crossfire_Party* left, Crossfire_Party* right) |
80 | { |
80 | { |
81 | return (left->party < right->party ? -1 : ( left->party == right->party ? 0 : 1 ) ); |
81 | return ((int)left->party - (int)right->party); |
82 | } |
82 | } |