Update of /cvsroot/wpdev/wolfpack/python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26712/python
Modified Files:
global.cpp pyspawnregion.cpp
Log Message:
Spawnregion updates
Index: global.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/global.cpp,v
retrieving revision 1.163
retrieving revision 1.164
diff -C2 -d -r1.163 -r1.164
*** global.cpp 1 Oct 2004 19:43:57 -0000 1.163
--- global.cpp 13 Oct 2004 14:45:20 -0000 1.164
***************
*** 62,65 ****
--- 62,66 ----
#include "tempeffect.h"
#include "worlditerator.h"
+ #include "pyspawnregion.h"
// Library Includes
***************
*** 568,571 ****
--- 569,591 ----
/*
+ \function wolfpack.spawnregion
+ \param id The spawnregion id.
+ \return A <object id="spawnregion">spawnregion</object> object or None if there is no region with the given name.
+ \description Finds a spawnregion with the given id.
+ */
+ static PyObject* wpSpawnregion( PyObject* self, PyObject* args )
+ {
+ Q_UNUSED( self );
+
+ // Three arguments
+ char *name;
+ if ( !PyArg_ParseTuple( args, "s:wolfpack.spawnregion", &name) )
+ return 0;
+
+ cSpawnRegion *spawn = SpawnRegions::instance()->region(name);
+ return PyGetSpawnRegionObject(spawn);
+ }
+
+ /*
\function wolfpack.currenttime
\return An interger value.
***************
*** 1845,1848 ****
--- 1865,1869 ----
{ "effect", wpEffect, METH_VARARGS, "Shows a graphical effect." },
{ "region", wpRegion, METH_VARARGS, "Gets the region at a specific position" },
+ { "spawnregion", wpSpawnregion, METH_VARARGS, 0 },
{ "currenttime", wpCurrenttime, METH_NOARGS, "Time in ms since server-start" },
{ "newguild", wpNewguild, METH_VARARGS, 0},
Index: pyspawnregion.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/pyspawnregion.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pyspawnregion.cpp 2 Oct 2004 22:15:52 -0000 1.6
--- pyspawnregion.cpp 13 Oct 2004 14:45:20 -0000 1.7
***************
*** 63,67 ****
/*
! \method spawnregion.removeitem
\param serial
\description Remove the given object from a spawnregion, freeing the slot for a new item
--- 63,83 ----
/*
! \method spawnregion.add
! \param object
! \description Add the given object to this spawnregion.
! */
! static PyObject* wpSpawnRegion_add( wpSpawnRegion *self, PyObject *args) {
! cUObject *object;
!
! if (!PyArg_ParseTuple(args, "O&:spawnregion.add(obj)", &PyConvertObject, &object)) {
! return 0;
! }
!
! object->setSpawnregion(self->pRegion);
! Py_RETURN_NONE;
! }
!
! /*
! \method spawnregion.remove
\param serial
\description Remove the given object from a spawnregion, freeing the slot for a new item
***************
*** 96,112 ****
/*
! \method spawnregion.spawn
! \param baseids [Optional] is a list of BaseIDs to be spawned from
! \description Remove the given object from a spawnregion, freeing the slot for a new item
! to be spawned.
*/
! static PyObject* wpSpawnRegion_spawn( wpSpawnRegion* /*self*/, PyObject* args )
{
! PyObject* baseids = 0;
! if ( !PyArg_ParseTuple( args, "|O!:spawnregion.spawn([baseids])", &PyList_Type, &baseids ) )
! {
! return 0;
! }
!
Py_RETURN_NONE;
}
--- 112,131 ----
/*
! \method spawnregion.respawn
! \description Issue a spawn cycle of this spawnregion.
*/
! static PyObject* wpSpawnRegion_respawn( wpSpawnRegion* self, PyObject* args )
{
! self->pRegion->reSpawn();
! Py_RETURN_NONE;
! }
!
! /*
! \method spawnregion.clear
! \description Clear this spawnregion.
! */
! static PyObject* wpSpawnRegion_clear( wpSpawnRegion* self, PyObject* args )
! {
! self->pRegion->deSpawn();
Py_RETURN_NONE;
}
***************
*** 114,119 ****
static PyMethodDef wpSpawnRegionMethods[] =
{
{ "remove", ( getattrofunc ) wpSpawnRegion_remove, METH_VARARGS, NULL },
! { "spawn", ( getattrofunc ) wpSpawnRegion_spawn, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
--- 133,140 ----
static PyMethodDef wpSpawnRegionMethods[] =
{
+ { "add", ( getattrofunc ) wpSpawnRegion_add, METH_VARARGS, NULL },
{ "remove", ( getattrofunc ) wpSpawnRegion_remove, METH_VARARGS, NULL },
! { "respawn", ( getattrofunc ) wpSpawnRegion_respawn, METH_VARARGS, NULL },
! { "clear", ( getattrofunc ) wpSpawnRegion_clear, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
***************
*** 129,211 ****
}
/*
! \rproperty spawnregion.maxitemspawn
*/
! else if ( !strcmp( name, "maxitemspawn" ) )
{
return PyInt_FromLong( self->pRegion->maxItems() );
}
/*
! \rproperty spawnregion.maxnpcspawn
*/
! else if ( !strcmp( name, "maxnpcspawn" ) )
{
return PyInt_FromLong( self->pRegion->maxNpcs() );
}
/*
! \rproperty spawnregion.npcspawncount
*/
! else if ( !strcmp( name, "npcspawncount" ) )
{
return PyInt_FromLong( self->pRegion->npcs() );
}
/*
! \rproperty spawnregion.itemspawncount
*/
! else if ( !strcmp( name, "itemspawncount" ) )
{
return PyInt_FromLong( self->pRegion->items() );
}
/*
! \rproperty spawnregion.npcspawnlist
! */
! else if ( !strcmp( name, "npcspawnlist" ) )
! {
! /* QStringList sections = self->pRegion->npcSections();
! PyObject* tuple = PyTuple_New( sections.size() );
! for ( uint i = 0; i < sections.size(); ++i )
! {
! PyTuple_SetItem( tuple, i, QString2Python( sections[i] ) );
! }
! return tuple;*/
! }
! /*
! \rproperty spawnregion.itemspawnlist
! */
! else if ( !strcmp( name, "itemspawnlist" ) )
! {
! /*QStringList sections = self->pRegion->itemSections();
! PyObject* tuple = PyTuple_New( sections.size() );
! for ( uint i = 0; i < sections.size(); ++i )
! {
! PyTuple_SetItem( tuple, i, QString2Python( sections[i] ) );
! }
! return tuple;*/
! }
! /*
! \rproperty spawnregion.spawneditems
*/
! else if ( !strcmp( name, "spawneditems" ) )
{
QPtrList<cUObject> objects = self->pRegion->spawnedItems();
PyObject* list = PyList_New( objects.count() );
cUObject *object;
for ( object = objects.first(); object; object = objects.next() )
! PyList_Append( list, PyInt_FromLong( object->serial() ) );
return list;
}
/*
! \rproperty spawnregion.spawnednpcs
*/
! else if ( !strcmp( name, "spawnednpcs" ) )
{
QPtrList<cUObject> objects = self->pRegion->spawnedNpcs();
PyObject* list = PyList_New( objects.count() );
cUObject *object;
for ( object = objects.first(); object; object = objects.next() )
! PyList_Append( list, PyInt_FromLong( object->serial() ) );
return list;
}
return Py_FindMethod( wpSpawnRegionMethods, ( PyObject * ) self, name );
--- 150,218 ----
}
/*
! \rproperty spawnregion.maxitems The maximum number of items spawned by this region.
*/
! else if ( !strcmp( name, "maxitems" ) )
{
return PyInt_FromLong( self->pRegion->maxItems() );
}
/*
! \rproperty spawnregion.maxnpcs The maximum number of npcs spawned by this region.
*/
! else if ( !strcmp( name, "maxnpcs" ) )
{
return PyInt_FromLong( self->pRegion->maxNpcs() );
}
/*
! \rproperty spawnregion.spawnednpcs The number of npcs currently spawned in this region.
*/
! else if ( !strcmp( name, "spawnednpcs" ) )
{
return PyInt_FromLong( self->pRegion->npcs() );
}
/*
! \rproperty spawnregion.spawneditems The number of items currently spawned in this region.
*/
! else if ( !strcmp( name, "spawneditems" ) )
{
return PyInt_FromLong( self->pRegion->items() );
}
/*
! \rproperty spawnregion.items A list of serials for the items currently spawned in this region.
*/
! else if ( !strcmp( name, "items" ) )
{
QPtrList<cUObject> objects = self->pRegion->spawnedItems();
PyObject* list = PyList_New( objects.count() );
cUObject *object;
+ int offset = 0;
for ( object = objects.first(); object; object = objects.next() )
! PyList_SetItem( list, offset++, PyInt_FromLong( object->serial() ) );
return list;
}
/*
! \rproperty spawnregion.npcs A list of serials for the npcs currently spawned in this region.
*/
! else if ( !strcmp( name, "npcs" ) )
{
QPtrList<cUObject> objects = self->pRegion->spawnedNpcs();
PyObject* list = PyList_New( objects.count() );
cUObject *object;
+ int offset = 0;
for ( object = objects.first(); object; object = objects.next() )
! PyList_SetItem( list, offset++, PyInt_FromLong( object->serial() ) );
return list;
}
+ /*
+ \property spawnregion.active Indicates whether this spawnregion is currently active.
+ */
+ else if (!strcmp( name, "active") ) {
+ if (self->pRegion->active()) {
+ Py_RETURN_TRUE;
+ } else {
+ Py_RETURN_FALSE;
+ }
+ }
return Py_FindMethod( wpSpawnRegionMethods, ( PyObject * ) self, name );
***************
*** 217,221 ****
Q_UNUSED( name );
Q_UNUSED( value );
! // SpawnRegions have no changeable attributes yet
return 0;
}
--- 224,236 ----
Q_UNUSED( name );
Q_UNUSED( value );
!
! if (!strcmp(name, "active")) {
! if (PyObject_IsTrue(value)) {
! self->pRegion->setActive(true);
! } else {
! self->pRegion->setActive(false);
! }
! }
!
return 0;
}
|