[wpdev-commits] wolfpack/python pyaccounts.h,NONE,1.1 global.cpp,1.147,1.148
Brought to you by:
rip,
thiagocorrea
From: Sebastian H. <dar...@us...> - 2004-08-31 00:42:45
|
Update of /cvsroot/wpdev/wolfpack/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32108/python Modified Files: global.cpp Added Files: pyaccounts.h Log Message: accounts iterator Index: global.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/global.cpp,v retrieving revision 1.147 retrieving revision 1.148 diff -C2 -d -r1.147 -r1.148 *** global.cpp 24 Aug 2004 00:23:23 -0000 1.147 --- global.cpp 31 Aug 2004 00:42:31 -0000 1.148 *************** *** 56,59 **** --- 56,60 ---- #include "../basedef.h" + #include "pyaccounts.h" #include "pypacket.h" #include "regioniterator.h" *************** *** 2041,2044 **** --- 2042,2058 ---- } + /* + \function wolfpack.accounts.iterator + \description Return an iterator object to iterate trough all account objects. + */ + static PyObject* wpAccountsIterator( PyObject* self, PyObject* args ) + { + Q_UNUSED( self ); + Q_UNUSED( args ); + + wpAccountsIter *obj = PyObject_New(wpAccountsIter, &wpAccountsIterType); + return (PyObject*)obj; + } + /*! wolfpack.accounts *************** *** 2047,2050 **** --- 2061,2065 ---- static PyMethodDef wpAccounts[] = { + { "iterator", wpAccountsIterator, METH_VARARGS, "" }, { "count", wpAccountsCount, METH_VARARGS, "" }, { "find", wpAccountsFind, METH_VARARGS, "Finds an account object." }, --- NEW FILE: pyaccounts.h --- /* * Wolfpack Emu (WP) * UO Server Emulation Program * * Copyright 2001-2004 by holders identified in AUTHORS.txt * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Palace - Suite 330, Boston, MA 02111-1307, USA. * * In addition to that license, if you are running this program or modified * versions of it on a public system you HAVE TO make the complete source of * the version used by you available or provide people with a location to * download it. * * Wolfpack Homepage: http://wpdev.sf.net/ */ #ifndef __CONTENT_H__ #define __CONTENT_H__ #include "../defines.h" #include "../accounts.h" #include "../items.h" #include "../world.h" #include "../basechar.h" #include "utilities.h" typedef struct { PyObject_HEAD; cAccounts::const_iterator it; } wpAccountsIter; static PyObject *wpAccountsIter_First(wpAccountsIter *self) { self->it = Accounts::instance()->begin(); return (PyObject*)self; } static PyObject *wpAccountsIter_Next(wpAccountsIter *self) { if (self->it == Accounts::instance()->end()) { PyErr_SetNone(PyExc_StopIteration); return 0; } else { return PyGetAccountObject(*(self->it++)); } } static PyTypeObject wpAccountsIterType = { PyObject_HEAD_INIT( NULL ) 0, "wpAccountsIter", sizeof( wpAccountsIterType ), 0, wpDealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Py_TPFLAGS_HAVE_ITER, 0, 0, 0, 0, 0, (getiterfunc)wpAccountsIter_First, (iternextfunc)wpAccountsIter_Next, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif |