2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2011-12-27 13:05:19 +01:00
|
|
|
// Copyright (C) 2000-2011 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-01-26 16:38:23 +00:00
|
|
|
|
2006-10-26 00:48:00 +00:00
|
|
|
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp,
rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h,
rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h,
rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h,
rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
#include "Py_Vector3D.h"
|
2006-05-02 22:45:58 +00:00
|
|
|
|
2006-04-19 22:46:00 +00:00
|
|
|
#include "Py_Quaternion.h"
|
2009-05-27 14:10:26 +01:00
|
|
|
#include "Py_Message.h"
|
2000-11-20 20:28:08 +00:00
|
|
|
|
2009-08-22 04:32:48 +01:00
|
|
|
#include <Atlas/Message/Element.h>
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * Vector3D_dot(PyVector3D * self, PyVector3D * other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2000-12-16 20:28:06 +00:00
|
|
|
if (!PyVector3D_Check(other)) {
|
2000-12-06 18:21:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Can only dot with Vector3D");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-07-18 00:43:53 +00:00
|
|
|
return PyFloat_FromDouble(Dot(self->coords, other->coords));
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * Vector3D_cross(PyVector3D * self, PyVector3D * other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2000-12-16 20:28:06 +00:00
|
|
|
if (!PyVector3D_Check(other)) {
|
2000-12-06 18:21:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Can only cross with Vector3D");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * ret = newPyVector3D();
|
2009-07-04 14:16:41 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
|
ret->coords = Cross(self->coords, other->coords);
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
|
|
|
|
return (PyObject *)ret;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * Vector3D_rotatex(PyVector3D * self, PyObject * arg)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2006-01-22 02:13:52 +00:00
|
|
|
if (!PyFloat_CheckExact(arg)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Can only rotatex with a float");
|
2009-11-13 02:39:19 +00:00
|
|
|
return NULL;
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
2006-01-22 02:13:52 +00:00
|
|
|
double angle = PyFloat_AsDouble(arg);
|
2003-07-18 00:43:53 +00:00
|
|
|
self->coords.rotateX(angle);
|
2000-12-06 18:21:35 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * Vector3D_rotatey(PyVector3D * self, PyObject * arg)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2006-01-22 02:13:52 +00:00
|
|
|
if (!PyFloat_CheckExact(arg)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Can only rotatey with a float");
|
2009-11-13 02:39:19 +00:00
|
|
|
return NULL;
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
2006-01-22 02:13:52 +00:00
|
|
|
double angle = PyFloat_AsDouble(arg);
|
2003-07-18 00:43:53 +00:00
|
|
|
self->coords.rotateY(angle);
|
2000-12-06 18:21:35 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * Vector3D_rotatez(PyVector3D * self, PyObject * arg)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2006-01-22 02:13:52 +00:00
|
|
|
if (!PyFloat_CheckExact(arg)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Can only rotatez with a float");
|
2009-11-13 02:39:19 +00:00
|
|
|
return NULL;
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
2006-01-22 02:13:52 +00:00
|
|
|
double angle = PyFloat_AsDouble(arg);
|
2003-07-18 00:43:53 +00:00
|
|
|
self->coords.rotateZ(angle);
|
2000-12-06 18:21:35 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-19 22:46:00 +00:00
|
|
|
static PyObject * Vector3D_rotate(PyVector3D * self, PyQuaternion * arg)
|
|
|
|
|
{
|
|
|
|
|
if (!PyQuaternion_Check(arg)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Can only rotate with a quaternion");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
self->coords.rotate(arg->rotation);
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * Vector3D_angle(PyVector3D * self, PyVector3D * other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2000-12-16 20:28:06 +00:00
|
|
|
if (!PyVector3D_Check(other)) {
|
2000-12-06 18:21:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Can get angle to Vector3D");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-07-18 00:43:53 +00:00
|
|
|
return PyFloat_FromDouble(Angle(self->coords, other->coords));
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
|
|
|
|
|
2004-10-24 01:38:59 +00:00
|
|
|
static PyObject * Vector3D_sqr_mag(PyVector3D * self)
|
|
|
|
|
{
|
|
|
|
|
return PyFloat_FromDouble(self->coords.sqrMag());
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-23 17:19:26 +00:00
|
|
|
static PyObject * Vector3D_mag(PyVector3D * self)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
|
|
|
|
return PyFloat_FromDouble(self->coords.mag());
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-24 01:38:59 +00:00
|
|
|
static PyObject * Vector3D_is_valid(PyVector3D * self)
|
|
|
|
|
{
|
2004-10-24 12:13:39 +00:00
|
|
|
PyObject * ret = self->coords.isValid() ? Py_True : Py_False;
|
|
|
|
|
Py_INCREF(ret);
|
|
|
|
|
return ret;
|
2004-10-24 01:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
2004-06-23 17:19:26 +00:00
|
|
|
static PyObject * Vector3D_unit_vector(PyVector3D * self)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * ret = newPyVector3D();
|
2000-12-06 18:21:35 +00:00
|
|
|
if (ret == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-07-18 00:43:53 +00:00
|
|
|
ret->coords = self->coords;
|
2005-03-31 13:30:33 +00:00
|
|
|
WFMath::CoordType the_mag = ret->coords.mag();
|
|
|
|
|
if (!the_mag > 0) {
|
|
|
|
|
PyErr_SetString(PyExc_ZeroDivisionError, "Attempt to normalize a vector with zero magnitude");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
ret->coords /= the_mag;
|
2000-12-06 18:21:35 +00:00
|
|
|
return (PyObject *)ret;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject *Vector3D_unit_vector_to(PyVector3D * self, PyVector3D * other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2000-12-16 20:28:06 +00:00
|
|
|
if (!PyVector3D_Check(other)) {
|
2005-03-31 13:30:33 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Argument must be a Vector3D");
|
2000-12-06 18:21:35 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * ret = newPyVector3D();
|
2000-12-06 18:21:35 +00:00
|
|
|
if (ret == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-07-18 00:43:53 +00:00
|
|
|
ret->coords = (other->coords - self->coords);
|
2005-03-31 13:30:33 +00:00
|
|
|
WFMath::CoordType the_mag = ret->coords.mag();
|
|
|
|
|
if (!the_mag > 0) {
|
|
|
|
|
PyErr_SetString(PyExc_ZeroDivisionError, "Attempt to normalize a vector with zero magnitude");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
ret->coords /= the_mag;
|
2000-12-06 18:21:35 +00:00
|
|
|
return (PyObject *)ret;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-26 14:41:10 +00:00
|
|
|
static PyMethodDef Vector3D_methods[] = {
|
2006-01-22 02:13:52 +00:00
|
|
|
{"dot", (PyCFunction)Vector3D_dot, METH_O},
|
|
|
|
|
{"cross", (PyCFunction)Vector3D_cross, METH_O},
|
2006-04-19 22:46:00 +00:00
|
|
|
{"rotatex", (PyCFunction)Vector3D_rotatex, METH_O},
|
|
|
|
|
{"rotatey", (PyCFunction)Vector3D_rotatey, METH_O},
|
|
|
|
|
{"rotatez", (PyCFunction)Vector3D_rotatez, METH_O},
|
|
|
|
|
{"rotate", (PyCFunction)Vector3D_rotate, METH_O},
|
2006-01-22 02:13:52 +00:00
|
|
|
{"angle", (PyCFunction)Vector3D_angle, METH_O},
|
2004-10-24 01:38:59 +00:00
|
|
|
{"square_mag", (PyCFunction)Vector3D_sqr_mag, METH_NOARGS},
|
2004-06-23 17:19:26 +00:00
|
|
|
{"mag", (PyCFunction)Vector3D_mag, METH_NOARGS},
|
2004-10-24 01:38:59 +00:00
|
|
|
{"is_valid", (PyCFunction)Vector3D_is_valid, METH_NOARGS},
|
2004-06-23 17:19:26 +00:00
|
|
|
{"unit_vector", (PyCFunction)Vector3D_unit_vector, METH_NOARGS},
|
2006-01-22 02:13:52 +00:00
|
|
|
{"unit_vector_to", (PyCFunction)Vector3D_unit_vector_to, METH_O},
|
2003-08-13 13:46:00 +00:00
|
|
|
{NULL, NULL} /* sentinel */
|
2000-11-20 20:28:08 +00:00
|
|
|
};
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static void Vector3D_dealloc(PyVector3D *self)
|
2000-11-20 20:28:08 +00:00
|
|
|
{
|
2003-08-13 16:26:48 +00:00
|
|
|
self->coords.~Vector3D();
|
2006-05-02 22:45:58 +00:00
|
|
|
self->ob_type->tp_free(self);
|
2000-11-20 20:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
2005-06-18 20:24:58 +00:00
|
|
|
static PyObject* Vector3D_repr(PyVector3D * self)
|
|
|
|
|
{
|
2005-12-05 Al Riddoch <alriddoch@zepler.org>
* rulesets/Py_BBox.cpp, rulesets/Py_Optime.cpp,
rulesets/Py_Statistics.cpp, rulesets/Py_Thing.cpp: Ensure that
setattr returns an exception if the attribute is not a valid one.
* rulesets/Py_Map.cpp, rulesets/Py_Point3D.cpp,
rulesets/Py_Quaternion.cpp, rulesets/Py_World.cpp,
rulesets/Py_WorldTime.cpp: Remove setattr, as no attributes can
be set on this type.
* rulesets/Py_Mind.cpp, rulesets/Py_Oplist.cpp,
rulesets/Py_Vector3D.cpp: Clean up type structure.
* rulesets/basic/mind/goals/common/move.py: Remove attempt
to set "rotation" attribute on location, as its obsolete
and pointless.
2005-12-05 04:01:11 +00:00
|
|
|
char buf[64];
|
|
|
|
|
::snprintf(buf, 64, "(%f, %f, %f)", self->coords.x(), self->coords.y(), self->coords.z());
|
|
|
|
|
return PyString_FromString(buf);
|
2005-06-18 20:24:58 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-27 13:05:19 +01:00
|
|
|
static PyObject * Vector3D_getattro(PyVector3D *self, PyObject *oname)
|
2000-11-20 20:28:08 +00:00
|
|
|
{
|
2011-12-27 13:05:19 +01:00
|
|
|
char * name = PyString_AsString(oname);
|
2003-07-18 00:43:53 +00:00
|
|
|
if (strcmp(name, "x") == 0) { return PyFloat_FromDouble(self->coords.x()); }
|
|
|
|
|
if (strcmp(name, "y") == 0) { return PyFloat_FromDouble(self->coords.y()); }
|
|
|
|
|
if (strcmp(name, "z") == 0) { return PyFloat_FromDouble(self->coords.z()); }
|
2000-12-13 12:10:48 +00:00
|
|
|
|
2011-12-27 13:05:19 +01:00
|
|
|
return PyObject_GenericGetAttr((PyObject *)self, oname);
|
2000-11-20 20:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-27 13:05:19 +01:00
|
|
|
static int Vector3D_setattro(PyVector3D *self, PyObject *oname, PyObject *v)
|
2000-11-20 20:28:08 +00:00
|
|
|
{
|
2011-12-27 13:05:19 +01:00
|
|
|
char * name = PyString_AsString(oname);
|
2004-12-19 01:46:23 +00:00
|
|
|
float val;
|
|
|
|
|
if (PyInt_Check(v)) {
|
|
|
|
|
val = PyInt_AsLong(v);
|
|
|
|
|
} else if (PyFloat_Check(v)) {
|
|
|
|
|
val = PyFloat_AsDouble(v);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D attributes must be numeric");
|
2004-12-23 13:42:49 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(name, "x") == 0) {
|
|
|
|
|
self->coords.x() = val;
|
|
|
|
|
} else if (strcmp(name, "y") == 0) {
|
|
|
|
|
self->coords.y() = val;
|
|
|
|
|
} else if (strcmp(name, "z") == 0) {
|
|
|
|
|
self->coords.z() = val;
|
|
|
|
|
} else {
|
2005-01-23 23:01:32 +00:00
|
|
|
PyErr_SetString(PyExc_AttributeError, "Vector3D attribute does not exist");
|
2004-12-23 13:42:49 +00:00
|
|
|
return -1;
|
2004-12-19 01:46:23 +00:00
|
|
|
}
|
2001-04-17 10:14:20 +00:00
|
|
|
return 0;
|
2000-11-20 20:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static int Vector3D_compare(PyVector3D * self, PyVector3D * other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
|
|
|
|
if (self->coords == other->coords) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-30 11:40:08 +01:00
|
|
|
/*
|
|
|
|
|
* Vector3D sequence methods.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#if PY_VERSION_HEX < 0x02050000
|
|
|
|
|
typedef int Py_ssize_t;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static Py_ssize_t Vector3D_seq_length(PyVector3D * self)
|
|
|
|
|
{
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject * Vector3D_seq_item(PyVector3D * self, Py_ssize_t item)
|
|
|
|
|
{
|
|
|
|
|
if (item < 0 || item >= 3) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError,"Vector3D.[]: Index out of range.");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return PyFloat_FromDouble(self->coords[item]);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-30 11:52:33 +01:00
|
|
|
static int Vector3D_seq_ass_item(PyVector3D * self,
|
|
|
|
|
Py_ssize_t item,
|
|
|
|
|
PyObject * val)
|
|
|
|
|
{
|
|
|
|
|
if (item < 0 || item >= 3) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError,"Vector3D.[]: Index out of range.");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (!PyFloat_Check(val)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError,"Vector3D.[]: Value must be float.");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
self->coords[item] = PyFloat_AsDouble(val);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static PyVector3D*Vector3D_num_add(PyVector3D*self,PyVector3D*other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2000-12-16 20:28:06 +00:00
|
|
|
if (!PyVector3D_Check(other)) {
|
2000-12-06 18:21:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Can only add Vector3D to Vector3D");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * ret = newPyVector3D();
|
2009-07-04 14:16:41 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
|
ret->coords = (self->coords + other->coords);
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static PyVector3D*Vector3D_num_sub(PyVector3D*self,PyVector3D*other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2000-12-16 20:28:06 +00:00
|
|
|
if (!PyVector3D_Check(other)) {
|
2000-12-06 18:21:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Can only sub Vector3D from Vector3D");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * ret = newPyVector3D();
|
2009-07-04 14:16:41 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
|
ret->coords = (self->coords - other->coords);
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static PyVector3D * Vector3D_num_mul(PyVector3D * self, PyObject * _other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
|
|
|
|
double other;
|
|
|
|
|
if (PyInt_Check(_other)) {
|
|
|
|
|
other = PyInt_AsLong(_other);
|
|
|
|
|
} else if (PyFloat_Check(_other)) {
|
|
|
|
|
other = PyFloat_AsDouble(_other);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D can only be multiplied by numeric value");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * ret = newPyVector3D();
|
2009-07-04 14:16:41 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
|
ret->coords = (self->coords * other);
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static PyVector3D * Vector3D_num_div(PyVector3D * self, PyObject * _other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
|
|
|
|
double other;
|
|
|
|
|
if (PyInt_Check(_other)) {
|
|
|
|
|
other = PyInt_AsLong(_other);
|
|
|
|
|
} else if (PyFloat_Check(_other)) {
|
|
|
|
|
other = PyFloat_AsDouble(_other);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D can only be divided by numeric value");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * ret = newPyVector3D();
|
2009-07-04 14:16:41 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
|
ret->coords = (self->coords / other);
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-26 14:41:10 +00:00
|
|
|
static int Vector3D_num_coerce(PyObject ** self, PyObject ** other)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
|
|
|
|
Py_INCREF(*self);
|
|
|
|
|
Py_INCREF(*other);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-02 22:45:58 +00:00
|
|
|
static int Vector3D_init(PyVector3D * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
|
|
|
|
PyObject * clist;
|
|
|
|
|
switch (PyTuple_Size(args)) {
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
clist = PyTuple_GetItem(args, 0);
|
2012-01-04 16:59:44 +00:00
|
|
|
if (!PyList_Check(clist)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D() from single value must be a list");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (PyList_Size(clist) != 3) {
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "Vector3D() from a list must be 3 long");
|
2006-05-02 22:45:58 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
for(int i = 0; i < 3; i++) {
|
|
|
|
|
PyObject * item = PyList_GetItem(clist, i);
|
|
|
|
|
if (PyInt_Check(item)) {
|
|
|
|
|
self->coords[i] = (float)PyInt_AsLong(item);
|
|
|
|
|
} else if (PyFloat_Check(item)) {
|
|
|
|
|
self->coords[i] = PyFloat_AsDouble(item);
|
2009-05-27 18:22:56 +01:00
|
|
|
} else if (PyMessage_Check(item)) {
|
|
|
|
|
PyMessage * mitem = (PyMessage*)item;
|
2006-05-02 22:45:58 +00:00
|
|
|
if (!mitem->m_obj->isNum()) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D() must take list of floats, or ints");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
self->coords[i] = mitem->m_obj->asNum();
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D() must take list of floats, or ints");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self->coords.setValid();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
for(int i = 0; i < 3; i++) {
|
|
|
|
|
PyObject * item = PyTuple_GetItem(args, i);
|
|
|
|
|
if (PyInt_Check(item)) {
|
|
|
|
|
self->coords[i] = (float)PyInt_AsLong(item);
|
|
|
|
|
} else if (PyFloat_Check(item)) {
|
|
|
|
|
self->coords[i] = PyFloat_AsDouble(item);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D() must take list of floats, or ints");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self->coords.setValid();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Vector3D must take list of floats, or ints, 3 ints or 3 floats");
|
|
|
|
|
return -1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-06 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/newid.cpp, server/server.cpp:
Modify new ID checks so that code still runs when database is
unavailable, and events requiring new IDs fail cleanly.
* server/Connection.cpp: Report a failure to create a player
account if no ID available.
* rulesets/BaseMind.cpp: When processing appearance ops, handle
stamp more efficiently, report an error if ID is missing
from argument.
* server/IdlePSQLConnector.cpp, server/IdlePSQLConnector.h:
Implement re-connecting to the Database if connection is lost.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Thing.cpp:
Ensure STAMP is present on appearance op args.
* server/CommListener.cpp, server/CommListener.h,
server/CommPeerListener.cpp, server/CommPeerListener.h,
server/CommSlaveListener.cpp, server/CommSlaveListener.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Add a return value to method for creating new client socket
objects, and use it to return failure if no ID is available
from the database for a new object.
* rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp: Add "new" method for class wrappers, and
call the in place constructor from new rather than init. Re-write
internal function for creating new instances so it uses the "new"
method.
* rulesets/Py_Statistics.cpp: Remove some obsolete code inadvertedly
copied from another file. Comment out some unused code to get rid
of a warning.
* server/CommPSQLSocket.cpp: Clear the database connection from
destructor.
* tests/python_class.cpp: A new test for experimenting with new
Python wrappers.
2006-05-06 21:36:57 +00:00
|
|
|
static PyObject * Vector3D_new(PyTypeObject * type, PyObject *, PyObject *)
|
|
|
|
|
{
|
|
|
|
|
// This looks allot like the default implementation, except we call the
|
|
|
|
|
// in-place constructor.
|
|
|
|
|
PyVector3D * self = (PyVector3D *)type->tp_alloc(type, 0);
|
|
|
|
|
if (self != NULL) {
|
|
|
|
|
new (&(self->coords)) Vector3D();
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)self;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-30 11:40:08 +01:00
|
|
|
static PySequenceMethods Vector3D_seq = {
|
2011-08-30 11:52:33 +01:00
|
|
|
(lenfunc)Vector3D_seq_length, /* sq_length */
|
|
|
|
|
NULL, /* sq_concat */
|
|
|
|
|
NULL, /* sq_repeat */
|
|
|
|
|
(ssizeargfunc)Vector3D_seq_item, /* sq_item */
|
|
|
|
|
NULL, /* sq_slice */
|
|
|
|
|
(ssizeobjargproc)Vector3D_seq_ass_item, /* sq_ass_item */
|
|
|
|
|
NULL /* sq_ass_slice */
|
2011-08-30 11:40:08 +01:00
|
|
|
};
|
|
|
|
|
|
2000-12-06 18:21:35 +00:00
|
|
|
static PyNumberMethods Vector3D_num = {
|
2003-08-13 13:46:00 +00:00
|
|
|
(binaryfunc)Vector3D_num_add, /* nb_add */
|
|
|
|
|
(binaryfunc)Vector3D_num_sub, /* nb_subtract */
|
|
|
|
|
(binaryfunc)Vector3D_num_mul, /* nb_multiply */
|
|
|
|
|
(binaryfunc)Vector3D_num_div, /* nb_divide */
|
|
|
|
|
0, /* nb_remainder */
|
|
|
|
|
0, /* nb_divmod */
|
|
|
|
|
0, /* nb_power */
|
|
|
|
|
0, /* nb_negative */
|
|
|
|
|
0, /* nb_positive */
|
|
|
|
|
0, /* nb_absolute */
|
|
|
|
|
0, /* nb_nonzero */
|
|
|
|
|
0, /* nb_invert */
|
|
|
|
|
0, /* nb_lshift */
|
|
|
|
|
0, /* nb_rshift */
|
|
|
|
|
0, /* nb_and */
|
|
|
|
|
0, /* nb_xor */
|
|
|
|
|
0, /* nb_or */
|
|
|
|
|
Vector3D_num_coerce, /* nb_coerce */
|
|
|
|
|
0, /* nb_int */
|
|
|
|
|
0, /* nb_long */
|
|
|
|
|
0, /* nb_float */
|
|
|
|
|
0, /* nb_oct */
|
|
|
|
|
0 /* nb_hex */
|
2000-12-06 18:21:35 +00:00
|
|
|
};
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyTypeObject PyVector3D_Type = {
|
2006-05-02 22:45:58 +00:00
|
|
|
PyObject_HEAD_INIT(0)
|
|
|
|
|
0, // ob_size
|
2009-05-20 19:33:39 +01:00
|
|
|
"physics.Vector3D", // tp_name
|
2006-05-02 22:45:58 +00:00
|
|
|
sizeof(PyVector3D), // tp_basicsize
|
|
|
|
|
0, // tp_itemsize
|
|
|
|
|
// methods
|
|
|
|
|
(destructor)Vector3D_dealloc, // tp_dealloc
|
2009-11-13 02:46:24 +00:00
|
|
|
0, // tp_print
|
2011-12-27 13:05:19 +01:00
|
|
|
0, // tp_getattr
|
|
|
|
|
0, // tp_setattr
|
2006-05-02 22:45:58 +00:00
|
|
|
(cmpfunc)Vector3D_compare, // tp_compare
|
|
|
|
|
(reprfunc)Vector3D_repr, // tp_repr
|
|
|
|
|
&Vector3D_num, // tp_as_number
|
2011-08-30 11:40:08 +01:00
|
|
|
&Vector3D_seq, // tp_as_sequence
|
2006-05-02 22:45:58 +00:00
|
|
|
0, // tp_as_mapping
|
|
|
|
|
0, // tp_hash
|
|
|
|
|
0, // tp_call
|
|
|
|
|
0, // tp_str
|
2011-12-27 13:05:19 +01:00
|
|
|
(getattrofunc)Vector3D_getattro,// tp_getattro
|
|
|
|
|
(setattrofunc)Vector3D_setattro,// tp_setattro
|
2006-05-02 22:45:58 +00:00
|
|
|
0, // tp_as_buffer
|
|
|
|
|
Py_TPFLAGS_DEFAULT, // tp_flags
|
|
|
|
|
"Vector3D objects", // tp_doc
|
|
|
|
|
0, // tp_travers
|
|
|
|
|
0, // tp_clear
|
|
|
|
|
0, // tp_richcompare
|
|
|
|
|
0, // tp_weaklistoffset
|
|
|
|
|
0, // tp_iter
|
|
|
|
|
0, // tp_iternext
|
2011-12-27 13:05:19 +01:00
|
|
|
Vector3D_methods, // tp_methods
|
2006-05-02 22:45:58 +00:00
|
|
|
0, // tp_members
|
|
|
|
|
0, // tp_getset
|
|
|
|
|
0, // tp_base
|
|
|
|
|
0, // tp_dict
|
|
|
|
|
0, // tp_descr_get
|
|
|
|
|
0, // tp_descr_set
|
|
|
|
|
0, // tp_dictoffset
|
|
|
|
|
(initproc)Vector3D_init, // tp_init
|
|
|
|
|
0, // tp_alloc
|
2006-05-06 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/newid.cpp, server/server.cpp:
Modify new ID checks so that code still runs when database is
unavailable, and events requiring new IDs fail cleanly.
* server/Connection.cpp: Report a failure to create a player
account if no ID available.
* rulesets/BaseMind.cpp: When processing appearance ops, handle
stamp more efficiently, report an error if ID is missing
from argument.
* server/IdlePSQLConnector.cpp, server/IdlePSQLConnector.h:
Implement re-connecting to the Database if connection is lost.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Thing.cpp:
Ensure STAMP is present on appearance op args.
* server/CommListener.cpp, server/CommListener.h,
server/CommPeerListener.cpp, server/CommPeerListener.h,
server/CommSlaveListener.cpp, server/CommSlaveListener.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Add a return value to method for creating new client socket
objects, and use it to return failure if no ID is available
from the database for a new object.
* rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp: Add "new" method for class wrappers, and
call the in place constructor from new rather than init. Re-write
internal function for creating new instances so it uses the "new"
method.
* rulesets/Py_Statistics.cpp: Remove some obsolete code inadvertedly
copied from another file. Comment out some unused code to get rid
of a warning.
* server/CommPSQLSocket.cpp: Clear the database connection from
destructor.
* tests/python_class.cpp: A new test for experimenting with new
Python wrappers.
2006-05-06 21:36:57 +00:00
|
|
|
Vector3D_new, // tp_new
|
2000-11-20 20:28:08 +00:00
|
|
|
};
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyVector3D * newPyVector3D()
|
2000-11-20 20:28:08 +00:00
|
|
|
{
|
2006-05-06 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/newid.cpp, server/server.cpp:
Modify new ID checks so that code still runs when database is
unavailable, and events requiring new IDs fail cleanly.
* server/Connection.cpp: Report a failure to create a player
account if no ID available.
* rulesets/BaseMind.cpp: When processing appearance ops, handle
stamp more efficiently, report an error if ID is missing
from argument.
* server/IdlePSQLConnector.cpp, server/IdlePSQLConnector.h:
Implement re-connecting to the Database if connection is lost.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Thing.cpp:
Ensure STAMP is present on appearance op args.
* server/CommListener.cpp, server/CommListener.h,
server/CommPeerListener.cpp, server/CommPeerListener.h,
server/CommSlaveListener.cpp, server/CommSlaveListener.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Add a return value to method for creating new client socket
objects, and use it to return failure if no ID is available
from the database for a new object.
* rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp: Add "new" method for class wrappers, and
call the in place constructor from new rather than init. Re-write
internal function for creating new instances so it uses the "new"
method.
* rulesets/Py_Statistics.cpp: Remove some obsolete code inadvertedly
copied from another file. Comment out some unused code to get rid
of a warning.
* server/CommPSQLSocket.cpp: Clear the database connection from
destructor.
* tests/python_class.cpp: A new test for experimenting with new
Python wrappers.
2006-05-06 21:36:57 +00:00
|
|
|
return (PyVector3D *)PyVector3D_Type.tp_new(&PyVector3D_Type, 0, 0);
|
2000-11-20 20:28:08 +00:00
|
|
|
}
|