wpdev-commits Mailing List for Wolfpack Emu (Page 40)
Brought to you by:
rip,
thiagocorrea
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(14) |
Aug
(121) |
Sep
(256) |
Oct
(59) |
Nov
(73) |
Dec
(120) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(259) |
Feb
(381) |
Mar
(501) |
Apr
(355) |
May
(427) |
Jun
(270) |
Jul
(394) |
Aug
(412) |
Sep
(724) |
Oct
(578) |
Nov
(65) |
Dec
|
From: Sebastian H. <dar...@us...> - 2004-09-16 18:44:26
|
Update of /cvsroot/wpdev/xmlscripts/definitions/items/equipment In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3825/items/equipment Modified Files: clothes.xml Log Message: fixes Index: clothes.xml =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/definitions/items/equipment/clothes.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** clothes.xml 27 Aug 2004 14:43:26 -0000 1.16 --- clothes.xml 16 Sep 2004 18:44:16 -0000 1.17 *************** *** 12,15 **** --- 12,16 ---- <item id="2305"> <id>0x2305</id> + <dye /> <category>Clothes\Accessories\Flower Garland (N/S)</category> <weight>1.0</weight> *************** *** 26,29 **** --- 27,31 ---- <item id="230d"> <id>0x230d</id> + <dye /> <category>Clothes\Torso\Gilded Dress (W/E)</category> <weight>3.0</weight> *************** *** 40,43 **** --- 42,46 ---- <item id="2309"> <id>0x2309</id> + <dye /> <category>Clothes\Accessories\Fur Cape (W/E)</category> <weight>4.0</weight> *************** *** 54,57 **** --- 57,61 ---- <item id="230b"> <id>0x230b</id> + <dye /> <category>Clothes\Accessories\Fur Sarong (W/E)</category> <weight>3.0</weight> *************** *** 70,73 **** --- 74,78 ---- <category>Clothes\Torso\Formal Shirt (W/E)</category> <weight>1.0</weight> + <dye /> <basescripts>equipment</basescripts> </item> |
From: Sebastian H. <dar...@us...> - 2004-09-16 16:43:37
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8797 Modified Files: coord.cpp wolfpack.vcproj Log Message: Fixes Index: wolfpack.vcproj =================================================================== RCS file: /cvsroot/wpdev/wolfpack/wolfpack.vcproj,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** wolfpack.vcproj 16 Sep 2004 01:40:17 -0000 1.48 --- wolfpack.vcproj 16 Sep 2004 16:43:27 -0000 1.49 *************** *** 726,750 **** <File RelativePath=".\python\target.cpp"> - <FileConfiguration - Name="Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - ObjectFile="$(IntDir)/$(InputName)1.obj"/> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32"> - <Tool - Name="VCCLCompilerTool" - ObjectFile="$(IntDir)/$(InputName)1.obj"/> - </FileConfiguration> - <FileConfiguration - Name="Web-Release|Win32"> - <Tool - Name="VCCLCompilerTool" - ObjectFile="$(IntDir)/$(InputName)1.obj"/> - </FileConfiguration> - </File> - <File - RelativePath=".\target.cpp"> </File> <File --- 726,729 ---- Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** coord.cpp 16 Sep 2004 01:41:02 -0000 1.61 --- coord.cpp 16 Sep 2004 16:43:27 -0000 1.62 *************** *** 241,246 **** QValueList<Coord_cl> pointList = getPointList(*this, target); - bool result = true; - int lastX = -1, lastY = -1; QValueList<stBlockingItem> blockingItems; --- 241,244 ---- *************** *** 263,268 **** // Play an effect for the tile if (blocked) { - result = false; point.effect(0x181D, 10, 50, 0x21); } else { point.effect(0x181D, 10, 50, 0x44); --- 261,266 ---- // Play an effect for the tile if (blocked) { point.effect(0x181D, 10, 50, 0x21); + return false; } else { point.effect(0x181D, 10, 50, 0x44); *************** *** 270,274 **** } ! return result; } --- 268,272 ---- } ! return true; } |
From: Sebastian H. <dar...@us...> - 2004-09-16 16:42:39
|
Update of /cvsroot/wpdev/xmlscripts/scripts/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8542/wolfpack Modified Files: properties.py Log Message: Fixes Index: properties.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/wolfpack/properties.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** properties.py 10 Sep 2004 20:20:44 -0000 1.12 --- properties.py 16 Sep 2004 16:42:29 -0000 1.13 *************** *** 229,254 **** # If the npc has mindamage and maxdamage tags, they # override all other settings ! ! mindamage = char.getintproperty( 'mindamage', 1 ) ! if char.hastag('mindamage'): ! mindamage = int(char.gettag('mindamage')) ! ! maxdamage = char.getintproperty( 'maxdamage', 3 ) ! if char.hastag('maxdamage'): ! maxdamage = int(char.gettag('maxdamage')) ! ! return (mindamage, maxdamage) # Special treatment for fists. if not weapon: # Use the basedef values. ! if char.maxdamage != 0: ! return (char.mindamage, char.maxdamage) ! ! mindamage = char.strength / 28 ! maxdamage = mindamage + 7 else: mindamage = fromitem(weapon, MINDAMAGE) maxdamage = fromitem(weapon, MAXDAMAGE) else: if not weapon and char.maxdamage != 0: --- 229,255 ---- # If the npc has mindamage and maxdamage tags, they # override all other settings ! mindamage = char.mindamage ! maxdamage = char.maxdamage ! ! try: ! if char.hastag('mindamage'): ! mindamage = int(char.gettag('mindamage')) ! ! if char.hastag('maxdamage'): ! maxdamage = int(char.gettag('maxdamage')) ! except: ! pass # Special treatment for fists. if not weapon: # Use the basedef values. ! if maxdamage == 0: ! mindamage = char.strength / 28 ! maxdamage = mindamage + 7 else: mindamage = fromitem(weapon, MINDAMAGE) maxdamage = fromitem(weapon, MAXDAMAGE) + + return (mindamage, maxdamage) else: if not weapon and char.maxdamage != 0: |
From: Sebastian H. <dar...@us...> - 2004-09-16 16:42:39
|
Update of /cvsroot/wpdev/xmlscripts/scripts/magic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8542/magic Modified Files: __init__.py circle4.py Log Message: Fixes Index: circle4.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/circle4.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** circle4.py 1 Sep 2004 23:45:59 -0000 1.14 --- circle4.py 16 Sep 2004 16:42:28 -0000 1.15 *************** *** 179,190 **** self.harmful = 1 self.resistable = 1 def target(self, char, mode, targettype, target, args, item): char.turnto(target) - if not char.canreach(target, 10): - char.message(500237) - return - if not self.consumerequirements(char, mode, args, target, item): return --- 179,187 ---- self.harmful = 1 self.resistable = 1 + self.range = 10 def target(self, char, mode, targettype, target, args, item): char.turnto(target) if not self.consumerequirements(char, mode, args, target, item): return Index: __init__.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/__init__.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** __init__.py 7 Sep 2004 20:09:52 -0000 1.16 --- __init__.py 16 Sep 2004 16:42:28 -0000 1.17 *************** *** 101,105 **** char.socket.clilocmessage(500446) return ! if not char.canreach(target.char, spell.range): if char.socket: char.socket.clilocmessage(500237) --- 101,105 ---- char.socket.clilocmessage(500446) return ! if not char.canreach(target, spell.range): if char.socket: char.socket.clilocmessage(500237) *************** *** 119,123 **** char.socket.clilocmessage(500237) return ! if not char.canreach(target.item, spell.range): if char.socket: char.socket.clilocmessage(500237) --- 119,123 ---- char.socket.clilocmessage(500237) return ! if not char.canreach(target, spell.range): if char.socket: char.socket.clilocmessage(500237) *************** *** 145,149 **** char.socket.clilocmessage(500446) return ! if not char.canreach(pos, spell.range): if char.socket: char.socket.clilocmessage(500237) --- 145,149 ---- char.socket.clilocmessage(500446) return ! if not char.canreach(target, spell.range): if char.socket: char.socket.clilocmessage(500237) |
From: Sebastian H. <dar...@us...> - 2004-09-16 16:42:38
|
Update of /cvsroot/wpdev/xmlscripts/scripts/skills In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8542/skills Modified Files: begging.py Log Message: Fixes Index: begging.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/skills/begging.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** begging.py 16 Jul 2004 07:09:27 -0000 1.14 --- begging.py 16 Sep 2004 16:42:29 -0000 1.15 *************** *** 55,59 **** # You are too far away... ! if not char.canreach( npc.pos, BEGGING_RANGE ): # male npc if not npc.gender: --- 55,59 ---- # You are too far away... ! if not char.canreach( npc, BEGGING_RANGE ): # male npc if not npc.gender: |
From: Sebastian H. <dar...@us...> - 2004-09-16 16:42:38
|
Update of /cvsroot/wpdev/xmlscripts/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8542 Modified Files: potions.py Log Message: Fixes Index: potions.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/potions.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** potions.py 11 Sep 2004 15:58:57 -0000 1.50 --- potions.py 16 Sep 2004 16:42:29 -0000 1.51 *************** *** 129,133 **** if char.distanceto(target.char) > check: return 0 ! if not char.canreach(target.char, check): return 0 pos = target.char.pos --- 129,133 ---- if char.distanceto(target.char) > check: return 0 ! if not char.canreach(target, check): return 0 pos = target.char.pos *************** *** 137,141 **** if char.distanceto(target.item) > check: return 0 ! if not char.canreach(target.item, check): return 0 item = target.item.getoutmostitem() --- 137,141 ---- if char.distanceto(target.item) > check: return 0 ! if not char.canreach(target, check): return 0 item = target.item.getoutmostitem() *************** *** 145,149 **** pos = item.pos else: ! if not char.canreach(target.pos, check): return 0 pos = target.pos --- 145,149 ---- pos = item.pos else: ! if not char.canreach(target, check): return 0 pos = target.pos |
From: Sebastian H. <dar...@us...> - 2004-09-16 16:42:37
|
Update of /cvsroot/wpdev/xmlscripts/scripts/guilds In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8542/guilds Modified Files: deed.py Log Message: Fixes Index: deed.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/guilds/deed.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** deed.py 25 Aug 2004 17:03:05 -0000 1.5 --- deed.py 16 Sep 2004 16:42:28 -0000 1.6 *************** *** 18,22 **** # player.socket.clilocmessage(500312) else: ! if not player.canreach(target.pos, 3): player.socket.clilocmessage(500312) elif not target.pos.validspawnspot(): --- 18,22 ---- # player.socket.clilocmessage(500312) else: ! if not player.canreach(target, 3): player.socket.clilocmessage(500312) elif not target.pos.validspawnspot(): |
From: Sebastian H. <dar...@us...> - 2004-09-16 16:42:37
|
Update of /cvsroot/wpdev/xmlscripts/scripts/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8542/commands Modified Files: __init__.py Log Message: Fixes Index: __init__.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/commands/__init__.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** __init__.py 15 Sep 2004 01:25:53 -0000 1.18 --- __init__.py 16 Sep 2004 16:42:28 -0000 1.19 *************** *** 196,200 **** srcpos.z += 15 ! srcpos.lineofsightnew(targpos) def newlos(socket, command, arguments): --- 196,201 ---- srcpos.z += 15 ! result = srcpos.lineofsightnew(targpos) ! char.socket.sysmessage('RESULT: ' + str(result)) def newlos(socket, command, arguments): |
From: spddmn <xxx...@us...> - 2004-09-16 14:57:57
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17581 Modified Files: wolf.dsp Log Message: new LOS (python\target.cpp) Index: wolf.dsp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/wolf.dsp,v retrieving revision 1.272 retrieving revision 1.273 diff -C2 -d -r1.272 -r1.273 *** wolf.dsp 2 Sep 2004 17:19:59 -0000 1.272 --- wolf.dsp 16 Sep 2004 14:57:45 -0000 1.273 *************** *** 790,793 **** --- 790,797 ---- # Begin Source File + SOURCE=.\python\target.cpp + # End Source File + # Begin Source File + SOURCE=.\python\target.h # End Source File |
From: Sebastian H. <dar...@us...> - 2004-09-16 01:41:20
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5162 Modified Files: coord.cpp inlines.h Log Message: New Line Of Sight Index: inlines.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/inlines.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** inlines.h 16 Sep 2004 01:40:17 -0000 1.28 --- inlines.h 16 Sep 2004 01:41:02 -0000 1.29 *************** *** 65,69 **** } ! inline int round(double n) { double f = n - floor(n); if (f >= 0.50) { --- 65,69 ---- } ! inline int roundInt(double n) { double f = n - floor(n); if (f >= 0.50) { Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** coord.cpp 16 Sep 2004 01:40:17 -0000 1.60 --- coord.cpp 16 Sep 2004 01:41:02 -0000 1.61 *************** *** 79,85 **** while (isBetween(currentX, target.x, origin.x) && isBetween(currentY, target.y, origin.y) && isBetween(currentZ, target.z, origin.z)) { ! pos.x = round(currentX); ! pos.y = round(currentY); ! pos.z = round(currentZ); if (pointList.count() == 0 || pointList.last() != pos) { --- 79,85 ---- while (isBetween(currentX, target.x, origin.x) && isBetween(currentY, target.y, origin.y) && isBetween(currentZ, target.z, origin.z)) { ! pos.x = roundInt(currentX); ! pos.y = roundInt(currentY); ! pos.z = roundInt(currentZ); if (pointList.count() == 0 || pointList.last() != pos) { |
From: Sebastian H. <dar...@us...> - 2004-09-16 01:40:29
|
Update of /cvsroot/wpdev/wolfpack/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4974/python Modified Files: char.cpp pycoord.cpp python.pri target.h Added Files: target.cpp Log Message: New Line Of Sight Index: python.pri =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/python.pri,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** python.pri 31 Aug 2004 19:16:49 -0000 1.3 --- python.pri 16 Sep 2004 01:40:19 -0000 1.4 *************** *** 29,32 **** --- 29,33 ---- $$PYTHON_CPP/region.cpp \ $$PYTHON_CPP/socket.cpp \ + $$PYTHON_CPP/target.cpp \ $$PYTHON_CPP/worlditerator.cpp \ Index: pycoord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/pycoord.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** pycoord.cpp 15 Sep 2004 16:06:54 -0000 1.24 --- pycoord.cpp 16 Sep 2004 01:40:19 -0000 1.25 *************** *** 163,169 **** \method coord.lineofsight \param coord Another <object id="coord">coord</object> object. ! \param targetheight The height of the line of sight target. ! Can be 0. ! \param touch A boolean value. Defaults to false. \description Returns true if an object at the given coordinate with the given height can be seen from this coordinate. Touch determines whether the target needs to be touched or only be seen. --- 163,167 ---- \method coord.lineofsight \param coord Another <object id="coord">coord</object> object. ! \param debug A boolean value. Defaults to false. \description Returns true if an object at the given coordinate with the given height can be seen from this coordinate. Touch determines whether the target needs to be touched or only be seen. *************** *** 172,221 **** { Coord_cl pos; ! ushort targetheight; ! char touch = 0; ! if ( !PyArg_ParseTuple( args, "O&i|b:coord.lineofsight(coord, targetheight, [touch=0])", &PyConvertCoord, &pos, &targetheight, &touch ) ) return 0; ! if ( self->coord.lineOfSight( pos, targetheight, touch ) ) Py_RETURN_TRUE; Py_RETURN_FALSE; } - extern bool lineOfSightNew(Coord_cl origin, Coord_cl target); - extern void getMapTileSpan(const Coord_cl &pos, unsigned short &id, int &bottom, int &top); - extern Coord_cl getItemLosCoord(P_ITEM pItem); - extern Coord_cl getCharLosCoord(P_CHAR pChar, bool eye); - - static PyObject* wpCoord_lineofsightnew( wpCoord* self, PyObject* args ) - { - PyObject *object; - if ( !PyArg_ParseTuple( args, "O:coord.lineofsight(obj)", &object ) ) - return 0; - - Coord_cl pos; - - if (checkWpCoord(object)) { - pos = getWpCoord(object); - - // Get the average elevation - int bottom, top; - unsigned short id; - getMapTileSpan(pos, id, bottom, top); - - // Use the top - pos.z = top; - } else if ( checkWpItem(object) ) { - pos = getItemLosCoord(getWpItem(object)); - } else if ( checkWpChar(object) ) { - pos = getCharLosCoord(getWpChar(object), false); - } - - if ( lineOfSightNew( self->coord, pos ) ) - { - Py_RETURN_TRUE; - } else { - Py_RETURN_FALSE; - } - } - static PyMethodDef wpCoordMethods[] = { --- 170,181 ---- { Coord_cl pos; ! char debug = 0; ! if ( !PyArg_ParseTuple( args, "O&|b:coord.lineofsight(coord, [debug=0])", &PyConvertCoord, &pos, &debug ) ) return 0; ! if ( self->coord.lineOfSight( pos, debug != 0 ) ) Py_RETURN_TRUE; Py_RETURN_FALSE; } static PyMethodDef wpCoordMethods[] = { *************** *** 224,228 **** { "validspawnspot", ( getattrofunc ) wpCoord_validspawnspot, METH_VARARGS, NULL }, { "lineofsight", ( getattrofunc ) wpCoord_lineofsight, METH_VARARGS, NULL }, - { "lineofsightnew", ( getattrofunc ) wpCoord_lineofsightnew, METH_VARARGS, NULL }, { 0, 0, 0, 0 } }; --- 184,187 ---- --- NEW FILE: target.cpp --- #include "target.h" static PyObject* wpTarget_getAttr( wpTarget* self, char* name ) { /* \rproperty target.pos The value of this property is a <object id="coord">coord</object> object representing the location of the targetted object or ground tile. Remember that this value should not be trusted. */ 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, this property contains the body id of the targetted character. Please note that this value is sent by the client and not determined by the server. */ 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. */ else if ( !strcmp( name, "item" ) ) { if ( isItemSerial( self->object ) ) { if ( !self->py_obj ) self->py_obj = PyGetItemObject( FindItemBySerial( self->object ) ); Py_INCREF( self->py_obj ); return self->py_obj; } } /* \rproperty target.char If a valid character has been targetted, this property contains a <object id="char">char</object> object for the targetted character. */ 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 ); } PyTypeObject wpTargetType = { PyObject_HEAD_INIT( NULL ) 0, "wpTarget", sizeof( wpTargetType ), 0, ( destructor ) wpTarget_Dealloc, 0, ( getattrfunc ) wpTarget_getAttr, 0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; static PyObject* PyGetTarget( cUORxTarget* target, Q_UINT8 map ) { if ( !target ) { Py_RETURN_NONE; } wpTarget* returnVal = PyObject_New( wpTarget, &wpTargetType ); Coord_cl pos; pos.x = target->x(); pos.y = target->y(); pos.z = target->z(); 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; } bool cPythonTarget::responsed( cUOSocket* socket, cUORxTarget* target ) { // Try to call the python function // Get everything before the last dot if ( responsefunc.contains( "." ) ) { // Find the last dot int position = responsefunc.findRev( "." ); QString sModule = responsefunc.left( position ); QString sFunction = responsefunc.right( responsefunc.length() - ( position + 1 ) ); PyObject* pModule = PyImport_ImportModule( const_cast<char*>( sModule.latin1() ) ); if ( pModule ) { PyObject* pFunc = PyObject_GetAttrString( pModule, const_cast<char*>( sFunction.latin1() ) ); if ( pFunc && PyCallable_Check( pFunc ) ) { // Create our Argument list PyObject* p_args = PyTuple_New( 3 ); PyTuple_SetItem( p_args, 0, PyGetCharObject( socket->player() ) ); PyTuple_SetItem( p_args, 1, args ); PyTuple_SetItem( p_args, 2, PyGetTarget( target, socket->player()->pos().map ) ); PyObject* result = PyEval_CallObject( pFunc, p_args ); Py_XDECREF( result ); reportPythonError( sModule ); } Py_XDECREF( pFunc ); } Py_XDECREF( pModule ); } Py_DECREF( args ); return true; } void cPythonTarget::timedout( cUOSocket* socket ) { if ( !timeoutfunc.isNull() && !timeoutfunc.isEmpty() && timeoutfunc.contains( "." ) ) { // Find the last dot int position = timeoutfunc.findRev( "." ); QString sModule = timeoutfunc.left( position ); QString sFunction = timeoutfunc.right( timeoutfunc.length() - ( position + 1 ) ); PyObject* pModule = PyImport_ImportModule( const_cast<char*>( sModule.latin1() ) ); if ( pModule ) { PyObject* pFunc = PyObject_GetAttrString( pModule, const_cast<char*>( sFunction.latin1() ) ); if ( pFunc && PyCallable_Check( pFunc ) ) { // Create our Argument list PyObject* args = PyTuple_New( 1 ); PyTuple_SetItem( args, 0, PyGetCharObject( socket->player() ) ); PyObject* result = PyEval_CallObject( pFunc, args ); Py_XDECREF( result ); reportPythonError( sModule ); } Py_XDECREF( pFunc ); } Py_XDECREF( pModule ); } Py_DECREF( args ); } void cPythonTarget::canceled( cUOSocket* socket ) { if ( !cancelfunc.isNull() && !cancelfunc.isEmpty() && cancelfunc.contains( "." ) ) { // Find the last dot int position = cancelfunc.findRev( "." ); QString sModule = cancelfunc.left( position ); QString sFunction = cancelfunc.right( cancelfunc.length() - ( position + 1 ) ); PyObject* pModule = PyImport_ImportModule( const_cast<char*>( sModule.latin1() ) ); if ( pModule ) { PyObject* pFunc = PyObject_GetAttrString( pModule, const_cast<char*>( sFunction.latin1() ) ); if ( pFunc && PyCallable_Check( pFunc ) ) { // Create our Argument list PyObject* args = PyTuple_New( 1 ); PyTuple_SetItem( args, 0, PyGetCharObject( socket->player() ) ); PyObject* result = PyEval_CallObject( pFunc, args ); Py_XDECREF( result ); reportPythonError( sModule ); } Py_XDECREF( pFunc ); } Py_XDECREF( pModule ); } Py_DECREF( args ); } Index: target.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/target.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** target.h 26 Aug 2004 00:52:13 -0000 1.23 --- target.h 16 Sep 2004 01:40:19 -0000 1.24 *************** *** 48,158 **** } wpTarget; ! ! static PyObject* wpTarget_getAttr( wpTarget* self, char* name ) ! { ! /* ! \rproperty target.pos The value of this property is a <object id="coord">coord</object> object representing the location of the targetted object or ground tile. ! Remember that this value should not be trusted. ! */ ! 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, ! this property contains the body id of the targetted character. Please note that this value is sent by the client and not determined by the server. ! */ ! 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. ! */ ! else if ( !strcmp( name, "item" ) ) ! { ! if ( isItemSerial( self->object ) ) ! { ! if ( !self->py_obj ) ! self->py_obj = PyGetItemObject( FindItemBySerial( self->object ) ); ! ! Py_INCREF( self->py_obj ); ! return self->py_obj; ! } ! } ! /* ! \rproperty target.char If a valid character has been targetted, this property contains a <object id="char">char</object> object for the targetted character. ! */ ! 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 = ! { ! PyObject_HEAD_INIT( NULL ) ! 0, ! "wpTarget", ! sizeof( wpTargetType ), ! 0, ! ( destructor ) wpTarget_Dealloc, ! 0, ! ( getattrfunc ) wpTarget_getAttr, ! 0, ! 0, ! 0, ! 0, ! 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, ! ! }; ! ! ! static PyObject* PyGetTarget( cUORxTarget* target, Q_UINT8 map ) ! { ! if ( !target ) ! { ! Py_RETURN_NONE; ! } ! ! wpTarget* returnVal = PyObject_New( wpTarget, &wpTargetType ); ! ! Coord_cl pos; ! pos.x = target->x(); ! pos.y = target->y(); ! pos.z = target->z(); ! 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; ! } class cPythonTarget : public cTargetRequest --- 48,52 ---- } wpTarget; ! extern PyTypeObject wpTargetType; class cPythonTarget : public cTargetRequest *************** *** 169,283 **** } ! bool responsed( cUOSocket* socket, cUORxTarget* target ) ! { ! // Try to call the python function ! // Get everything before the last dot ! if ( responsefunc.contains( "." ) ) ! { ! // Find the last dot ! int position = responsefunc.findRev( "." ); ! QString sModule = responsefunc.left( position ); ! QString sFunction = responsefunc.right( responsefunc.length() - ( position + 1 ) ); ! ! PyObject* pModule = PyImport_ImportModule( const_cast<char*>( sModule.latin1() ) ); ! ! if ( pModule ) ! { ! PyObject* pFunc = PyObject_GetAttrString( pModule, const_cast<char*>( sFunction.latin1() ) ); ! ! if ( pFunc && PyCallable_Check( pFunc ) ) ! { ! // Create our Argument list ! PyObject* p_args = PyTuple_New( 3 ); ! PyTuple_SetItem( p_args, 0, PyGetCharObject( socket->player() ) ); ! PyTuple_SetItem( p_args, 1, args ); ! PyTuple_SetItem( p_args, 2, PyGetTarget( target, socket->player()->pos().map ) ); ! ! PyObject* result = PyEval_CallObject( pFunc, p_args ); ! Py_XDECREF( result ); ! reportPythonError( sModule ); ! } ! ! Py_XDECREF( pFunc ); ! } ! ! Py_XDECREF( pModule ); ! } ! ! Py_DECREF( args ); ! return true; ! } ! ! void timedout( cUOSocket* socket ) ! { ! if ( !timeoutfunc.isNull() && !timeoutfunc.isEmpty() && timeoutfunc.contains( "." ) ) ! { ! // Find the last dot ! int position = timeoutfunc.findRev( "." ); ! QString sModule = timeoutfunc.left( position ); ! QString sFunction = timeoutfunc.right( timeoutfunc.length() - ( position + 1 ) ); ! ! PyObject* pModule = PyImport_ImportModule( const_cast<char*>( sModule.latin1() ) ); ! ! if ( pModule ) ! { ! PyObject* pFunc = PyObject_GetAttrString( pModule, const_cast<char*>( sFunction.latin1() ) ); ! ! if ( pFunc && PyCallable_Check( pFunc ) ) ! { ! // Create our Argument list ! PyObject* args = PyTuple_New( 1 ); ! PyTuple_SetItem( args, 0, PyGetCharObject( socket->player() ) ); ! ! PyObject* result = PyEval_CallObject( pFunc, args ); ! Py_XDECREF( result ); ! reportPythonError( sModule ); ! } ! ! Py_XDECREF( pFunc ); ! } ! ! Py_XDECREF( pModule ); ! } ! ! Py_DECREF( args ); ! } ! ! void canceled( cUOSocket* socket ) ! { ! if ( !cancelfunc.isNull() && !cancelfunc.isEmpty() && cancelfunc.contains( "." ) ) ! { ! // Find the last dot ! int position = cancelfunc.findRev( "." ); ! QString sModule = cancelfunc.left( position ); ! QString sFunction = cancelfunc.right( cancelfunc.length() - ( position + 1 ) ); ! ! PyObject* pModule = PyImport_ImportModule( const_cast<char*>( sModule.latin1() ) ); ! ! if ( pModule ) ! { ! PyObject* pFunc = PyObject_GetAttrString( pModule, const_cast<char*>( sFunction.latin1() ) ); ! ! if ( pFunc && PyCallable_Check( pFunc ) ) ! { ! // Create our Argument list ! PyObject* args = PyTuple_New( 1 ); ! PyTuple_SetItem( args, 0, PyGetCharObject( socket->player() ) ); ! ! PyObject* result = PyEval_CallObject( pFunc, args ); ! Py_XDECREF( result ); ! ! reportPythonError( sModule ); ! } ! ! Py_XDECREF( pFunc ); ! } ! ! Py_XDECREF( pModule ); ! } ! ! Py_DECREF( args ); ! } }; #endif --- 63,71 ---- } ! bool responsed( cUOSocket* socket, cUORxTarget* target ); ! void timedout( cUOSocket* socket ); ! void canceled( cUOSocket* socket ); }; + #endif Index: char.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/char.cpp,v retrieving revision 1.192 retrieving revision 1.193 diff -C2 -d -r1.192 -r1.193 *** char.cpp 14 Sep 2004 00:31:58 -0000 1.192 --- char.cpp 16 Sep 2004 01:40:19 -0000 1.193 *************** *** 28,31 **** --- 28,32 ---- #include "engine.h" + #include "target.h" #include "../territories.h" #include "../skills.h" *************** *** 1979,1991 **** \description Check if the character can reach the given object or coordinate and if he is in within a given range. ! \param target The object the character wants to reach. This can either be an item, a character or a ! coordinate object. ! \param range The range the character needs to be within. \return True if the character can reach the given object, false otherwise. */ ! static PyObject* wpChar_canreach( wpChar* self, PyObject* args ) ! { ! Q_UNUSED( args ); ! if ( self->pChar->free || ( !checkArgObject( 0 ) && !checkArgCoord( 0 ) ) || !checkArgInt( 1 ) ) Py_RETURN_FALSE; --- 1980,1991 ---- \description Check if the character can reach the given object or coordinate and if he is in within a given range. ! \param target The object the character wants to reach. This can either be an item, a character, a ! coordinate or a target object. ! \param range The range the character needs to be within. If this is -1 the target needs to be in the ! characters posessions. \return True if the character can reach the given object, false otherwise. */ ! static PyObject* wpChar_canreach( wpChar* self, PyObject* args ) { ! if (self->pChar->free) Py_RETURN_FALSE; *************** *** 1995,2069 **** Py_RETURN_TRUE; ! Coord_cl pos; ! P_ITEM pItem = 0; ! P_CHAR pChar = 0; ! // Parameter 1: Coordinate ! if ( checkArgCoord( 0 ) ) ! { ! pos = getArgCoord( 0 ); ! // Parameter1: Item/Char ! } ! else ! { ! pChar = getArgChar( 0 ); ! if ( !pChar ) ! { ! pItem = getArgItem( 0 ); ! if ( !pItem ) ! { ! Py_INCREF( Py_False ); ! return Py_False; ! } ! if ( pItem->getOutmostChar() == self->pChar ) ! { ! Py_INCREF( Py_True ); ! return Py_True; ! } ! pos = pItem->pos(); } ! else ! { ! pos = pChar->pos(); } } ! Q_UINT32 range = getArgInt( 1 ); ! if ( self->pChar->pos().map != pos.map ) Py_RETURN_FALSE; ! if ( self->pChar->pos().distance( pos ) > range ) Py_RETURN_FALSE; - - if ( pItem ) - { - if ( !self->pChar->lineOfSight( pItem, true ) ) - { - Py_INCREF( Py_False ); - return Py_False; - } - } - else if ( pChar ) - { - if ( !self->pChar->lineOfSight( pChar, true ) ) - { - Py_INCREF( Py_False ); - return Py_False; - } } ! else ! { ! if ( !self->pChar->lineOfSight( pos, true ) ) ! { ! Py_INCREF( Py_False ); ! return Py_False; ! } } Py_RETURN_TRUE; } --- 1995,2089 ---- Py_RETURN_TRUE; ! PyObject *target; ! int range; ! int debug = 0; ! if (!PyArg_ParseTuple(args, "Oi|i:char.canreach(target, range)", &target, &range, &debug)) { ! return 0; ! } ! Coord_cl targetPos; ! if (checkWpCoord(target)) { ! if (range == -1) { ! Py_RETURN_FALSE; ! } ! targetPos = getWpCoord(target).losMapPoint(); ! } else if (checkWpItem(target)) { ! P_ITEM pItem = getWpItem(target); ! // Range -1 means that the item has to be on the char ! if (range == -1 && pItem->getOutmostChar() != self->pChar) { ! Py_RETURN_FALSE; ! } ! targetPos = pItem->pos().losItemPoint(pItem->id()); ! } else if (checkWpChar(target)) { ! if (range == -1) { ! Py_RETURN_FALSE; } ! ! P_CHAR pChar = getWpChar(target); ! targetPos = pChar->pos().losCharPoint(false); ! } else if (target->ob_type == &wpTargetType) { ! SERIAL object = ((wpTarget*)target)->object; ! Coord_cl pos = ((wpTarget*)target)->pos; ! unsigned short model = ((wpTarget*)target)->model; ! ! P_ITEM pItem = dynamic_cast<P_ITEM>(World::instance()->findItem(object)); ! ! if (pItem) { ! pItem = pItem->getOutmostItem(); ! ! if (pItem->container() && pItem->container()->isChar()) { ! if (range == -1) { ! Py_RETURN_TRUE; ! } ! ! targetPos = pItem->container()->pos().losCharPoint(); ! } else { ! if (range == -1) { ! Py_RETURN_FALSE; ! } ! ! targetPos = pItem->pos().losItemPoint(pItem->id()); ! } ! } else { ! if (range == -1) { ! Py_RETURN_FALSE; ! } ! ! P_CHAR pChar = dynamic_cast<P_CHAR>(World::instance()->findChar(object)); ! if (pChar) { ! targetPos = pChar->pos().losCharPoint(); ! } else { ! if (model != 0) { ! targetPos = pos.losItemPoint(model); ! } else { ! targetPos = pos.losMapPoint(); ! } ! } } + } else { + PyErr_SetString(PyExc_TypeError, "Unknown target type for char.canreach()"); + return 0; } ! // Now that we have the target position, measure the distance. ! Coord_cl pos = self->pChar->pos().losCharPoint(true); ! if (pos.map != targetPos.map) { Py_RETURN_FALSE; + } ! if (pos.distance(targetPos) > range) { Py_RETURN_FALSE; } ! ! if (!pos.lineOfSight(targetPos, debug != 0)) { ! Py_RETURN_FALSE; } + Py_RETURN_TRUE; } |
From: Sebastian H. <dar...@us...> - 2004-09-16 01:40:27
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4974 Modified Files: basechar.cpp basechar.h coord.cpp coord.h dragdrop.cpp inlines.h wolfpack.vcproj Log Message: New Line Of Sight Index: coord.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** coord.h 13 Aug 2004 08:55:25 -0000 1.21 --- coord.h 16 Sep 2004 01:40:17 -0000 1.22 *************** *** 31,43 **** // Platform specifics #include "platform.h" ! ! //Forward class declaration ! class Coord_cl; ! ! // typedefs ! ! ! //Class definitions class Coord_cl --- 31,37 ---- // Platform specifics #include "platform.h" + #include "typedefs.h" ! class cUORxTarget; class Coord_cl *************** *** 55,60 **** unsigned int distance( const Coord_cl& src ) const; unsigned int direction( const Coord_cl& dest ) const; ! bool lineOfSight( const Coord_cl& target, bool touch = false ); ! bool lineOfSight( const Coord_cl& target, UI16 targethight, bool touch = false ); static UI32 distance( const Coord_cl& a, const Coord_cl& b ); --- 49,60 ---- unsigned int distance( const Coord_cl& src ) const; unsigned int direction( const Coord_cl& dest ) const; ! bool lineOfSight(const Coord_cl &dest, bool debug = false) const; ! ! // Utility functions for getting correct LOS points ! Coord_cl losCharPoint(bool eye = false) const; ! Coord_cl losItemPoint(unsigned short id) const; ! Coord_cl losMapPoint() const; ! static Coord_cl losTargetPoint(cUORxTarget *target, unsigned char map); ! static UI32 distance( const Coord_cl& a, const Coord_cl& b ); *************** *** 62,72 **** Displays an effect staying at this position. */ ! void effect( UI16 id, UI08 speed = 10, UI08 duration = 5, UI16 hue = 0, UI16 renderMode = 0 ); static Coord_cl null; - private: - double specialFloor( const double value ) const; - public: UI16 x; --- 62,69 ---- Displays an effect staying at this position. */ ! void effect( UI16 id, UI08 speed = 10, UI08 duration = 5, UI16 hue = 0, UI16 renderMode = 0 ) const; static Coord_cl null; public: UI16 x; Index: dragdrop.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/dragdrop.cpp,v retrieving revision 1.244 retrieving revision 1.245 diff -C2 -d -r1.244 -r1.245 *** dragdrop.cpp 14 Sep 2004 04:40:31 -0000 1.244 --- dragdrop.cpp 16 Sep 2004 01:40:17 -0000 1.245 *************** *** 78,81 **** --- 78,87 ---- } + // Check if the item can be reached + if (pItem->getOutmostChar() != pChar && !pChar->lineOfSight(pItem)) { + socket->bounceItem( pItem, BR_OUT_OF_REACH ); + return; + } + if ( pItem->onPickup( pChar ) ) return; *************** *** 534,538 **** // Can wee see our target ! if ( !pChar->lineOfSight( pOtherChar->pos(), true ) ) { socket->bounceItem( pItem, BR_OUT_OF_SIGHT ); --- 540,544 ---- // Can wee see our target ! if ( !pChar->lineOfSight( pOtherChar ) ) { socket->bounceItem( pItem, BR_OUT_OF_SIGHT ); *************** *** 594,598 **** // Check if the destination is in line of sight ! if ( !pChar->lineOfSight( pos, false ) ) { socket->bounceItem( pItem, BR_OUT_OF_SIGHT ); --- 600,604 ---- // Check if the destination is in line of sight ! if ( !pChar->lineOfSight( pos.losItemPoint(pItem->id()) ) ) { socket->bounceItem( pItem, BR_OUT_OF_SIGHT ); Index: basechar.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v retrieving revision 1.147 retrieving revision 1.148 diff -C2 -d -r1.147 -r1.148 *** basechar.cpp 14 Sep 2004 00:31:57 -0000 1.147 --- basechar.cpp 16 Sep 2004 01:40:16 -0000 1.148 *************** *** 3244,3253 **** if ( weapon && ( weapon->type() == 1006 || weapon->type() == 1007 ) ) { ! if ( !lineOfSight( attackTarget_, false ) ) { return; } } ! else if ( !lineOfSight( attackTarget_, true ) ) { return; --- 3244,3253 ---- if ( weapon && ( weapon->type() == 1006 || weapon->type() == 1007 ) ) { ! if ( !lineOfSight( attackTarget_ ) ) { return; } } ! else if ( !lineOfSight( attackTarget_ ) ) { return; *************** *** 3280,3307 **** } ! bool cBaseChar::lineOfSight( P_CHAR target, bool touch ) { ! if ( target == this ) ! { return true; } ! Coord_cl eyes = pos_ + Coord_cl( 0, 0, 15 ); ! return eyes.lineOfSight( target->pos(), 15, touch ); } ! bool cBaseChar::lineOfSight( P_ITEM target, bool touch ) { ! tile_st tile = TileCache::instance()->getTile( target->id() ); ! Coord_cl eyes = pos_ + Coord_cl( 0, 0, 15 ); ! return eyes.lineOfSight( target->pos(), tile.height, touch ); } ! bool cBaseChar::lineOfSight( const Coord_cl& target, bool touch ) ! { ! Coord_cl eyes = pos_ + Coord_cl( 0, 0, 15 ); ! return eyes.lineOfSight( target, 0, touch ); } --- 3280,3315 ---- } ! bool cBaseChar::lineOfSight( P_CHAR target, bool debug ) { ! if (target == this) { return true; } ! // From us (eye) to target (no eye) ! return pos_.losCharPoint(true).lineOfSight(target->pos().losCharPoint(), debug); } ! bool cBaseChar::lineOfSight( P_ITEM target, bool debug ) { ! target = target->getOutmostItem(); ! Coord_cl pos; ! if (target->container() && target->container()->isChar()) { ! pos = target->container()->pos().losCharPoint(false); ! } else { ! pos = target->pos().losItemPoint(target->id()); ! } ! ! return pos_.losCharPoint(true).lineOfSight(pos, debug); } ! bool cBaseChar::lineOfSight( const Coord_cl& target, bool debug ) ! { ! return pos_.losCharPoint(true).lineOfSight(target.losMapPoint(), debug); ! } ! bool cBaseChar::lineOfSight( const Coord_cl& target, unsigned short id, bool debug ) ! { ! return pos_.losCharPoint(true).lineOfSight(target.losItemPoint(id), debug); } Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** coord.cpp 15 Sep 2004 16:11:09 -0000 1.59 --- coord.cpp 16 Sep 2004 01:40:17 -0000 1.60 *************** *** 32,35 **** --- 32,36 ---- #include "sectors.h" #include "items.h" + #include "inlines.h" #include "muls/multiscache.h" #include "muls/maps.h" *************** *** 45,80 **** #include <set> [...1394 lines suppressed...] ! Coord_cl Coord_cl::losTargetPoint(cUORxTarget *target, unsigned char map) { ! SERIAL serial = target->serial(); ! P_ITEM pItem = World::instance()->findItem(serial); ! P_CHAR pChar = World::instance()->findChar(serial); ! if (pItem) { ! pItem = pItem->getOutmostItem(); ! if (pItem->container() && pItem->container()->isChar()) { ! return pItem->container()->pos().losCharPoint(); ! } else { ! return pItem->pos().losItemPoint(pItem->id()); } ! } else if (pChar) { ! return pChar->pos().losCharPoint(); ! } else { ! return Coord_cl(target->x(), target->y(), target->z(), map); } } Index: wolfpack.vcproj =================================================================== RCS file: /cvsroot/wpdev/wolfpack/wolfpack.vcproj,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** wolfpack.vcproj 31 Aug 2004 19:16:49 -0000 1.47 --- wolfpack.vcproj 16 Sep 2004 01:40:17 -0000 1.48 *************** *** 725,728 **** --- 725,752 ---- </File> <File + RelativePath=".\python\target.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Web-Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\target.cpp"> + </File> + <File RelativePath=".\python\target.h"> </File> Index: basechar.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/basechar.h,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** basechar.h 14 Sep 2004 00:00:36 -0000 1.85 --- basechar.h 16 Sep 2004 01:40:16 -0000 1.86 *************** *** 138,144 **** virtual bool canSeeItem( P_ITEM item ); virtual void moveTo( const Coord_cl& pos, bool noremove = false ); ! bool lineOfSight( P_ITEM item, bool touch = false ); ! bool lineOfSight( const Coord_cl& position, bool touch = false ); ! bool lineOfSight( P_CHAR character, bool touch = false ); /*! --- 138,161 ---- virtual bool canSeeItem( P_ITEM item ); virtual void moveTo( const Coord_cl& pos, bool noremove = false ); ! ! /* ! Line of sight check for an item. ! */ ! bool lineOfSight( P_ITEM item, bool debug = false ); ! ! /* ! Line of sight check for a static item ! */ ! bool lineOfSight( const Coord_cl& position, unsigned short id, bool debug = false ); ! ! /* ! Line of Sight check for a map tile ! */ ! bool lineOfSight( const Coord_cl& position, bool debug = false ); ! ! /* ! Line of Sight check for another character. ! */ ! bool lineOfSight( P_CHAR character, bool debug = false ); /*! Index: inlines.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/inlines.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** inlines.h 2 Jun 2004 15:04:05 -0000 1.27 --- inlines.h 16 Sep 2004 01:40:17 -0000 1.28 *************** *** 30,33 **** --- 30,35 ---- // library Includes + #include <algorithm> + #include <math.h> #include "qapplication.h" #include "qstring.h" *************** *** 63,65 **** --- 65,85 ---- } + inline int round(double n) { + double f = n - floor(n); + if (f >= 0.50) { + return (int)ceil(n); + } else { + return (int)floor(n); + } + } + + inline bool isBetween(double n, int lower, int higher, double tolerance = 0.5) { + // Swap the bounds if they are out of order + if (lower > higher) { + std::swap(lower, higher); + } + + return (n > lower - tolerance) && (n < higher + tolerance); + } + #endif |
From: Sebastian H. <dar...@us...> - 2004-09-16 01:40:27
|
Update of /cvsroot/wpdev/wolfpack/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4974/network Modified Files: uosocket.cpp Log Message: New Line Of Sight Index: uosocket.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.cpp,v retrieving revision 1.411 retrieving revision 1.412 diff -C2 -d -r1.411 -r1.412 *** uosocket.cpp 14 Sep 2004 04:20:24 -0000 1.411 --- uosocket.cpp 16 Sep 2004 01:40:17 -0000 1.412 *************** *** 3166,3170 **** return false; } ! else if ( !_player->lineOfSight( item, true ) ) { clilocMessage( 0x7A258, "", 0x3b2 ); // You cannot reach that --- 3166,3170 ---- return false; } ! else if ( !_player->lineOfSight( item ) ) { clilocMessage( 0x7A258, "", 0x3b2 ); // You cannot reach that |
From: Sebastian H. <dar...@us...> - 2004-09-16 01:40:26
|
Update of /cvsroot/wpdev/wolfpack/muls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4974/muls Modified Files: maps.cpp maps.h Log Message: New Line Of Sight Index: maps.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/muls/maps.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** maps.cpp 27 Aug 2004 18:56:59 -0000 1.10 --- maps.cpp 16 Sep 2004 01:40:17 -0000 1.11 *************** *** 400,403 **** --- 400,427 ---- } + void cMaps::mapTileSpan(const Coord_cl &pos, unsigned short &id, int &bottom, int &top) const { + int topZ, bottomZ, leftZ, rightZ; + + // Get the elevation of the tile itself + map_st tile = seekMap(pos.map, pos.x, pos.y); + topZ = tile.z; + id = tile.id; + + // Get the elevation of the tile on the lower left + leftZ = seekMap(pos.map, pos.x, pos.y + 1).z; + + // Get the elevation of the tile on the lower right + rightZ = seekMap(pos.map, pos.x + 1, pos.y).z; + + // Get the elevation of the tile below + bottomZ = seekMap(pos.map, pos.x + 1, pos.y + 1).z; + + // Get the smallest of the z values + bottom = QMIN( QMIN( QMIN(topZ, leftZ), rightZ), bottomZ); + + // Get the highest of the z values + top = QMAX( QMAX( QMAX(topZ, leftZ), rightZ), bottomZ); + } + /*! Returns the average elevation (z) of coordinates \a p and it's Index: maps.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/muls/maps.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** maps.h 13 Aug 2004 08:55:27 -0000 1.3 --- maps.h 16 Sep 2004 01:40:17 -0000 1.4 *************** *** 125,128 **** --- 125,129 ---- signed char mapElevation( const Coord_cl& p ) const; signed char mapAverageElevation( const Coord_cl& p, int* top = 0, int* botton = 0 ) const; + void mapTileSpan(const Coord_cl &pos, unsigned short &id, int &bottom, int &top) const; signed char dynamicElevation( const Coord_cl& pos ) const; signed char height( const Coord_cl& pos ); |
From: Sebastian H. <dar...@us...> - 2004-09-15 16:11:21
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5841 Modified Files: coord.cpp Log Message: further cleanups Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** coord.cpp 15 Sep 2004 16:06:53 -0000 1.58 --- coord.cpp 15 Sep 2004 16:11:09 -0000 1.59 *************** *** 59,63 **** } ! bool isBetween(double n, int lower, int higher, double tolerance = 0.5) { // Swap the bounds if they are out of order if (lower > higher) { --- 59,63 ---- } ! inline bool isBetween(double n, int lower, int higher, double tolerance = 0.5) { // Swap the bounds if they are out of order if (lower > higher) { *************** *** 68,77 **** } ! double round(double n) { double f = n - floor(n); if (f >= 0.50) { ! return ceil(n); } else { ! return floor(n); } } --- 68,77 ---- } ! inline int round(double n) { double f = n - floor(n); if (f >= 0.50) { ! return (int)ceil(n); } else { ! return (int)floor(n); } } *************** *** 82,111 **** QValueList<Coord_cl> pointList; ! int xDiff = target.x - origin.x; // i1 ! int yDiff = target.y - origin.y; // j1 ! int zDiff = target.z - origin.z; // k1 // Calculate the length of the X,Y diagonal ! double xyDiagonal = sqrt( (double)( xDiff * xDiff + yDiff * yDiff ) ); // d3 // Calculate the length of the second diagonal ! double zDiagonal; // d4 if (zDiff != 0) { ! zDiagonal = sqrt( xyDiagonal * xyDiagonal + (double)( zDiff * zDiff ) ); } else { ! zDiagonal = xyDiagonal; } ! // Calculate the "increases" ! double d1 = yDiff / zDiagonal; ! double d2 = xDiff / zDiagonal; ! xyDiagonal = zDiff / zDiagonal; ! double d6 = origin.y; // CurrentY ? ! double d7 = origin.z; // CurrentZ ? ! double d5 = origin.x; // CurrentX ? ! while (isBetween(d5, target.x, origin.x) && isBetween(d6, target.y, origin.y) && isBetween(d7, target.z, origin.z)) { ! Coord_cl pos((int)round(d5), (int)round(d6), (int)round(d7), origin.map); if (pointList.count() == 0 || pointList.last() != pos) { --- 82,116 ---- QValueList<Coord_cl> pointList; ! int xDiff = target.x - origin.x; ! int yDiff = target.y - origin.y; ! int zDiff = target.z - origin.z; // Calculate the length of the X,Y diagonal ! double xyDiagonal = sqrt( (double)( xDiff * xDiff + yDiff * yDiff ) ); // Calculate the length of the second diagonal ! double lineLength; if (zDiff != 0) { ! lineLength = sqrt( xyDiagonal * xyDiagonal + (double)( zDiff * zDiff ) ); } else { ! lineLength = xyDiagonal; } ! // Calculate the stepsize for each coordinate ! double xStep = yDiff / lineLength; ! double yStep = xDiff / lineLength; ! double zStep = zDiff / lineLength; ! // Initialize loop variables ! double currentY = origin.y; ! double currentZ = origin.z; ! double currentX = origin.x; ! Coord_cl pos = origin; ! ! while (isBetween(currentX, target.x, origin.x) && isBetween(currentY, target.y, origin.y) && isBetween(currentZ, target.z, origin.z)) { ! pos.x = round(currentX); ! pos.y = round(currentY); ! pos.z = round(currentZ); if (pointList.count() == 0 || pointList.last() != pos) { *************** *** 114,120 **** // Jump to the next set of coordinates. ! d7 += xyDiagonal; ! d5 += d2; ! d6 += d1; } --- 119,125 ---- // Jump to the next set of coordinates. ! currentX += xStep; ! currentY += yStep; ! currentZ += zStep; } |
From: Sebastian H. <dar...@us...> - 2004-09-15 16:07:03
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4857 Modified Files: coord.cpp Log Message: los optimization Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** coord.cpp 15 Sep 2004 02:26:33 -0000 1.57 --- coord.cpp 15 Sep 2004 16:06:53 -0000 1.58 *************** *** 94,98 **** zDiagonal = sqrt( xyDiagonal * xyDiagonal + (double)( zDiff * zDiff ) ); } else { ! zDiagonal = zDiff; } --- 94,98 ---- zDiagonal = sqrt( xyDiagonal * xyDiagonal + (double)( zDiff * zDiff ) ); } else { ! zDiagonal = xyDiagonal; } *************** *** 128,147 **** } ! void getAverageZ(const Coord_cl &pos, int &z, int &average, int &top) { ! int elevations[4]; Coord_cl tempPos = pos; // Get the elevation of the tile itself ! elevations[0] = Maps::instance()->seekMap(tempPos).z; // Get the elevation of the tile on the lower left tempPos = pos; tempPos.y += 1; ! elevations[1] = Maps::instance()->seekMap(tempPos).z; // Get the elevation of the tile on the lower right tempPos = pos; tempPos.x += 1; ! elevations[2] = Maps::instance()->seekMap(tempPos).z; // Get the elevation of the tile below --- 128,149 ---- } ! void getMapTileSpan(const Coord_cl &pos, unsigned short &id, int &bottom, int &top) { ! int topZ, bottomZ, leftZ, rightZ; Coord_cl tempPos = pos; // Get the elevation of the tile itself ! map_st tile = Maps::instance()->seekMap(tempPos); ! topZ = tile.z; ! id = tile.id; // Get the elevation of the tile on the lower left tempPos = pos; tempPos.y += 1; ! leftZ = Maps::instance()->seekMap(tempPos).z; // Get the elevation of the tile on the lower right tempPos = pos; tempPos.x += 1; ! rightZ = Maps::instance()->seekMap(tempPos).z; // Get the elevation of the tile below *************** *** 149,264 **** tempPos.x += 1; tempPos.y += 1; ! elevations[3] = Maps::instance()->seekMap(tempPos).z; // Get the smallest of the z values ! z = QMIN( QMIN( QMIN(elevations[0], elevations[1]), elevations[2]), elevations[3]); // Get the highest of the z values ! top = QMAX( QMAX( QMAX(elevations[0], elevations[1]), elevations[2]), elevations[3]); ! ! // Whatever difference is smaller leads to the average elevation of the tile ! if (abs(elevations[0] - elevations[3]) > abs(elevations[1] - elevations[2])) { ! average = (int)floor((elevations[1] + elevations[2]) / 2.0); ! } else { ! average = (int)floor((elevations[0] + elevations[3]) / 2.0); ! } } ! // Check for blocking tiles at the given position ! inline bool checkBlockingTiles(const Coord_cl &pos, const Coord_cl &target) { ! // Check Map first ! map_st maptile = Maps::instance()->seekMap(pos); ! int mapBottom, mapTop, mapAverage; ! getAverageZ(pos, mapBottom, mapAverage, mapTop); ! ! // Ignore certain types of maptiles (Thanks to Krrios for help) ! if (maptile.id != 2 && maptile.id != 0x1DB && (maptile.id < 0x1AE || maptile.id > 0x1B5)) { ! // See if we intersect the maptile ! if (pos.z >= mapBottom && pos.z <= mapTop) { ! // The maptile won't block if it's our target. ! if (pos.x != target.x || pos.y != target.y || mapBottom > target.z || mapTop < target.z) { ! return true; ! } ! } ! } ! // Search for statics at that position ! StaticsIterator statics = Maps::instance()->staticsIterator(pos, true); ! // There is a special behaviour for 0x244 maptiles if there ! // is no static item or dynamic item in the area. ! if (maptile.id == 0x244 && statics.atEnd()) { ! // If there are *any* items at that position, skip the special behaviour. ! cItemSectorIterator *items = SectorMaps::instance()->findItems(pos, 0); ! bool found = false; ! for (P_ITEM item = items->first(); item; item = items->next()) { ! if (item->visible() == 0) { ! found = true; ! break; ! } ! } ! delete items; ! if (!found) { ! return true; ! } ! } // Find blocking statics for (; !statics.atEnd(); ++statics) { ! const staticrecord &item = *statics; ! ! tile_st tile = TileCache::instance()->getTile(item.itemid); ! int height = tile.height; ! // Bridges are half as high as normal tiles ! if (tile.flag2 & 0x04) { ! height /= 2; ! } ! if (item.zoff <= pos.z && item.zoff + height >= pos.z) { ! // Window and noshoot tiles block ! if (tile.flag2 & 0x30) { ! // This will not block if it's "within" our target. ! if (pos.x != target.x || pos.y != target.y || item.zoff > target.z || item.zoff + height < target.z) { ! return true; ! } ! } ! } } // Search for items at the given location ! cItemSectorIterator *items = SectorMaps::instance()->findItems(pos, 0); ! for (P_ITEM item = items->first(); item; item = items->next()) { // If the item is invisible or a multi, skip past it. ! if (item->visible() != 0 || item->isMulti()) { continue; } ! tile_st tile = TileCache::instance()->getTile(item->id()); // Window and noshoot tiles block if (tile.flag2 & 0x30) { ! // Calculate the correct height ! int height = tile.height; ! if (tile.flag2 & 0x04) { ! height /= 2; ! } ! ! // See if the item intersects our current position ! if (pos.z >= item->pos().z && pos.z <= item->pos().z + height) { ! // This will not block if it's "within" our target. ! if (pos.x != target.x || pos.y != target.y || item->pos().z > target.z || item->pos().z + height < target.z) { ! delete items; ! return true; ! } ! } } } ! delete items; // Check for multis around the area --- 151,226 ---- tempPos.x += 1; tempPos.y += 1; ! bottomZ = Maps::instance()->seekMap(tempPos).z; // Get the smallest of the z values ! bottom = QMIN( QMIN( QMIN(topZ, leftZ), rightZ), bottomZ); // Get the highest of the z values ! top = QMAX( QMAX( QMAX(topZ, leftZ), rightZ), bottomZ); } ! // A small structure used to check for blocking dynamics at the given position ! struct stBlockingItem { ! unsigned short id; ! int bottom; ! int top; ! bool maptile; ! }; ! // Get blocking tiles at the given x,y,map coordinate ! void getBlockingTiles(const Coord_cl &pos, QValueList<stBlockingItem> &items) { ! stBlockingItem item; ! // Maptiles first ! getMapTileSpan(pos, item.id, item.bottom, item.top); ! item.maptile = true; ! // Only include this maptile if it's relevant for our line of sight ! if (item.id != 2 && item.id != 0x1DB && (item.id < 0x1AE || item.id > 0x1B5)) { ! items.append(item); ! } ! item.maptile = false; ! // Search for statics at the same position ! StaticsIterator statics = Maps::instance()->staticsIterator(pos, true); // Find blocking statics for (; !statics.atEnd(); ++statics) { ! const staticrecord &sitem = *statics; ! tile_st tile = TileCache::instance()->getTile(sitem.itemid); ! if (tile.flag2 & 0x30) { ! item.bottom = sitem.zoff; ! // Bridges are only half as high ! item.top = item.bottom + (tile.flag2 & 0x04) ? (tile.height / 2) : tile.height; ! item.id = sitem.itemid; ! items.append(item); ! } } // Search for items at the given location ! cItemSectorIterator *ditems = SectorMaps::instance()->findItems(pos, 0); ! for (P_ITEM ditem = ditems->first(); ditem; ditem = ditems->next()) { // If the item is invisible or a multi, skip past it. ! if (ditem->visible() != 0 || ditem->isMulti()) { continue; } ! tile_st tile = TileCache::instance()->getTile(ditem->id()); // Window and noshoot tiles block if (tile.flag2 & 0x30) { ! item.id = ditem->id(); ! item.bottom = ditem->pos().z; ! // Bridges are only half as high ! item.top = item.bottom + (tile.flag2 & 0x04) ? (tile.height / 2) : tile.height; ! items.append(item); } } ! delete ditems; // Check for multis around the area *************** *** 270,301 **** MultiDefinition *data = MultiCache::instance()->getMulti(multi->id() - 0x4000); if (data) { ! QValueVector<multiItem_st> items = data->getEntries(); QValueVector<multiItem_st>::iterator it; ! for (it = items.begin(); it != items.end(); ++it) { ! multiItem_st item = *it; ! int itemz = item.z + multi->pos().z; ! if (multi->pos().x + item.x != pos.x || multi->pos().y + item.y != pos.y) { continue; } ! tile_st tile = TileCache::instance()->getTile(item.tile); ! ! // Calculate the correct height ! int height = tile.height; ! if (tile.flag2 & 0x04) { ! height /= 2; ! } ! // Has to be visible and blocking ! if (item.visible && tile.flag2 & 0x30) { ! if (pos.z >= itemz && pos.z <= itemz + height) { ! // This will not block if it's "within" our target. ! if (pos.x != target.x || pos.y != target.y || itemz > target.z || itemz + height < target.z) { ! delete multis; ! return true; ! } ! } } } --- 232,254 ---- MultiDefinition *data = MultiCache::instance()->getMulti(multi->id() - 0x4000); if (data) { ! QValueVector<multiItem_st> mitems = data->getEntries(); QValueVector<multiItem_st>::iterator it; ! for (it = mitems.begin(); it != mitems.end(); ++it) { ! multiItem_st mitem = *it; ! // Skip this multi tile if it's not at the position we need it to be ! if (!mitem.visible || multi->pos().x + mitem.x != pos.x || multi->pos().y + mitem.y != pos.y) { continue; } ! tile_st tile = TileCache::instance()->getTile(mitem.tile); ! // Has to be blocking ! if (tile.flag2 & 0x30) { ! item.bottom = mitem.z + multi->pos().z; ! item.top = item.bottom + (tile.flag2 & 0x04) ? (tile.height / 2) : tile.height; ! item.id = mitem.tile; ! items.append(item); } } *************** *** 304,324 **** delete multis; - - return false; } ! // Make sure that the points are aligned from top to bottom ! inline void normalizeCoords(Coord_cl &a, Coord_cl &b) { ! if (a.x > b.x) { ! std::swap(a.x, b.x); ! } ! if (a.y > b.y) { ! std::swap(a.y, b.y); ! } ! if (a.z > b.z) { ! std::swap(a.z, b.z); } } --- 257,285 ---- delete multis; } ! // Check for blocking tiles at the given position ! inline bool checkBlockingTiles(const QValueList<stBlockingItem> &items, const Coord_cl &pos, const Coord_cl &target) { ! // Iterate trough all blocking tiles ! QValueList<stBlockingItem>::const_iterator it; ! for (it = items.begin(); it != items.end(); ++it) { ! stBlockingItem item = *it; ! // 0x244 tiles are handled differently. If they're the only ! // tile at the xy position, they're blocking. ! if (item.maptile && item.id == 0x244 && items.count() != 1) { ! continue; ! } ! // Do we intersect the blocking tile? ! if (pos.z >= item.bottom && pos.z <= item.top) { ! // If the blocking item is within our target area, forget about it. ! if (pos.x != target.x || pos.y != target.y || item.bottom > target.z || item.top < target.z) { ! return true; ! } ! } } + + return false; } *************** *** 340,349 **** bool result = true; QValueList<Coord_cl>::const_iterator it; for (it = pointList.begin(); it != pointList.end(); ++it) { Coord_cl point = *it; // Check if there are blocking map, static or dynamic items. ! bool blocked = checkBlockingTiles(point, target); // Play an effect for the tile --- 301,319 ---- bool result = true; + int lastX = -1, lastY = -1; + QValueList<stBlockingItem> blockingItems; + QValueList<Coord_cl>::const_iterator it; for (it = pointList.begin(); it != pointList.end(); ++it) { Coord_cl point = *it; + // Get a fresh tile-list + if (point.x != lastX || point.y != lastY) { + blockingItems.clear(); + getBlockingTiles(point, blockingItems); + } + // Check if there are blocking map, static or dynamic items. ! bool blocked = checkBlockingTiles(blockingItems, point, target); // Play an effect for the tile |
From: Sebastian H. <dar...@us...> - 2004-09-15 16:07:03
|
Update of /cvsroot/wpdev/wolfpack/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4857/python Modified Files: pycoord.cpp Log Message: los optimization Index: pycoord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/pycoord.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pycoord.cpp 15 Sep 2004 15:05:51 -0000 1.23 --- pycoord.cpp 15 Sep 2004 16:06:54 -0000 1.24 *************** *** 182,186 **** extern bool lineOfSightNew(Coord_cl origin, Coord_cl target); ! extern void getAverageZ(const Coord_cl &pos, int &z, int &average, int &top); extern Coord_cl getItemLosCoord(P_ITEM pItem); extern Coord_cl getCharLosCoord(P_CHAR pChar, bool eye); --- 182,186 ---- extern bool lineOfSightNew(Coord_cl origin, Coord_cl target); ! extern void getMapTileSpan(const Coord_cl &pos, unsigned short &id, int &bottom, int &top); extern Coord_cl getItemLosCoord(P_ITEM pItem); extern Coord_cl getCharLosCoord(P_CHAR pChar, bool eye); *************** *** 198,203 **** // Get the average elevation ! int bottom, average, top; ! getAverageZ(pos, bottom, average, top); // Use the top --- 198,204 ---- // Get the average elevation ! int bottom, top; ! unsigned short id; ! getMapTileSpan(pos, id, bottom, top); // Use the top |
From: Sebastian H. <dar...@us...> - 2004-09-15 15:06:01
|
Update of /cvsroot/wpdev/wolfpack/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22266/python Modified Files: pycoord.cpp Log Message: Fix for los Index: pycoord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/pycoord.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** pycoord.cpp 15 Sep 2004 01:25:46 -0000 1.22 --- pycoord.cpp 15 Sep 2004 15:05:51 -0000 1.23 *************** *** 177,182 **** return 0; if ( self->coord.lineOfSight( pos, targetheight, touch ) ) ! return Py_True; ! return Py_False; } --- 177,182 ---- return 0; if ( self->coord.lineOfSight( pos, targetheight, touch ) ) ! Py_RETURN_TRUE; ! Py_RETURN_FALSE; } *************** *** 210,216 **** if ( lineOfSightNew( self->coord, pos ) ) ! return Py_True; ! ! return Py_False; } --- 210,218 ---- if ( lineOfSightNew( self->coord, pos ) ) ! { ! Py_RETURN_TRUE; ! } else { ! Py_RETURN_FALSE; ! } } |
From: Sebastian H. <dar...@us...> - 2004-09-15 02:26:43
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23673 Modified Files: coord.cpp Log Message: newlos Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** coord.cpp 15 Sep 2004 02:15:28 -0000 1.56 --- coord.cpp 15 Sep 2004 02:26:33 -0000 1.57 *************** *** 338,341 **** --- 338,343 ---- QValueList<Coord_cl> pointList = getPointList(origin, target); + bool result = true; + QValueList<Coord_cl>::const_iterator it; for (it = pointList.begin(); it != pointList.end(); ++it) { *************** *** 347,350 **** --- 349,353 ---- // Play an effect for the tile if (blocked) { + result = false; point.effect(0x181D, 10, 50, 0x21); } else { *************** *** 353,357 **** } ! return true; } --- 356,360 ---- } ! return result; } |
From: Sebastian H. <dar...@us...> - 2004-09-15 02:15:37
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21810 Modified Files: coord.cpp multi.cpp sectors.cpp sectors.h Log Message: newlos Index: multi.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/multi.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** multi.cpp 15 Aug 2004 02:17:39 -0000 1.14 --- multi.cpp 15 Sep 2004 02:15:28 -0000 1.15 *************** *** 163,167 **** // Multi Range = BUILDRANGE ! cItemSectorIterator* iter = SectorMaps::instance()->findItems( pos, BUILDRANGE ); for ( cItem*item = iter->first(); item; item = iter->next() ) --- 163,167 ---- // Multi Range = BUILDRANGE ! cItemSectorIterator* iter = SectorMaps::instance()->findMultis( pos, BUILDRANGE ); for ( cItem*item = iter->first(); item; item = iter->next() ) Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** coord.cpp 15 Sep 2004 01:25:45 -0000 1.55 --- coord.cpp 15 Sep 2004 02:15:28 -0000 1.56 *************** *** 34,37 **** --- 34,38 ---- #include "muls/multiscache.h" #include "muls/maps.h" + #include "multi.h" #include "muls/tilecache.h" *************** *** 199,207 **** } ! if (!found) { return true; } } for (; !statics.atEnd(); ++statics) { const staticrecord &item = *statics; --- 200,211 ---- } ! delete items; ! ! if (!found) { return true; } } + // Find blocking statics for (; !statics.atEnd(); ++statics) { const staticrecord &item = *statics; *************** *** 216,220 **** if (item.zoff <= pos.z && item.zoff + height >= pos.z) { ! // Either a window or noshoot tile if (tile.flag2 & 0x30) { // This will not block if it's "within" our target. --- 220,224 ---- if (item.zoff <= pos.z && item.zoff + height >= pos.z) { ! // Window and noshoot tiles block if (tile.flag2 & 0x30) { // This will not block if it's "within" our target. *************** *** 226,229 **** --- 230,308 ---- } + // Search for items at the given location + cItemSectorIterator *items = SectorMaps::instance()->findItems(pos, 0); + + for (P_ITEM item = items->first(); item; item = items->next()) { + // If the item is invisible or a multi, skip past it. + if (item->visible() != 0 || item->isMulti()) { + continue; + } + + tile_st tile = TileCache::instance()->getTile(item->id()); + + // Window and noshoot tiles block + if (tile.flag2 & 0x30) { + // Calculate the correct height + int height = tile.height; + if (tile.flag2 & 0x04) { + height /= 2; + } + + // See if the item intersects our current position + if (pos.z >= item->pos().z && pos.z <= item->pos().z + height) { + // This will not block if it's "within" our target. + if (pos.x != target.x || pos.y != target.y || item->pos().z > target.z || item->pos().z + height < target.z) { + delete items; + return true; + } + } + } + } + + delete items; + + // Check for multis around the area + cItemSectorIterator *multis = SectorMaps::instance()->findMultis(pos, BUILDRANGE); + + // Check if there is an intersecting item for this multi + for (P_MULTI multi = (P_MULTI)multis->first(); multi; multi = (P_MULTI)multis->next()) { + // Get all items for this multi + MultiDefinition *data = MultiCache::instance()->getMulti(multi->id() - 0x4000); + if (data) { + QValueVector<multiItem_st> items = data->getEntries(); + QValueVector<multiItem_st>::iterator it; + + for (it = items.begin(); it != items.end(); ++it) { + multiItem_st item = *it; + int itemz = item.z + multi->pos().z; + + if (multi->pos().x + item.x != pos.x || multi->pos().y + item.y != pos.y) { + continue; + } + + tile_st tile = TileCache::instance()->getTile(item.tile); + + // Calculate the correct height + int height = tile.height; + if (tile.flag2 & 0x04) { + height /= 2; + } + + // Has to be visible and blocking + if (item.visible && tile.flag2 & 0x30) { + if (pos.z >= itemz && pos.z <= itemz + height) { + // This will not block if it's "within" our target. + if (pos.x != target.x || pos.y != target.y || itemz > target.z || itemz + height < target.z) { + delete multis; + return true; + } + } + } + } + } + } + + delete multis; + return false; } Index: sectors.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/sectors.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** sectors.h 7 Sep 2004 03:21:47 -0000 1.12 --- sectors.h 15 Sep 2004 02:15:28 -0000 1.13 *************** *** 132,136 **** MT_CHARS, MT_CHARSANDOFFLINE, ! MT_ITEMS }; --- 132,137 ---- MT_CHARS, MT_CHARSANDOFFLINE, ! MT_ITEMS, ! MT_MULTIS }; *************** *** 157,160 **** --- 158,164 ---- cItemSectorIterator* findItems( unsigned char map, uint x1, uint y1, uint x2, uint y2 ); cItemSectorIterator* findItems( const Coord_cl& center, unsigned char distance ); + + cItemSectorIterator* findMultis( const Coord_cl& center, unsigned char distance ); + cItemSectorIterator* findMultis( unsigned char map, uint x1, uint y1, uint x2, uint y2 ); cCharSectorIterator* findChars( unsigned char map, uint x, uint y, bool includeoffline = false ); // Find items in a specific block Index: sectors.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/sectors.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** sectors.cpp 7 Sep 2004 03:21:46 -0000 1.30 --- sectors.cpp 15 Sep 2004 02:15:28 -0000 1.31 *************** *** 499,502 **** --- 499,507 ---- items[offset++] = object; } + } else if (type == MT_MULTIS) { + P_ITEM item = dynamic_cast<P_ITEM>(object); + if (item && item->isMulti()) { + items[offset++] = object; + } } else { items[offset++] = object; *************** *** 517,520 **** --- 522,526 ---- { case MT_ITEMS: + case MT_MULTIS: return new cItemSectorIterator( offset, items ); *************** *** 543,546 **** --- 549,553 ---- { case MT_ITEMS: + case MT_MULTIS: return new cItemSectorIterator( count, items ); *************** *** 560,563 **** --- 567,575 ---- } + cItemSectorIterator* cSectorMaps::findMultis( const Coord_cl& center, unsigned char distance ) + { + return findMultis( center.map, QMAX( ( int ) center.x - ( int ) distance, 0 ), QMAX( ( int ) center.y - ( int ) distance, 0 ), ( int ) center.x + distance, ( int ) center.y + distance ); + } + cCharSectorIterator* cSectorMaps::findChars( const Coord_cl& center, unsigned char distance, bool includeoffline ) { *************** *** 608,611 **** --- 620,636 ---- } + cItemSectorIterator* cSectorMaps::findMultis( unsigned char map, uint x1, uint y1, uint x2, uint y2 ) + { + std::map<unsigned char, cSectorMap*>::const_iterator it = itemmaps.find( map ); + + if ( it == itemmaps.end() ) + { + Console::instance()->log( LOG_ERROR, QString( "Couldn't find a map with the id %1. (cSectorMaps::findMultis)" ).arg( map ) ); + return new cItemSectorIterator( 0, 0 ); // Return an empty iterator + } + + return static_cast<cItemSectorIterator*>( findObjects( MT_MULTIS, it->second, x1, y1, x2, y2 ) ); + } + cCharSectorIterator* cSectorMaps::findChars( unsigned char map, uint x1, uint y1, uint x2, uint y2, bool includeoffline ) { |
From: Sebastian H. <dar...@us...> - 2004-09-15 01:26:02
|
Update of /cvsroot/wpdev/xmlscripts/scripts/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12961/commands Modified Files: __init__.py Log Message: los Index: __init__.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/commands/__init__.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** __init__.py 14 Sep 2004 23:03:09 -0000 1.17 --- __init__.py 15 Sep 2004 01:25:53 -0000 1.18 *************** *** 189,196 **** if target.item: ! targpos = target.item.pos elif target.char: ! targpos = target.item.char ! targpos.z += 10 srcpos = char.pos --- 189,195 ---- if target.item: ! targpos = target.item elif target.char: ! targpos = target.char srcpos = char.pos |
From: Sebastian H. <dar...@us...> - 2004-09-15 01:25:56
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12938 Modified Files: coord.cpp Log Message: Line of Sight work! Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** coord.cpp 14 Sep 2004 23:03:06 -0000 1.54 --- coord.cpp 15 Sep 2004 01:25:45 -0000 1.55 *************** *** 51,55 **** } ! Coord_cl getItemLosCoord(P_ITEM pItem, bool eye) { Coord_cl pos = pItem->getOutmostPos(); tile_st tile = TileCache::instance()->getTile(pItem->id()); --- 51,55 ---- } ! Coord_cl getItemLosCoord(P_ITEM pItem) { Coord_cl pos = pItem->getOutmostPos(); tile_st tile = TileCache::instance()->getTile(pItem->id()); *************** *** 118,125 **** } return pointList; } ! bool lineOfSightNew(const Coord_cl &origin, const Coord_cl &target) { // If the target is out of range, save cpu time by not calculating the // line of sight --- 118,249 ---- } + // Add the target to the end of the pointlist if it's not already + // there + if (pointList.count() != 0 && pointList.last() != target) { + pointList.append(target); + } + return pointList; } ! void getAverageZ(const Coord_cl &pos, int &z, int &average, int &top) { ! int elevations[4]; ! Coord_cl tempPos = pos; ! ! // Get the elevation of the tile itself ! elevations[0] = Maps::instance()->seekMap(tempPos).z; ! ! // Get the elevation of the tile on the lower left ! tempPos = pos; ! tempPos.y += 1; ! elevations[1] = Maps::instance()->seekMap(tempPos).z; ! ! // Get the elevation of the tile on the lower right ! tempPos = pos; ! tempPos.x += 1; ! elevations[2] = Maps::instance()->seekMap(tempPos).z; ! ! // Get the elevation of the tile below ! tempPos = pos; ! tempPos.x += 1; ! tempPos.y += 1; ! elevations[3] = Maps::instance()->seekMap(tempPos).z; ! ! // Get the smallest of the z values ! z = QMIN( QMIN( QMIN(elevations[0], elevations[1]), elevations[2]), elevations[3]); ! ! // Get the highest of the z values ! top = QMAX( QMAX( QMAX(elevations[0], elevations[1]), elevations[2]), elevations[3]); ! ! // Whatever difference is smaller leads to the average elevation of the tile ! if (abs(elevations[0] - elevations[3]) > abs(elevations[1] - elevations[2])) { ! average = (int)floor((elevations[1] + elevations[2]) / 2.0); ! } else { ! average = (int)floor((elevations[0] + elevations[3]) / 2.0); ! } ! } ! ! // Check for blocking tiles at the given position ! inline bool checkBlockingTiles(const Coord_cl &pos, const Coord_cl &target) { ! // Check Map first ! map_st maptile = Maps::instance()->seekMap(pos); ! int mapBottom, mapTop, mapAverage; ! getAverageZ(pos, mapBottom, mapAverage, mapTop); ! ! // Ignore certain types of maptiles (Thanks to Krrios for help) ! if (maptile.id != 2 && maptile.id != 0x1DB && (maptile.id < 0x1AE || maptile.id > 0x1B5)) { ! // See if we intersect the maptile ! if (pos.z >= mapBottom && pos.z <= mapTop) { ! // The maptile won't block if it's our target. ! if (pos.x != target.x || pos.y != target.y || mapBottom > target.z || mapTop < target.z) { ! return true; ! } ! } ! } ! ! // Search for statics at that position ! StaticsIterator statics = Maps::instance()->staticsIterator(pos, true); ! ! // There is a special behaviour for 0x244 maptiles if there ! // is no static item or dynamic item in the area. ! if (maptile.id == 0x244 && statics.atEnd()) { ! // If there are *any* items at that position, skip the special behaviour. ! cItemSectorIterator *items = SectorMaps::instance()->findItems(pos, 0); ! ! bool found = false; ! for (P_ITEM item = items->first(); item; item = items->next()) { ! if (item->visible() == 0) { ! found = true; ! break; ! } ! } ! ! if (!found) { ! return true; ! } ! } ! ! for (; !statics.atEnd(); ++statics) { ! const staticrecord &item = *statics; ! ! tile_st tile = TileCache::instance()->getTile(item.itemid); ! int height = tile.height; ! ! // Bridges are half as high as normal tiles ! if (tile.flag2 & 0x04) { ! height /= 2; ! } ! ! if (item.zoff <= pos.z && item.zoff + height >= pos.z) { ! // Either a window or noshoot tile ! if (tile.flag2 & 0x30) { ! // This will not block if it's "within" our target. ! if (pos.x != target.x || pos.y != target.y || item.zoff > target.z || item.zoff + height < target.z) { ! return true; ! } ! } ! } ! } ! ! return false; ! } ! ! // Make sure that the points are aligned from top to bottom ! inline void normalizeCoords(Coord_cl &a, Coord_cl &b) { ! if (a.x > b.x) { ! std::swap(a.x, b.x); ! } ! ! if (a.y > b.y) { ! std::swap(a.y, b.y); ! } ! ! if (a.z > b.z) { ! std::swap(a.z, b.z); ! } ! } ! ! // Check the line of sight from a source to a target coordinate. ! bool lineOfSightNew(Coord_cl origin, Coord_cl target) { // If the target is out of range, save cpu time by not calculating the // line of sight *************** *** 139,147 **** Coord_cl point = *it; // Play an effect for the tile ! point.effect(0x181D, 10, 20); } ! return false; } --- 263,278 ---- Coord_cl point = *it; + // Check if there are blocking map, static or dynamic items. + bool blocked = checkBlockingTiles(point, target); + // Play an effect for the tile ! if (blocked) { ! point.effect(0x181D, 10, 50, 0x21); ! } else { ! point.effect(0x181D, 10, 50, 0x44); ! } } ! return true; } |
From: Sebastian H. <dar...@us...> - 2004-09-15 01:25:56
|
Update of /cvsroot/wpdev/wolfpack/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12938/python Modified Files: pycoord.cpp Log Message: Line of Sight work! Index: pycoord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/pycoord.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** pycoord.cpp 14 Sep 2004 23:03:17 -0000 1.21 --- pycoord.cpp 15 Sep 2004 01:25:46 -0000 1.22 *************** *** 29,32 **** --- 29,34 ---- #include "../coord.h" #include "../walking.h" + #include "../items.h" + #include "../basechar.h" /* *************** *** 179,189 **** } ! extern bool lineOfSightNew(const Coord_cl &origin, const Coord_cl &target); static PyObject* wpCoord_lineofsightnew( wpCoord* self, PyObject* args ) { ! Coord_cl pos; ! if ( !PyArg_ParseTuple( args, "O&:coord.lineofsight(coord)", &PyConvertCoord, &pos ) ) return 0; if ( lineOfSightNew( self->coord, pos ) ) --- 181,211 ---- } ! extern bool lineOfSightNew(Coord_cl origin, Coord_cl target); ! extern void getAverageZ(const Coord_cl &pos, int &z, int &average, int &top); ! extern Coord_cl getItemLosCoord(P_ITEM pItem); ! extern Coord_cl getCharLosCoord(P_CHAR pChar, bool eye); static PyObject* wpCoord_lineofsightnew( wpCoord* self, PyObject* args ) { ! PyObject *object; ! if ( !PyArg_ParseTuple( args, "O:coord.lineofsight(obj)", &object ) ) return 0; + + Coord_cl pos; + + if (checkWpCoord(object)) { + pos = getWpCoord(object); + + // Get the average elevation + int bottom, average, top; + getAverageZ(pos, bottom, average, top); + + // Use the top + pos.z = top; + } else if ( checkWpItem(object) ) { + pos = getItemLosCoord(getWpItem(object)); + } else if ( checkWpChar(object) ) { + pos = getCharLosCoord(getWpChar(object), false); + } if ( lineOfSightNew( self->coord, pos ) ) |
From: Sebastian H. <dar...@us...> - 2004-09-14 23:03:26
|
Update of /cvsroot/wpdev/wolfpack/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19211/python Modified Files: pycoord.cpp Log Message: los Index: pycoord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/pycoord.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** pycoord.cpp 3 Sep 2004 16:55:17 -0000 1.20 --- pycoord.cpp 14 Sep 2004 23:03:17 -0000 1.21 *************** *** 179,182 **** --- 179,196 ---- } + extern bool lineOfSightNew(const Coord_cl &origin, const Coord_cl &target); + + static PyObject* wpCoord_lineofsightnew( wpCoord* self, PyObject* args ) + { + Coord_cl pos; + if ( !PyArg_ParseTuple( args, "O&:coord.lineofsight(coord)", &PyConvertCoord, &pos ) ) + return 0; + + if ( lineOfSightNew( self->coord, pos ) ) + return Py_True; + + return Py_False; + } + static PyMethodDef wpCoordMethods[] = { *************** *** 185,188 **** --- 199,203 ---- { "validspawnspot", ( getattrofunc ) wpCoord_validspawnspot, METH_VARARGS, NULL }, { "lineofsight", ( getattrofunc ) wpCoord_lineofsight, METH_VARARGS, NULL }, + { "lineofsightnew", ( getattrofunc ) wpCoord_lineofsightnew, METH_VARARGS, NULL }, { 0, 0, 0, 0 } }; |
From: Sebastian H. <dar...@us...> - 2004-09-14 23:03:26
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19211 Modified Files: coord.cpp items.cpp items.h Log Message: los Index: items.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/items.h,v retrieving revision 1.215 retrieving revision 1.216 diff -C2 -d -r1.215 -r1.216 *** items.h 27 Aug 2004 14:41:16 -0000 1.215 --- items.h 14 Sep 2004 23:03:16 -0000 1.216 *************** *** 428,431 **** --- 428,432 ---- P_ITEM getOutmostItem(); P_CHAR getOutmostChar(); + Coord_cl getOutmostPos(); void createTooltip( cUOTxTooltipList& tooltip, cPlayer* player ); Index: items.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/items.cpp,v retrieving revision 1.447 retrieving revision 1.448 diff -C2 -d -r1.447 -r1.448 *** items.cpp 14 Sep 2004 00:00:37 -0000 1.447 --- items.cpp 14 Sep 2004 23:03:06 -0000 1.448 *************** *** 2329,2330 **** --- 2329,2343 ---- return cUObject::hasScript(name); } + + Coord_cl cItem::getOutmostPos() { + if (container_) { + if (container_->isChar()) { + return container_->pos(); + } + P_ITEM container = dynamic_cast<P_ITEM>(container_); + if (container) { + return container->getOutmostPos(); + } + } + return pos_; + } Index: coord.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** coord.cpp 19 Aug 2004 01:55:55 -0000 1.53 --- coord.cpp 14 Sep 2004 23:03:06 -0000 1.54 *************** *** 44,47 **** --- 44,149 ---- #include <set> + // New Line Of Sight Code + Coord_cl getCharLosCoord(P_CHAR pChar, bool eye) { + Coord_cl result = pChar->pos(); + result.z += eye ? 15 : 10; + return result; + } + + Coord_cl getItemLosCoord(P_ITEM pItem, bool eye) { + Coord_cl pos = pItem->getOutmostPos(); + tile_st tile = TileCache::instance()->getTile(pItem->id()); + pos.z += tile.height / 2 + 1; + return pos; + } + + bool isBetween(double n, int lower, int higher, double tolerance = 0.5) { + // Swap the bounds if they are out of order + if (lower > higher) { + std::swap(lower, higher); + } + + return (n > lower - tolerance) && (n < higher + tolerance); + } + + double round(double n) { + double f = n - floor(n); + if (f >= 0.50) { + return ceil(n); + } else { + return floor(n); + } + } + + inline QValueList<Coord_cl> getPointList(const Coord_cl &origin, const Coord_cl &target) { + // Create a list of coordinates we are going to "touch" when looking + // from point a to point b + QValueList<Coord_cl> pointList; + + int xDiff = target.x - origin.x; // i1 + int yDiff = target.y - origin.y; // j1 + int zDiff = target.z - origin.z; // k1 + + // Calculate the length of the X,Y diagonal + double xyDiagonal = sqrt( (double)( xDiff * xDiff + yDiff * yDiff ) ); // d3 + + // Calculate the length of the second diagonal + double zDiagonal; // d4 + if (zDiff != 0) { + zDiagonal = sqrt( xyDiagonal * xyDiagonal + (double)( zDiff * zDiff ) ); + } else { + zDiagonal = zDiff; + } + + // Calculate the "increases" + double d1 = yDiff / zDiagonal; + double d2 = xDiff / zDiagonal; + xyDiagonal = zDiff / zDiagonal; + + double d6 = origin.y; // CurrentY ? + double d7 = origin.z; // CurrentZ ? + double d5 = origin.x; // CurrentX ? + + while (isBetween(d5, target.x, origin.x) && isBetween(d6, target.y, origin.y) && isBetween(d7, target.z, origin.z)) { + Coord_cl pos((int)round(d5), (int)round(d6), (int)round(d7), origin.map); + + if (pointList.count() == 0 || pointList.last() != pos) { + pointList.append(pos); + } + + // Jump to the next set of coordinates. + d7 += xyDiagonal; + d5 += d2; + d6 += d1; + } + + return pointList; + } + + bool lineOfSightNew(const Coord_cl &origin, const Coord_cl &target) { + // If the target is out of range, save cpu time by not calculating the + // line of sight + if (origin.map != target.map || origin.distance(target) > 25) { + return false; + } + + // LoS always succeeds for the same points + if (origin == target) { + return true; + } + + QValueList<Coord_cl> pointList = getPointList(origin, target); + + QValueList<Coord_cl>::const_iterator it; + for (it = pointList.begin(); it != pointList.end(); ++it) { + Coord_cl point = *it; + + // Play an effect for the tile + point.effect(0x181D, 10, 20); + } + + return false; + } + Coord_cl Coord_cl::null( 0xFFFF, 0xFFFF, 0xFF, 0xFF ); |