Update of /cvsroot/wpdev/wolfpack/python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10137/python
Modified Files:
global.cpp
Log Message:
housing updates
Index: global.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/python/global.cpp,v
retrieving revision 1.166
retrieving revision 1.167
diff -C2 -d -r1.166 -r1.167
*** global.cpp 15 Oct 2004 14:38:23 -0000 1.166
--- global.cpp 21 Oct 2004 12:11:19 -0000 1.167
***************
*** 44,47 ****
--- 44,48 ----
#include "../multi.h"
#include "../scriptmanager.h"
+ #include "../muls/multiscache.h"
#include "../definitions.h"
#include "../pythonscript.h"
***************
*** 623,627 ****
Q_UNUSED( self );
// Minimum is x, y, map
! uint x = 0,
y = 0,
map = 0;
--- 624,628 ----
Q_UNUSED( self );
// Minimum is x, y, map
! int x = 0,
y = 0,
map = 0;
***************
*** 630,633 ****
--- 631,647 ----
return 0;
+ if (!Maps::instance()->hasMap(map)) {
+ PyErr_Format(PyExc_RuntimeError, "Unable to access unknown map %u.", map);
+ }
+
+ if (x < 0)
+ x = 0;
+ if (x >= Maps::instance()->mapTileWidth(map))
+ x = Maps::instance()->mapTileWidth(map) - 1;
+ if (y < 0)
+ y = 0;
+ if (y >= Maps::instance()->mapTileHeight(map))
+ y = Maps::instance()->mapTileHeight(map) - 1;
+
StaticsIterator iter = Maps::instance()->staticsIterator( Coord_cl( x, y, 0, map ), exact );
***************
*** 756,759 ****
--- 770,812 ----
/*
+ \function wolfpack.canplace
+ \param pos The position.
+ \param id The display id of the multi (0x0000 to 0x4000).
+ \param yard The size of the multis yard.
+ \return True if the given multi can be placed by a player at the given location.
+ \description This function checks if a multi can be placed at a certain location by players.
+ */
+ static PyObject *wpCanPlace( PyObject* self, PyObject *args ) {
+ Coord_cl pos;
+ unsigned short multiid;
+ unsigned short yard;
+ if (!PyArg_ParseTuple(args, "O&hh:wolfpack.canplace(id, yard)", &PyConvertCoord, &pos, &multiid, &yard)) {
+ return 0;
+ }
+
+ QPtrList<cUObject> moveOut; // List of objects to move out
+
+ PyObject *result = PyTuple_New(2);
+
+ if (cMulti::canPlace(pos, multiid, moveOut, yard)) {
+ Py_INCREF(Py_True);
+ PyTuple_SET_ITEM(result, 0, Py_True);
+
+ PyObject *list = PyTuple_New(moveOut.count());
+ int i = 0;
+ for (cUObject *obj = moveOut.first(); obj; obj = moveOut.next()) {
+ PyTuple_SET_ITEM(list, i++, obj->getPyObject());
+ }
+ PyTuple_SET_ITEM(result, 1, list);
+ } else {
+ Py_INCREF(Py_True);
+ PyTuple_SET_ITEM(result, 0, Py_False);
+ PyTuple_SET_ITEM(result, 1, PyTuple_New(0));
+ }
+
+ return result;
+ }
+
+ /*
\function wolfpack.effect
\param id The art id of the effect that should be shown.
***************
*** 1864,1867 ****
--- 1917,1921 ----
{ "addtimer", wpAddtimer, METH_VARARGS, "Adds a timed effect" },
{ "effect", wpEffect, METH_VARARGS, "Shows a graphical effect." },
+ { "canplace", wpCanPlace, METH_VARARGS, 0 },
{ "region", wpRegion, METH_VARARGS, "Gets the region at a specific position" },
{ "spawnregion", wpSpawnregion, METH_VARARGS, 0 },
|