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
|
|
|
|
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
|
|
|
|
2018-05-02 11:57:10 +02:00
|
|
|
#include "Py_MemMap.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"
|
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"
|
2016-08-19 19:12:18 +02:00
|
|
|
#include "rulesets/mind/AwareMind.h"
|
2000-11-17 00:18:32 +00:00
|
|
|
|
2015-09-25 21:25:04 +02:00
|
|
|
#include "navigation/Steering.h"
|
|
|
|
|
|
2009-05-25 03:14:01 +01:00
|
|
|
#include "common/id.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"
|
2018-05-01 14:22:06 +02:00
|
|
|
#include "StatisticsProperty.h"
|
|
|
|
|
#include "TerrainProperty.h"
|
|
|
|
|
#include "TerrainModProperty.h"
|
2018-05-07 10:09:18 +02:00
|
|
|
#include "CyPy_Props.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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.l == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr entity in Entity.as_entity");
|
|
|
|
|
return nullptr;
|
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
|
|
|
#endif // NDEBUG
|
2009-05-27 18:22:56 +01:00
|
|
|
PyMessage * ret = newPyMessage();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (ret != nullptr) {
|
2009-07-04 14:16:13 +01:00
|
|
|
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},
|
2018-01-30 16:54:49 +01:00
|
|
|
{nullptr, nullptr} /* sentinel */
|
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
|
|
|
};
|
|
|
|
|
|
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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.e == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr entity in Entity.send_world");
|
|
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
#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");
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
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},
|
2018-01-30 16:54:49 +01:00
|
|
|
{nullptr, nullptr} /* sentinel */
|
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-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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.l == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr entity in Entity.start_task");
|
|
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
2009-07-29 12:54:24 +01:00
|
|
|
PyObject * task;
|
|
|
|
|
PyObject * op;
|
|
|
|
|
PyObject * res;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OOO", &task, &op, &res)) {
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2009-07-29 12:54:24 +01:00
|
|
|
}
|
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");
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2009-07-29 12:54:24 +01:00
|
|
|
}
|
|
|
|
|
if (!PyOperation_Check(op)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity.start_task must be an op");
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2009-07-29 12:54:24 +01:00
|
|
|
}
|
|
|
|
|
if (!PyOplist_Check(res)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity.start_task must be an oplist");
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
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-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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.l == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr entity in Entity.mind2body");
|
|
|
|
|
return nullptr;
|
2006-01-15 06:57:34 +00:00
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
if (!PyOperation_Check(op)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Entity.mind2body must be an operation");
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2006-01-15 06:57:34 +00:00
|
|
|
}
|
|
|
|
|
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();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (ret != nullptr) {
|
2009-07-04 14:16:13 +01:00
|
|
|
ret->operation = res[0];
|
|
|
|
|
}
|
2006-01-15 06:57:34 +00:00
|
|
|
return (PyObject*)ret;
|
|
|
|
|
} else {
|
|
|
|
|
PyOplist * ret = newPyOplist();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (ret != nullptr) {
|
2009-07-04 14:16:13 +01:00
|
|
|
ret->ops = new OpVector(res);
|
|
|
|
|
}
|
2006-01-15 06:57:34 +00:00
|
|
|
return (PyObject*)ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 23:28:05 +01:00
|
|
|
static PyObject * Mind_refreshPath(PyEntity * self)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.l == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr entity in Entity.refreshPath");
|
|
|
|
|
return nullptr;
|
2016-03-08 23:28:05 +01:00
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
AwareMind* awareMind = dynamic_cast<AwareMind*>(self->m_entity.m);
|
|
|
|
|
if (!awareMind) {
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2016-03-08 23:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int result = awareMind->updatePath();
|
|
|
|
|
// int result = awareMind->getSteering().updatePath(awareMind->m_location.m_pos);
|
|
|
|
|
return Py_BuildValue("i", result);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 21:45:02 +02:00
|
|
|
static PyObject * Mind_describeEntity(PyEntity * self)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.l == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr entity in Entity.mind2body");
|
|
|
|
|
return nullptr;
|
2016-06-08 21:45:02 +02:00
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
AwareMind* awareMind = dynamic_cast<AwareMind*>(self->m_entity.m);
|
|
|
|
|
if (!awareMind) {
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2016-06-08 21:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string result = awareMind->describeEntity();
|
2018-05-02 11:57:10 +02:00
|
|
|
return PyUnicode_FromString(result.c_str());
|
2016-06-08 21:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-03-20 22:48:03 +01:00
|
|
|
static PyObject* Mind_setDestination(PyEntity* self, PyObject* args)
|
|
|
|
|
{
|
|
|
|
|
AwareMind* awareMind = dynamic_cast<AwareMind*>(self->m_entity.m);
|
|
|
|
|
if (!awareMind) {
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2016-03-20 22:48:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyObject * destination_arg;
|
|
|
|
|
float radius;
|
2016-04-03 21:25:39 +02:00
|
|
|
const char* entityIdString;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "Ofz", &destination_arg, &radius, &entityIdString)) {
|
2016-03-20 22:48:03 +01:00
|
|
|
awareMind->getSteering().stopSteering();
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2016-03-20 22:48:03 +01:00
|
|
|
}
|
|
|
|
|
if (!PyPoint3D_Check(destination_arg)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Argument must be a Point3D");
|
|
|
|
|
awareMind->getSteering().stopSteering();
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2016-03-20 22:48:03 +01:00
|
|
|
}
|
|
|
|
|
PyPoint3D * destination = (PyPoint3D *)destination_arg;
|
|
|
|
|
|
|
|
|
|
if (!destination->coords.isValid()) {
|
|
|
|
|
awareMind->getSteering().stopSteering();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 21:25:39 +02:00
|
|
|
int entityId;
|
|
|
|
|
//If no entity id was specified, the location is relative to the parent entity.
|
|
|
|
|
if (entityIdString == nullptr) {
|
|
|
|
|
entityId = awareMind->m_location.m_loc->getIntId();
|
|
|
|
|
} else {
|
|
|
|
|
entityId = std::atoi(entityIdString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
awareMind->getSteering().setDestination(entityId, destination->coords, radius, awareMind->getCurrentServerTime());
|
2016-03-20 22:48:03 +01:00
|
|
|
awareMind->getSteering().startSteering();
|
|
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 23:28:05 +01:00
|
|
|
|
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},
|
2018-01-30 16:54:49 +01:00
|
|
|
{nullptr, nullptr} /* sentinel */
|
2000-11-17 00:18:32 +00:00
|
|
|
};
|
|
|
|
|
|
2016-03-08 23:28:05 +01:00
|
|
|
static PyMethodDef Mind_methods[] = {
|
|
|
|
|
{"refreshPath", (PyCFunction)Mind_refreshPath, METH_NOARGS},
|
2016-03-20 22:48:03 +01:00
|
|
|
{"setDestination", (PyCFunction)Mind_setDestination, METH_VARARGS},
|
2016-06-08 21:45:02 +02:00
|
|
|
{"describeEntity", (PyCFunction)Mind_describeEntity, METH_NOARGS},
|
2018-01-30 16:54:49 +01:00
|
|
|
{nullptr, nullptr} /* sentinel */
|
2016-03-08 23:28:05 +01:00
|
|
|
};
|
|
|
|
|
|
2018-05-12 00:42:43 +02:00
|
|
|
static PyEntity * LocatedEntity_new(PyTypeObject *type,
|
|
|
|
|
PyObject *args,
|
|
|
|
|
PyObject *kwds)
|
2011-10-12 15:29:52 +01:00
|
|
|
{
|
|
|
|
|
PyEntity * self = (PyEntity *)type->tp_alloc(type, 0);
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self != nullptr) {
|
|
|
|
|
self->m_weakreflist = nullptr;
|
2011-10-12 15:29:52 +01:00
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-12 00:42:43 +02:00
|
|
|
static void LocatedEntity_dealloc(PyEntity *self)
|
2000-11-17 00:18:32 +00:00
|
|
|
{
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_weakreflist != nullptr) {
|
2011-10-12 15:29:52 +01:00
|
|
|
PyObject_ClearWeakRefs((PyObject *) self);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-02 11:57:10 +02:00
|
|
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
2000-11-17 00:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-12 00:42:43 +02:00
|
|
|
static PyObject * LocatedEntity_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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.e == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr entity in Entity.getattr");
|
|
|
|
|
return nullptr;
|
2000-11-22 12:44:47 +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
|
|
|
#endif // NDEBUG
|
2018-05-02 11:57:10 +02:00
|
|
|
char * name = PyUnicode_AsUTF8(oname);
|
2001-02-26 14:41:10 +00:00
|
|
|
// If operation search gets to here, it goes no further
|
2018-05-07 10:09:18 +02:00
|
|
|
|
2018-05-12 00:42:43 +02:00
|
|
|
if (strcmp(name, "id") == 0) {
|
|
|
|
|
return PyUnicode_FromString(self->m_entity.m->getId().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-07 10:09:18 +02:00
|
|
|
if (strcmp(name, "props") == 0) {
|
|
|
|
|
CyPyProps* props = newCyPyProps();
|
|
|
|
|
props->owner = self->m_entity.e;
|
|
|
|
|
self->m_entity.e->incRef();
|
|
|
|
|
Py_INCREF(props);
|
|
|
|
|
return (PyObject*)props;
|
|
|
|
|
}
|
|
|
|
|
|
2000-12-11 13:06:12 +00:00
|
|
|
if (strcmp(name, "type") == 0) {
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.e->getType() == nullptr) {
|
2009-05-25 03:34:47 +01:00
|
|
|
PyErr_SetString(PyExc_AttributeError, name);
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2009-05-25 03:34:47 +01:00
|
|
|
}
|
2000-12-11 13:06:12 +00:00
|
|
|
PyObject * list = PyList_New(0);
|
2018-01-30 16:54:49 +01:00
|
|
|
if (list == nullptr) {
|
|
|
|
|
return nullptr;
|
2000-12-11 13:06:12 +00:00
|
|
|
}
|
2018-05-02 11:57:10 +02:00
|
|
|
PyObject * ent = PyUnicode_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;
|
|
|
|
|
}
|
2018-05-12 00:42:43 +02:00
|
|
|
if (strcmp(name, "time") == 0) {
|
|
|
|
|
PyWorldTime * worldtime = newPyWorldTime();
|
|
|
|
|
if (worldtime != nullptr) {
|
|
|
|
|
worldtime->time = self->m_entity.m->getTime();
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)worldtime;
|
|
|
|
|
}
|
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();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (loc != nullptr) {
|
2009-07-04 14:16:13 +01:00
|
|
|
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);
|
2018-01-30 16:54:49 +01:00
|
|
|
if (list == nullptr) {
|
|
|
|
|
return nullptr;
|
2005-06-04 15:35:07 +00:00
|
|
|
}
|
2018-05-12 00:42:43 +02:00
|
|
|
auto I = self->m_entity.e->m_contains->begin();
|
|
|
|
|
auto 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);
|
2018-01-30 16:54:49 +01:00
|
|
|
if (wrapper == nullptr) {
|
2005-06-04 15:35:07 +00:00
|
|
|
Py_DECREF(list);
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2005-06-04 15:35:07 +00:00
|
|
|
}
|
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;
|
|
|
|
|
}
|
2013-06-15 23:46:59 +02:00
|
|
|
if (strcmp(name, "visible") == 0) {
|
|
|
|
|
if (self->m_entity.e->isVisible()) {
|
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
}
|
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
|
}
|
2015-09-27 16:50:43 +02:00
|
|
|
|
2009-07-01 01:59:54 +01:00
|
|
|
return PyObject_GenericGetAttr((PyObject *)self, oname);
|
2000-11-17 00:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-12 00:42:43 +02:00
|
|
|
static int LocatedEntity_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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.e == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr entity in Entity.setattr");
|
2000-11-17 00:18:32 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2005-12-03 03:07:30 +00:00
|
|
|
#endif // NDEBUG
|
2018-05-02 11:57:10 +02:00
|
|
|
char * name = PyUnicode_AsUTF8(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);
|
2018-01-30 16:54:49 +01:00
|
|
|
//if (v == nullptr) {
|
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;
|
|
|
|
|
}
|
2018-05-02 11:57:10 +02:00
|
|
|
if (!PyUnicode_CheckExact(v)) {
|
2009-11-12 22:14:31 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "No string type");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2018-05-02 11:57:10 +02:00
|
|
|
const TypeNode * type = Inheritance::instance().getType(PyUnicode_AsUTF8(v));
|
2009-11-12 22:14:31 +00:00
|
|
|
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;
|
|
|
|
|
}
|
2018-05-12 00:42:43 +02:00
|
|
|
auto ret = PyObject_GenericSetAttr((PyObject *)self, oname, v);
|
|
|
|
|
return ret;
|
2000-11-17 00:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-12 00:42:43 +02:00
|
|
|
static PyObject* LocatedEntity_compare(PyObject *a, PyObject *b, int op)
|
2000-12-30 23:16:57 +00:00
|
|
|
{
|
2018-05-04 19:17:55 +02:00
|
|
|
PyObject *result = Py_NotImplemented;
|
|
|
|
|
|
2018-05-02 11:57:10 +02:00
|
|
|
auto self = (PyEntity*)a;
|
|
|
|
|
if (PyEntity_Check(b)) {
|
|
|
|
|
auto other = (PyEntity*)b;
|
|
|
|
|
if (self->m_entity.e == nullptr || other->m_entity.e == nullptr) {
|
2018-05-04 19:17:55 +02:00
|
|
|
result = Py_False;
|
2018-05-02 11:57:10 +02:00
|
|
|
}
|
|
|
|
|
if (op == Py_EQ) {
|
2018-05-04 19:17:55 +02:00
|
|
|
result = (self->m_entity.e == other->m_entity.e) ? Py_True : Py_False;
|
|
|
|
|
} else if (op == Py_NE) {
|
|
|
|
|
result = (self->m_entity.e != other->m_entity.e) ? Py_True : Py_False;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (op == Py_EQ) {
|
|
|
|
|
result = Py_False;
|
2018-05-02 11:57:10 +02:00
|
|
|
} else if (op == Py_NE) {
|
2018-05-04 19:17:55 +02:00
|
|
|
result = Py_True;
|
2018-05-02 11:57:10 +02:00
|
|
|
}
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
2018-05-02 11:57:10 +02:00
|
|
|
|
2018-05-04 19:17:55 +02:00
|
|
|
Py_INCREF(result);
|
|
|
|
|
return result;
|
2000-12-30 23:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-02 11:57:10 +02:00
|
|
|
|
2009-05-25 04:06:31 +01:00
|
|
|
static int LocatedEntity_init(PyEntity * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2018-01-30 16:54:49 +01:00
|
|
|
char * id = nullptr;
|
2009-05-25 04:06:31 +01:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2018-05-02 11:57:10 +02:00
|
|
|
if (PyUnicode_Check(arg)) {
|
|
|
|
|
char * id = PyUnicode_AsUTF8(arg);
|
2009-07-01 01:59:54 +01:00
|
|
|
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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (character->m_entity.c == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr character Task.__init__");
|
2009-07-01 01:59:54 +01:00
|
|
|
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;
|
|
|
|
|
}
|
2018-05-02 11:57:10 +02:00
|
|
|
if (PyUnicode_Check(arg)) {
|
|
|
|
|
char * id = PyUnicode_AsUTF8(arg);
|
2009-07-01 01:59:54 +01:00
|
|
|
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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (character->m_entity.c == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr character Task.__init__");
|
2009-07-01 01:59:54 +01:00
|
|
|
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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.m == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr mind in Mind.getattr");
|
|
|
|
|
return nullptr;
|
2011-11-07 19:16:50 +00:00
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
2018-05-02 11:57:10 +02:00
|
|
|
char * name = PyUnicode_AsUTF8(oname);
|
2011-11-07 19:16:50 +00:00
|
|
|
if (strcmp(name, "map") == 0) {
|
2018-05-02 11:57:10 +02:00
|
|
|
PyMemMap * map = newPyMemMap();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (map != nullptr) {
|
2011-11-07 19:16:50 +00:00
|
|
|
map->m_map = self->m_entity.m->getMap();
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *)map;
|
|
|
|
|
}
|
2016-03-13 14:03:13 +01:00
|
|
|
if (strcmp(name, "unawareTilesCount") == 0) {
|
|
|
|
|
AwareMind* awareMind = dynamic_cast<AwareMind*>(self->m_entity.m);
|
|
|
|
|
if (!awareMind) {
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2016-03-13 14:03:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t count = awareMind->getSteering().unawareAreaCount();
|
2015-09-27 16:50:43 +02:00
|
|
|
|
2018-05-02 11:57:10 +02:00
|
|
|
return PyLong_FromSize_t(count);
|
2016-03-13 14:03:13 +01:00
|
|
|
}
|
2015-09-27 16:50:43 +02:00
|
|
|
if (strcmp(name, "path") == 0) {
|
|
|
|
|
AwareMind* awareMind = dynamic_cast<AwareMind*>(self->m_entity.m);
|
|
|
|
|
if (!awareMind) {
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2015-09-27 16:50:43 +02:00
|
|
|
}
|
|
|
|
|
const auto& path = awareMind->getSteering().getPath();
|
|
|
|
|
PyObject * list = PyList_New(0);
|
2018-01-30 16:54:49 +01:00
|
|
|
if (list == nullptr) {
|
|
|
|
|
return nullptr;
|
2015-09-27 16:50:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& point : path) {
|
|
|
|
|
auto py_point = newPyPoint3D();
|
|
|
|
|
py_point->coords = point;
|
|
|
|
|
|
|
|
|
|
PyList_Append(list, (PyObject*)py_point);
|
|
|
|
|
Py_DECREF(py_point);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-13 23:24:01 +01:00
|
|
|
if (strcmp(name, "pathResult") == 0) {
|
|
|
|
|
AwareMind* awareMind = dynamic_cast<AwareMind*>(self->m_entity.m);
|
|
|
|
|
if (!awareMind) {
|
2018-01-30 16:54:49 +01:00
|
|
|
return nullptr;
|
2016-03-13 23:24:01 +01:00
|
|
|
}
|
|
|
|
|
|
2018-05-02 11:57:10 +02:00
|
|
|
return PyLong_FromLong(awareMind->getSteering().getPathResult());
|
2016-03-13 23:24:01 +01:00
|
|
|
}
|
|
|
|
|
|
2018-05-12 00:42:43 +02:00
|
|
|
return LocatedEntity_getattro(self, oname);
|
2011-11-07 19:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int Mind_setattro(PyEntity *self, PyObject *oname, PyObject *v)
|
|
|
|
|
{
|
2018-05-02 11:57:10 +02:00
|
|
|
char * name = PyUnicode_AsUTF8(oname);
|
2011-11-07 19:16:50 +00:00
|
|
|
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
|
2018-01-30 16:54:49 +01:00
|
|
|
if (self->m_entity.m == nullptr) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "nullptr mind in Mind.setattr");
|
2011-11-07 19:16:50 +00:00
|
|
|
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;
|
|
|
|
|
}
|
2015-09-25 21:25:04 +02:00
|
|
|
|
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_init(PyEntity * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2018-01-30 16:54:49 +01:00
|
|
|
char * id = nullptr;
|
2011-11-07 19:16:50 +00:00
|
|
|
|
|
|
|
|
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 = {
|
2018-05-02 11:57:10 +02:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
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 */
|
2018-05-12 00:42:43 +02:00
|
|
|
(destructor)LocatedEntity_dealloc, /*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*/
|
2018-05-02 11:57:10 +02:00
|
|
|
0, /*tp_compare*/
|
2009-05-25 04:06:31 +01:00
|
|
|
0, /*tp_repr*/
|
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
|
0, /*tp_hash*/
|
|
|
|
|
0, // tp_call
|
|
|
|
|
0, // tp_str
|
2018-05-12 00:42:43 +02:00
|
|
|
(getattrofunc)LocatedEntity_getattro, // tp_getattro
|
|
|
|
|
(setattrofunc)LocatedEntity_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
|
2018-05-12 00:42:43 +02:00
|
|
|
(richcmpfunc)LocatedEntity_compare, // 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
|
2018-05-04 19:17:55 +02:00
|
|
|
PyType_GenericAlloc, // tp_alloc
|
2018-05-12 00:42:43 +02:00
|
|
|
(newfunc)LocatedEntity_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 = {
|
2018-05-02 11:57:10 +02:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
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*/
|
2018-05-02 11:57:10 +02:00
|
|
|
0, /*tp_compare*/
|
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_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
|
2018-05-12 00:42:43 +02:00
|
|
|
(richcmpfunc)LocatedEntity_compare, // 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
|
2018-05-04 19:17:55 +02:00
|
|
|
PyType_GenericAlloc, // tp_alloc
|
2018-05-12 00:42:43 +02:00
|
|
|
(newfunc)LocatedEntity_new, // tp_new
|
2000-11-17 00:18:32 +00:00
|
|
|
};
|
|
|
|
|
|
2009-05-25 04:06:31 +01:00
|
|
|
PyTypeObject PyCharacter_Type = {
|
2018-05-02 11:57:10 +02:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
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*/
|
2018-05-02 11:57:10 +02:00
|
|
|
0, /*tp_compare*/
|
2009-05-25 04:06:31 +01:00
|
|
|
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
|
2018-05-12 00:42:43 +02:00
|
|
|
(richcmpfunc)LocatedEntity_compare, // 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
|
2018-05-04 19:17:55 +02:00
|
|
|
PyType_GenericAlloc, // tp_alloc
|
2018-05-12 00:42:43 +02:00
|
|
|
(newfunc)LocatedEntity_new, // tp_new
|
2009-05-25 04:06:31 +01:00
|
|
|
};
|
|
|
|
|
|
2011-11-07 19:16:50 +00:00
|
|
|
PyTypeObject PyMind_Type = {
|
2018-05-02 11:57:10 +02:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
2011-11-07 19:16:50 +00:00
|
|
|
"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
|
2018-05-02 11:57:10 +02:00
|
|
|
0, // tp_compare
|
2011-11-07 19:16:50 +00:00
|
|
|
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
|
2018-05-12 00:42:43 +02:00
|
|
|
(richcmpfunc)LocatedEntity_compare, // tp_richcompare
|
2011-11-07 19:16:50 +00:00
|
|
|
0, // tp_weaklistoffset
|
|
|
|
|
0, // tp_iter
|
|
|
|
|
0, // tp_iternext
|
2016-03-08 23:28:05 +01:00
|
|
|
Mind_methods, // 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
|
2018-05-04 19:17:55 +02:00
|
|
|
PyType_GenericAlloc, // tp_alloc
|
2018-05-12 00:42:43 +02:00
|
|
|
(newfunc)LocatedEntity_new, // tp_new
|
2011-11-07 19:16:50 +00:00
|
|
|
};
|
|
|
|
|
|
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();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (pe == nullptr) {
|
|
|
|
|
return nullptr;
|
2011-12-14 00:41:02 +00:00
|
|
|
}
|
|
|
|
|
pe->m_entity.c = ch_entity;
|
|
|
|
|
} else {
|
|
|
|
|
pe = newPyEntity();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (pe == nullptr) {
|
|
|
|
|
return nullptr;
|
2011-12-14 00:41:02 +00:00
|
|
|
}
|
|
|
|
|
pe->m_entity.e = entity;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
pe = newPyLocatedEntity();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (pe == nullptr) {
|
|
|
|
|
return nullptr;
|
2011-12-14 00:41:02 +00:00
|
|
|
}
|
|
|
|
|
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();
|
2018-01-30 16:54:49 +01:00
|
|
|
if (pm == nullptr) {
|
|
|
|
|
return nullptr;
|
2011-12-15 13:19:41 +00:00
|
|
|
}
|
|
|
|
|
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();
|
2018-01-30 16:54:49 +01:00
|
|
|
assert(wrapper != nullptr);
|
2011-10-13 14:20:46 +01:00
|
|
|
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);
|
|
|
|
|
}
|