Update of /cvsroot/wpdev/wolfpack/python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20076/python
Modified Files:
char.cpp global.cpp item.cpp regioniterator.h
Log Message:
python fixes.
new code for allshow support
Index: regioniterator.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/regioniterator.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** regioniterator.h 24 Aug 2004 00:23:24 -0000 1.14
--- regioniterator.h 7 Sep 2004 03:21:50 -0000 1.15
***************
*** 167,182 ****
};
! static PyObject* PyGetCharRegionIterator( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char map )
{
wpRegionIteratorChars* returnVal = PyObject_New( wpRegionIteratorChars, &wpRegionIteratorCharsType );
! returnVal->iter = SectorMaps::instance()->findChars( map, x1, y1, x2, y2 );
return ( PyObject * ) returnVal;
}
! static PyObject* PyGetCharRegionIterator( unsigned short xBlock, unsigned short yBlock, unsigned char map )
{
wpRegionIteratorChars* returnVal = PyObject_New( wpRegionIteratorChars, &wpRegionIteratorCharsType );
! returnVal->iter = SectorMaps::instance()->findChars( map, xBlock * 8, yBlock * 8 );
return ( PyObject * ) returnVal;
}
--- 167,182 ----
};
! static PyObject* PyGetCharRegionIterator( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char map, bool includeoffline = false )
{
wpRegionIteratorChars* returnVal = PyObject_New( wpRegionIteratorChars, &wpRegionIteratorCharsType );
! returnVal->iter = SectorMaps::instance()->findChars( map, x1, y1, x2, y2, includeoffline );
return ( PyObject * ) returnVal;
}
! static PyObject* PyGetCharRegionIterator( unsigned short xBlock, unsigned short yBlock, unsigned char map, bool includeoffline = false )
{
wpRegionIteratorChars* returnVal = PyObject_New( wpRegionIteratorChars, &wpRegionIteratorCharsType );
! returnVal->iter = SectorMaps::instance()->findChars( map, xBlock * 8, yBlock * 8, includeoffline );
return ( PyObject * ) returnVal;
}
Index: item.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/item.cpp,v
retrieving revision 1.128
retrieving revision 1.129
diff -C2 -d -r1.128 -r1.129
*** item.cpp 5 Sep 2004 17:43:52 -0000 1.128
--- item.cpp 7 Sep 2004 03:21:50 -0000 1.129
***************
*** 437,444 ****
--- 437,453 ----
self->pItem->setTag( key, cVariant( ( int ) PyInt_AsLong( object ) ) );
}
+ else if ( PyLong_Check( object ) )
+ {
+ self->pItem->setTag( key, cVariant( ( int ) PyLong_AsLong( object ) ) );
+ }
else if ( PyFloat_Check( object ) )
{
self->pItem->setTag( key, cVariant( ( double ) PyFloat_AsDouble( object ) ) );
}
+ else
+ {
+ PyErr_SetString( PyExc_TypeError, "You passed an unknown object type to char.settag." );
+ return 0;
+ }
Py_RETURN_NONE;
***************
*** 1379,1382 ****
--- 1388,1393 ----
else if ( PyInt_Check( value ) )
val = cVariant( PyInt_AsLong( value ) );
+ else if ( PyLong_Check( value ) )
+ val = cVariant( PyLong_AsLong( value ) );
else if ( checkWpItem( value ) )
val = cVariant( getWpItem( value ) );
***************
*** 1407,1411 ****
PyErr_Format( PyExc_TypeError, "Error while setting attribute '%s': %s", name, error->text.latin1() );
delete error;
! return 0;
}
}
--- 1418,1422 ----
PyErr_Format( PyExc_TypeError, "Error while setting attribute '%s': %s", name, error->text.latin1() );
delete error;
! return -1;
}
}
Index: global.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/global.cpp,v
retrieving revision 1.153
retrieving revision 1.154
diff -C2 -d -r1.153 -r1.154
*** global.cpp 2 Sep 2004 15:09:57 -0000 1.153
--- global.cpp 7 Sep 2004 03:21:49 -0000 1.154
***************
*** 711,714 ****
--- 711,715 ----
This is the range in which the server should search for characters. Please remember that this is not
a circle.
+ \param offline Defaults to False. Indicates whether logged out characters should be included.
\return A list of <object id="char">char</object> objects.
\description This function searches for characters at the given
***************
*** 723,741 ****
map = 0,
range = 1;
! if ( !PyArg_ParseTuple( args, "iii|i:wolfpack.chars", &x, &y, &map, &range ) )
return 0;
Coord_cl pos( x, y, 0, map );
! RegionIterator4Chars iter( pos, range );
!
PyObject* list = PyList_New( 0 );
! for ( iter.Begin(); !iter.atEnd(); iter++ )
! {
! P_CHAR pChar = iter.GetData();
!
! if ( pChar )
! PyList_Append( list, PyGetCharObject( pChar ) );
}
return list;
}
--- 724,741 ----
map = 0,
range = 1;
! PyObject *offline = Py_False;
! if ( !PyArg_ParseTuple( args, "iii|iO:wolfpack.chars", &x, &y, &map, &range, &offline ) )
return 0;
Coord_cl pos( x, y, 0, map );
! cCharSectorIterator *iter = SectorMaps::instance()->findChars(pos, range, PyObject_IsTrue(offline) != 0);
!
PyObject* list = PyList_New( 0 );
! for ( P_CHAR pChar = iter->first(); pChar; pChar = iter->next() ) {
! PyList_Append( list, pChar->getPyObject() );
}
+ delete iter;
+
return list;
}
***************
*** 1221,1224 ****
--- 1221,1225 ----
\param y2 The bottom edge of the rectangle.
\param map The map to search on.
+ \param offline Defaults to false, indicates whether offline characters should be included.
\return A <object id="charregioniterator">charregioniterator</object> oject.
\description This function returns an object that will allow you to iterate over characters
***************
*** 1231,1239 ****
unsigned int x1, y1, x2, y2;
unsigned char map;
! if ( !PyArg_ParseTuple( args, "iiiib:wolfpack.charregion", &x1, &y1, &x2, &y2, &map ) )
return 0;
! return PyGetCharRegionIterator( x1, y1, x2, y2, map );
}
--- 1232,1241 ----
unsigned int x1, y1, x2, y2;
unsigned char map;
+ PyObject *offline = Py_False;
! if ( !PyArg_ParseTuple( args, "iiiib|O:wolfpack.charregion", &x1, &y1, &x2, &y2, &map, &offline ) )
return 0;
! return PyGetCharRegionIterator( x1, y1, x2, y2, map, PyObject_IsTrue( offline ) != 0 );
}
Index: char.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/char.cpp,v
retrieving revision 1.187
retrieving revision 1.188
diff -C2 -d -r1.187 -r1.188
*** char.cpp 5 Sep 2004 17:43:51 -0000 1.187
--- char.cpp 7 Sep 2004 03:21:49 -0000 1.188
***************
*** 993,996 ****
--- 993,1000 ----
self->pChar->setTag( key, cVariant( QString::fromUcs2( ( ushort * ) PyUnicode_AsUnicode( object ) ) ) );
}
+ else if ( PyLong_Check( object ) )
+ {
+ self->pChar->setTag( key, cVariant( ( int ) PyLong_AsLong( object ) ) );
+ }
else if ( PyInt_Check( object ) )
{
***************
*** 1001,1004 ****
--- 1005,1013 ----
self->pChar->setTag( key, cVariant( ( double ) PyFloat_AsDouble( object ) ) );
}
+ else
+ {
+ PyErr_SetString( PyExc_TypeError, "You passed an unknown object type to char.settag." );
+ return 0;
+ }
Py_RETURN_NONE;
***************
*** 2800,2803 ****
--- 2809,2814 ----
else if ( PyInt_Check( value ) )
val = cVariant( PyInt_AsLong( value ) );
+ else if ( PyLong_Check( value ) )
+ val = cVariant( PyLong_AsLong( value ) );
else if ( checkWpItem( value ) )
val = cVariant( getWpItem( value ) );
***************
*** 2818,2824 ****
PyErr_Format( PyExc_TypeError, "Error while setting attribute '%s': %s", name, error->text.latin1() );
delete error;
}
! return 0;
}
--- 2829,2836 ----
PyErr_Format( PyExc_TypeError, "Error while setting attribute '%s': %s", name, error->text.latin1() );
delete error;
+ return -1;
}
! return 0;
}
|