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
|
2005-05-14 23:02:02 +00:00
|
|
|
// Copyright (C) 2000-2005 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
|
|
|
|
2008-11-29 Al Riddoch <alriddoch@googlemail.com>
* rulesets/Character.cpp, rulesets/Character.h: Remove all traces
of the hard coded statistics property from Character.
* rulesets/Py_Property.cpp: Don't use Py_StatisticsProperty as the
default wrapper for a statistics property because it will no
longer work this way.
* rulesets/Python_API.cpp: Remove the setup for the Statistics
wrapper.
* rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h:
Change the footprint of this class so it is no longer hooked
into part of the Character class, and instead handles looking
up values from the script directly, and owns the script itself.
* server/ArithmeticFactory.cpp, server/ArithmeticFactory.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/PersistantThingFactory.cpp: Remove setup of hard coded
statistics property.
* rulesets/Statistics.h, rulesets/Statistics.cpp,
rulesets/Py_Statistics.h, rulesets/Py_Statistics.cpp,
rulesets/Makefile.am: Remove clases that are no longer used.
2008-11-29 23:17:38 +00:00
|
|
|
// $Id$
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2004-11-20 10:28:24 +00:00
|
|
|
#include "Python.h"
|
|
|
|
|
|
* 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 "Python_API.h"
|
2005-05-14 23:02:02 +00:00
|
|
|
#include "Python_Script_Utils.h"
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2005-06-22 14:56:14 +00:00
|
|
|
#include "Py_BBox.h"
|
* 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_Object.h"
|
|
|
|
|
#include "Py_Thing.h"
|
|
|
|
|
#include "Py_Mind.h"
|
|
|
|
|
#include "Py_Map.h"
|
|
|
|
|
#include "Py_Location.h"
|
|
|
|
|
#include "Py_Vector3D.h"
|
2004-09-20 Al Riddoch <alriddoch@zepler.org>
* physics/Vector3D.h, physics/Vector3D.cpp, modules/Location.h,
modules/Location.cpp: Convert to using WFMath::Point instead of
WFMath::Vector for position.
* physics/Collision.h, physics/Collision.cpp: Update collision code
to use new pos type.
* rulesets/Py_Point3D.h, rulesets/Py_Point3D.cpp: New python
wrappers for WFMath::Point.
* rulesets/Py_Location.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp:
Update python wrappers to take into account new pos type.
Ensure that only apropriate functionality is available for
point and vector.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Line.cpp, rulesets/Movement.cpp, rulesets/Movement.h,
rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
server/WorldRouter.h: Update the rest of the code for new pos
type, converting all places where entity parenting is changed
to use WFMath toParentCoords() and toLocalCoords() methods,
so that orientation is handled correctly.
* tests/transformtest.cpp: New test to ensure that toParentCoords()
and toLocalCoords() perform as expected.
* tests/Creatortest.cpp, tests/Locationtest.cpp, tests/Worldtest.cpp,
tests/collisiontest.cpp, tests/emergencetest.cpp:
Update the rest of the tests.
2004-09-20 10:16:04 +00:00
|
|
|
#include "Py_Point3D.h"
|
2002-03-03 00:48:28 +00:00
|
|
|
#include "Py_Quaternion.h"
|
* 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_WorldTime.h"
|
|
|
|
|
#include "Py_World.h"
|
|
|
|
|
#include "Py_Operation.h"
|
2005-09-10 23:47:25 +00:00
|
|
|
#include "Py_RootEntity.h"
|
* 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_Oplist.h"
|
2007-07-04 16:42:10 +00:00
|
|
|
#include "Py_Property.h"
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2009-03-22 15:58:06 +00:00
|
|
|
#include "PythonEntityScript.h"
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
#include "World.h"
|
2001-04-10 19:05:14 +00:00
|
|
|
#include "BaseMind.h"
|
2000-11-21 19:24:29 +00:00
|
|
|
|
2009-03-20 15:31:38 +00:00
|
|
|
#include "common/Inheritance.h"
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
#include "common/compose.hpp"
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/globals.h"
|
|
|
|
|
#include "common/const.h"
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
|
#include "common/log.h"
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
#include <Atlas/Objects/Operation.h>
|
2005-09-11 17:48:26 +00:00
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* 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/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
using Atlas::Message::Element;
|
2005-08-27 14:52:12 +00:00
|
|
|
using Atlas::Objects::Root;
|
|
|
|
|
using Atlas::Objects::Operation::RootOperation;
|
2005-09-11 17:48:26 +00:00
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* 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/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
2006-12-22 Al Riddoch <alriddoch@zepler.org>
* server/CommClient.h, server/CommListener.h, server/CommLocalClient.h,
server/CommMDNSPublisher.h, server/CommMaster.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommPeer.h, server/CommPeerListener.h,
server/CommRemoteClient.h, server/CommServer.h,
server/CommSlaveClient.h, server/CommSlaveListener.h,
server/CommSocket.cpp, server/CommSocket.h,
server/CommUnixListener.h: Add a documentation group for socket
classes.
* rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.h, rulesets/Py_Map.h, rulesets/Py_Mind.h,
rulesets/Py_Object.h, rulesets/Py_Operation.h,
rulesets/Py_Oplist.h, rulesets/Py_Optime.h, rulesets/Py_Point3D.h,
rulesets/Py_Property.h, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.h, rulesets/Py_Task.h, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.h, rulesets/Py_World.h, rulesets/Py_WorldTime.h,
rulesets/Python_API.cpp: Add documentation group for Python wrapper
types.
* rulesets/Container.h, rulesets/PythonScript.cpp,
server/ScriptFactory.h, server/ScriptFactory.cpp:
Add more inline documentation comments.
2006-12-22 02:14:44 +00:00
|
|
|
/// \defgroup PythonWrappers Python Wrapper Types
|
|
|
|
|
///
|
|
|
|
|
/// Structure types based on the PyObject header used to wrap C++ objects
|
|
|
|
|
/// in Python.
|
|
|
|
|
|
2004-12-27 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.h, client/CharacterClient.h,
client/ClientConnection.h, client/CreatorClient.h,
client/ObserverClient.h, client/Py_CreatorClient.h,
common/Burn.h, common/Chop.h, common/Cut.h, common/Database.h,
common/Eat.h, common/Generic.h, common/Nourish.h, common/Setup.h,
common/Tick.h, common/Unseen.h, common/Use.h, common/Wield.h,
common/accountbase.h, common/inheritance.h, rulesets/Container.h,
rulesets/Creator.h, rulesets/LineProperty.h, rulesets/MemMap.h,
rulesets/MindFactory.h, rulesets/Movement.h, rulesets/Pedestrian.h,
rulesets/Py_BBox.h, rulesets/Py_Location.h, rulesets/Py_Map.h,
rulesets/Py_Mind.h, rulesets/Py_Object.h, rulesets/Py_Operation.h,
rulesets/Py_Oplist.h, rulesets/Py_Optime.h, rulesets/Py_Point3D.h,
rulesets/Py_Quaternion.h, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.h, rulesets/Py_World.h, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/TerrainProperty.h, rulesets/ThingFactory.h, server/Admin.h,
server/EntityFactory.h, server/Master.h, server/Peer.h,
server/Persistance.h, server/PersistantThingFactory.h,
server/Persistor.h, server/Player.h, server/Restoration.h,
server/Restorer.h, server/TrustedConnection.h: Make sure all
classes have up updated description in the comments.
2004-12-27 03:06:54 +00:00
|
|
|
/// \brief Python wrapper for C++ functions to be exposed to Python
|
* 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
|
|
|
typedef struct {
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
} FunctionObject;
|
|
|
|
|
|
2000-11-29 18:02:01 +00:00
|
|
|
static void Function_dealloc(FunctionObject * self)
|
|
|
|
|
{
|
2007-01-12 Al Riddoch <alriddoch@zepler.org>
* rulesets/Py_BBox.cpp, rulesets/Py_Location.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Oplist.cpp,
rulesets/Py_Optime.cpp, rulesets/Py_Quaternion.cpp,
rulesets/Py_RootEntity.cpp, rulesets/Py_Task.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_World.cpp,
rulesets/Python_API.cpp: Replace calls to PyMem_DEL with calls
to PyObject_Free. Thanks to Kai for doing most of the digging
on this one.
2007-01-12 12:38:05 +00:00
|
|
|
PyObject_Free(self);
|
2000-11-29 18:02:01 +00:00
|
|
|
}
|
|
|
|
|
|
2000-12-01 00:13:39 +00:00
|
|
|
static PyObject * log_debug(PyObject * self, PyObject * args, PyObject * kwds)
|
2000-11-29 18:02:01 +00:00
|
|
|
{
|
2006-10-20 15:09:59 +00:00
|
|
|
if (consts::debug_level != 0) {
|
|
|
|
|
int level;
|
|
|
|
|
char *message;
|
|
|
|
|
PyObject * op;
|
2006-10-20 14:26:19 +00:00
|
|
|
|
2006-10-20 15:09:59 +00:00
|
|
|
if (!PyArg_ParseTuple(args, "is|O", &level, &message, &op)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2006-10-20 14:26:19 +00:00
|
|
|
|
2006-10-20 15:09:59 +00:00
|
|
|
if (consts::debug_level >= level) {
|
|
|
|
|
log(SCRIPT, message);
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-10-20 14:26:19 +00:00
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject * log_think(PyObject * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2006-10-20 15:09:59 +00:00
|
|
|
if (consts::debug_thinking != 0) {
|
|
|
|
|
char *message;
|
2006-10-20 14:26:19 +00:00
|
|
|
|
2006-10-20 15:09:59 +00:00
|
|
|
if (!PyArg_ParseTuple(args, "s", &message)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2006-10-20 14:26:19 +00:00
|
|
|
|
2006-10-20 15:09:59 +00:00
|
|
|
log(SCRIPT, message);
|
|
|
|
|
}
|
2006-10-20 14:26:19 +00:00
|
|
|
|
2000-11-29 18:02:01 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyTypeObject log_debug_type = {
|
2003-07-18 23:05:26 +00:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0,
|
|
|
|
|
"Function",
|
|
|
|
|
sizeof(FunctionObject),
|
|
|
|
|
0,
|
|
|
|
|
/* methods */
|
|
|
|
|
(destructor)Function_dealloc,
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
0, /* tp_getattr */
|
|
|
|
|
0, /* tp_setattr */
|
|
|
|
|
0, /* tp_compare */
|
|
|
|
|
0, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
|
0, /* tp_hash */
|
|
|
|
|
log_debug, /* tp_call */
|
2000-11-29 18:02:01 +00:00
|
|
|
};
|
2000-11-19 00:02:29 +00:00
|
|
|
|
2006-10-20 14:26:19 +00:00
|
|
|
PyTypeObject log_think_type = {
|
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0,
|
|
|
|
|
"Function",
|
|
|
|
|
sizeof(FunctionObject),
|
|
|
|
|
0,
|
|
|
|
|
/* methods */
|
|
|
|
|
(destructor)Function_dealloc,
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
0, /* tp_getattr */
|
|
|
|
|
0, /* tp_setattr */
|
|
|
|
|
0, /* tp_compare */
|
|
|
|
|
0, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
|
0, /* tp_hash */
|
|
|
|
|
log_think, /* tp_call */
|
|
|
|
|
};
|
|
|
|
|
|
2003-08-30 11:41:58 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Logger replaces sys.stdout and sys.stderr so the nothing goes to output
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2004-12-27 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.h, client/CharacterClient.h,
client/ClientConnection.h, client/CreatorClient.h,
client/ObserverClient.h, client/Py_CreatorClient.h,
common/Burn.h, common/Chop.h, common/Cut.h, common/Database.h,
common/Eat.h, common/Generic.h, common/Nourish.h, common/Setup.h,
common/Tick.h, common/Unseen.h, common/Use.h, common/Wield.h,
common/accountbase.h, common/inheritance.h, rulesets/Container.h,
rulesets/Creator.h, rulesets/LineProperty.h, rulesets/MemMap.h,
rulesets/MindFactory.h, rulesets/Movement.h, rulesets/Pedestrian.h,
rulesets/Py_BBox.h, rulesets/Py_Location.h, rulesets/Py_Map.h,
rulesets/Py_Mind.h, rulesets/Py_Object.h, rulesets/Py_Operation.h,
rulesets/Py_Oplist.h, rulesets/Py_Optime.h, rulesets/Py_Point3D.h,
rulesets/Py_Quaternion.h, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.h, rulesets/Py_World.h, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/TerrainProperty.h, rulesets/ThingFactory.h, server/Admin.h,
server/EntityFactory.h, server/Master.h, server/Peer.h,
server/Persistance.h, server/PersistantThingFactory.h,
server/Persistor.h, server/Player.h, server/Restoration.h,
server/Restorer.h, server/TrustedConnection.h: Make sure all
classes have up updated description in the comments.
2004-12-27 03:06:54 +00:00
|
|
|
/// \brief Python struct to handle output from python scripts
|
|
|
|
|
///
|
|
|
|
|
/// In instance of this struct is used to replace sys.stdout and sys.stderr
|
|
|
|
|
/// in the Python interpreter so that all script output goes to the cyphesis
|
|
|
|
|
/// log subsystem
|
2003-08-30 11:41:58 +00:00
|
|
|
typedef struct {
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
} PyLogger;
|
|
|
|
|
|
2004-10-04 23:08:26 +00:00
|
|
|
static void python_log(LogLevel lvl, const char * msg)
|
|
|
|
|
{
|
2005-12-26 18:49:14 +00:00
|
|
|
static std::string message;
|
|
|
|
|
|
|
|
|
|
message += msg;
|
2004-10-04 23:08:26 +00:00
|
|
|
std::string::size_type n = 0;
|
|
|
|
|
std::string::size_type p;
|
|
|
|
|
for (p = message.find_first_of('\n');
|
|
|
|
|
p != std::string::npos;
|
|
|
|
|
p = message.find_first_of('\n', n)) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(lvl, message.substr(n, p - n));
|
2004-10-04 23:08:26 +00:00
|
|
|
n = p + 1;
|
|
|
|
|
}
|
|
|
|
|
if (message.size() > n) {
|
2005-12-26 18:49:14 +00:00
|
|
|
message = message.substr(n, message.size() - n);
|
|
|
|
|
} else {
|
|
|
|
|
message.clear();
|
2004-10-04 23:08:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * PyOutLogger_write(PyObject * self, PyObject * arg)
|
2003-08-30 11:41:58 +00:00
|
|
|
{
|
2006-01-22 02:13:52 +00:00
|
|
|
if (!PyString_CheckExact(arg)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "write must be a string");
|
2003-08-30 11:41:58 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
2006-01-22 02:13:52 +00:00
|
|
|
char * mesg = PyString_AsString(arg);
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2004-10-04 23:08:26 +00:00
|
|
|
python_log(SCRIPT, mesg);
|
2003-08-30 11:41:58 +00:00
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * PyErrLogger_write(PyObject * self, PyObject * arg)
|
2003-08-30 11:41:58 +00:00
|
|
|
{
|
2006-01-22 02:13:52 +00:00
|
|
|
if (!PyString_CheckExact(arg)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "write must be a string");
|
2003-08-30 11:41:58 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
2006-01-22 02:13:52 +00:00
|
|
|
char * mesg = PyString_AsString(arg);
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2004-10-04 23:08:26 +00:00
|
|
|
python_log(SCRIPT_ERROR, mesg);
|
2003-08-30 11:41:58 +00:00
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-29 21:32:53 +00:00
|
|
|
static PyMethodDef PyOutLogger_methods[] = {
|
2006-01-22 02:13:52 +00:00
|
|
|
{"write", PyOutLogger_write, METH_O},
|
2004-11-29 21:32:53 +00:00
|
|
|
{NULL, NULL} /* Sentinel */
|
2003-08-30 11:41:58 +00:00
|
|
|
};
|
|
|
|
|
|
2004-11-29 21:32:53 +00:00
|
|
|
static PyMethodDef PyErrLogger_methods[] = {
|
2006-01-22 02:13:52 +00:00
|
|
|
{"write", PyErrLogger_write, METH_O},
|
2004-11-29 21:32:53 +00:00
|
|
|
{NULL, NULL} /* Sentinel */
|
2003-08-30 11:41:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void PyLogger_dealloc(PyObject * self)
|
|
|
|
|
{
|
2007-01-12 Al Riddoch <alriddoch@zepler.org>
* rulesets/Py_BBox.cpp, rulesets/Py_Location.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Oplist.cpp,
rulesets/Py_Optime.cpp, rulesets/Py_Quaternion.cpp,
rulesets/Py_RootEntity.cpp, rulesets/Py_Task.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_World.cpp,
rulesets/Python_API.cpp: Replace calls to PyMem_DEL with calls
to PyObject_Free. Thanks to Kai for doing most of the digging
on this one.
2007-01-12 12:38:05 +00:00
|
|
|
PyObject_Free(self);
|
2003-08-30 11:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-29 21:32:53 +00:00
|
|
|
static PyObject * PyOutLogger_getattr(PyObject * self, char *name)
|
2003-08-30 11:41:58 +00:00
|
|
|
{
|
2004-11-29 21:32:53 +00:00
|
|
|
return Py_FindMethod(PyOutLogger_methods, self, name);
|
2003-08-30 11:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-29 21:32:53 +00:00
|
|
|
static PyObject * PyErrLogger_getattr(PyObject * self, char *name)
|
2003-08-30 11:41:58 +00:00
|
|
|
{
|
2004-11-29 21:32:53 +00:00
|
|
|
return Py_FindMethod(PyErrLogger_methods, self, name);
|
2003-08-30 11:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-29 21:32:53 +00:00
|
|
|
PyTypeObject PyOutLogger_Type = {
|
2003-08-30 11:41:58 +00:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, // ob_size
|
2004-11-29 21:32:53 +00:00
|
|
|
"OutLogger", // tp_name
|
2003-08-30 11:41:58 +00:00
|
|
|
sizeof(PyLogger), // tp_basicsize
|
|
|
|
|
0, // tp_itemsize
|
|
|
|
|
// methods
|
|
|
|
|
PyLogger_dealloc, // tp_dealloc
|
|
|
|
|
0, // tp_print
|
2004-11-29 21:32:53 +00:00
|
|
|
PyOutLogger_getattr, // tp_getattr
|
2003-08-30 11:41:58 +00:00
|
|
|
0, // tp_setattr
|
|
|
|
|
0, // tp_compare
|
|
|
|
|
0, // tp_repr
|
|
|
|
|
0, // tp_as_number
|
|
|
|
|
0, // tp_as_sequence
|
|
|
|
|
0, // tp_as_mapping
|
|
|
|
|
0, // tp_hash
|
|
|
|
|
};
|
|
|
|
|
|
2004-11-29 21:32:53 +00:00
|
|
|
PyTypeObject PyErrLogger_Type = {
|
2003-08-30 11:41:58 +00:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, // ob_size
|
2004-11-29 21:32:53 +00:00
|
|
|
"ErrLogger", // tp_name
|
2003-08-30 11:41:58 +00:00
|
|
|
sizeof(PyLogger), // tp_basicsize
|
|
|
|
|
0, // tp_itemsize
|
|
|
|
|
// methods
|
|
|
|
|
PyLogger_dealloc, // tp_dealloc
|
|
|
|
|
0, // tp_print
|
2004-11-29 21:32:53 +00:00
|
|
|
PyErrLogger_getattr, // tp_getattr
|
2003-08-30 11:41:58 +00:00
|
|
|
0, // tp_setattr
|
|
|
|
|
0, // tp_compare
|
|
|
|
|
0, // tp_repr
|
|
|
|
|
0, // tp_as_number
|
|
|
|
|
0, // tp_as_sequence
|
|
|
|
|
0, // tp_as_mapping
|
|
|
|
|
0, // tp_hash
|
|
|
|
|
};
|
|
|
|
|
|
2001-08-02 14:27:06 +00:00
|
|
|
static PyObject * Get_PyClass(const std::string & package,
|
2005-05-14 20:46:48 +00:00
|
|
|
const std::string & type)
|
2000-11-19 00:02:29 +00:00
|
|
|
{
|
2005-05-14 20:46:48 +00:00
|
|
|
std::string classname(type);
|
|
|
|
|
classname[0] = toupper(classname[0]);
|
2000-12-13 12:10:48 +00:00
|
|
|
PyObject * package_name = PyString_FromString((char *)package.c_str());
|
2005-05-14 20:46:48 +00:00
|
|
|
PyObject * module = PyImport_Import(package_name);
|
2001-06-22 22:03:59 +00:00
|
|
|
Py_DECREF(package_name);
|
2005-05-14 20:46:48 +00:00
|
|
|
if (module == NULL) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Missing python module \"%1\"", package));
|
2001-08-14 17:52:50 +00:00
|
|
|
PyErr_Print();
|
2001-04-10 19:05:14 +00:00
|
|
|
return NULL;
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
2007-07-29 21:23:40 +00:00
|
|
|
PyObject * py_class = PyObject_GetAttrString(module, (char *)classname.c_str());
|
2005-05-14 20:46:48 +00:00
|
|
|
Py_DECREF(module);
|
2007-07-29 21:23:40 +00:00
|
|
|
if (py_class == NULL) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Could not find python class \"%1.%2\"",
|
|
|
|
|
package, classname));
|
2000-12-11 13:06:12 +00:00
|
|
|
PyErr_Print();
|
2001-04-10 19:05:14 +00:00
|
|
|
return NULL;
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
2007-07-29 21:23:40 +00:00
|
|
|
if (PyCallable_Check(py_class) == 0) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Could not instance python class \"%1.%2\"",
|
|
|
|
|
package, classname));
|
2007-07-29 21:23:40 +00:00
|
|
|
Py_DECREF(py_class);
|
2001-04-10 19:05:14 +00:00
|
|
|
return NULL;
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
2003-11-22 15:30:30 +00:00
|
|
|
#if 0
|
2006-01-06 21:39:00 +00:00
|
|
|
// In later versions of python using PyType_* will become the right thing
|
|
|
|
|
// to do. This might become true when things have been done right with
|
|
|
|
|
// installing types.
|
2007-07-29 21:23:40 +00:00
|
|
|
if (PyType_Check(py_class) == 0) {
|
2003-08-30 11:41:58 +00:00
|
|
|
std::cerr << "PyCallable_Check returned true, but PyType_Check returned false " << package << "." << type << std::endl << std::flush;
|
|
|
|
|
} else {
|
|
|
|
|
std::cerr << "PyType_Check returned true" << std::endl << std::flush;
|
|
|
|
|
}
|
2003-11-22 15:30:30 +00:00
|
|
|
#endif
|
2007-07-29 21:23:40 +00:00
|
|
|
return py_class;
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-29 21:23:40 +00:00
|
|
|
PyObject * Create_PyScript(PyObject * wrapper, PyObject * py_class)
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
{
|
2007-07-29 21:23:40 +00:00
|
|
|
PyObject * pyob = PyEval_CallFunction(py_class,"(O)", wrapper);
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
|
|
|
|
|
if (pyob == NULL) {
|
2000-11-19 00:02:29 +00:00
|
|
|
if (PyErr_Occurred() == NULL) {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, "Could not create python instance");
|
2000-11-19 00:02:29 +00:00
|
|
|
} else {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, "Reporting python error");
|
2000-11-19 00:02:29 +00:00
|
|
|
PyErr_Print();
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-12-11 20:33:43 +00:00
|
|
|
Py_DECREF(wrapper);
|
2001-04-10 19:05:14 +00:00
|
|
|
return pyob;
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-02 14:27:06 +00:00
|
|
|
void Create_PyMind(BaseMind * mind, const std::string & package,
|
2005-05-13 23:25:32 +00:00
|
|
|
const std::string & type)
|
2001-04-10 19:05:14 +00:00
|
|
|
{
|
2007-07-29 21:23:40 +00:00
|
|
|
PyObject * py_class = Get_PyClass(package, type);
|
|
|
|
|
if (py_class == NULL) { return; }
|
2005-12-11 20:33:43 +00:00
|
|
|
PyMind * wrapper = newPyMind();
|
|
|
|
|
wrapper->m_mind = mind;
|
2007-07-29 21:23:40 +00:00
|
|
|
PyObject * o = Create_PyScript((PyObject *)wrapper, py_class);
|
|
|
|
|
Py_DECREF(py_class);
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
|
2001-04-10 19:05:14 +00:00
|
|
|
if (o != NULL) {
|
2007-11-24 16:54:09 +00:00
|
|
|
mind->setScript(new PythonEntityScript(o, (PyObject *)wrapper));
|
2001-04-10 19:05:14 +00:00
|
|
|
}
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-22 02:13:52 +00:00
|
|
|
static PyObject * is_location(PyObject * self, PyObject * loc)
|
2000-12-04 20:08:21 +00:00
|
|
|
{
|
2000-12-16 20:28:06 +00:00
|
|
|
if (PyLocation_Check(loc)) {
|
2000-12-04 20:08:21 +00:00
|
|
|
Py_INCREF(Py_True);
|
|
|
|
|
return Py_True;
|
|
|
|
|
}
|
|
|
|
|
Py_INCREF(Py_False);
|
|
|
|
|
return Py_False;
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-20 20:28:08 +00:00
|
|
|
static PyObject * location_new(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
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
|
|
|
PyLocation *o;
|
2000-12-05 14:26:04 +00:00
|
|
|
// We need to deal with actual args here
|
2004-06-29 12:19:02 +00:00
|
|
|
PyObject * refO = NULL, * coordsO = NULL;
|
2007-12-02 Al Riddoch <alriddoch@zepler.org>
* client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseWorld.h, common/types.h,
modules/Location.cpp, modules/Location.h,
rulesets/AtlasProperties.cpp, rulesets/AtlasProperties.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/LocatedEntity.cpp,
rulesets/LocatedEntity.h, rulesets/MemEntity.cpp,
rulesets/MemEntity.h, rulesets/MemMap.cpp, rulesets/Motion.cpp,
rulesets/Motion.h, rulesets/Py_Location.h, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Script.cpp, rulesets/Script.h,
rulesets/Thing.cpp, rulesets/World.cpp, server/WorldRouter.cpp,
server/WorldRouter.h: Refactor all the entity code so there is now
a new base class for entities in the world simulation, and in the
mind which only contains things which are trully common to both.
This moves a lot of functionality which should not have been
present in mind entities away, and makes that code safer and more
efficient.
* tests/TestWorld.h: Update the test world API to match the base
class.
2007-12-02 23:49:05 +00:00
|
|
|
LocatedEntity * ref_ent = NULL;
|
2001-10-09 14:03:12 +00:00
|
|
|
bool decrefO = false;
|
2004-06-29 12:19:02 +00:00
|
|
|
if (!PyArg_ParseTuple(args, "|OO", &refO, &coordsO)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (refO != NULL) {
|
2007-07-30 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, common/Database.cpp,
common/accountbase.cpp, common/system.cpp, rulesets/Character.cpp,
rulesets/Motion.cpp, rulesets/Plant.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Mind.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Point3D.cpp, rulesets/Py_Statistics.cpp,
rulesets/Py_Task.cpp, rulesets/Py_TerrainProperty.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Py_WorldTime.cpp, rulesets/Python_API.cpp,
rulesets/TerrainProperty.cpp, server/Admin.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cyctrl.cpp:
Remove unnecessary () from conditional expressions, where operator
binding is clear.
2007-07-30 18:12:50 +00:00
|
|
|
if (!PyEntity_Check(refO) && !PyWorld_Check(refO) && !PyMind_Check(refO)) {
|
2001-02-19 06:13:31 +00:00
|
|
|
if (PyObject_HasAttrString(refO, "cppthing")) {
|
|
|
|
|
refO = PyObject_GetAttrString(refO, "cppthing");
|
2001-10-09 14:03:12 +00:00
|
|
|
decrefO = true;
|
2000-12-07 12:14:35 +00:00
|
|
|
}
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
if (!PyEntity_Check(refO) && !PyMind_Check(refO)) {
|
2001-02-19 06:13:31 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Arg ref required");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2000-12-07 12:14:35 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-07-30 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, common/Database.cpp,
common/accountbase.cpp, common/system.cpp, rulesets/Character.cpp,
rulesets/Motion.cpp, rulesets/Plant.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Mind.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Point3D.cpp, rulesets/Py_Statistics.cpp,
rulesets/Py_Task.cpp, rulesets/Py_TerrainProperty.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Py_WorldTime.cpp, rulesets/Python_API.cpp,
rulesets/TerrainProperty.cpp, server/Admin.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cyctrl.cpp:
Remove unnecessary () from conditional expressions, where operator
binding is clear.
2007-07-30 18:12:50 +00:00
|
|
|
if (coordsO != NULL && !PyPoint3D_Check(coordsO)) {
|
2000-12-07 12:14:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Arg coords required");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2000-12-05 14:26:04 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2004-06-29 12:19:02 +00:00
|
|
|
|
2001-02-19 06:13:31 +00:00
|
|
|
if (PyWorld_Check(refO)) {
|
2008-01-05 00:05:29 +00:00
|
|
|
ref_ent = &BaseWorld::instance().m_gameWorld;
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
} else if (PyMind_Check(refO)) {
|
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
|
|
|
PyMind * ref = (PyMind*)refO;
|
|
|
|
|
#ifndef NDEBUG
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
if (ref->m_mind == 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
|
|
|
PyErr_SetString(PyExc_AssertionError, "Parent mind is invalid");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +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
|
|
|
#endif // NDEBUG
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
ref_ent = ref->m_mind;
|
2000-12-13 12:10:48 +00:00
|
|
|
} else {
|
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
|
|
|
PyEntity * ref = (PyEntity*)refO;
|
|
|
|
|
#ifndef NDEBUG
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
if (ref->m_entity == 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
|
|
|
PyErr_SetString(PyExc_AssertionError, "Parent thing is invalid");
|
2001-10-09 14:03:12 +00:00
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2000-12-13 12:10:48 +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
|
|
|
#endif // NDEBUG
|
2003-05-05 Al Riddoch <alriddoch@zepler.org>
* server/EntityFactory.cpp, rulesets/Python_API.h,
rulesets/Python_API.cpp, rulesets/PythonThingScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonMindScript.cpp,
rulesets/Py_World.cpp, rulesets/Py_Thing.h, rulesets/Py_Thing.cpp,
rulesets/Py_Operation.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Location.cpp, rulesets/Movement.h,
rulesets/MemMap_methods.h, rulesets/MemMap.h, rulesets/MemMap.cpp,
rulesets/Entity.cpp, rulesets/BaseMind.cpp,
client/Py_CreatorClient.cpp:
Rename all references from thing to entity, as thing is
no longer the base class for IG entities.
* rulesets/World.h, rulesets/World.cpp, rulesets/Thing.h,
rulesets/Structure.h, rulesets/Stackable.h, rulesets/Stackable.cpp,
rulesets/Plant.h, rulesets/Plant.cpp, rulesets/Missile.h,
rulesets/Line.h, rulesets/Line.cpp, rulesets/Food.h,
rulesets/Food.cpp, rulesets/Creator.h, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp:
Add a typedef for the parent class of all entity classes.
* rulesets/Plant.h, rulesets/Plant.cpp:
Add in code to fully integrate hardcoded attributes.
2003-05-05 21:57:50 +00:00
|
|
|
ref_ent = ref->m_entity;
|
2000-12-05 14:26:04 +00:00
|
|
|
}
|
2004-06-29 12:19:02 +00:00
|
|
|
}
|
|
|
|
|
if (decrefO) { Py_DECREF(refO); }
|
2004-09-20 Al Riddoch <alriddoch@zepler.org>
* physics/Vector3D.h, physics/Vector3D.cpp, modules/Location.h,
modules/Location.cpp: Convert to using WFMath::Point instead of
WFMath::Vector for position.
* physics/Collision.h, physics/Collision.cpp: Update collision code
to use new pos type.
* rulesets/Py_Point3D.h, rulesets/Py_Point3D.cpp: New python
wrappers for WFMath::Point.
* rulesets/Py_Location.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp:
Update python wrappers to take into account new pos type.
Ensure that only apropriate functionality is available for
point and vector.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Line.cpp, rulesets/Movement.cpp, rulesets/Movement.h,
rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
server/WorldRouter.h: Update the rest of the code for new pos
type, converting all places where entity parenting is changed
to use WFMath toParentCoords() and toLocalCoords() methods,
so that orientation is handled correctly.
* tests/transformtest.cpp: New test to ensure that toParentCoords()
and toLocalCoords() perform as expected.
* tests/Creatortest.cpp, tests/Locationtest.cpp, tests/Worldtest.cpp,
tests/collisiontest.cpp, tests/emergencetest.cpp:
Update the rest of the tests.
2004-09-20 10:16:04 +00:00
|
|
|
PyPoint3D * coords = (PyPoint3D*)coordsO;
|
2004-06-29 12:19:02 +00:00
|
|
|
o = newPyLocation();
|
|
|
|
|
if ( o == NULL ) {
|
2000-12-05 14:26:04 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2004-06-29 12:19:02 +00:00
|
|
|
if (coords == NULL) {
|
|
|
|
|
o->location = new Location(ref_ent);
|
|
|
|
|
} else {
|
|
|
|
|
o->location = new Location(ref_ent, coords->coords);
|
|
|
|
|
}
|
2000-12-05 14:26:04 +00:00
|
|
|
return (PyObject *)o;
|
2000-11-20 20:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-29 21:32:53 +00:00
|
|
|
static PyObject * distance_to(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
|
|
|
|
PyObject * near, * other;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OO", &near, &other)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!PyLocation_Check(near) || !PyLocation_Check(other)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Arg Location required");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyLocation * sloc = (PyLocation *)near,
|
|
|
|
|
* oloc = (PyLocation *)other;
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (sloc->location == NULL || oloc == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "Null location pointer");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
PyVector3D * ret = newPyVector3D();
|
|
|
|
|
if (ret == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
ret->coords = distanceTo(*sloc->location, *oloc->location);
|
|
|
|
|
return (PyObject *)ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject * square_distance(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
|
|
|
|
PyObject * near, * other;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OO", &near, &other)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!PyLocation_Check(near) || !PyLocation_Check(other)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Arg Location required");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyLocation * sloc = (PyLocation *)near,
|
|
|
|
|
* oloc = (PyLocation *)other;
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (sloc->location == NULL || oloc == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "Null location pointer");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
return PyFloat_FromDouble(squareDistance(*sloc->location, *oloc->location));
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-23 12:46:28 +00:00
|
|
|
static PyObject * square_horizontal_distance(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
|
|
|
|
PyObject * near, * other;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OO", &near, &other)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!PyLocation_Check(near) || !PyLocation_Check(other)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Arg Location required");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyLocation * sloc = (PyLocation *)near,
|
|
|
|
|
* oloc = (PyLocation *)other;
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (sloc->location == NULL || oloc == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "Null location pointer");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
return PyFloat_FromDouble(squareHorizontalDistance(*sloc->location, *oloc->location));
|
|
|
|
|
}
|
|
|
|
|
|
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 inline void addToOplist(PyOperation * op, PyOplist * o)
|
2000-12-07 12:14:35 +00:00
|
|
|
{
|
|
|
|
|
if (op != NULL) {
|
2000-12-16 20:28:06 +00:00
|
|
|
if (PyOperation_Check(op)) {
|
|
|
|
|
o->ops->push_back(op->operation);
|
|
|
|
|
} else if ((PyObject*)op != Py_None) {
|
2000-12-07 12:14:35 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Argument must be an op");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-11-29 15:19:36 +00:00
|
|
|
static PyObject * oplist_new(PyObject * self, PyObject * args)
|
|
|
|
|
{
|
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
|
|
|
PyOplist *o;
|
2003-07-18 23:05:26 +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
|
|
|
PyOperation *op1 = NULL, *op2 = NULL, *op3 = NULL, *op4 = NULL;
|
2003-07-18 23:05:26 +00:00
|
|
|
if (!PyArg_ParseTuple(args, "|OOOO", &op1, &op2, &op3, &op4)) {
|
|
|
|
|
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
|
|
|
o = newPyOplist();
|
2003-07-18 23:05:26 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
o->ops = new OpVector();
|
2000-12-07 12:14:35 +00:00
|
|
|
addToOplist(op1, o);
|
|
|
|
|
addToOplist(op2, o);
|
|
|
|
|
addToOplist(op3, o);
|
|
|
|
|
addToOplist(op4, o);
|
2003-07-18 23:05:26 +00:00
|
|
|
return (PyObject *)o;
|
2000-11-29 15:19:36 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-15 15:38:29 +00:00
|
|
|
static int PySequence_asVector(PyObject * o, std::vector<double> & ret)
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
PyObject * item;
|
|
|
|
|
if (PyList_Check(o)) {
|
|
|
|
|
len = PyList_Size(o);
|
|
|
|
|
ret.resize(len);
|
|
|
|
|
for(int i = 0; i < len; i++) {
|
|
|
|
|
item = PyList_GetItem(o, i);
|
|
|
|
|
if (PyFloat_Check(item)) {
|
|
|
|
|
ret[i] = PyFloat_AsDouble(item);
|
|
|
|
|
} else if (PyInt_Check(item)) {
|
|
|
|
|
ret[i] = PyInt_AsLong(item);
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (PyTuple_Check(o)) {
|
|
|
|
|
len = PyTuple_Size(o);
|
|
|
|
|
ret.resize(len);
|
|
|
|
|
for(int i = 0; i < len; i++) {
|
|
|
|
|
item = PyTuple_GetItem(o, i);
|
|
|
|
|
if (PyFloat_Check(item)) {
|
|
|
|
|
ret[i] = PyFloat_AsDouble(item);
|
|
|
|
|
} else if (PyInt_Check(item)) {
|
|
|
|
|
ret[i] = PyInt_AsLong(item);
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-12-01 00:13:39 +00:00
|
|
|
static PyObject * entity_new(PyObject * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2000-12-30 23:16:57 +00:00
|
|
|
char * id = NULL;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "|s", &id)) {
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
return NULL;
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
2005-09-11 17:48:26 +00:00
|
|
|
Anonymous ent;
|
2000-12-30 23:16:57 +00:00
|
|
|
if (id != NULL) {
|
2005-09-11 17:48:26 +00:00
|
|
|
ent->setId(id);
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
2007-07-30 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, common/Database.cpp,
common/accountbase.cpp, common/system.cpp, rulesets/Character.cpp,
rulesets/Motion.cpp, rulesets/Plant.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Mind.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Point3D.cpp, rulesets/Py_Statistics.cpp,
rulesets/Py_Task.cpp, rulesets/Py_TerrainProperty.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Py_WorldTime.cpp, rulesets/Python_API.cpp,
rulesets/TerrainProperty.cpp, server/Admin.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cyctrl.cpp:
Remove unnecessary () from conditional expressions, where operator
binding is clear.
2007-07-30 18:12:50 +00:00
|
|
|
if (kwds != NULL && PyDict_Check(kwds)) {
|
2000-12-06 18:21:35 +00:00
|
|
|
PyObject * keys = PyDict_Keys(kwds);
|
|
|
|
|
PyObject * vals = PyDict_Values(kwds);
|
2007-07-30 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, common/Database.cpp,
common/accountbase.cpp, common/system.cpp, rulesets/Character.cpp,
rulesets/Motion.cpp, rulesets/Plant.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Mind.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Point3D.cpp, rulesets/Py_Statistics.cpp,
rulesets/Py_Task.cpp, rulesets/Py_TerrainProperty.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Py_WorldTime.cpp, rulesets/Python_API.cpp,
rulesets/TerrainProperty.cpp, server/Admin.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cyctrl.cpp:
Remove unnecessary () from conditional expressions, where operator
binding is clear.
2007-07-30 18:12:50 +00:00
|
|
|
if (keys == NULL || vals == 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
|
|
|
PyErr_SetString(PyExc_RuntimeError, "Error in keywords");
|
2000-12-01 00:13:39 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
int i, size = PyList_Size(keys);
|
2000-12-01 00:13:39 +00:00
|
|
|
for(i = 0; i < size; i++) {
|
|
|
|
|
char * key = PyString_AsString(PyList_GetItem(keys, i));
|
|
|
|
|
PyObject * val = PyList_GetItem(vals, i);
|
2006-08-15 15:38:29 +00:00
|
|
|
if (strcmp(key, "location") == 0) {
|
|
|
|
|
if (!PyLocation_Check(val)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "location must be a Location object");
|
|
|
|
|
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
|
|
|
PyLocation * loc = (PyLocation*)val;
|
2005-09-11 17:48:26 +00:00
|
|
|
loc->location->addToEntity(ent);
|
2006-08-29 23:54:08 +00:00
|
|
|
} else if (strcmp(key, "pos") == 0) {
|
2006-08-15 15:38:29 +00:00
|
|
|
std::vector<double> vector_val;
|
|
|
|
|
if (PySequence_asVector(val, vector_val) != 0) {
|
2006-08-29 23:54:08 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "pos must be a number sequence.");
|
2006-08-15 15:38:29 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
ent->setPos(vector_val);
|
|
|
|
|
} else if (strcmp(key, "parent") == 0) {
|
|
|
|
|
if (!PyString_Check(val)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "parent must be a string.");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-09-11 17:48:26 +00:00
|
|
|
ent->setLoc(PyString_AsString(val));
|
2006-08-15 15:38:29 +00:00
|
|
|
} else if (strcmp(key, "type") == 0) {
|
|
|
|
|
if (!PyString_Check(val)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "type must be a string.");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-09-11 17:48:26 +00:00
|
|
|
ent->setParents(std::list<std::string>(1, PyString_AsString(val)));
|
|
|
|
|
ent->setObjtype("obj");
|
2000-12-01 00:13:39 +00:00
|
|
|
} else {
|
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
|
|
|
Element val_obj = PyObject_asMessageElement(val);
|
2003-08-07 23:03:26 +00:00
|
|
|
if (val_obj.getType() == Element::TYPE_NONE) {
|
2000-12-11 13:06:12 +00:00
|
|
|
Py_DECREF(keys);
|
|
|
|
|
Py_DECREF(vals);
|
2004-10-02 15:36:34 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Arg has no type.");
|
2000-12-01 00:13:39 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-09-11 17:48:26 +00:00
|
|
|
ent->setAttr(key, val_obj);
|
2000-12-01 00:13:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2000-12-11 13:06:12 +00:00
|
|
|
Py_DECREF(keys);
|
|
|
|
|
Py_DECREF(vals);
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-11 17:48:26 +00:00
|
|
|
PyRootEntity * o = newPyRootEntity();
|
2000-12-30 23:16:57 +00:00
|
|
|
if ( o == NULL ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-09-11 17:48:26 +00:00
|
|
|
o->entity = ent;
|
2000-12-30 23:16:57 +00:00
|
|
|
return (PyObject *)o;
|
2000-12-01 00:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-14 21:42:50 +00:00
|
|
|
static int addToArgs(std::vector<Root> & args, PyObject * arg)
|
2000-12-03 23:17:52 +00:00
|
|
|
{
|
2005-09-10 23:47:25 +00:00
|
|
|
if (PyMessageElement_Check(arg)) {
|
|
|
|
|
PyMessageElement * obj = (PyMessageElement*)arg;
|
2006-08-14 21:42:50 +00:00
|
|
|
#ifndef NDEBUG
|
2000-12-03 23:17:52 +00:00
|
|
|
if (obj->m_obj == NULL) {
|
2006-08-14 21:42:50 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError,"NULL MessageElement in Operation constructor argument");
|
|
|
|
|
return -1;
|
2000-12-03 23:17:52 +00:00
|
|
|
}
|
2006-08-14 21:42:50 +00:00
|
|
|
#endif // NDEBUG
|
2005-09-11 17:04:32 +00:00
|
|
|
const Element & o = *obj->m_obj;
|
2005-08-28 15:01:25 +00:00
|
|
|
if (o.isMap()) {
|
2005-08-27 14:52:12 +00:00
|
|
|
args.push_back(Atlas::Objects::Factories::instance()->createObject(o.asMap()));
|
|
|
|
|
} else {
|
2006-08-14 21:42:50 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Operation arg is not a map");
|
|
|
|
|
return -1;
|
2001-05-20 19:02:41 +00:00
|
|
|
}
|
2005-09-10 23:47:25 +00:00
|
|
|
} else if (PyOperation_Check(arg)) {
|
|
|
|
|
PyOperation * op = (PyOperation*)arg;
|
2006-08-14 21:42:50 +00:00
|
|
|
#ifndef NDEBUG
|
2005-08-27 14:52:12 +00:00
|
|
|
if (!op->operation.isValid()) {
|
2006-08-14 21:42:50 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError,"Invalid operation in Operation constructor argument");
|
|
|
|
|
return -1;
|
2000-12-14 12:03:05 +00:00
|
|
|
}
|
2006-08-14 21:42:50 +00:00
|
|
|
#endif // NDEBUG
|
2005-08-27 14:52:12 +00:00
|
|
|
args.push_back(op->operation);
|
2005-09-10 23:47:25 +00:00
|
|
|
} else if (PyRootEntity_Check(arg)) {
|
|
|
|
|
PyRootEntity * ent = (PyRootEntity*)arg;
|
2006-08-14 21:42:50 +00:00
|
|
|
#ifndef NDEBUG
|
2005-09-10 23:47:25 +00:00
|
|
|
if (!ent->entity.isValid()) {
|
2006-08-14 21:42:50 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError,"Invalid rootentity in Operation constructor argument");
|
|
|
|
|
return -1;
|
2005-09-10 23:47:25 +00:00
|
|
|
}
|
2006-08-14 21:42:50 +00:00
|
|
|
#endif // NDEBUG
|
2005-09-10 23:47:25 +00:00
|
|
|
args.push_back(ent->entity);
|
2000-12-03 23:17:52 +00:00
|
|
|
} else {
|
2006-08-14 21:42:50 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Operation arg is of unknown type");
|
|
|
|
|
return -1;
|
2000-12-03 23:17:52 +00:00
|
|
|
}
|
2006-08-14 21:42:50 +00:00
|
|
|
return 0;
|
2000-12-03 23:17:52 +00:00
|
|
|
}
|
|
|
|
|
|
2000-11-21 19:24:29 +00:00
|
|
|
static PyObject * operation_new(PyObject * self, PyObject * args, PyObject * kwds)
|
2000-11-14 15:52:10 +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
|
|
|
PyOperation * op;
|
2000-11-21 19:24:29 +00:00
|
|
|
|
|
|
|
|
char * type;
|
|
|
|
|
PyObject * arg1 = NULL;
|
|
|
|
|
PyObject * arg2 = NULL;
|
|
|
|
|
PyObject * arg3 = NULL;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s|OOO", &type, &arg1, &arg2, &arg3)) {
|
|
|
|
|
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
|
|
|
op = newPyOperation();
|
2000-11-21 19:24:29 +00:00
|
|
|
if (op == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-08-27 14:52:12 +00:00
|
|
|
if (strcmp(type, "thought") == 0 || strcmp(type, "goal_info") == 0) {
|
2000-12-14 12:03:05 +00:00
|
|
|
Py_DECREF(op);
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
2000-11-21 19:24:29 +00:00
|
|
|
} else {
|
2005-08-27 14:52:12 +00:00
|
|
|
Root r = Atlas::Objects::Factories::instance()->createObject(type);
|
|
|
|
|
op->operation = Atlas::Objects::smart_dynamic_cast<RootOperation>(r);
|
|
|
|
|
if (!op->operation.isValid()) {
|
|
|
|
|
Py_DECREF(op);
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Operation() unknown operation type requested");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-11-21 19:24:29 +00:00
|
|
|
}
|
2005-12-24 02:23:31 +00:00
|
|
|
if (kwds != NULL) {
|
2006-01-20 15:03:33 +00:00
|
|
|
PyObject * from = PyDict_GetItemString(kwds, "from_");
|
|
|
|
|
if (from != NULL) {
|
|
|
|
|
PyObject * from_id = 0;
|
|
|
|
|
if (PyString_Check(from)) {
|
|
|
|
|
from_id = from;
|
|
|
|
|
Py_INCREF(from_id);
|
|
|
|
|
} else if ((from_id = PyObject_GetAttrString(from, "id")) == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "from is not a string and has no id");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!PyString_Check(from_id)) {
|
|
|
|
|
Py_DECREF(from_id);
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "id of from is not a string");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
op->operation->setFrom(PyString_AsString(from_id));
|
|
|
|
|
Py_DECREF(from_id);
|
|
|
|
|
}
|
2005-12-24 02:23:31 +00:00
|
|
|
PyObject * to = PyDict_GetItemString(kwds, "to");
|
|
|
|
|
if (to != NULL) {
|
|
|
|
|
PyObject * to_id = 0;
|
|
|
|
|
if (PyString_Check(to)) {
|
|
|
|
|
to_id = to;
|
|
|
|
|
Py_INCREF(to_id);
|
|
|
|
|
} else if ((to_id = PyObject_GetAttrString(to, "id")) == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "to is not a string and has no id");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!PyString_Check(to_id)) {
|
|
|
|
|
Py_DECREF(to_id);
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "id of to is not a string");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
op->operation->setTo(PyString_AsString(to_id));
|
2001-10-09 14:03:12 +00:00
|
|
|
Py_DECREF(to_id);
|
2005-12-23 23:34:19 +00:00
|
|
|
}
|
2000-11-21 19:24:29 +00:00
|
|
|
}
|
2005-08-27 14:52:12 +00:00
|
|
|
std::vector<Root> & args_list = op->operation->modifyArgs();
|
2006-08-14 22:51:42 +00:00
|
|
|
assert(args_list.empty());
|
2006-08-14 21:42:50 +00:00
|
|
|
if (arg1 != 0 && addToArgs(args_list, arg1) != 0) {
|
|
|
|
|
Py_DECREF(op);
|
2006-08-14 22:51:42 +00:00
|
|
|
op = NULL;
|
2006-08-14 21:42:50 +00:00
|
|
|
}
|
|
|
|
|
if (arg2 != 0 && addToArgs(args_list, arg2) != 0) {
|
|
|
|
|
Py_DECREF(op);
|
2006-08-14 22:51:42 +00:00
|
|
|
op = NULL;
|
2006-08-14 21:42:50 +00:00
|
|
|
}
|
|
|
|
|
if (arg3 != 0 && addToArgs(args_list, arg3) != 0) {
|
|
|
|
|
Py_DECREF(op);
|
2006-08-14 22:51:42 +00:00
|
|
|
op = NULL;
|
2006-08-14 21:42:50 +00:00
|
|
|
}
|
2000-11-21 19:24:29 +00:00
|
|
|
return (PyObject *)op;
|
2000-11-14 15:52:10 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-05 16:52:52 +00:00
|
|
|
// In Python 2.3 or later this it is okay to pass in null for the methods
|
|
|
|
|
// of a module, making this obsolete.
|
|
|
|
|
static PyMethodDef no_methods[] = {
|
|
|
|
|
{NULL, NULL} /* Sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
2000-11-19 00:02:29 +00:00
|
|
|
static PyMethodDef atlas_methods[] = {
|
2003-07-18 23:05:26 +00:00
|
|
|
{"Operation", (PyCFunction)operation_new, METH_VARARGS|METH_KEYWORDS},
|
2006-01-22 02:13:52 +00:00
|
|
|
{"isLocation", is_location, METH_O},
|
2003-07-18 23:05:26 +00:00
|
|
|
{"Location", location_new, METH_VARARGS},
|
|
|
|
|
{"Entity", (PyCFunction)entity_new, METH_VARARGS|METH_KEYWORDS},
|
2004-11-29 21:32:53 +00:00
|
|
|
{NULL, NULL} /* Sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static PyMethodDef physics_methods[] = {
|
|
|
|
|
{"distance_to",distance_to, METH_VARARGS},
|
|
|
|
|
{"square_distance",square_distance, METH_VARARGS},
|
2005-06-23 12:46:28 +00:00
|
|
|
{"square_horizontal_distance",
|
|
|
|
|
square_horizontal_distance, METH_VARARGS},
|
2004-11-29 21:32:53 +00:00
|
|
|
{NULL, NULL} /* Sentinel */
|
2000-11-14 15:52:10 +00:00
|
|
|
};
|
|
|
|
|
|
2000-11-20 20:28:08 +00:00
|
|
|
static PyMethodDef common_methods[] = {
|
2004-11-29 21:32:53 +00:00
|
|
|
//{"null", null_new, METH_VARARGS},
|
|
|
|
|
{NULL, NULL} /* Sentinel */
|
2000-11-20 20:28:08 +00:00
|
|
|
};
|
|
|
|
|
|
2000-11-14 15:52:10 +00:00
|
|
|
void init_python_api()
|
|
|
|
|
{
|
2000-12-13 12:10:48 +00:00
|
|
|
Py_Initialize();
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2003-08-30 11:41:58 +00:00
|
|
|
PyObject * sys_name = PyString_FromString("sys");
|
|
|
|
|
PyObject * sys_module = PyImport_Import(sys_name);
|
|
|
|
|
Py_DECREF(sys_name);
|
2004-06-15 18:06:59 +00:00
|
|
|
|
|
|
|
|
if (sys_module == 0) {
|
|
|
|
|
log(CRITICAL, "Python could not import sys module");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-29 21:23:40 +00:00
|
|
|
PyObject * out_logger = (PyObject*)PyObject_NEW(PyLogger, &PyOutLogger_Type);
|
|
|
|
|
PyObject_SetAttrString(sys_module, "stdout", out_logger);
|
|
|
|
|
Py_DECREF(out_logger);
|
2004-11-29 21:32:53 +00:00
|
|
|
|
2007-07-29 21:23:40 +00:00
|
|
|
PyObject * err_logger = (PyObject*)PyObject_NEW(PyLogger, &PyErrLogger_Type);
|
|
|
|
|
PyObject_SetAttrString(sys_module, "stderr", err_logger);
|
|
|
|
|
Py_DECREF(err_logger);
|
2004-06-15 18:06:59 +00:00
|
|
|
|
|
|
|
|
PyObject * sys_path = PyObject_GetAttrString(sys_module, "path");
|
|
|
|
|
if (sys_path != 0) {
|
|
|
|
|
if (PyList_Check(sys_path)) {
|
2007-06-18 13:19:52 +00:00
|
|
|
// Add the path to the non-ruleset specific code.
|
|
|
|
|
std::string p = share_directory + "/cyphesis/scripts";
|
|
|
|
|
PyObject * path = PyString_FromString(p.c_str());
|
|
|
|
|
PyList_Append(sys_path, path);
|
|
|
|
|
Py_DECREF(path);
|
|
|
|
|
|
2007-06-19 12:54:54 +00:00
|
|
|
p = share_directory + "/cyphesis/rulesets/basic";
|
|
|
|
|
path = PyString_FromString(p.c_str());
|
|
|
|
|
PyList_Append(sys_path, path);
|
|
|
|
|
Py_DECREF(path);
|
|
|
|
|
|
2007-06-19 13:19:57 +00:00
|
|
|
// Add the path to the ruleset specific code.
|
|
|
|
|
p = share_directory + "/cyphesis/rulesets/" + ruleset;
|
|
|
|
|
path = PyString_FromString(p.c_str());
|
|
|
|
|
PyList_Append(sys_path, path);
|
|
|
|
|
Py_DECREF(path);
|
2004-05-16 03:51:28 +00:00
|
|
|
} else {
|
2004-06-15 18:06:59 +00:00
|
|
|
log(CRITICAL, "Python sys.path is not a list");
|
2004-05-16 03:51:28 +00:00
|
|
|
}
|
2003-08-30 11:41:58 +00:00
|
|
|
} else {
|
2004-06-15 18:06:59 +00:00
|
|
|
log(CRITICAL, "Python could not import sys.path");
|
2003-08-30 11:41:58 +00:00
|
|
|
}
|
2004-06-15 18:06:59 +00:00
|
|
|
Py_DECREF(sys_module);
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2009-05-21 04:40:45 +01:00
|
|
|
PyObject * atlas = Py_InitModule("atlas", atlas_methods);
|
|
|
|
|
if (atlas == NULL) {
|
2004-10-02 15:36:34 +00:00
|
|
|
log(CRITICAL, "Python init failed to create atlas module\n");
|
2000-12-13 12:10:48 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2009-05-21 04:40:45 +01:00
|
|
|
if (PyType_Ready(&PyOplist_Type) < 0) {
|
|
|
|
|
log(CRITICAL, "Python init failed to ready Oplist wrapper type");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-05-21 16:34:01 +01:00
|
|
|
PyModule_AddObject(atlas, "Oplist", (PyObject *)&PyOplist_Type);
|
2000-11-20 20:28:08 +00:00
|
|
|
|
2009-05-20 19:33:39 +01:00
|
|
|
PyObject * physics = Py_InitModule("physics", physics_methods);
|
|
|
|
|
if (physics == NULL) {
|
2004-11-29 21:32:53 +00:00
|
|
|
log(CRITICAL, "Python init failed to create physics module\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-05-20 19:33:39 +01:00
|
|
|
if (PyType_Ready(&PyVector3D_Type) < 0) {
|
|
|
|
|
log(CRITICAL, "Python init failed to ready Vector3D wrapper type");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PyModule_AddObject(physics, "Vector3D", (PyObject *)&PyVector3D_Type);
|
|
|
|
|
if (PyType_Ready(&PyPoint3D_Type) < 0) {
|
|
|
|
|
log(CRITICAL, "Python init failed to ready Point3D wrapper type");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PyModule_AddObject(physics, "Point3D", (PyObject *)&PyPoint3D_Type);
|
2009-05-20 20:01:59 +01:00
|
|
|
if (PyType_Ready(&PyBBox_Type) < 0) {
|
|
|
|
|
log(CRITICAL, "Python init failed to ready BBox wrapper type");
|
2004-09-20 Al Riddoch <alriddoch@zepler.org>
* physics/Vector3D.h, physics/Vector3D.cpp, modules/Location.h,
modules/Location.cpp: Convert to using WFMath::Point instead of
WFMath::Vector for position.
* physics/Collision.h, physics/Collision.cpp: Update collision code
to use new pos type.
* rulesets/Py_Point3D.h, rulesets/Py_Point3D.cpp: New python
wrappers for WFMath::Point.
* rulesets/Py_Location.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp:
Update python wrappers to take into account new pos type.
Ensure that only apropriate functionality is available for
point and vector.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Line.cpp, rulesets/Movement.cpp, rulesets/Movement.h,
rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
server/WorldRouter.h: Update the rest of the code for new pos
type, converting all places where entity parenting is changed
to use WFMath toParentCoords() and toLocalCoords() methods,
so that orientation is handled correctly.
* tests/transformtest.cpp: New test to ensure that toParentCoords()
and toLocalCoords() perform as expected.
* tests/Creatortest.cpp, tests/Locationtest.cpp, tests/Worldtest.cpp,
tests/collisiontest.cpp, tests/emergencetest.cpp:
Update the rest of the tests.
2004-09-20 10:16:04 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2009-05-20 20:01:59 +01:00
|
|
|
PyModule_AddObject(physics, "BBox", (PyObject *)&PyBBox_Type);
|
2009-05-20 20:48:54 +01:00
|
|
|
if (PyType_Ready(&PyQuaternion_Type) < 0) {
|
|
|
|
|
log(CRITICAL, "Python init failed to ready Quaternion wrapper type");
|
2002-03-03 00:48:28 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2009-05-20 20:48:54 +01:00
|
|
|
PyModule_AddObject(physics, "Quaternion", (PyObject *)&PyQuaternion_Type);
|
2002-03-03 00:48:28 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
PyObject * common = Py_InitModule("common", common_methods);
|
|
|
|
|
if (common == NULL) {
|
2004-10-02 15:36:34 +00:00
|
|
|
log(CRITICAL, "Python init failed to create common module\n");
|
2000-12-13 12:10:48 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
PyObject * common_dict = PyModule_GetDict(common);
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
/// Create the common.log module
|
2004-10-02 15:36:34 +00:00
|
|
|
PyObject * log_mod = PyModule_New("log");
|
|
|
|
|
PyDict_SetItemString(common_dict, "log", log_mod);
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
PyObject * debug = (PyObject*)PyObject_NEW(FunctionObject, &log_debug_type);
|
2004-10-02 15:36:34 +00:00
|
|
|
PyObject_SetAttrString(log_mod, "debug", debug);
|
2001-10-08 23:21:18 +00:00
|
|
|
Py_DECREF(debug);
|
2006-10-20 14:26:19 +00:00
|
|
|
|
|
|
|
|
PyObject * think = (PyObject*)PyObject_NEW(FunctionObject, &log_think_type);
|
|
|
|
|
PyObject_SetAttrString(log_mod, "thinking", think);
|
|
|
|
|
Py_DECREF(think);
|
|
|
|
|
|
2004-10-02 15:36:34 +00:00
|
|
|
Py_DECREF(log_mod);
|
2003-07-22 15:06:31 +00:00
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
PyObject * o;
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
/// Create the common.const module
|
|
|
|
|
PyObject * _const = PyModule_New("const");
|
|
|
|
|
PyDict_SetItemString(common_dict, "const", _const);
|
|
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
o = PyInt_FromLong(consts::debug_level);
|
|
|
|
|
PyObject_SetAttrString(_const, "debug_level", o);
|
|
|
|
|
Py_DECREF(o);
|
2006-07-08 20:45:10 +00:00
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
o = PyInt_FromLong(consts::debug_thinking);
|
|
|
|
|
PyObject_SetAttrString(_const, "debug_thinking", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
|
|
|
|
|
o = PyFloat_FromDouble(consts::time_multiplier);
|
|
|
|
|
PyObject_SetAttrString(_const, "time_multiplier", o);
|
|
|
|
|
Py_DECREF(o);
|
2006-07-08 20:45:10 +00:00
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
o = PyFloat_FromDouble(consts::base_velocity_coefficient);
|
|
|
|
|
PyObject_SetAttrString(_const, "base_velocity_coefficient", o);
|
|
|
|
|
Py_DECREF(o);
|
2006-07-08 20:45:10 +00:00
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
o = PyFloat_FromDouble(consts::base_velocity);
|
|
|
|
|
PyObject_SetAttrString(_const, "base_velocity", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
|
|
|
|
|
o = PyFloat_FromDouble(consts::basic_tick);
|
|
|
|
|
PyObject_SetAttrString(_const, "basic_tick", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
|
2006-08-03 20:31:28 +00:00
|
|
|
o = PyFloat_FromDouble(WFMATH_EPSILON);
|
|
|
|
|
PyObject_SetAttrString(_const, "epsilon", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
|
2001-10-08 23:21:18 +00:00
|
|
|
Py_DECREF(_const);
|
2000-12-13 12:10:48 +00:00
|
|
|
|
2003-07-22 15:06:31 +00:00
|
|
|
/// Create the common.globals module
|
|
|
|
|
PyObject * globals = PyModule_New("globals");
|
|
|
|
|
PyDict_SetItemString(common_dict, "globals", globals);
|
2002-09-14 18:46:34 +00:00
|
|
|
o = PyString_FromString(share_directory.c_str());
|
|
|
|
|
PyObject_SetAttrString(globals, "share_directory", o);
|
|
|
|
|
Py_DECREF(o);
|
|
|
|
|
Py_DECREF(globals);
|
|
|
|
|
|
2006-01-05 16:52:52 +00:00
|
|
|
PyObject * server = Py_InitModule("server", no_methods);
|
|
|
|
|
if (server == NULL) {
|
|
|
|
|
log(CRITICAL, "Python init failed to create server module");
|
2000-12-13 12:10:48 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2006-01-05 16:52:52 +00:00
|
|
|
|
|
|
|
|
// New module code
|
|
|
|
|
// PyWorldTime_Type.tp_new = PyType_GenericNew;
|
|
|
|
|
if (PyType_Ready(&PyWorldTime_Type) < 0) {
|
|
|
|
|
log(CRITICAL, "Python init failed to ready WorldTime wrapper type");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PyModule_AddObject(server, "WorldTime", (PyObject *)&PyWorldTime_Type);
|
|
|
|
|
|
2008-01-04 23:57:30 +00:00
|
|
|
PyWorld * world = newPyWorld();
|
|
|
|
|
PyModule_AddObject(server, "world", (PyObject *)world);
|
|
|
|
|
|
2008-11-29 Al Riddoch <alriddoch@googlemail.com>
* rulesets/Character.cpp, rulesets/Character.h: Remove all traces
of the hard coded statistics property from Character.
* rulesets/Py_Property.cpp: Don't use Py_StatisticsProperty as the
default wrapper for a statistics property because it will no
longer work this way.
* rulesets/Python_API.cpp: Remove the setup for the Statistics
wrapper.
* rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h:
Change the footprint of this class so it is no longer hooked
into part of the Character class, and instead handles looking
up values from the script directly, and owns the script itself.
* server/ArithmeticFactory.cpp, server/ArithmeticFactory.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/PersistantThingFactory.cpp: Remove setup of hard coded
statistics property.
* rulesets/Statistics.h, rulesets/Statistics.cpp,
rulesets/Py_Statistics.h, rulesets/Py_Statistics.cpp,
rulesets/Makefile.am: Remove clases that are no longer used.
2008-11-29 23:17:38 +00:00
|
|
|
// FIXME Remove once we are sure.
|
|
|
|
|
// PyObject * rules = Py_InitModule("rulesets", no_methods);
|
|
|
|
|
// if (rules == NULL) {
|
|
|
|
|
// log(CRITICAL, "Python init failed to create rules module");
|
|
|
|
|
// // return;
|
|
|
|
|
// }
|
|
|
|
|
// if (PyType_Ready(&PyStatistics_Type) < 0) {
|
|
|
|
|
// log(CRITICAL, "Python init failed to ready Statistics wrapper type");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// PyModule_AddObject(rules, "Statistics", (PyObject *)&PyStatistics_Type);
|
2006-01-06 21:14:33 +00:00
|
|
|
|
2007-07-04 16:42:10 +00:00
|
|
|
if (PyType_Ready(&PyTerrainProperty_Type) < 0) {
|
|
|
|
|
log(CRITICAL, "Python init failed to ready TerrainProperty wrapper type");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-14 18:46:34 +00:00
|
|
|
|
2004-06-15 18:06:59 +00:00
|
|
|
debug(std::cout << Py_GetPath() << std::endl << std::flush;);
|
2001-10-08 23:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void shutdown_python_api()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Py_Finalize();
|
2000-11-14 15:52:10 +00:00
|
|
|
}
|