Update of /cvsroot/wpdev/wolfpack/python
In directory sc8-pr-cvs1:/tmp/cvs-serv14446/python
Modified Files:
char.cpp item.cpp pycoord.cpp
Log Message:
Encryption Fixes for Linux and
some Python Fixes / Additions.
Index: char.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/char.cpp,v
retrieving revision 1.109
retrieving revision 1.110
diff -C2 -d -r1.109 -r1.110
*** char.cpp 26 Sep 2003 00:01:52 -0000 1.109
--- char.cpp 30 Sep 2003 15:06:30 -0000 1.110
***************
*** 939,943 ****
{
PyErr_BadArgument();
! return NULL;
}
--- 939,943 ----
{
PyErr_BadArgument();
! return 0;
}
***************
*** 947,953 ****
object = getArgChar( 0 );
else if( checkArgItem( 0 ) )
! object = getArgItem( 0 );
! if( object )
self->pChar->turnTo( object );
--- 947,962 ----
object = getArgChar( 0 );
else if( checkArgItem( 0 ) )
! {
! P_ITEM pItem = getArgItem( 0 );
!
! pItem = pItem->getOutmostItem();
! if( pItem->container() && pItem->container()->isChar() )
! object = pItem->container();
! else
! object = pItem;
! }
!
! if( object && object != self->pChar )
self->pChar->turnTo( object );
***************
*** 1535,1538 ****
--- 1544,1622 ----
}
+ static PyObject* wpChar_cansee( wpChar *self, PyObject *args )
+ {
+ if( self->pChar->free )
+ return PyFalse;
+
+ PyObject *object = 0;
+ unsigned int touch = 1;
+
+ if( !PyArg_ParseTuple( args, "O|i:char.cansee( [char,item,pos], [touch] )", &object, &touch ) )
+ return 0;
+
+ Coord_cl &pos = Coord_cl::null;
+
+ // Item
+ if( checkWpItem( object ) )
+ {
+ P_ITEM pItem = getWpItem( object );
+
+ // Invisibility Check
+ if( ( ( pItem->visible() == 1 && pItem->owner() != self->pChar ) || pItem->visible() == 2 ) )
+ {
+ P_PLAYER pPlayer = dynamic_cast< P_PLAYER >( self->pChar );
+ if( !pPlayer || !pPlayer->isGM() )
+ return PyFalse;
+ }
+
+ pos = pItem->pos();
+ }
+
+ // Char
+ else if( checkWpChar( object ) )
+ {
+ P_CHAR pChar = getWpChar( object );
+
+ if( pChar->isHidden() || pChar->isInvisible() )
+ {
+ P_PLAYER pPlayer = dynamic_cast< P_PLAYER >( self->pChar );
+ if( !pPlayer || !pPlayer->isGM() )
+ return PyFalse;
+ }
+
+ pos = pChar->pos();
+ }
+
+ // Position
+ else if( checkWpCoord( object ) )
+ {
+ pos = getWpCoord( object );
+ }
+ else
+ {
+ PyErr_SetString( PyExc_RuntimeError, "Incompatible Object for char.cansee()." );
+ return 0;
+ }
+
+ if( pos == Coord_cl::null )
+ return PyFalse;
+
+ bool result = self->pChar->pos().lineOfSight( pos, touch != 0 );
+
+ return result ? PyTrue : PyFalse;
+ }
+
+ static PyObject* wpChar_lightning( wpChar *self, PyObject *args )
+ {
+ unsigned short hue = 0;
+
+ if( !PyArg_ParseTuple( args, "|h:char.lightning( [hue] )", &hue ) )
+ return 0;
+
+ self->pChar->lightning( hue );
+
+ return PyTrue;
+ }
+
static PyMethodDef wpCharMethods[] =
{
***************
*** 1564,1567 ****
--- 1648,1653 ----
{ "canreach", (getattrofunc)wpChar_canreach, METH_VARARGS, "Checks if this character can reach a certain object." },
{ "canpickup", (getattrofunc)wpChar_canpickup, METH_VARARGS, NULL },
+ { "cansee", (getattrofunc)wpChar_cansee, METH_VARARGS, NULL },
+ { "lightning", (getattrofunc)wpChar_lightning, METH_VARARGS, NULL },
// Mostly NPC functions
Index: item.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/item.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -d -r1.76 -r1.77
*** item.cpp 23 Sep 2003 23:55:25 -0000 1.76
--- item.cpp 30 Sep 2003 15:06:30 -0000 1.77
***************
*** 630,633 ****
--- 630,645 ----
}
+ static PyObject* wpItem_lightning( wpItem *self, PyObject *args )
+ {
+ unsigned short hue = 0;
+
+ if( !PyArg_ParseTuple( args, "|h:item.lightning( [hue] )", &hue ) )
+ return 0;
+
+ self->pItem->lightning( hue );
+
+ return PyTrue;
+ }
+
static PyMethodDef wpItemMethods[] =
{
***************
*** 646,650 ****
{ "getoutmostitem", (getattrofunc)wpItem_getoutmostitem, METH_VARARGS, "Get the outmost item." },
{ "getname", (getattrofunc)wpItem_getname, METH_VARARGS, "Get item name." },
! { "multi", (getattrofunc)wpItem_multi, METH_VARARGS, NULL },
// Effects
--- 658,663 ----
{ "getoutmostitem", (getattrofunc)wpItem_getoutmostitem, METH_VARARGS, "Get the outmost item." },
{ "getname", (getattrofunc)wpItem_getname, METH_VARARGS, "Get item name." },
! { "multi", (getattrofunc)wpItem_multi, METH_VARARGS, 0 },
! { "lightning", (getattrofunc)wpItem_lightning, METH_VARARGS, 0 },
// Effects
***************
*** 851,854 ****
return !( pA == pB );
}
-
-
--- 864,865 ----
Index: pycoord.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/pycoord.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pycoord.cpp 10 Aug 2003 04:26:42 -0000 1.6
--- pycoord.cpp 30 Sep 2003 15:06:30 -0000 1.7
***************
*** 31,34 ****
--- 31,35 ----
#include "utilities.h"
#include "../coord.h"
+ #include "../walking.h"
/*!
***************
*** 75,81 ****
--- 76,106 ----
}
+ static PyObject *wpCoord_direction( wpCoord *self, PyObject *args )
+ {
+ // Check if the paramter is a coordinate
+ if( !checkWpCoord( PyTuple_GetItem( args, 0 ) ) )
+ {
+ return PyInt_FromLong( -1 );
+ }
+ else
+ {
+ Coord_cl pos = getWpCoord( PyTuple_GetItem( args, 0 ) );
+
+ // Calculate the distance
+ return PyInt_FromLong( self->coord.direction( pos ) );
+ }
+ }
+
+ static PyObject *wpCoord_validspawnspot( wpCoord *self, PyObject *args )
+ {
+ return Movement::instance()->canLandMonsterMoveHere( self->coord ) ? PyTrue : PyFalse;
+ }
+
static PyMethodDef wpCoordMethods[] =
{
{ "distance", (getattrofunc)wpCoord_distance, METH_VARARGS, "Whats the distance between Point A and Point B" },
+ { "direction", (getattrofunc)wpCoord_direction, METH_VARARGS, NULL },
+ { "validspawnspot", (getattrofunc)wpCoord_validspawnspot, METH_VARARGS, NULL },
+ { 0, 0, 0, 0 }
};
|