2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2005-05-14 23:02:02 +00:00
|
|
|
// Copyright (C) 2000-2005 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-01-26 16:38:23 +00:00
|
|
|
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2004-11-20 10:28:24 +00:00
|
|
|
#include "Python.h"
|
|
|
|
|
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Location.h, rulesets/Py_Map.cpp,
rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h,
rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h,
rulesets/Py_Optime.cpp, rulesets/Py_Optime.h,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h,
rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
#include "Python_API.h"
|
2005-05-14 23:02:02 +00:00
|
|
|
#include "Python_Script_Utils.h"
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2001-04-10 19:05:14 +00:00
|
|
|
#include "BaseMind.h"
|
2000-11-21 19:24:29 +00:00
|
|
|
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/globals.h"
|
|
|
|
|
#include "common/const.h"
|
|
|
|
|
#include "common/debug.h"
|
2000-11-14 15:52:10 +00:00
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
#include <Atlas/Objects/Operation.h>
|
2005-09-11 17:48:26 +00:00
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
2018-04-30 23:34:58 +02:00
|
|
|
#include <common/AssetsManager.h>
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
2018-05-10 01:15:35 +02:00
|
|
|
#include <boost/asio/steady_timer.hpp>
|
2018-07-21 13:57:30 +02:00
|
|
|
#include <rulesets/python/CyPy_EntityFilter.h>
|
|
|
|
|
#include <rulesets/python/CyPy_Common.h>
|
|
|
|
|
#include <rulesets/python/CyPy_Atlas.h>
|
|
|
|
|
#include <rulesets/python/CyPy_Physics.h>
|
2018-07-22 19:47:35 +02:00
|
|
|
#include <rulesets/python/CyPy_Server.h>
|
2018-07-23 11:00:54 +02:00
|
|
|
#include <rulesets/python/WrapperBase.h>
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
using Atlas::Message::Element;
|
2005-08-27 14:52:12 +00:00
|
|
|
using Atlas::Objects::Root;
|
|
|
|
|
using Atlas::Objects::Operation::RootOperation;
|
2005-09-11 17:48:26 +00:00
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
2006-12-22 Al Riddoch <alriddoch@zepler.org>
* server/CommClient.h, server/CommListener.h, server/CommLocalClient.h,
server/CommMDNSPublisher.h, server/CommMaster.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommPeer.h, server/CommPeerListener.h,
server/CommRemoteClient.h, server/CommServer.h,
server/CommSlaveClient.h, server/CommSlaveListener.h,
server/CommSocket.cpp, server/CommSocket.h,
server/CommUnixListener.h: Add a documentation group for socket
classes.
* rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.h, rulesets/Py_Map.h, rulesets/Py_Mind.h,
rulesets/Py_Object.h, rulesets/Py_Operation.h,
rulesets/Py_Oplist.h, rulesets/Py_Optime.h, rulesets/Py_Point3D.h,
rulesets/Py_Property.h, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.h, rulesets/Py_Task.h, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.h, rulesets/Py_World.h, rulesets/Py_WorldTime.h,
rulesets/Python_API.cpp: Add documentation group for Python wrapper
types.
* rulesets/Container.h, rulesets/PythonScript.cpp,
server/ScriptFactory.h, server/ScriptFactory.cpp:
Add more inline documentation comments.
2006-12-22 02:14:44 +00:00
|
|
|
/// \defgroup PythonWrappers Python Wrapper Types
|
|
|
|
|
///
|
|
|
|
|
/// Structure types based on the PyObject header used to wrap C++ objects
|
|
|
|
|
/// in Python.
|
|
|
|
|
|
2006-10-20 14:26:19 +00:00
|
|
|
|
2003-08-30 11:41:58 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Logger replaces sys.stdout and sys.stderr so the nothing goes to output
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
|
2009-06-04 12:47:53 +01:00
|
|
|
/// \brief Python type to handle output from python scripts
|
2004-12-27 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.h, client/CharacterClient.h,
client/ClientConnection.h, client/CreatorClient.h,
client/ObserverClient.h, client/Py_CreatorClient.h,
common/Burn.h, common/Chop.h, common/Cut.h, common/Database.h,
common/Eat.h, common/Generic.h, common/Nourish.h, common/Setup.h,
common/Tick.h, common/Unseen.h, common/Use.h, common/Wield.h,
common/accountbase.h, common/inheritance.h, rulesets/Container.h,
rulesets/Creator.h, rulesets/LineProperty.h, rulesets/MemMap.h,
rulesets/MindFactory.h, rulesets/Movement.h, rulesets/Pedestrian.h,
rulesets/Py_BBox.h, rulesets/Py_Location.h, rulesets/Py_Map.h,
rulesets/Py_Mind.h, rulesets/Py_Object.h, rulesets/Py_Operation.h,
rulesets/Py_Oplist.h, rulesets/Py_Optime.h, rulesets/Py_Point3D.h,
rulesets/Py_Quaternion.h, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.h, rulesets/Py_World.h, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/TerrainProperty.h, rulesets/ThingFactory.h, server/Admin.h,
server/EntityFactory.h, server/Master.h, server/Peer.h,
server/Persistance.h, server/PersistantThingFactory.h,
server/Persistor.h, server/Player.h, server/Restoration.h,
server/Restorer.h, server/TrustedConnection.h: Make sure all
classes have up updated description in the comments.
2004-12-27 03:06:54 +00:00
|
|
|
///
|
2009-06-04 12:47:53 +01:00
|
|
|
/// In instance of this type is used to replace sys.stdout and sys.stderr
|
2004-12-27 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.h, client/CharacterClient.h,
client/ClientConnection.h, client/CreatorClient.h,
client/ObserverClient.h, client/Py_CreatorClient.h,
common/Burn.h, common/Chop.h, common/Cut.h, common/Database.h,
common/Eat.h, common/Generic.h, common/Nourish.h, common/Setup.h,
common/Tick.h, common/Unseen.h, common/Use.h, common/Wield.h,
common/accountbase.h, common/inheritance.h, rulesets/Container.h,
rulesets/Creator.h, rulesets/LineProperty.h, rulesets/MemMap.h,
rulesets/MindFactory.h, rulesets/Movement.h, rulesets/Pedestrian.h,
rulesets/Py_BBox.h, rulesets/Py_Location.h, rulesets/Py_Map.h,
rulesets/Py_Mind.h, rulesets/Py_Object.h, rulesets/Py_Operation.h,
rulesets/Py_Oplist.h, rulesets/Py_Optime.h, rulesets/Py_Point3D.h,
rulesets/Py_Quaternion.h, rulesets/Py_Thing.h,
rulesets/Py_Vector3D.h, rulesets/Py_World.h, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/TerrainProperty.h, rulesets/ThingFactory.h, server/Admin.h,
server/EntityFactory.h, server/Master.h, server/Peer.h,
server/Persistance.h, server/PersistantThingFactory.h,
server/Persistor.h, server/Player.h, server/Restoration.h,
server/Restorer.h, server/TrustedConnection.h: Make sure all
classes have up updated description in the comments.
2004-12-27 03:06:54 +00:00
|
|
|
/// in the Python interpreter so that all script output goes to the cyphesis
|
|
|
|
|
/// log subsystem
|
2018-07-23 11:00:54 +02:00
|
|
|
struct LogWriter : public WrapperBase<LogLevel, LogWriter>
|
2004-10-04 23:08:26 +00:00
|
|
|
{
|
2018-07-23 16:43:39 +02:00
|
|
|
std::string m_message;
|
2018-07-23 11:00:54 +02:00
|
|
|
LogWriter(Py::PythonClassInstance* self, Py::Tuple& args, Py::Dict& kwds)
|
|
|
|
|
: WrapperBase(self, args, kwds)
|
|
|
|
|
{
|
|
|
|
|
|
2004-10-04 23:08:26 +00:00
|
|
|
}
|
2018-07-23 11:00:54 +02:00
|
|
|
|
|
|
|
|
LogWriter(Py::PythonClassInstance* self, LogLevel value)
|
|
|
|
|
: WrapperBase(self, value)
|
|
|
|
|
{
|
|
|
|
|
|
2004-10-04 23:08:26 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-23 16:43:39 +02:00
|
|
|
void python_log(LogLevel lvl, const std::string& msg)
|
2018-07-23 11:00:54 +02:00
|
|
|
{
|
2018-07-23 16:43:39 +02:00
|
|
|
|
|
|
|
|
m_message += msg;
|
2018-07-23 11:00:54 +02:00
|
|
|
std::string::size_type n = 0;
|
|
|
|
|
std::string::size_type p;
|
2018-07-23 16:43:39 +02:00
|
|
|
for (p = m_message.find_first_of('\n');
|
2018-07-23 11:00:54 +02:00
|
|
|
p != std::string::npos;
|
2018-07-23 16:43:39 +02:00
|
|
|
p = m_message.find_first_of('\n', n)) {
|
|
|
|
|
log(lvl, m_message.substr(n, p - n));
|
2018-07-23 11:00:54 +02:00
|
|
|
n = p + 1;
|
|
|
|
|
}
|
2018-07-23 16:43:39 +02:00
|
|
|
if (m_message.size() > n) {
|
|
|
|
|
m_message = m_message.substr(n, m_message.size() - n);
|
2018-07-23 11:00:54 +02:00
|
|
|
} else {
|
2018-07-23 16:43:39 +02:00
|
|
|
m_message.clear();
|
2018-07-23 11:00:54 +02:00
|
|
|
}
|
2018-07-23 16:43:39 +02:00
|
|
|
|
2003-08-30 11:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
Py::Object write(const Py::Tuple& args)
|
|
|
|
|
{
|
2018-07-24 21:18:26 +02:00
|
|
|
if (args.length() > 0) {
|
2018-07-23 16:43:39 +02:00
|
|
|
python_log(m_value, verifyString(args.front()));
|
|
|
|
|
}
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
return Py::None();
|
2003-08-30 11:41:58 +00:00
|
|
|
}
|
2018-07-23 11:00:54 +02:00
|
|
|
PYCXX_VARARGS_METHOD_DECL(LogWriter, write)
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
Py::Object flush()
|
|
|
|
|
{
|
|
|
|
|
return Py::None();
|
|
|
|
|
}
|
|
|
|
|
PYCXX_NOARGS_METHOD_DECL(LogWriter, flush)
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
static void init_type() {
|
|
|
|
|
behaviors().name("LogWriter");
|
|
|
|
|
behaviors().doc("");
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
PYCXX_ADD_NOARGS_METHOD(flush, flush, "");
|
|
|
|
|
PYCXX_ADD_VARARGS_METHOD(write, write, "");
|
2003-08-30 11:41:58 +00:00
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
behaviors().readyType();
|
|
|
|
|
}
|
2003-08-30 11:41:58 +00:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2011-12-19 09:01:40 +00:00
|
|
|
/// \brief Find a class in a Python module
|
|
|
|
|
///
|
|
|
|
|
/// @param module the imported Python module
|
|
|
|
|
/// @param package the name of the module for error reporting
|
|
|
|
|
/// @param type the name of the class or type
|
|
|
|
|
/// @return new reference
|
2018-07-24 21:18:26 +02:00
|
|
|
Py::Object Get_PyClass(const Py::Module& module,
|
2009-07-02 17:23:02 +01:00
|
|
|
const std::string & package,
|
|
|
|
|
const std::string & type)
|
2000-11-19 00:02:29 +00:00
|
|
|
{
|
2018-07-23 16:43:39 +02:00
|
|
|
auto py_class = module.getAttr(type);
|
|
|
|
|
if (py_class.isNull()) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Could not find python class \"%1.%2\"",
|
2009-06-30 17:53:00 +01:00
|
|
|
package, type));
|
2000-12-11 13:06:12 +00:00
|
|
|
PyErr_Print();
|
2018-07-23 16:43:39 +02:00
|
|
|
return Py::Null();
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
2018-07-23 16:43:39 +02:00
|
|
|
if (!py_class.isCallable()) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Could not instance python class \"%1.%2\"",
|
2009-06-30 17:53:00 +01:00
|
|
|
package, type));
|
2018-07-23 16:43:39 +02:00
|
|
|
return Py::Null();
|
2003-08-30 11:41:58 +00:00
|
|
|
}
|
2018-07-24 21:18:26 +02:00
|
|
|
return py_class;
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-19 09:01:40 +00:00
|
|
|
/// \brief Import a Python module
|
|
|
|
|
///
|
|
|
|
|
/// @param package the name of the module
|
|
|
|
|
/// @return new reference
|
2018-07-23 16:43:39 +02:00
|
|
|
Py::Module Get_PyModule(const std::string & package)
|
2009-07-02 18:06:40 +01:00
|
|
|
{
|
2018-07-23 16:43:39 +02:00
|
|
|
Py::String package_name(package);
|
|
|
|
|
PyObject * module = PyImport_Import(package_name.ptr());
|
2018-01-30 16:54:49 +01:00
|
|
|
if (module == nullptr) {
|
2009-07-02 18:06:40 +01:00
|
|
|
log(ERROR, String::compose("Missing python module \"%1\"", package));
|
|
|
|
|
PyErr_Print();
|
2018-07-24 21:18:26 +02:00
|
|
|
return Py::Module(nullptr);
|
2009-07-02 18:06:40 +01:00
|
|
|
}
|
2018-07-23 16:43:39 +02:00
|
|
|
return Py::Module(module);
|
2009-07-02 18:06:40 +01:00
|
|
|
}
|
|
|
|
|
|
2018-07-23 16:43:39 +02:00
|
|
|
Py::Object Create_PyScript(const Py::Object& wrapper, const Py::Callable& py_class)
|
* Renamed Operataion method names throughout so they no longer
all have the name Operation but are now called MoveOperation,
according to the type of operation they handle.
* modules/DateTime.cpp, modules/DataTime.h: Filled in functionality,
allowing initialisation and updating from a time values in seconds.
* modules/Location.h: Modified collision detection code so no
checking is done between two moving objects.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp, rulesets/Entity.h,
rulesets/Entity.cpp: Removed virtual getMap() method and replaced
with a fixed method in BaseMind only. Added time member veriable
to BaseMind so each mind keeps track of time by itself.
* rulesets/Python_API.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h:
Added specific python interface for mind objects, because if
increasing differences in the way this must be handled.
* rulesets/Character.h, rulesets/Character.cpp: Added isAlive flag
which is cleared if the character is dead. If this flag is cleared,
operations are no longer sent to the mind.
* rulesets/Movement.h, rulesets/Movement.cpp, rulesets/Pedestrian.h,
rulesets/Pedestrian.cpp: Cleaned up the code, made members more
distinctive, and make interface more general.
* rulesets/Py_Thing.cpp: Removed features used to support mind.
* rulesets/Py_WorldTime.cpp: Added support for comparison of
time with strings, to establish whether it matches descriptions
of time.
* rulesets/Python_API.cpp: Modified creating of scripts so mind
scripts use a slightly different interface from entity scripts,
to support the fact that a mind handles its own timekeeping,
has a memory map, and has no access to the world.
* server/WorldTime.cpp, server/WorldTime.h: Brought WorldTime into
the build. Used to track details of the time. Added support for
checking time descriptions such as "midday", "summer" against
DateTime.
Al Riddoch <alriddoch@zepler.org>
2001-05-28 14:58:24 +00:00
|
|
|
{
|
2018-07-24 21:18:26 +02:00
|
|
|
try {
|
|
|
|
|
return py_class.apply(Py::TupleN(wrapper));
|
|
|
|
|
} catch (...) {
|
2018-01-30 16:54:49 +01:00
|
|
|
if (PyErr_Occurred() == nullptr) {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, "Could not create python instance");
|
2000-11-19 00:02:29 +00:00
|
|
|
} else {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, "Reporting python error");
|
2000-11-19 00:02:29 +00:00
|
|
|
PyErr_Print();
|
|
|
|
|
}
|
2018-07-24 21:18:26 +02:00
|
|
|
return Py::None();
|
2000-11-19 00:02:29 +00:00
|
|
|
}
|
2001-04-10 19:05:14 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-30 23:34:58 +02:00
|
|
|
sigc::signal<void> python_reload_scripts;
|
2018-05-10 01:15:35 +02:00
|
|
|
std::vector<std::string> python_directories;
|
|
|
|
|
|
|
|
|
|
std::map<boost::filesystem::path, std::string> changedPaths;
|
|
|
|
|
|
|
|
|
|
void reloadChangedPaths() {
|
|
|
|
|
if (!changedPaths.empty()) {
|
|
|
|
|
|
|
|
|
|
for (auto& entry : changedPaths) {
|
|
|
|
|
auto& package = entry.second;
|
|
|
|
|
auto& path = entry.first;
|
|
|
|
|
auto module = Get_PyModule(package);
|
2018-07-23 16:43:39 +02:00
|
|
|
if (module.isNull()) {
|
2018-05-10 01:15:35 +02:00
|
|
|
log(INFO, String::compose("Reloading module \"%1\" from file %2.", package, path));
|
2018-07-23 16:43:39 +02:00
|
|
|
auto result = PyImport_ReloadModule(module.ptr());
|
|
|
|
|
if (result != module.ptr()) {
|
2018-05-10 01:15:35 +02:00
|
|
|
log(WARNING, String::compose("New pointer returned when reloading module \"%1\".", package));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2018-04-30 23:34:58 +02:00
|
|
|
|
2018-05-10 01:15:35 +02:00
|
|
|
}
|
|
|
|
|
python_reload_scripts();
|
|
|
|
|
changedPaths.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void observe_python_directories(boost::asio::io_service& io_service, AssetsManager& assetsManager) {
|
|
|
|
|
|
|
|
|
|
for (auto& directory : python_directories) {
|
|
|
|
|
AssetsManager::instance().observeDirectory(directory, [=, &io_service](const boost::filesystem::path& path) {
|
|
|
|
|
//Trim the ".py" extension
|
2018-04-30 23:34:58 +02:00
|
|
|
if (boost::ends_with(path.string(), ".py")) {
|
|
|
|
|
auto relative = path.string().substr(directory.length() + 1);
|
|
|
|
|
relative = relative.substr(0, relative.size() - 3);
|
2018-05-01 17:12:14 +02:00
|
|
|
static char separator[] = {boost::filesystem::path::preferred_separator, 0};
|
2018-04-30 23:34:58 +02:00
|
|
|
auto package = boost::replace_all_copy(relative, separator, ".");
|
2018-05-10 01:15:35 +02:00
|
|
|
changedPaths[path] = package;
|
2018-04-30 23:34:58 +02:00
|
|
|
|
2018-05-10 01:15:35 +02:00
|
|
|
auto timer = std::make_shared<boost::asio::steady_timer>(io_service);
|
|
|
|
|
timer->expires_from_now(std::chrono::milliseconds(20));
|
|
|
|
|
timer->async_wait([&, timer](const boost::system::error_code& ec) {
|
|
|
|
|
if (!ec) {
|
|
|
|
|
reloadChangedPaths();
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-04-30 23:34:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-02 15:27:55 +02:00
|
|
|
|
2018-07-22 19:47:35 +02:00
|
|
|
CyPy_Server* server;
|
|
|
|
|
|
|
|
|
|
void register_baseworld_with_python(BaseWorld* baseWorld)
|
|
|
|
|
{
|
|
|
|
|
server->registerWorld(baseWorld);
|
|
|
|
|
}
|
2018-05-02 15:27:55 +02:00
|
|
|
|
2018-05-04 19:17:55 +02:00
|
|
|
void init_python_api(const std::string & ruleset, bool log_stdout)
|
2018-05-02 15:27:55 +02:00
|
|
|
{
|
|
|
|
|
|
2018-07-21 13:57:30 +02:00
|
|
|
PyImport_AppendInittab("entity_filter", [](){
|
|
|
|
|
static auto module = new CyPy_EntityFilter();
|
|
|
|
|
return module->module().ptr();
|
|
|
|
|
});
|
|
|
|
|
PyImport_AppendInittab("atlas", [](){
|
|
|
|
|
static auto module = new CyPy_Atlas();
|
|
|
|
|
return module->module().ptr();
|
|
|
|
|
});
|
|
|
|
|
PyImport_AppendInittab("physics", [](){
|
|
|
|
|
static auto module = new CyPy_Physics();
|
|
|
|
|
return module->module().ptr();
|
|
|
|
|
});
|
|
|
|
|
PyImport_AppendInittab("common", [](){
|
|
|
|
|
static auto module = new CyPy_Common();
|
|
|
|
|
return module->module().ptr();
|
|
|
|
|
});
|
2018-07-22 19:47:35 +02:00
|
|
|
PyImport_AppendInittab("server", [](){
|
|
|
|
|
server = new CyPy_Server();
|
|
|
|
|
return server->module().ptr();
|
|
|
|
|
});
|
2018-05-02 15:27:55 +02:00
|
|
|
|
|
|
|
|
Py_InitializeEx(0);
|
|
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
//Make sure that all modules are imported, since this is needed to initialize all types.
|
|
|
|
|
//Otherwise we risk that we try to invoke the types from the C++ code before they have
|
|
|
|
|
//been populated.
|
|
|
|
|
PyImport_ImportModule("atlas");
|
|
|
|
|
PyImport_ImportModule("common");
|
|
|
|
|
PyImport_ImportModule("physics");
|
|
|
|
|
PyImport_ImportModule("entity_filter");
|
|
|
|
|
PyImport_ImportModule("server");
|
2018-07-23 16:43:39 +02:00
|
|
|
PyImport_ImportModule("sys");
|
2010-09-18 19:59:40 +01:00
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
Py::Module sys_module(PyImport_Import(Py::String("sys").ptr()));
|
2018-05-02 15:27:55 +02:00
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
if (sys_module.isNull()) {
|
2018-05-02 15:27:55 +02:00
|
|
|
log(CRITICAL, "Python could not import sys module");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (log_stdout) {
|
2018-07-23 11:00:54 +02:00
|
|
|
LogWriter::init_type();
|
|
|
|
|
sys_module.setAttr("stdout", LogWriter::wrap(SCRIPT));
|
|
|
|
|
sys_module.setAttr("stderr", LogWriter::wrap(SCRIPT_ERROR));
|
2018-05-02 15:27:55 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
auto sys_path = sys_module.getAttr("path");
|
|
|
|
|
if (!sys_path.isNull()) {
|
|
|
|
|
if (sys_path.isList()) {
|
|
|
|
|
Py::List paths(sys_path);
|
2018-05-02 15:27:55 +02:00
|
|
|
|
2018-07-23 11:00:54 +02:00
|
|
|
// Add the path to the non-ruleset specific code.
|
|
|
|
|
python_directories.push_back(share_directory + "/cyphesis/scripts");
|
|
|
|
|
python_directories.push_back(share_directory + "/cyphesis/rulesets/basic/scripts");
|
2018-05-02 15:27:55 +02:00
|
|
|
// Add the path to the ruleset specific code.
|
2018-07-23 11:00:54 +02:00
|
|
|
python_directories.push_back(share_directory + "/cyphesis/rulesets/" + ruleset + "/scripts");
|
|
|
|
|
|
|
|
|
|
for (auto& path : python_directories) {
|
|
|
|
|
paths.append(Py::String(path));
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-02 15:27:55 +02:00
|
|
|
} else {
|
|
|
|
|
log(CRITICAL, "Python sys.path is not a list");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log(CRITICAL, "Python could not import sys.path");
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-15 18:06:59 +00:00
|
|
|
debug(std::cout << Py_GetPath() << std::endl << std::flush;);
|
2001-10-08 23:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void shutdown_python_api()
|
|
|
|
|
{
|
2018-07-21 13:57:30 +02:00
|
|
|
|
2018-05-14 23:41:54 +02:00
|
|
|
Py_Finalize();
|
2000-11-14 15:52:10 +00:00
|
|
|
}
|