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
|
2001-01-26 16:38:23 +00:00
|
|
|
// Copyright (C) 2000 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-10-01 18:20:57 +00:00
|
|
|
// $Id$
|
2006-10-26 00:48:00 +00:00
|
|
|
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp,
rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h,
rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h,
rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h,
rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
#include "Py_Thing.h"
|
2011-11-07 19:16:50 +00:00
|
|
|
|
|
|
|
|
#include "Py_Map.h"
|
2009-05-27 14:10:26 +01:00
|
|
|
#include "Py_Message.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_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"
|
* 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_Location.h"
|
|
|
|
|
#include "Py_World.h"
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
#include "Py_Property.h"
|
|
|
|
|
#include "Py_Operation.h"
|
2006-01-15 06:57:34 +00:00
|
|
|
#include "Py_Oplist.h"
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
#include "Py_Task.h"
|
2011-11-07 19:16:50 +00:00
|
|
|
#include "Py_WorldTime.h"
|
2005-12-12 23:27:41 +00:00
|
|
|
#include "PythonWrapper.h"
|
2011-11-07 19:16:50 +00:00
|
|
|
|
|
|
|
|
#include "BaseMind.h"
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
#include "Character.h"
|
2000-11-17 00:18:32 +00:00
|
|
|
|
2009-05-25 03:14:01 +01:00
|
|
|
#include "common/id.h"
|
2005-12-12 23:27:41 +00:00
|
|
|
#include "common/log.h"
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
#include "common/Property.h"
|
2007-12-27 Al Riddoch <alriddoch@zepler.org>
* common/TypeNode.h, common/TypeNode.cpp: Move TypeNode into
its own files.
* common/Makefile.am, common/inheritance.cpp, common/inheritance.h:
Add the new files to the build and remove the old implementation.
* client/Py_CreatorClient.cpp, rulesets/Character.cpp,
rulesets/Entity.cpp, rulesets/MemMap.cpp,
rulesets/MindFactory.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Stackable.cpp,
server/WorldRouter.cpp: Fix up the includes for all code that
uses TypeNode.
2007-12-27 03:31:47 +00:00
|
|
|
#include "common/TypeNode.h"
|
2009-11-12 22:14:31 +00:00
|
|
|
#include "common/Inheritance.h"
|
2005-12-12 23:27:41 +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;
|
|
|
|
|
using Atlas::Message::MapType;
|
|
|
|
|
|
2009-06-12 20:19:52 +01:00
|
|
|
static PyObject * Entity_as_entity(PyEntity * self)
|
2000-12-06 18:21:35 +00:00
|
|
|
{
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
#ifndef NDEBUG
|
2009-06-12 20:19:52 +01:00
|
|
|
if (self->m_entity.l == NULL) {
|
2005-12-03 03:07:30 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL entity in Entity.as_entity");
|
2000-12-06 18:21:35 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
#endif // NDEBUG
|
2009-05-27 18:22:56 +01:00
|
|
|
PyMessage * ret = newPyMessage();
|
2009-07-04 14:16:13 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
|
ret->m_obj = new Element(MapType());
|
|
|
|
|
self->m_entity.l->addToMessage(ret->m_obj->asMap());
|
2000-12-06 18:21:35 +00:00
|
|
|
}
|
|
|
|
|
return (PyObject *)ret;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static PyMethodDef LocatedEntity_methods[] = {
|
|
|
|
|
{"as_entity", (PyCFunction)Entity_as_entity, METH_NOARGS},
|
|
|
|
|
{NULL, NULL} /* sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
2006-01-21 14:55:20 +00:00
|
|
|
static PyObject * Entity_send_world(PyEntity * self, PyOperation * op)
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
2009-06-12 11:36:07 +01:00
|
|
|
if (self->m_entity.e == NULL) {
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL entity in Entity.send_world");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
if (PyOperation_Check(op)) {
|
2009-06-12 11:36:07 +01:00
|
|
|
self->m_entity.e->sendWorld(op->operation);
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity.send_world must be an op");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static PyMethodDef Entity_methods[] = {
|
2006-01-21 14:55:20 +00:00
|
|
|
{"send_world", (PyCFunction)Entity_send_world, METH_O},
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
{NULL, NULL} /* sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
2009-07-29 12:54:24 +01:00
|
|
|
static PyObject * Character_start_task(PyEntity * self, PyObject * args)
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
2009-06-12 20:19:52 +01:00
|
|
|
if (self->m_entity.l == NULL) {
|
2009-07-29 12:54:24 +01:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL entity in Entity.start_task");
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
2009-07-29 12:54:24 +01:00
|
|
|
PyObject * task;
|
|
|
|
|
PyObject * op;
|
|
|
|
|
PyObject * res;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OOO", &task, &op, &res)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
if (!PyTask_Check(task)) {
|
2009-07-29 12:54:24 +01:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity.start_task must be a task");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!PyOperation_Check(op)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity.start_task must be an op");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!PyOplist_Check(res)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity.start_task must be an oplist");
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2009-07-29 12:54:24 +01:00
|
|
|
self->m_entity.c->startTask(((PyTask*)task)->m_task,
|
|
|
|
|
((PyOperation*)op)->operation,
|
|
|
|
|
*((PyOplist*)res)->ops);
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-12 20:19:52 +01:00
|
|
|
static PyObject * Character_mind2body(PyEntity * self, PyOperation * op)
|
2006-01-15 06:57:34 +00:00
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
2009-06-12 20:19:52 +01:00
|
|
|
if (self->m_entity.l == NULL) {
|
2009-06-10 13:21:08 +04:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL entity in Entity.mind2body");
|
2006-01-15 06:57:34 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
if (!PyOperation_Check(op)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity.mind2body must be an operation");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
OpVector res;
|
2009-06-12 20:19:52 +01:00
|
|
|
self->m_entity.c->mind2body(op->operation, res);
|
2006-01-15 06:57:34 +00:00
|
|
|
if (res.empty()) {
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
} else if (res.size() == 1) {
|
|
|
|
|
PyOperation * ret = newPyOperation();
|
2009-07-04 14:16:13 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
|
ret->operation = res[0];
|
|
|
|
|
}
|
2006-01-15 06:57:34 +00:00
|
|
|
return (PyObject*)ret;
|
|
|
|
|
} else {
|
|
|
|
|
PyOplist * ret = newPyOplist();
|
2009-07-04 14:16:13 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
|
ret->ops = new OpVector(res);
|
|
|
|
|
}
|
2006-01-15 06:57:34 +00:00
|
|
|
return (PyObject*)ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
static PyMethodDef Character_methods[] = {
|
2009-07-29 12:54:24 +01:00
|
|
|
{"start_task", (PyCFunction)Character_start_task, METH_VARARGS},
|
2006-01-21 14:55:20 +00:00
|
|
|
{"mind2body", (PyCFunction)Character_mind2body, METH_O},
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
{NULL, NULL} /* sentinel */
|
2000-11-17 00:18:32 +00:00
|
|
|
};
|
|
|
|
|
|
2011-10-12 15:29:52 +01:00
|
|
|
static PyEntity * Entity_new(PyTypeObject * type,
|
|
|
|
|
PyObject * args,
|
|
|
|
|
PyObject * kwds)
|
|
|
|
|
{
|
|
|
|
|
PyEntity * self = (PyEntity *)type->tp_alloc(type, 0);
|
|
|
|
|
if (self != NULL) {
|
|
|
|
|
self->m_weakreflist = NULL;
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static void Entity_dealloc(PyEntity *self)
|
2000-11-17 00:18:32 +00:00
|
|
|
{
|
2011-10-12 15:29:52 +01:00
|
|
|
if (self->m_weakreflist != NULL) {
|
|
|
|
|
PyObject_ClearWeakRefs((PyObject *) self);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-03 18:23:06 +01:00
|
|
|
self->ob_type->tp_free((PyObject*)self);
|
2000-11-17 00:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-01 00:00:36 +01:00
|
|
|
static PyObject * Entity_getattro(PyEntity *self, PyObject *oname)
|
2000-11-17 00:18:32 +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
|
|
|
#ifndef NDEBUG
|
2009-06-12 11:36:07 +01:00
|
|
|
if (self->m_entity.e == NULL) {
|
2005-12-03 03:07:30 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL entity in Entity.getattr");
|
2000-11-22 12:44:47 +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
|
2009-07-01 00:00:36 +01:00
|
|
|
char * name = PyString_AsString(oname);
|
2001-02-26 14:41:10 +00:00
|
|
|
// If operation search gets to here, it goes no further
|
2000-12-11 13:06:12 +00:00
|
|
|
if (strcmp(name, "type") == 0) {
|
2009-06-12 11:36:07 +01:00
|
|
|
if (self->m_entity.e->getType() == NULL) {
|
2009-05-25 03:34:47 +01:00
|
|
|
PyErr_SetString(PyExc_AttributeError, name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2000-12-11 13:06:12 +00:00
|
|
|
PyObject * list = PyList_New(0);
|
|
|
|
|
if (list == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2009-06-12 11:36:07 +01:00
|
|
|
PyObject * ent = PyString_FromString(self->m_entity.e->getType()->name().c_str());
|
2001-06-22 22:03:59 +00:00
|
|
|
PyList_Append(list, ent);
|
|
|
|
|
Py_DECREF(ent);
|
2000-12-11 13:06:12 +00:00
|
|
|
return list;
|
|
|
|
|
}
|
2000-11-22 12:44:47 +00:00
|
|
|
if (strcmp(name, "location") == 0) {
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyLocation * loc = newPyLocation();
|
2009-07-04 14:16:13 +01:00
|
|
|
if (loc != NULL) {
|
|
|
|
|
loc->location = &self->m_entity.e->m_location;
|
|
|
|
|
loc->owner = self->m_entity.e;
|
|
|
|
|
}
|
2000-11-22 12:44:47 +00:00
|
|
|
return (PyObject *)loc;
|
|
|
|
|
}
|
2005-06-04 15:35:07 +00:00
|
|
|
if (strcmp(name, "contains") == 0) {
|
2009-06-12 11:36:07 +01:00
|
|
|
if (self->m_entity.e->m_contains == 0) {
|
2008-01-05 Al Riddoch <alriddoch@googlemail.com>
* rulesets/LocatedEntity.cpp, rulesets/LocatedEntity.h:
Don't allocated storage for m_contains by default, only
on demand. Add a convenience method which checks, and
allocates the storage if required. Set up the ID property
on this base class rather then Entity.
* rulesets/Py_Thing.cpp: Remove special handling of ID attribute
as it is now handled by the property.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/MemMap.cpp,
rulesets/Motion.cpp, rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/WorldRouter.cpp:
Make sure all parts of the code where contains is used have
the right checks, as it could be null.
2008-01-05 14:05:05 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
2005-06-04 15:35:07 +00:00
|
|
|
PyObject * list = PyList_New(0);
|
|
|
|
|
if (list == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2009-06-12 11:36:07 +01:00
|
|
|
LocatedEntitySet::const_iterator I = self->m_entity.e->m_contains->begin();
|
|
|
|
|
LocatedEntitySet::const_iterator Iend = self->m_entity.e->m_contains->end();
|
2005-06-04 15:35:07 +00:00
|
|
|
for (; I != Iend; ++I) {
|
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 * child = *I;
|
2005-12-12 23:27:41 +00:00
|
|
|
PyObject * wrapper = wrapEntity(child);
|
2005-12-12 21:13:32 +00:00
|
|
|
if (wrapper == NULL) {
|
2005-06-04 15:35:07 +00:00
|
|
|
Py_DECREF(list);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-12-12 23:27:41 +00:00
|
|
|
PyList_Append(list, wrapper);
|
2005-12-12 21:13:32 +00:00
|
|
|
Py_DECREF(wrapper);
|
2005-06-04 15:35:07 +00:00
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
2009-06-12 11:36:07 +01:00
|
|
|
Entity * entity = self->m_entity.e;
|
2008-10-01 18:20:57 +00:00
|
|
|
PropertyBase * prop = entity->modProperty(name);
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
if (prop != 0) {
|
|
|
|
|
PyObject * ret = Property_asPyObject(prop, entity);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
Element attr;
|
2006-05-10 Al Riddoch <alriddoch@zepler.org>
* common/Property.h, common/Property_impl.h,
rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Entity.cpp, rulesets/EntityProperties.cpp,
rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/Py_Thing.cpp, rulesets/StatisticsProperty.cpp,
rulesets/StatisticsProperty.h, rulesets/TerrainProperty.cpp,
rulesets/TerrainProperty.h: Change return value of Property::get
to bool, and use it to indicate if the property has a value.
2006-05-10 13:46:15 +00:00
|
|
|
// If this property is not set with a value, return none.
|
2011-09-29 20:58:57 +01:00
|
|
|
if (prop->get(attr) == 0) {
|
2006-05-10 Al Riddoch <alriddoch@zepler.org>
* common/Property.h, common/Property_impl.h,
rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Entity.cpp, rulesets/EntityProperties.cpp,
rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/Py_Thing.cpp, rulesets/StatisticsProperty.cpp,
rulesets/StatisticsProperty.h, rulesets/TerrainProperty.cpp,
rulesets/TerrainProperty.h: Change return value of Property::get
to bool, and use it to indicate if the property has a value.
2006-05-10 13:46:15 +00:00
|
|
|
return MessageElement_asPyObject(attr);
|
|
|
|
|
} else {
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
2003-04-19 Al Riddoch <alriddoch@zepler.org>
* rulesets/World.h, rulesets/World.cpp, rulesets/Stackable.h,
rulesets/Stackable.cpp, rulesets/Plant.h,
rulesets/Plant.cpp, rulesets/Line.h, rulesets/Line.cpp,
rulesets/Entity.h, rulesets/Entity.cpp, rulesets/Character.h,
rulesets/Character.cpp, rulesets/Area.h, rulesets/Area.cpp,
common/type_utils.h, rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp,
client/Py_CreatorClient.cpp: Modify the way entities are queried
to avoid return by value, and use references instead.
2003-04-19 21:34:29 +00:00
|
|
|
}
|
2009-07-01 01:59:54 +01:00
|
|
|
return PyObject_GenericGetAttr((PyObject *)self, oname);
|
2000-11-17 00:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-01 00:00:36 +01:00
|
|
|
static int Entity_setattro(PyEntity *self, PyObject *oname, PyObject *v)
|
2000-11-17 00:18:32 +00:00
|
|
|
{
|
2005-12-03 03:07:30 +00:00
|
|
|
#ifndef NDEBUG
|
2009-06-12 11:36:07 +01:00
|
|
|
if (self->m_entity.e == NULL) {
|
2009-11-12 23:35:21 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL entity in Entity.setattr");
|
2000-11-17 00:18:32 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2005-12-03 03:07:30 +00:00
|
|
|
#endif // NDEBUG
|
2009-07-01 00:00:36 +01:00
|
|
|
char * name = PyString_AsString(oname);
|
2000-11-19 00:02:29 +00:00
|
|
|
if (strcmp(name, "map") == 0) {
|
2005-12-05 Al Riddoch <alriddoch@zepler.org>
* rulesets/Py_BBox.cpp, rulesets/Py_Optime.cpp,
rulesets/Py_Statistics.cpp, rulesets/Py_Thing.cpp: Ensure that
setattr returns an exception if the attribute is not a valid one.
* rulesets/Py_Map.cpp, rulesets/Py_Point3D.cpp,
rulesets/Py_Quaternion.cpp, rulesets/Py_World.cpp,
rulesets/Py_WorldTime.cpp: Remove setattr, as no attributes can
be set on this type.
* rulesets/Py_Mind.cpp, rulesets/Py_Oplist.cpp,
rulesets/Py_Vector3D.cpp: Clean up type structure.
* rulesets/basic/mind/goals/common/move.py: Remove attempt
to set "rotation" attribute on location, as its obsolete
and pointless.
2005-12-05 04:01:11 +00:00
|
|
|
PyErr_SetString(PyExc_AttributeError, "map attribute forbidden");
|
2000-11-19 00:02:29 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2009-06-12 11:36:07 +01:00
|
|
|
Entity * entity = self->m_entity.e;
|
2001-08-02 14:27:06 +00:00
|
|
|
//std::string attr(name);
|
2001-02-26 14:41:10 +00:00
|
|
|
//if (v == NULL) {
|
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
|
|
|
//entity->attributes.erase(attr);
|
2001-04-17 10:14:20 +00:00
|
|
|
//return 0;
|
2001-02-26 14:41:10 +00:00
|
|
|
//}
|
2009-11-12 22:14:31 +00:00
|
|
|
if (strcmp(name, "type") == 0) {
|
|
|
|
|
if (entity->getType() != 0) {
|
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "Cannot mutate entity type");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (!PyString_CheckExact(v)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "No string type");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
const TypeNode * type = Inheritance::instance().getType(PyString_AsString(v));
|
|
|
|
|
if (type == 0) {
|
2012-01-04 16:52:40 +00:00
|
|
|
PyErr_SetString(PyExc_ValueError, "Entity type unknown");
|
2009-11-12 22:14:31 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
entity->setType(type);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2009-05-27 03:13:15 +01:00
|
|
|
Element obj;
|
|
|
|
|
if (PyObject_asMessageElement(v, obj) == 0) {
|
2011-02-27 23:56:29 +00:00
|
|
|
PropertyBase * p = entity->setAttr(name, obj);
|
|
|
|
|
if (p != 0) {
|
|
|
|
|
p->setFlags(flag_unsent);
|
|
|
|
|
}
|
2001-04-17 10:14:20 +00:00
|
|
|
return 0;
|
2000-11-17 00:18:32 +00:00
|
|
|
}
|
2011-12-27 10:28:14 +01:00
|
|
|
return PyObject_GenericSetAttr((PyObject *)self, oname, v);
|
2000-11-17 00:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
static int Entity_compare(PyEntity *self, PyEntity *other)
|
2000-12-30 23:16:57 +00:00
|
|
|
{
|
2009-06-12 11:36:07 +01:00
|
|
|
if (self->m_entity.e == NULL || other->m_entity.e == NULL) {
|
2005-12-04 01:40:42 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL Entity in Entity.compare");
|
2000-12-30 23:16:57 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2009-06-12 11:36:07 +01:00
|
|
|
return (self->m_entity.e == other->m_entity.e) ? 0 : 1;
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
2009-05-25 04:06:31 +01:00
|
|
|
static int LocatedEntity_init(PyEntity * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
|
|
|
|
char * id = NULL;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s", &id)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
long intId = integerId(id);
|
|
|
|
|
if (intId == -1L) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity() requires string/int ID");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-06-12 11:36:07 +01:00
|
|
|
self->m_entity.l = new Entity(id, intId);
|
2009-05-25 04:06:31 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-24 16:20:17 +01:00
|
|
|
static int Entity_init(PyEntity * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2009-07-01 01:59:54 +01:00
|
|
|
PyObject * arg;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O", &arg)) {
|
2009-05-25 03:14:01 +01:00
|
|
|
return -1;
|
|
|
|
|
}
|
2009-07-01 01:59:54 +01:00
|
|
|
if (PyString_Check(arg)) {
|
|
|
|
|
char * id = PyString_AsString(arg);
|
|
|
|
|
long intId = integerId(id);
|
|
|
|
|
if (intId == -1L) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity() requires string/int ID");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
self->m_entity.e = new Entity(id, intId);
|
|
|
|
|
return 0;
|
2009-05-25 03:14:01 +01:00
|
|
|
}
|
2011-12-13 19:39:09 +00:00
|
|
|
if (PyEntity_Check(arg)) {
|
2009-07-01 01:59:54 +01:00
|
|
|
PyEntity * character = (PyEntity *)arg;
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (character->m_entity.c == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL character Task.__init__");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
self->m_entity.c = character->m_entity.c;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity() requires string ID or Entity");
|
|
|
|
|
return -1;
|
|
|
|
|
|
2009-05-25 04:06:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int Character_init(PyEntity * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2009-07-01 01:59:54 +01:00
|
|
|
PyObject * arg;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O", &arg)) {
|
2009-05-25 04:06:31 +01:00
|
|
|
return -1;
|
|
|
|
|
}
|
2009-07-01 01:59:54 +01:00
|
|
|
if (PyString_Check(arg)) {
|
|
|
|
|
char * id = PyString_AsString(arg);
|
|
|
|
|
long intId = integerId(id);
|
|
|
|
|
if (intId == -1L) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity() requires string/int ID");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
self->m_entity.c = new Character(id, intId);
|
|
|
|
|
return 0;
|
2009-05-25 04:06:31 +01:00
|
|
|
}
|
2011-12-13 19:19:09 +00:00
|
|
|
if (PyCharacter_Check(arg)) {
|
2009-07-01 01:59:54 +01:00
|
|
|
PyEntity * character = (PyEntity *)arg;
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (character->m_entity.c == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL character Task.__init__");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
self->m_entity.c = character->m_entity.c;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Character() requires string ID or Character");
|
|
|
|
|
return -1;
|
|
|
|
|
|
2009-05-24 16:20:17 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-07 19:16:50 +00:00
|
|
|
static PyObject * Mind_getattro(PyEntity *self, PyObject *oname)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_entity.m == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL mind in Mind.getattr");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
char * name = PyString_AsString(oname);
|
|
|
|
|
if (strcmp(name, "id") == 0) {
|
|
|
|
|
return (PyObject *)PyString_FromString(self->m_entity.m->getId().c_str());
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(name, "type") == 0) {
|
|
|
|
|
if (self->m_entity.m->getType() == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AttributeError, name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyObject * list = PyList_New(0);
|
|
|
|
|
if (list == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyObject * ent = PyString_FromString(self->m_entity.m->getType()->name().c_str());
|
|
|
|
|
PyList_Append(list, ent);
|
|
|
|
|
Py_DECREF(ent);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(name, "map") == 0) {
|
|
|
|
|
PyMap * map = newPyMap();
|
|
|
|
|
if (map != NULL) {
|
|
|
|
|
map->m_map = self->m_entity.m->getMap();
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)map;
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(name, "location") == 0) {
|
|
|
|
|
PyLocation * loc = newPyLocation();
|
|
|
|
|
if (loc != NULL) {
|
|
|
|
|
loc->location = &self->m_entity.m->m_location;
|
|
|
|
|
loc->owner = self->m_entity.m;
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)loc;
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(name, "time") == 0) {
|
|
|
|
|
PyWorldTime * worldtime = newPyWorldTime();
|
|
|
|
|
if (worldtime != NULL) {
|
|
|
|
|
worldtime->time = self->m_entity.m->getTime();
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)worldtime;
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(name, "contains") == 0) {
|
|
|
|
|
if (self->m_entity.m->m_contains == 0) {
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
PyObject * list = PyList_New(0);
|
|
|
|
|
if (list == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
LocatedEntitySet::const_iterator I = self->m_entity.m->m_contains->begin();
|
|
|
|
|
LocatedEntitySet::const_iterator Iend = self->m_entity.m->m_contains->end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
LocatedEntity * child = *I;
|
|
|
|
|
PyObject * wrapper = wrapEntity(child);
|
|
|
|
|
if (wrapper == NULL) {
|
|
|
|
|
Py_DECREF(list);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
PyList_Append(list, wrapper);
|
|
|
|
|
Py_DECREF(wrapper);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
LocatedEntity * mind = self->m_entity.m;
|
|
|
|
|
Element attr;
|
|
|
|
|
if (mind->getAttr(name, attr) == 0) {
|
|
|
|
|
return MessageElement_asPyObject(attr);
|
|
|
|
|
}
|
|
|
|
|
return PyObject_GenericGetAttr((PyObject *)self, oname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int Mind_setattro(PyEntity *self, PyObject *oname, PyObject *v)
|
|
|
|
|
{
|
|
|
|
|
char * name = PyString_AsString(oname);
|
|
|
|
|
if (strcmp(name, "mind") == 0) {
|
|
|
|
|
if (!PyMind_Check(v)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Mind.mind requires Mind");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
self->m_entity.m = ((PyEntity*)v)->m_entity.m;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_entity.m == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL mind in Mind.setattr");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
if (strcmp(name, "map") == 0) {
|
2012-01-04 16:52:40 +00:00
|
|
|
PyErr_SetString(PyExc_AttributeError, "Setting map on mind is forbidden");
|
2011-11-07 19:16:50 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
LocatedEntity * entity = self->m_entity.m;
|
|
|
|
|
// Should we support removal of attributes?
|
|
|
|
|
//std::string attr(name);
|
|
|
|
|
//if (v == NULL) {
|
|
|
|
|
//entity->attributes.erase(attr);
|
|
|
|
|
//return 0;
|
|
|
|
|
//}
|
|
|
|
|
Element obj;
|
|
|
|
|
if (PyObject_asMessageElement(v, obj, true) == 0) {
|
|
|
|
|
assert(!obj.isMap() && !obj.isList());
|
|
|
|
|
// In the Python wrapper for Entity in Py_Thing.cpp notices are issued
|
|
|
|
|
// for some types.
|
|
|
|
|
entity->setAttr(name, obj);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2011-12-27 10:28:14 +01:00
|
|
|
return PyObject_GenericSetAttr((PyObject *)self, oname, v);
|
2011-11-07 19:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int Mind_compare(PyEntity *self, PyEntity *other)
|
|
|
|
|
{
|
|
|
|
|
if (self->m_entity.m == NULL || other->m_entity.m == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL mind in Mind.compare");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return (self->m_entity.m == other->m_entity.m) ? 0 : 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int Mind_init(PyEntity * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
|
|
|
|
char * id = NULL;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s", &id)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
long intId = integerId(id);
|
|
|
|
|
if (intId == -1L) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Mind() requires string/int ID");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
self->m_entity.m = new BaseMind(id, intId);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-25 04:06:31 +01:00
|
|
|
PyTypeObject PyLocatedEntity_Type = {
|
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, /*ob_size*/
|
2009-06-08 01:42:25 +01:00
|
|
|
"server.LocatedEntity", /*tp_name*/
|
2009-06-12 20:19:52 +01:00
|
|
|
sizeof(PyEntity), /*tp_basicsize*/
|
2009-05-25 04:06:31 +01:00
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
/* methods */
|
|
|
|
|
(destructor)Entity_dealloc, /*tp_dealloc*/
|
|
|
|
|
0, /*tp_print*/
|
2009-07-01 00:00:36 +01:00
|
|
|
0, /*tp_getattr*/
|
|
|
|
|
0, /*tp_setattr*/
|
2009-05-25 04:06:31 +01:00
|
|
|
(cmpfunc)Entity_compare, /*tp_compare*/
|
|
|
|
|
0, /*tp_repr*/
|
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
|
0, /*tp_hash*/
|
|
|
|
|
0, // tp_call
|
|
|
|
|
0, // tp_str
|
2009-07-01 00:00:36 +01:00
|
|
|
(getattrofunc)Entity_getattro, // tp_getattro
|
|
|
|
|
(setattrofunc)Entity_setattro, // tp_setattro
|
2009-05-25 04:06:31 +01:00
|
|
|
0, // tp_as_buffer
|
2009-07-01 00:50:38 +01:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags
|
2009-06-08 01:42:25 +01:00
|
|
|
"LocatedEntity objects", // tp_doc
|
2009-05-25 04:06:31 +01:00
|
|
|
0, // tp_travers
|
|
|
|
|
0, // tp_clear
|
|
|
|
|
0, // tp_richcompare
|
2011-10-12 15:29:52 +01:00
|
|
|
offsetof(PyEntity, m_weakreflist), // tp_weaklistoffset
|
2009-05-25 04:06:31 +01:00
|
|
|
0, // tp_iter
|
|
|
|
|
0, // tp_iternext
|
|
|
|
|
LocatedEntity_methods, // tp_methods
|
|
|
|
|
0, // tp_members
|
|
|
|
|
0, // tp_getset
|
|
|
|
|
0, // tp_base
|
|
|
|
|
0, // tp_dict
|
|
|
|
|
0, // tp_descr_get
|
|
|
|
|
0, // tp_descr_set
|
|
|
|
|
0, // tp_dictoffset
|
|
|
|
|
(initproc)LocatedEntity_init, // tp_init
|
|
|
|
|
0, // tp_alloc
|
2011-10-12 15:29:52 +01:00
|
|
|
(newfunc)Entity_new, // tp_new
|
2009-05-25 04:06:31 +01:00
|
|
|
};
|
|
|
|
|
|
2003-09-08 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h,
rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp,
rulesets/Py_Object.h, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp,
rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp:
Clean up python API code, with decent names for types,
decent error reporting, and making the more paranoid checks
only present in debug build.
* common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp:
Remove pointless method setRefnoOp, and put it in the body as
an inline method.
* common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h,
common/Tick.h, common/operations.h, common/custom.cpp,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp,
rulesets/Script.h, server/EntityFactory.h:
Clean up the dependency trees using more forward declarations.
* common/inheritance.cpp, common/inheritance.h:
Move most of the implementation into the .cpp file as its
not suited to inlining.
* rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h:
Move contents of MemMap_methods.h into the .cpp file, as it is
not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
|
|
|
PyTypeObject PyEntity_Type = {
|
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, /*ob_size*/
|
2009-05-25 03:14:01 +01:00
|
|
|
"server.Entity", /*tp_name*/
|
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
|
|
|
sizeof(PyEntity), /*tp_basicsize*/
|
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
/* methods */
|
2011-12-13 18:53:35 +00:00
|
|
|
0, /*tp_dealloc*/
|
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
|
|
|
0, /*tp_print*/
|
2009-07-01 00:00:36 +01:00
|
|
|
0, /*tp_getattr*/
|
|
|
|
|
0, /*tp_setattr*/
|
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
|
|
|
(cmpfunc)Entity_compare, /*tp_compare*/
|
|
|
|
|
0, /*tp_repr*/
|
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
|
0, /*tp_hash*/
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_call
|
|
|
|
|
0, // tp_str
|
2011-12-13 18:53:35 +00:00
|
|
|
0, // tp_getattro
|
|
|
|
|
0, // tp_setattro
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_as_buffer
|
2009-07-01 00:50:38 +01:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags
|
2009-05-25 03:14:01 +01:00
|
|
|
"Entity objects", // tp_doc
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_travers
|
|
|
|
|
0, // tp_clear
|
|
|
|
|
0, // tp_richcompare
|
2011-12-13 18:53:35 +00:00
|
|
|
0, // tp_weaklistoffset
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_iter
|
|
|
|
|
0, // tp_iternext
|
2009-05-25 04:06:31 +01:00
|
|
|
Entity_methods, // tp_methods
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_members
|
|
|
|
|
0, // tp_getset
|
2011-12-13 18:53:35 +00:00
|
|
|
&PyLocatedEntity_Type, // tp_base
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_dict
|
|
|
|
|
0, // tp_descr_get
|
|
|
|
|
0, // tp_descr_set
|
|
|
|
|
0, // tp_dictoffset
|
2009-05-25 03:14:01 +01:00
|
|
|
(initproc)Entity_init, // tp_init
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_alloc
|
2011-10-12 15:29:52 +01:00
|
|
|
(newfunc)Entity_new, // tp_new
|
2000-11-17 00:18:32 +00:00
|
|
|
};
|
|
|
|
|
|
2009-05-25 04:06:31 +01:00
|
|
|
PyTypeObject PyCharacter_Type = {
|
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, /*ob_size*/
|
2009-06-08 01:42:25 +01:00
|
|
|
"server.Character", /*tp_name*/
|
2009-06-12 20:19:52 +01:00
|
|
|
sizeof(PyEntity), /*tp_basicsize*/
|
2009-05-25 04:06:31 +01:00
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
/* methods */
|
2011-12-13 18:53:35 +00:00
|
|
|
0, /*tp_dealloc*/
|
2009-05-25 04:06:31 +01:00
|
|
|
0, /*tp_print*/
|
2009-07-01 00:00:36 +01:00
|
|
|
0, /*tp_getattr*/
|
|
|
|
|
0, /*tp_setattr*/
|
2009-05-25 04:06:31 +01:00
|
|
|
(cmpfunc)Entity_compare, /*tp_compare*/
|
|
|
|
|
0, /*tp_repr*/
|
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
|
0, /*tp_hash*/
|
|
|
|
|
0, // tp_call
|
|
|
|
|
0, // tp_str
|
2011-12-13 18:53:35 +00:00
|
|
|
0, // tp_getattro
|
|
|
|
|
0, // tp_setattro
|
2009-05-25 04:06:31 +01:00
|
|
|
0, // tp_as_buffer
|
2009-07-01 00:50:38 +01:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags
|
2009-06-08 01:42:25 +01:00
|
|
|
"Character objects", // tp_doc
|
2009-05-25 04:06:31 +01:00
|
|
|
0, // tp_travers
|
|
|
|
|
0, // tp_clear
|
|
|
|
|
0, // tp_richcompare
|
2011-12-13 18:53:35 +00:00
|
|
|
0, // tp_weaklistoffset
|
2009-05-25 04:06:31 +01:00
|
|
|
0, // tp_iter
|
|
|
|
|
0, // tp_iternext
|
|
|
|
|
Character_methods, // tp_methods
|
|
|
|
|
0, // tp_members
|
|
|
|
|
0, // tp_getset
|
2011-12-13 18:53:35 +00:00
|
|
|
&PyEntity_Type, // tp_base
|
2009-05-25 04:06:31 +01:00
|
|
|
0, // tp_dict
|
|
|
|
|
0, // tp_descr_get
|
|
|
|
|
0, // tp_descr_set
|
|
|
|
|
0, // tp_dictoffset
|
|
|
|
|
(initproc)Character_init, // tp_init
|
|
|
|
|
0, // tp_alloc
|
2011-10-12 15:29:52 +01:00
|
|
|
(newfunc)Entity_new, // tp_new
|
2009-05-25 04:06:31 +01:00
|
|
|
};
|
|
|
|
|
|
2011-11-07 19:16:50 +00:00
|
|
|
PyTypeObject PyMind_Type = {
|
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, // ob_size
|
|
|
|
|
"server.Mind", // tp_name
|
|
|
|
|
sizeof(PyEntity), // tp_basicsize
|
|
|
|
|
0, // tp_itemsize
|
|
|
|
|
// methods
|
2011-12-13 18:53:35 +00:00
|
|
|
0, // tp_dealloc
|
2011-11-07 19:16:50 +00:00
|
|
|
0, // tp_print
|
|
|
|
|
0, // tp_getattr
|
|
|
|
|
0, // tp_setattr
|
|
|
|
|
(cmpfunc)Mind_compare, // tp_compare
|
|
|
|
|
0, // tp_repr
|
|
|
|
|
0, // tp_as_number
|
|
|
|
|
0, // tp_as_sequence
|
|
|
|
|
0, // tp_as_mapping
|
|
|
|
|
0, // tp_hash
|
|
|
|
|
0, // tp_call
|
|
|
|
|
0, // tp_str
|
|
|
|
|
(getattrofunc)Mind_getattro, // tp_getattro
|
|
|
|
|
(setattrofunc)Mind_setattro, // tp_setattro
|
|
|
|
|
0, // tp_as_buffer
|
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags
|
|
|
|
|
"Mind objects", // tp_doc
|
|
|
|
|
0, // tp_travers
|
|
|
|
|
0, // tp_clear
|
|
|
|
|
0, // tp_richcompare
|
|
|
|
|
0, // tp_weaklistoffset
|
|
|
|
|
0, // tp_iter
|
|
|
|
|
0, // tp_iternext
|
2011-12-27 15:02:28 +01:00
|
|
|
0, // tp_methods
|
2011-11-07 19:16:50 +00:00
|
|
|
0, // tp_members
|
|
|
|
|
0, // tp_getset
|
2011-12-13 18:53:35 +00:00
|
|
|
&PyLocatedEntity_Type, // tp_base
|
2011-11-07 19:16:50 +00:00
|
|
|
0, // tp_dict
|
|
|
|
|
0, // tp_descr_get
|
|
|
|
|
0, // tp_descr_set
|
|
|
|
|
0, // tp_dictoffset
|
|
|
|
|
(initproc)Mind_init, // tp_init
|
|
|
|
|
0, // tp_alloc
|
|
|
|
|
(newfunc)Entity_new, // tp_new
|
|
|
|
|
};
|
|
|
|
|
|
2011-12-14 16:37:26 +00:00
|
|
|
template<>
|
|
|
|
|
PyObject * wrapPython<LocatedEntity>(LocatedEntity * le)
|
2011-12-14 00:41:02 +00:00
|
|
|
{
|
|
|
|
|
PyEntity * pe;
|
|
|
|
|
Entity * entity = dynamic_cast<Entity *>(le);
|
|
|
|
|
if (entity != 0) {
|
|
|
|
|
Character * ch_entity = dynamic_cast<Character *>(entity);
|
|
|
|
|
if (ch_entity != 0) {
|
|
|
|
|
pe = newPyCharacter();
|
|
|
|
|
if (pe == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
pe->m_entity.c = ch_entity;
|
|
|
|
|
} else {
|
|
|
|
|
pe = newPyEntity();
|
|
|
|
|
if (pe == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
pe->m_entity.e = entity;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
pe = newPyLocatedEntity();
|
|
|
|
|
if (pe == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
pe->m_entity.l = le;
|
|
|
|
|
}
|
|
|
|
|
return (PyObject*)pe;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-14 16:37:26 +00:00
|
|
|
template<>
|
|
|
|
|
PyObject * wrapPython<Entity>(Entity * e)
|
|
|
|
|
{
|
|
|
|
|
return wrapPython<LocatedEntity>(e);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-15 13:19:41 +00:00
|
|
|
template<>
|
|
|
|
|
PyObject * wrapPython<BaseMind>(BaseMind * t)
|
|
|
|
|
{
|
|
|
|
|
PyEntity * pm = newPyMind();
|
|
|
|
|
if (pm == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
pm->m_entity.m = t;
|
|
|
|
|
return (PyObject*)pm;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
PyObject * wrapEntity(LocatedEntity * le)
|
2005-12-12 23:27:41 +00:00
|
|
|
{
|
2011-10-13 14:20:46 +01:00
|
|
|
PyObject * wrapper = 0;
|
|
|
|
|
if (le->script() == 0) {
|
2011-12-14 16:37:26 +00:00
|
|
|
wrapper = wrapPython(le);
|
2011-10-13 14:20:46 +01:00
|
|
|
le->setScript(new PythonWrapper(wrapper));
|
|
|
|
|
} else {
|
|
|
|
|
PythonWrapper * pw = dynamic_cast<PythonWrapper *>(le->script());
|
|
|
|
|
if (pw == 0) {
|
2005-12-12 23:27:41 +00:00
|
|
|
log(WARNING, "Entity has script of unknown type");
|
2011-10-13 14:20:46 +01:00
|
|
|
} else {
|
|
|
|
|
wrapper = pw->wrapper();
|
|
|
|
|
assert(wrapper != NULL);
|
|
|
|
|
Py_INCREF(wrapper);
|
2005-12-12 23:27:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return wrapper;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-25 03:14:01 +01:00
|
|
|
// FIXME if this is cleaner to use the methods field of the type for methods,
|
|
|
|
|
// one PyTypeObject for each, and just share the members. That way we lose
|
|
|
|
|
// the need for a members entry on the object.
|
|
|
|
|
|
2009-06-12 20:19:52 +01:00
|
|
|
PyEntity * newPyLocatedEntity()
|
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
|
|
|
{
|
2009-07-04 19:05:32 +01:00
|
|
|
return (PyEntity *)PyLocatedEntity_Type.tp_new(&PyLocatedEntity_Type, 0, 0);
|
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
|
|
|
}
|
|
|
|
|
|
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 * newPyEntity()
|
2000-11-17 00:18:32 +00:00
|
|
|
{
|
2009-07-04 19:05:32 +01:00
|
|
|
return (PyEntity *)PyEntity_Type.tp_new(&PyEntity_Type, 0, 0);
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-12 20:19:52 +01:00
|
|
|
PyEntity * newPyCharacter()
|
2005-12-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Character.cpp, rulesets/StatisticsProperty.h,
rulesets/StatisticsProperty.cpp: Add a property handler for
statistics.
* rulesets/Character.cpp: When setting task, check if an existing
task needs to be cleared first. When clearing a task, check
whether a task exists or not.
* rulesets/Character.cpp: When initiating combat task from task
factory, check to see if the task is successfully created before
using it.
* rulesets/Py_Property.cpp, rulesets/Py_Property.h: New python wrapper
class for entity properties.
* rulesets/Py_Mind.cpp: Re-work getattr logic to make it clearer.
* rulesets/Py_Object.cpp: Return Py_None when an Atlas Element cannot
be converted to python. This ensures that this function never returns
null.
* rulesets/Py_Statistics.cpp: Add temporary handlers for hardcoded
statistics for "attack", "defence", and "strength".
* rulesets/Py_Task.cpp: Add wrappers for methods Task.irrelevant and
Task.obsolete, as these are now required in combat scripts.
* rulesets/Py_Task.h: Fix the PyTask_Check macro, which was miscoded.
* rulesets/Py_Thing.cpp: Add wrapper for Entity.send_world so that
scripts can channel ops through entities.
* rulesets/Py_Thing.h, rulesets/Py_Thing.cpp: Add an addition structure
for directlty wrapping Character in a type safe way. Add method
structure pointer to Entity and Character wrappers so that
the same getattr method is used for both. Add new method table for
Character including wrappers for set_task and clear_task, allowing
task scripts to add themselves and remove themselves from
characters. Modify wrapEntity() to ensure that Character entities
get the right wrapper.
* rulesets/Py_Thing.cpp: Re-work getattr code so that properties and
soft attributes are checked individually, rather than in a single
call to Entity.get. Use new python property wrappers to wrap
properties explicitly if required rather than converting to Atlas
then to generic Python data.
* rulesets/TerrainProperty.h: Fix incorrect class description in
documentation.
* rulesets/mason/world/tasks/Combat.py: Complete implementation of
simple example combat.
* server/TaskFactory.cpp: Remove debug output.
2005-12-30 18:02:40 +00:00
|
|
|
{
|
2009-07-04 19:05:32 +01:00
|
|
|
return (PyEntity *)PyCharacter_Type.tp_new(&PyCharacter_Type, 0, 0);
|
2000-11-17 00:18:32 +00:00
|
|
|
}
|
2011-11-07 19:16:50 +00:00
|
|
|
|
|
|
|
|
PyEntity * newPyMind()
|
|
|
|
|
{
|
|
|
|
|
return (PyEntity *)PyMind_Type.tp_new(&PyMind_Type, 0, 0);
|
|
|
|
|
}
|