[wpdev-commits] wolfpack/python target.h,1.22,1.23
Brought to you by:
rip,
thiagocorrea
From: Jorge P. <ke...@us...> - 2004-08-26 00:52:23
|
Update of /cvsroot/wpdev/wolfpack/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11843 Modified Files: target.h Log Message: Create-once for python objects: target.char, target.item, target.pos. Index: target.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/target.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** target.h 22 Aug 2004 02:29:53 -0000 1.22 --- target.h 26 Aug 2004 00:52:13 -0000 1.23 *************** *** 43,48 **** --- 43,52 ---- Q_UINT16 model; SERIAL object; + + PyObject * py_pos; + PyObject * py_obj; // char or item } wpTarget; + static PyObject* wpTarget_getAttr( wpTarget* self, char* name ) { *************** *** 52,56 **** */ if ( !strcmp( name, "pos" ) ) ! return PyGetCoordObject( self->pos ); /* \rproperty target.model If a static tile has been targetted by the client, this property contains the art id of the targetted static tile. If a character has been targetted, --- 56,66 ---- */ if ( !strcmp( name, "pos" ) ) ! { ! if ( !self->py_pos ) ! self->py_pos = PyGetCoordObject( self->pos ); ! ! Py_INCREF( self->py_pos ); ! return self->py_pos; ! } /* \rproperty target.model If a static tile has been targetted by the client, this property contains the art id of the targetted static tile. If a character has been targetted, *************** *** 58,62 **** --- 68,74 ---- */ else if ( !strcmp( name, "model" ) ) + { return PyInt_FromLong( self->model ); + } /* \rproperty target.item If a valid item has been targetted, this property contains an <object id="item">item</object> object for the targetted item. *************** *** 65,69 **** { if ( isItemSerial( self->object ) ) ! return PyGetItemObject( FindItemBySerial( self->object ) ); } /* --- 77,87 ---- { if ( isItemSerial( self->object ) ) ! { ! if ( !self->py_obj ) ! self->py_obj = PyGetItemObject( FindItemBySerial( self->object ) ); ! ! Py_INCREF( self->py_obj ); ! return self->py_obj; ! } } /* *************** *** 71,80 **** */ else if ( !strcmp( name, "char" ) ) if ( isCharSerial( self->object ) ) ! return PyGetCharObject( FindCharBySerial( self->object ) ); Py_RETURN_FALSE; } static PyTypeObject wpTargetType = { --- 89,115 ---- */ else if ( !strcmp( name, "char" ) ) + { if ( isCharSerial( self->object ) ) ! { ! if ( !self->py_obj ) ! self->py_obj = PyGetCharObject( FindCharBySerial( self->object ) ); + Py_INCREF( self->py_obj ); + return self->py_obj; + } + } Py_RETURN_FALSE; } + + static void wpTarget_Dealloc( wpTarget * self ) + { + Py_XDECREF( self->py_pos ); + Py_XDECREF( self->py_obj ); + + wpDealloc( (PyObject*) self ); + } + + static PyTypeObject wpTargetType = { *************** *** 84,88 **** sizeof( wpTargetType ), 0, ! wpDealloc, 0, ( getattrfunc ) wpTarget_getAttr, --- 119,123 ---- sizeof( wpTargetType ), 0, ! ( destructor ) wpTarget_Dealloc, 0, ( getattrfunc ) wpTarget_getAttr, *************** *** 95,98 **** --- 130,134 ---- }; + static PyObject* PyGetTarget( cUORxTarget* target, Q_UINT8 map ) { *************** *** 110,116 **** pos.map = map; ! returnVal->pos = pos; ! returnVal->object = target->serial(); ! returnVal->model = target->model(); return ( PyObject * ) returnVal; --- 146,155 ---- pos.map = map; ! returnVal->pos = pos; ! returnVal->object = target->serial(); ! returnVal->model = target->model(); ! ! returnVal->py_pos = NULL; ! returnVal->py_obj = NULL; return ( PyObject * ) returnVal; |