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-12-03 03:07:30 +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
|
2005-12-03 03:07:30 +00:00
|
|
|
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2005-12-03 03:07:30 +00:00
|
|
|
#include "Py_Task.h"
|
|
|
|
|
|
2009-07-28 19:49:37 +01:00
|
|
|
#include "Py_Message.h"
|
2006-05-08 13:49:27 +00:00
|
|
|
#include "Py_Operation.h"
|
2009-07-28 19:49:37 +01:00
|
|
|
#include "Py_Thing.h"
|
2006-05-24 20:29:32 +00:00
|
|
|
#include "PythonWrapper.h"
|
2005-12-03 03:07:30 +00:00
|
|
|
|
2011-11-03 22:57:46 +00:00
|
|
|
#include "Task.h"
|
2005-12-14 15:07:21 +00:00
|
|
|
#include "Character.h"
|
2005-12-03 03:07:30 +00: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 PyObject * Task_irrelevant(PyTask * self)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_task == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL task in Task.irrelevant");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
self->m_task->irrelevant();
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject * Task_obsolete(PyTask * self)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_task == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL task in Task.irrelevant");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
PyObject * ret = self->m_task->obsolete() ? Py_True : Py_False;
|
|
|
|
|
Py_INCREF(ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-15 09:55:22 +00:00
|
|
|
static PyObject * Task_count(PyTask * self)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_task == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL task in Task.irrelevant");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
return PyInt_FromLong(self->m_task->count());
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-27 17:04:09 +00:00
|
|
|
static PyObject * Task_newtick(PyTask * self)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_task == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL task in Task.irrelevant");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
return PyInt_FromLong(self->m_task->newTick());
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-08 13:49:27 +00:00
|
|
|
static PyObject * Task_nexttick(PyTask * self, PyObject * arg)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_task == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL task in Task.irrelevant");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
double interval;
|
|
|
|
|
if (PyFloat_Check(arg)) {
|
|
|
|
|
interval = PyFloat_AsDouble(arg);
|
|
|
|
|
} else if (PyInt_Check(arg)) {
|
|
|
|
|
interval = PyInt_AsLong(arg);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Interval must be a number");
|
2006-05-09 10:19:33 +00:00
|
|
|
return NULL;
|
2006-05-08 13:49:27 +00:00
|
|
|
}
|
|
|
|
|
PyOperation * tick_op = newPyOperation();
|
|
|
|
|
if (tick_op != 0) {
|
|
|
|
|
tick_op->operation = self->m_task->nextTick(interval);
|
|
|
|
|
}
|
|
|
|
|
return (PyObject*)tick_op;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-03 03:07:30 +00:00
|
|
|
static PyMethodDef Task_methods[] = {
|
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
|
|
|
{"irrelevant", (PyCFunction)Task_irrelevant, METH_NOARGS},
|
|
|
|
|
{"obsolete", (PyCFunction)Task_obsolete, METH_NOARGS},
|
2006-04-15 09:55:22 +00:00
|
|
|
{"count", (PyCFunction)Task_count, METH_NOARGS},
|
2006-04-27 17:04:09 +00:00
|
|
|
{"new_tick", (PyCFunction)Task_newtick, METH_NOARGS},
|
2006-05-08 13:49:27 +00:00
|
|
|
{"next_tick", (PyCFunction)Task_nexttick, METH_O},
|
2005-12-03 03:07:30 +00:00
|
|
|
{NULL, NULL} /* sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
2009-06-16 01:35:19 +01:00
|
|
|
static PyObject * Task_getattro(PyTask *self, PyObject *oname)
|
2005-12-03 03:07:30 +00:00
|
|
|
{
|
|
|
|
|
// Fairly major re-write of this to use operator[] of Task base class
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_task == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL task Task.getattr");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
2009-06-16 01:35:19 +01:00
|
|
|
char * name = PyString_AsString(oname);
|
2005-12-14 15:07:21 +00:00
|
|
|
if (strcmp(name, "character") == 0) {
|
2011-12-02 23:10:41 +00:00
|
|
|
return wrapEntity(&self->m_task->owner());
|
2005-12-14 15:07:21 +00:00
|
|
|
}
|
2006-06-20 22:33:12 +00:00
|
|
|
if (strcmp(name, "progress") == 0) {
|
|
|
|
|
return PyFloat_FromDouble(self->m_task->progress());
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(name, "rate") == 0) {
|
|
|
|
|
return PyFloat_FromDouble(self->m_task->rate());
|
|
|
|
|
}
|
2009-07-28 19:49:37 +01:00
|
|
|
Atlas::Message::Element val;
|
2011-09-29 17:47:08 +01:00
|
|
|
if (self->m_task->getAttr(name, val) == 0) {
|
2009-07-28 19:49:37 +01:00
|
|
|
return MessageElement_asPyObject(val);
|
|
|
|
|
}
|
2009-07-03 02:04:15 +01:00
|
|
|
return PyObject_GenericGetAttr((PyObject *)self, oname);
|
2005-12-03 03:07:30 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-16 01:35:19 +01:00
|
|
|
static int Task_setattro(PyTask *self, PyObject * oname, PyObject *v)
|
2005-12-03 03:07:30 +00:00
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
if (self->m_task == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL task Task.setattr");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
2009-06-16 01:35:19 +01:00
|
|
|
char * name = PyString_AsString(oname);
|
2006-04-29 20:41:50 +00:00
|
|
|
if (strcmp(name, "progress") == 0) {
|
2006-06-20 18:06:50 +00:00
|
|
|
if (PyFloat_Check(v)) {
|
|
|
|
|
self->m_task->progress() = PyFloat_AsDouble(v);
|
|
|
|
|
} else if (PyInt_Check(v)) {
|
|
|
|
|
self->m_task->progress() = PyInt_AsLong(v);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "progress must be a number");
|
2006-04-29 20:41:50 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2006-05-08 13:49:27 +00:00
|
|
|
return 0;
|
2006-04-29 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
if (strcmp(name, "rate") == 0) {
|
2006-05-08 13:49:27 +00:00
|
|
|
double rate;
|
|
|
|
|
if (PyFloat_Check(v)) {
|
|
|
|
|
rate = PyFloat_AsDouble(v);
|
|
|
|
|
} else if (PyInt_Check(v)) {
|
|
|
|
|
rate = PyInt_AsLong(v);
|
|
|
|
|
} else {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "rate must be a number");
|
2006-04-29 20:41:50 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2006-05-08 13:49:27 +00:00
|
|
|
self->m_task->rate() = rate;
|
|
|
|
|
return 0;
|
2006-04-29 20:41:50 +00:00
|
|
|
}
|
2011-10-18 14:02:31 +01:00
|
|
|
if (PyWeakref_CheckProxy(v)) {
|
|
|
|
|
PyErr_SetString(PyExc_TypeError, "don't store proxy objects as attributes");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2011-12-13 19:39:09 +00:00
|
|
|
if (PyLocatedEntity_Check(v)) {
|
2011-10-19 13:11:29 +01:00
|
|
|
PyErr_SetString(PyExc_TypeError, "don't store server objects as attributes");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2005-12-03 03:07:30 +00:00
|
|
|
// FIXME Something may be required here long term, for task attributes.
|
2011-12-27 07:14:32 +00:00
|
|
|
return PyObject_GenericSetAttr((PyObject*)self, oname, v);
|
2005-12-03 03:07:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int Task_compare(PyTask *self, PyTask *other)
|
|
|
|
|
{
|
2009-06-03 20:47:15 +01:00
|
|
|
#ifndef NDEBUG
|
2007-07-30 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, common/Database.cpp,
common/accountbase.cpp, common/system.cpp, rulesets/Character.cpp,
rulesets/Motion.cpp, rulesets/Plant.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Mind.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Point3D.cpp, rulesets/Py_Statistics.cpp,
rulesets/Py_Task.cpp, rulesets/Py_TerrainProperty.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Py_WorldTime.cpp, rulesets/Python_API.cpp,
rulesets/TerrainProperty.cpp, server/Admin.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cyctrl.cpp:
Remove unnecessary () from conditional expressions, where operator
binding is clear.
2007-07-30 18:12:50 +00:00
|
|
|
if (self->m_task == NULL || other->m_task == NULL) {
|
2005-12-04 01:40:42 +00:00
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL Task in Task.compare");
|
2005-12-03 03:07:30 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2009-06-03 20:47:15 +01:00
|
|
|
#endif // NDEBUG
|
2005-12-03 03:07:30 +00:00
|
|
|
return (self->m_task == other->m_task) ? 0 : 1;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-24 16:20:17 +01:00
|
|
|
static int Task_init(PyTask * self, PyObject * args, PyObject * kwds)
|
|
|
|
|
{
|
2009-05-26 15:45:34 +01:00
|
|
|
PyObject * arg;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O", &arg)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-07-01 00:56:43 +01:00
|
|
|
if (PyTask_Check(arg)) {
|
|
|
|
|
PyTask * wrap_task = (PyTask *)arg;
|
2009-05-26 15:45:34 +01:00
|
|
|
#ifndef NDEBUG
|
2009-07-01 00:56:43 +01:00
|
|
|
if (wrap_task->m_task == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL task Task.__init__");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
#endif // NDEBUG
|
|
|
|
|
self->m_task = wrap_task->m_task;
|
|
|
|
|
return 0;
|
2009-05-26 15:45:34 +01:00
|
|
|
}
|
2011-12-14 01:55:01 +00:00
|
|
|
if (PyLocatedEntity_Check(arg)) {
|
|
|
|
|
PyEntity * owner = (PyEntity *)arg;
|
2009-07-01 00:56:43 +01:00
|
|
|
#ifndef NDEBUG
|
2011-12-14 01:55:01 +00:00
|
|
|
if (owner->m_entity.l == NULL) {
|
|
|
|
|
PyErr_SetString(PyExc_AssertionError, "NULL owner Task.__init__");
|
2009-07-01 00:56:43 +01:00
|
|
|
return -1;
|
|
|
|
|
}
|
2009-05-26 15:45:34 +01:00
|
|
|
#endif // NDEBUG
|
2011-12-14 01:55:01 +00:00
|
|
|
self->m_task = new Task(*owner->m_entity.l);
|
2009-07-01 00:56:43 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
2011-12-14 01:55:01 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "Task requires a Task, or Entity");
|
2009-07-01 00:56:43 +01:00
|
|
|
return -1;
|
2009-05-24 16:20:17 +01:00
|
|
|
}
|
|
|
|
|
|
2005-12-03 03:07:30 +00:00
|
|
|
PyTypeObject PyTask_Type = {
|
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
|
0, /*ob_size*/
|
|
|
|
|
"Task", /*tp_name*/
|
|
|
|
|
sizeof(PyTask), /*tp_basicsize*/
|
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
/* methods */
|
2011-12-27 07:18:13 +00:00
|
|
|
0, /*tp_dealloc*/
|
2005-12-03 03:07:30 +00:00
|
|
|
0, /*tp_print*/
|
2009-06-16 01:35:19 +01:00
|
|
|
0, /*tp_getattr*/
|
|
|
|
|
0, /*tp_setattr*/
|
2005-12-03 03:07:30 +00:00
|
|
|
(cmpfunc)Task_compare, /*tp_compare*/
|
|
|
|
|
0, /*tp_repr*/
|
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
|
0, /*tp_hash*/
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_call
|
|
|
|
|
0, // tp_str
|
2009-06-16 01:35:19 +01:00
|
|
|
(getattrofunc)Task_getattro, // tp_getattro
|
|
|
|
|
(setattrofunc)Task_setattro, // tp_setattro
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_as_buffer
|
2009-06-30 22:12:56 +01:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags
|
2009-05-24 16:20:17 +01:00
|
|
|
"Task objects", // tp_doc
|
|
|
|
|
0, // tp_travers
|
|
|
|
|
0, // tp_clear
|
|
|
|
|
0, // tp_richcompare
|
|
|
|
|
0, // tp_weaklistoffset
|
|
|
|
|
0, // tp_iter
|
|
|
|
|
0, // tp_iternext
|
2009-07-03 02:04:15 +01:00
|
|
|
Task_methods, // tp_methods
|
2009-05-24 16:20:17 +01:00
|
|
|
0, // tp_members
|
|
|
|
|
0, // tp_getset
|
|
|
|
|
0, // tp_base
|
|
|
|
|
0, // tp_dict
|
|
|
|
|
0, // tp_descr_get
|
|
|
|
|
0, // tp_descr_set
|
|
|
|
|
0, // tp_dictoffset
|
|
|
|
|
(initproc)Task_init, // tp_init
|
|
|
|
|
0, // tp_alloc
|
2009-06-04 15:29:34 +01:00
|
|
|
0, // tp_new
|
2005-12-03 03:07:30 +00:00
|
|
|
};
|
|
|
|
|
|
2009-11-12 20:53:11 +00:00
|
|
|
#if 0
|
2006-05-24 20:29:32 +00:00
|
|
|
PyObject * wrapTask(Task * task)
|
|
|
|
|
{
|
|
|
|
|
PyObject * wrapper;
|
2011-11-03 22:57:46 +00:00
|
|
|
Task * ts = dynamic_cast<Task *>(task);
|
2006-05-24 20:29:32 +00:00
|
|
|
PythonWrapper * pw;
|
|
|
|
|
if (ts == 0 || ((pw = dynamic_cast<PythonWrapper *>(ts->script())) == 0)) {
|
|
|
|
|
PyTask * pt = newPyTask();
|
2009-07-04 04:46:49 +01:00
|
|
|
if (pt != NULL) {
|
|
|
|
|
pt->m_task = task;
|
|
|
|
|
}
|
2006-05-24 20:29:32 +00:00
|
|
|
wrapper = (PyObject *)pt;
|
|
|
|
|
// This wrapper cannot be stashed back int the task yet so
|
|
|
|
|
// we don't have to do this next time.
|
|
|
|
|
} else {
|
|
|
|
|
wrapper = pw->wrapper();
|
|
|
|
|
assert(wrapper != NULL);
|
|
|
|
|
Py_INCREF(wrapper);
|
|
|
|
|
}
|
|
|
|
|
return wrapper;
|
|
|
|
|
}
|
2009-11-12 20:53:11 +00:00
|
|
|
#endif
|
2006-05-24 20:29:32 +00:00
|
|
|
|
2011-12-14 17:42:56 +00:00
|
|
|
template<>
|
|
|
|
|
PyObject * wrapPython<Task>(Task * t)
|
|
|
|
|
{
|
|
|
|
|
PyTask * pt = newPyTask();
|
|
|
|
|
if (pt == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
pt->m_task = t;
|
2011-12-15 13:02:24 +00:00
|
|
|
return (PyObject*)pt;
|
2011-12-14 17:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-03 03:07:30 +00:00
|
|
|
PyTask * newPyTask()
|
|
|
|
|
{
|
2009-05-24 16:20:17 +01:00
|
|
|
return (PyTask *)PyTask_Type.tp_new(&PyTask_Type, 0, 0);
|
2005-12-03 03:07:30 +00:00
|
|
|
}
|