Update of /cvsroot/wpdev/wolfpack/python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1813/python
Modified Files:
char.cpp item.cpp utilities.h
Log Message:
Added basedef properties.
Index: item.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/item.cpp,v
retrieving revision 1.127
retrieving revision 1.128
diff -C2 -d -r1.127 -r1.128
*** item.cpp 2 Sep 2004 00:43:24 -0000 1.127
--- item.cpp 5 Sep 2004 17:43:52 -0000 1.128
***************
*** 1091,1094 ****
--- 1091,1197 ----
}
+ /*
+ \method item.getintproperty
+ \description Get an integer property from the items definition.
+ \param name The name of the property. This name is not case sensitive.
+ \param default The default value that is returned if this property doesnt
+ exist. Defaults to 0.
+ \return The property value or the given default value.
+ */
+ static PyObject* wpItem_getintproperty( wpItem* self, PyObject* args )
+ {
+ unsigned int def = 0;
+ PyObject *pyname;
+
+ if (!PyArg_ParseTuple(args, "O|i:item.getintproperty(name, def)", &pyname, &def)) {
+ return 0;
+ }
+
+ QString name = Python2QString(pyname);
+ if (self->pItem->basedef() ) {
+ return PyInt_FromLong( self->pItem->basedef()->getIntProperty( name, def ) );
+ } else {
+ return PyInt_FromLong( def );
+ }
+ }
+
+ /*
+ \method item.getstrproperty
+ \description Get a string property from the items definition.
+ \param name The name of the property. This name is not case sensitive.
+ \param default The default value that is returned if this property doesnt
+ exist. Defaults to an empty string.
+ \return The property value or the given default value.
+ */
+ static PyObject* wpItem_getstrproperty( wpItem* self, PyObject* args )
+ {
+ PyObject *pydef = 0;
+ PyObject *pyname;
+
+ if (!PyArg_ParseTuple(args, "O|O:item.getstrproperty(name, def)", &pyname, &pydef)) {
+ return 0;
+ }
+
+ QString name = Python2QString(pyname);
+ QString def = Python2QString(pydef);
+
+ if (self->pItem->basedef() ) {
+ return QString2Python( self->pItem->basedef()->getStrProperty( name, def ) );
+ } else {
+ if (pydef) {
+ Py_INCREF(pydef);
+ return pydef;
+ } else {
+ return QString2Python( "" );
+ }
+ }
+ }
+
+ /*
+ \method item.hasstrproperty
+ \description Checks if the definition of this item has a string property with the given name.
+ \param name The name of the property. This name is not case sensitive.
+ \return True if the definition has the property, False otherwise.
+ */
+ static PyObject* wpItem_hasstrproperty( wpItem* self, PyObject* args )
+ {
+ PyObject *pyname;
+
+ if (!PyArg_ParseTuple(args, "O:item.hasstrproperty(name)", &pyname)) {
+ return 0;
+ }
+
+ QString name = Python2QString(pyname);
+
+ if (self->pItem->basedef() && self->pItem->basedef()->hasStrProperty(name)) {
+ Py_RETURN_TRUE;
+ } else {
+ Py_RETURN_FALSE;
+ }
+ }
+
+ /*
+ \method item.hasintproperty
+ \description Checks if the definition of this item has an integer property with the given name.
+ \param name The name of the property. This name is not case sensitive.
+ \return True if the definition has the property, False otherwise.
+ */
+ static PyObject* wpItem_hasintproperty( wpItem* self, PyObject* args )
+ {
+ PyObject *pyname;
+
+ if (!PyArg_ParseTuple(args, "O:item.hasintproperty(name)", &pyname)) {
+ return 0;
+ }
+
+ QString name = Python2QString(pyname);
+
+ if (self->pItem->basedef() && self->pItem->basedef()->hasIntProperty(name)) {
+ Py_RETURN_TRUE;
+ } else {
+ Py_RETURN_FALSE;
+ }
+ }
+
static PyMethodDef wpItemMethods[] =
{
***************
*** 1117,1120 ****
--- 1220,1229 ----
{ "effect", ( getattrofunc ) wpItem_effect, METH_VARARGS, 0 },
+ // Definition Properties
+ { "getintproperty", ( getattrofunc ) wpItem_getintproperty, METH_VARARGS, 0 },
+ { "getstrproperty", ( getattrofunc ) wpItem_getstrproperty, METH_VARARGS, 0 },
+ { "hasintproperty", ( getattrofunc ) wpItem_hasintproperty, METH_VARARGS, 0 },
+ { "hasstrproperty", ( getattrofunc ) wpItem_hasstrproperty, METH_VARARGS, 0 },
+
// Event handling
{ "callevent", ( getattrofunc ) wpItem_callevent, METH_VARARGS, 0 },
Index: utilities.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/utilities.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** utilities.h 19 Aug 2004 05:35:14 -0000 1.41
--- utilities.h 5 Sep 2004 17:43:52 -0000 1.42
***************
*** 153,157 ****
inline QString Python2QString( PyObject* object )
{
! if ( PyUnicode_Check( object ) )
{
#if defined(Py_UNICODE_WIDE)
--- 153,161 ----
inline QString Python2QString( PyObject* object )
{
! if ( !object )
! {
! return QString::null;
! }
! else if ( PyUnicode_Check( object ) )
{
#if defined(Py_UNICODE_WIDE)
Index: char.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/char.cpp,v
retrieving revision 1.186
retrieving revision 1.187
diff -C2 -d -r1.186 -r1.187
*** char.cpp 29 Aug 2004 20:40:50 -0000 1.186
--- char.cpp 5 Sep 2004 17:43:51 -0000 1.187
***************
*** 832,835 ****
--- 832,938 ----
/*
+ \method char.getintproperty
+ \description Get an integer property from the characters definition.
+ \param name The name of the property. This name is not case sensitive.
+ \param default The default value that is returned if this property doesnt
+ exist. Defaults to 0.
+ \return The property value or the given default value.
+ */
+ static PyObject* wpChar_getintproperty( wpChar* self, PyObject* args )
+ {
+ unsigned int def = 0;
+ PyObject *pyname;
+
+ if (!PyArg_ParseTuple(args, "O|i:char.getintproperty(name, def)", &pyname, &def)) {
+ return 0;
+ }
+
+ QString name = Python2QString(pyname);
+ if (self->pChar->basedef() ) {
+ return PyInt_FromLong( self->pChar->basedef()->getIntProperty( name, def ) );
+ } else {
+ return PyInt_FromLong( def );
+ }
+ }
+
+ /*
+ \method char.getstrproperty
+ \description Get a string property from the characters definition.
+ \param name The name of the property. This name is not case sensitive.
+ \param default The default value that is returned if this property doesnt
+ exist. Defaults to an empty string.
+ \return The property value or the given default value.
+ */
+ static PyObject* wpChar_getstrproperty( wpChar* self, PyObject* args )
+ {
+ PyObject *pydef = 0;
+ PyObject *pyname;
+
+ if (!PyArg_ParseTuple(args, "O|O:char.getstrproperty(name, def)", &pyname, &pydef)) {
+ return 0;
+ }
+
+ QString name = Python2QString(pyname);
+ QString def = Python2QString(pydef);
+
+ if (self->pChar->basedef() ) {
+ return QString2Python( self->pChar->basedef()->getStrProperty( name, def ) );
+ } else {
+ if (pydef) {
+ Py_INCREF(pydef);
+ return pydef;
+ } else {
+ return QString2Python( "" );
+ }
+ }
+ }
+
+ /*
+ \method char.hasstrproperty
+ \description Checks if the definition of this character has a string property with the given name.
+ \param name The name of the property. This name is not case sensitive.
+ \return True if the definition has the property, False otherwise.
+ */
+ static PyObject* wpChar_hasstrproperty( wpChar* self, PyObject* args )
+ {
+ PyObject *pyname;
+
+ if (!PyArg_ParseTuple(args, "O:char.hasstrproperty(name)", &pyname)) {
+ return 0;
+ }
+
+ QString name = Python2QString(pyname);
+
+ if (self->pChar->basedef() && self->pChar->basedef()->hasStrProperty(name)) {
+ Py_RETURN_TRUE;
+ } else {
+ Py_RETURN_FALSE;
+ }
+ }
+
+ /*
+ \method char.hasintproperty
+ \description Checks if the definition of this character has an integer property with the given name.
+ \param name The name of the property. This name is not case sensitive.
+ \return True if the definition has the property, False otherwise.
+ */
+ static PyObject* wpChar_hasintproperty( wpChar* self, PyObject* args )
+ {
+ PyObject *pyname;
+
+ if (!PyArg_ParseTuple(args, "O:char.hasintproperty(name)", &pyname)) {
+ return 0;
+ }
+
+ QString name = Python2QString(pyname);
+
+ if (self->pChar->basedef() && self->pChar->basedef()->hasIntProperty(name)) {
+ Py_RETURN_TRUE;
+ } else {
+ Py_RETURN_FALSE;
+ }
+ }
+
+ /*
\method char.gettag
\description Get a custom tag attached to the character.
***************
*** 2365,2368 ****
--- 2468,2477 ----
{ "updatehealth", ( getattrofunc ) wpChar_updatehealth, METH_VARARGS, "Resends the healthbar to the environment." },
+ // Definition Properties
+ { "getintproperty", ( getattrofunc ) wpChar_getintproperty, METH_VARARGS, 0 },
+ { "getstrproperty", ( getattrofunc ) wpChar_getstrproperty, METH_VARARGS, 0 },
+ { "hasintproperty", ( getattrofunc ) wpChar_hasintproperty, METH_VARARGS, 0 },
+ { "hasstrproperty", ( getattrofunc ) wpChar_hasstrproperty, METH_VARARGS, 0 },
+
// Mount/Unmount
{ "unmount", ( getattrofunc ) wpChar_unmount, METH_VARARGS, "Unmounts this character and returns the character it was previously mounted." },
|