cyphesis/rulesets/BaseMind.cpp

433 lines
14 KiB
C++
Raw Permalink Normal View History

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
// Copyright (C) 2000,2001 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
#include "BaseMind.h"
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
#include "Script.h"
#include "common/custom.h"
#include "common/debug.h"
#include "common/log.h"
#include "common/op_switch.h"
2016-03-12 14:02:51 +01:00
#include "common/compose.hpp"
#include <Atlas/Objects/SmartPtr.h>
#include <Atlas/Objects/Operation.h>
#include <Atlas/Objects/Anonymous.h>
using Atlas::Message::Element;
using Atlas::Objects::Root;
using Atlas::Objects::Operation::Look;
using Atlas::Objects::Entity::RootEntity;
using Atlas::Objects::Entity::Anonymous;
using Atlas::Objects::smart_dynamic_cast;
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
2003-09-08 Al Riddoch <alriddoch@zepler.org> * client/Py_CreatorClient.cpp, client/Py_CreatorClient.h, rulesets/Py_BBox.cpp, rulesets/Py_BBox.h, rulesets/Py_Location.cpp, rulesets/Py_Location.h, rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp, rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h, rulesets/Py_Operation.cpp, rulesets/Py_Operation.h, rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp, rulesets/Py_Optime.h, rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h, rulesets/Py_Thing.cpp, rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp, rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h, rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h, rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp: Clean up python API code, with decent names for types, decent error reporting, and making the more paranoid checks only present in debug build. * common/BaseEntity.cpp, common/BaseEntity.h, server/Account.cpp: Remove pointless method setRefnoOp, and put it in the body as an inline method. * common/BaseEntity.h, common/BaseWorld.cpp, common/Setup.h, common/Tick.h, common/operations.h, common/custom.cpp, common/types.h, common/utility.cpp, common/utility.h, modules/Location.h, physics/Vector3D.h, rulesets/BaseMind.cpp, rulesets/Script.h, server/EntityFactory.h: Clean up the dependency trees using more forward declarations. * common/inheritance.cpp, common/inheritance.h: Move most of the implementation into the .cpp file as its not suited to inlining. * rulesets/MemMap.cpp, rulesets/MemMap.h, rulesets/MemMap_methods.h: Move contents of MemMap_methods.h into the .cpp file, as it is not suited to inlining, and remove the file from the build.
2003-09-07 23:38:32 +00:00
static const bool debug_flag = false;
/// \brief BaseMind constructor
///
/// @param id String identifier
/// @param intId Integer identifier
/// @param body_name The name attribute of the body this mind controls
BaseMind::BaseMind(const std::string & id, long intId) :
MemEntity(id, intId), m_map(m_script)
{
setVisible(true);
setType(MemMap::m_entity_type);
m_map.addEntity(this);
}
BaseMind::~BaseMind()
{
m_map.m_entities.erase(getIntId());
// FIXME Remove this once MemMap uses parent refcounting
m_location.m_loc = 0;
// debug(std::cout << getId() << ":" << getType() << " flushing mind with "
// << m_map.getEntities().size() << " entities in it"
// << std::endl << std::flush;);
m_map.flush();
}
/// \brief Process the Sight of a Create operation.
///
/// @param op The Create operation to be processed.
/// @param res The result of the operation is returned here.
void BaseMind::sightCreateOperation(const Operation & op, OpVector & res)
{
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
debug( std::cout << " no args!" << std::endl << std::flush;);
return;
}
RootEntity ent(smart_dynamic_cast<RootEntity>(args.front()));
if (!ent.isValid()) {
log(ERROR, "Got sight(create) of non-entity");
return;
}
// This does not send a look, so anything added this way will not
// get flagged as visible until we get an appearance. This is important.
m_map.updateAdd(ent, op->getSeconds());
}
/// \brief Process the Sight of a Delete operation.
///
/// @param op The Delete operation to be processed.
/// @param res The result of the operation is returned here.
void BaseMind::sightDeleteOperation(const Operation & op, OpVector & res)
{
debug( std::cout << "Sight Delete operation" << std::endl << std::flush;);
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
debug( std::cout << " no args!" << std::endl << std::flush;);
return;
}
const Root & obj = args.front();
if (!obj.isValid()) {
log(ERROR, "Sight Delete with invalid entity");
return;
}
const std::string & id = obj->getId();
if (!id.empty()) {
m_map.del(obj->getId());
} else {
log(WARNING, "Sight Delete with no ID");
}
}
/// \brief Process the Sight of a Move operation.
///
/// @param op The Move operation to be processed.
/// @param res The result of the operation is returned here.
void BaseMind::sightMoveOperation(const Operation & op, OpVector & res)
{
debug( std::cout << "BaseMind::sightOperation(Sight, Move)" << std::endl << std::flush;);
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
debug( std::cout << " no args!" << std::endl << std::flush;);
return;
}
RootEntity ent(smart_dynamic_cast<RootEntity>(args.front()));
if (!ent.isValid()) {
log(ERROR, "Got sight(move) of non-entity");
return;
}
m_map.updateAdd(ent, op->getSeconds());
}
/// \brief Process the Sight of a Set operation.
///
/// @param op The Set operation to be processed.
/// @param res The result of the operation is returned here.
void BaseMind::sightSetOperation(const Operation & op, OpVector & res)
{
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
debug( std::cout << " no args!" << std::endl << std::flush;);
return;
}
RootEntity ent(smart_dynamic_cast<RootEntity>(args.front()));
if (!ent.isValid()) {
log(ERROR, "Got sight(set) of non-entity");
return;
}
m_map.updateAdd(ent, op->getSeconds());
}
void BaseMind::SoundOperation(const Operation & op, OpVector & res)
{
// Deliver argument to sound things
// Louder sounds might eventually make character wake up
2013-01-22 19:55:06 +00:00
if (!isAwake()) { return; }
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
debug( std::cout << " no args!" << std::endl << std::flush;);
return;
}
const Root & arg = args.front();
Operation op2(Atlas::Objects::smart_dynamic_cast<Operation>(arg));
if (op2.isValid()) {
debug( std::cout << " args is an op!" << std::endl << std::flush;);
std::string event_name("sound_");
event_name += op2->getParents().front();
if (m_script == 0 || m_script->operation(event_name, op2, res) == 0) {
callSoundOperation(op2, res);
}
}
}
void BaseMind::SightOperation(const Operation & op, OpVector & res)
{
debug( std::cout << "BaseMind::SightOperation(Sight)" << std::endl << std::flush;);
// Deliver argument to sight things
2013-01-22 19:55:06 +00:00
if (!isAwake()) { return; }
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
debug( std::cout << " no args!" << std::endl << std::flush;);
return;
}
const Root & arg = args.front();
Operation op2(Atlas::Objects::smart_dynamic_cast<Operation>(arg));
if (op2.isValid()) {
debug( std::cout << " args is an op!" << std::endl << std::flush;);
std::string event_name("sight_");
event_name += op2->getParents().front();
//Check that the argument had seconds set; if not the timestamp of the updates will be wrong.
if (!op2->hasAttrFlag(Atlas::Objects::Operation::SECONDS_FLAG)) {
//Copy from wrapping op to fix this. This indicates an error in the server.
op2->setSeconds(op->getSeconds());
2016-03-12 14:02:51 +01:00
log(WARNING, String::compose("Sight op argument had no seconds set, for argument %1.", op2->getParents().front()));
}
if (m_script == 0 || m_script->operation(event_name, op2, res) == 0) {
callSightOperation(op2, res);
}
} else /* if (op2->getObjtype() == "object") */ {
RootEntity ent(Atlas::Objects::smart_dynamic_cast<RootEntity>(arg));
if (!ent.isValid()) {
log(ERROR, "Arg of sigh operation is not an op or an entity");
return;
}
debug( std::cout << " arg is an entity!" << std::endl << std::flush;);
MemEntity * me = m_map.updateAdd(ent, op->getSeconds());
if (me != 0) {
me->setVisible();
}
}
}
void BaseMind::ThinkOperation(const Operation &op, OpVector &res)
{
//Get the contained op
debug(std::cout << "BaseMind::ThinkOperation(Think)" << std::endl << std::flush
;);
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
debug(std::cout << " no args!" << std::endl << std::flush
;);
return;
}
const Root & arg = args.front();
Operation op2(Atlas::Objects::smart_dynamic_cast<Operation>(arg));
if (op2.isValid()) {
debug(std::cout << " args is an op!" << std::endl << std::flush
;);
std::string event_name("think_");
event_name += op2->getParents().front();
OpVector mres;
if (m_script == nullptr || m_script->operation(event_name, op2, mres) == 0) {
int op2ClassNo = op2->getClassNo();
switch (op2ClassNo) {
case Atlas::Objects::Operation::SET_NO:
thinkSetOperation(op2, mres);
break;
case Atlas::Objects::Operation::DELETE_NO:
thinkDeleteOperation(op2, mres);
break;
case Atlas::Objects::Operation::GET_NO:
thinkGetOperation(op2, mres);
break;
case Atlas::Objects::Operation::LOOK_NO:
thinkLookOperation(op2, mres);
break;
default:
log(WARNING, "Got invalid Think operation. We only support 'Set', 'Delete', 'Get' and 'Look'.");
break;
}
}
if (!mres.empty() && !op->isDefaultSerialno()) {
mres.front()->setRefno(op->getSerialno());
}
for (auto& resOp : mres) {
res.push_back(resOp);
}
}
}
void BaseMind::thinkSetOperation(const Operation & op, OpVector & res)
{
}
void BaseMind::thinkDeleteOperation(const Operation & op, OpVector & res)
{
}
void BaseMind::thinkGetOperation(const Operation & op, OpVector & res)
{
}
void BaseMind::thinkLookOperation(const Operation & op, OpVector & res)
{
}
void BaseMind::AppearanceOperation(const Operation & op, OpVector & res)
* rulesets/Py_Location.cpp: Added bbox and bmedian attributes of location object to python wrappers. * rulesets/Character.cpp: Added initialisation of bounding box median for characters. * modules/DateTime.*: Added configurability to date so that each period of time has definable number of divisions. Default is as per real world calendar restricted to 30 day months. * Added Fire operation handling to Thing class, so that any entity with a burn_speed attribute will burn. * Added Food C++ base class, which implements cooking. * Altered the semantics of the Eat/Fire/Nourish operations so multiple arguments are no longer required. from is used to determine the other entity involved. * Added the beginnings of an astronomy system, but not yet used anywhere. * Added appearance handling to BaseMind and Memory. * Added sequence no to all entities, which is incremented each time a move or set operation is received. sequence no "seq" is included in args of Appearance operations. * Moved functionality from Animal python base class into Character C++ base class. This much improves the performance of modelling animals, and means that player characters, and NPCs get hungry and need to eat. Reduced the speed at which animals consume energy so they don't starve quite as quickly. * Added collision prediction functions that handle both entities having velocity. * Added combine functionality to Stackable. Divide comes next. Once functional, this will become the base class for any items which will commonly be used as stacks. Al
2001-03-07 11:49:43 +00:00
{
2013-01-22 19:55:06 +00:00
if (!isAwake()) { return; }
const std::vector<Root> & args = op->getArgs();
std::vector<Root>::const_iterator Iend = args.end();
for (std::vector<Root>::const_iterator I = args.begin(); I != Iend; ++I) {
2006-05-06 Al Riddoch <alriddoch@zepler.org> * common/Database.cpp, common/newid.cpp, server/server.cpp: Modify new ID checks so that code still runs when database is unavailable, and events requiring new IDs fail cleanly. * server/Connection.cpp: Report a failure to create a player account if no ID available. * rulesets/BaseMind.cpp: When processing appearance ops, handle stamp more efficiently, report an error if ID is missing from argument. * server/IdlePSQLConnector.cpp, server/IdlePSQLConnector.h: Implement re-connecting to the Database if connection is lost. * rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Thing.cpp: Ensure STAMP is present on appearance op args. * server/CommListener.cpp, server/CommListener.h, server/CommPeerListener.cpp, server/CommPeerListener.h, server/CommSlaveListener.cpp, server/CommSlaveListener.h, server/CommUnixListener.cpp, server/CommUnixListener.h: Add a return value to method for creating new client socket objects, and use it to return failure if no ID is available from the database for a new object. * rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp, rulesets/Python_API.cpp: Add "new" method for class wrappers, and call the in place constructor from new rather than init. Re-write internal function for creating new instances so it uses the "new" method. * rulesets/Py_Statistics.cpp: Remove some obsolete code inadvertedly copied from another file. Comment out some unused code to get rid of a warning. * server/CommPSQLSocket.cpp: Clear the database connection from destructor. * tests/python_class.cpp: A new test for experimenting with new Python wrappers.
2006-05-06 21:36:57 +00:00
if (!(*I)->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
log(ERROR, "BaseMind: Appearance op does not have ID");
continue;
}
const std::string & id = (*I)->getId();
MemEntity * me = m_map.getAdd(id);
if (me != 0) {
2006-05-06 Al Riddoch <alriddoch@zepler.org> * common/Database.cpp, common/newid.cpp, server/server.cpp: Modify new ID checks so that code still runs when database is unavailable, and events requiring new IDs fail cleanly. * server/Connection.cpp: Report a failure to create a player account if no ID available. * rulesets/BaseMind.cpp: When processing appearance ops, handle stamp more efficiently, report an error if ID is missing from argument. * server/IdlePSQLConnector.cpp, server/IdlePSQLConnector.h: Implement re-connecting to the Database if connection is lost. * rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Thing.cpp: Ensure STAMP is present on appearance op args. * server/CommListener.cpp, server/CommListener.h, server/CommPeerListener.cpp, server/CommPeerListener.h, server/CommSlaveListener.cpp, server/CommSlaveListener.h, server/CommUnixListener.cpp, server/CommUnixListener.h: Add a return value to method for creating new client socket objects, and use it to return failure if no ID is available from the database for a new object. * rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp, rulesets/Python_API.cpp: Add "new" method for class wrappers, and call the in place constructor from new rather than init. Re-write internal function for creating new instances so it uses the "new" method. * rulesets/Py_Statistics.cpp: Remove some obsolete code inadvertedly copied from another file. Comment out some unused code to get rid of a warning. * server/CommPSQLSocket.cpp: Clear the database connection from destructor. * tests/python_class.cpp: A new test for experimenting with new Python wrappers.
2006-05-06 21:36:57 +00:00
if ((*I)->hasAttrFlag(Atlas::Objects::STAMP_FLAG)) {
if ((int)(*I)->getStamp() != me->getSeq()) {
Look l;
Anonymous m;
m->setId(id);
l->setArgs1(m);
res.push_back(l);
}
} else {
log(ERROR, "BaseMind: Appearance op does not have stamp");
}
me->update(op->getSeconds());
me->setVisible();
}
* rulesets/Py_Location.cpp: Added bbox and bmedian attributes of location object to python wrappers. * rulesets/Character.cpp: Added initialisation of bounding box median for characters. * modules/DateTime.*: Added configurability to date so that each period of time has definable number of divisions. Default is as per real world calendar restricted to 30 day months. * Added Fire operation handling to Thing class, so that any entity with a burn_speed attribute will burn. * Added Food C++ base class, which implements cooking. * Altered the semantics of the Eat/Fire/Nourish operations so multiple arguments are no longer required. from is used to determine the other entity involved. * Added the beginnings of an astronomy system, but not yet used anywhere. * Added appearance handling to BaseMind and Memory. * Added sequence no to all entities, which is incremented each time a move or set operation is received. sequence no "seq" is included in args of Appearance operations. * Moved functionality from Animal python base class into Character C++ base class. This much improves the performance of modelling animals, and means that player characters, and NPCs get hungry and need to eat. Reduced the speed at which animals consume energy so they don't starve quite as quickly. * Added collision prediction functions that handle both entities having velocity. * Added combine functionality to Stackable. Divide comes next. Once functional, this will become the base class for any items which will commonly be used as stacks. Al
2001-03-07 11:49:43 +00:00
}
}
void BaseMind::DisappearanceOperation(const Operation & op, OpVector & res)
* rulesets/Py_Location.cpp: Added bbox and bmedian attributes of location object to python wrappers. * rulesets/Character.cpp: Added initialisation of bounding box median for characters. * modules/DateTime.*: Added configurability to date so that each period of time has definable number of divisions. Default is as per real world calendar restricted to 30 day months. * Added Fire operation handling to Thing class, so that any entity with a burn_speed attribute will burn. * Added Food C++ base class, which implements cooking. * Altered the semantics of the Eat/Fire/Nourish operations so multiple arguments are no longer required. from is used to determine the other entity involved. * Added the beginnings of an astronomy system, but not yet used anywhere. * Added appearance handling to BaseMind and Memory. * Added sequence no to all entities, which is incremented each time a move or set operation is received. sequence no "seq" is included in args of Appearance operations. * Moved functionality from Animal python base class into Character C++ base class. This much improves the performance of modelling animals, and means that player characters, and NPCs get hungry and need to eat. Reduced the speed at which animals consume energy so they don't starve quite as quickly. * Added collision prediction functions that handle both entities having velocity. * Added combine functionality to Stackable. Divide comes next. Once functional, this will become the base class for any items which will commonly be used as stacks. Al
2001-03-07 11:49:43 +00:00
{
2013-01-22 19:55:06 +00:00
if (!isAwake()) { return; }
const std::vector<Root> & args = op->getArgs();
std::vector<Root>::const_iterator Iend = args.end();
for (std::vector<Root>::const_iterator I = args.begin(); I != Iend; ++I) {
const std::string & id = (*I)->getId();
if (id.empty()) { continue; }
MemEntity * me = m_map.get(id);
if (me != 0) {
me->update(op->getSeconds());
me->setVisible(false);
}
}
* rulesets/Py_Location.cpp: Added bbox and bmedian attributes of location object to python wrappers. * rulesets/Character.cpp: Added initialisation of bounding box median for characters. * modules/DateTime.*: Added configurability to date so that each period of time has definable number of divisions. Default is as per real world calendar restricted to 30 day months. * Added Fire operation handling to Thing class, so that any entity with a burn_speed attribute will burn. * Added Food C++ base class, which implements cooking. * Altered the semantics of the Eat/Fire/Nourish operations so multiple arguments are no longer required. from is used to determine the other entity involved. * Added the beginnings of an astronomy system, but not yet used anywhere. * Added appearance handling to BaseMind and Memory. * Added sequence no to all entities, which is incremented each time a move or set operation is received. sequence no "seq" is included in args of Appearance operations. * Moved functionality from Animal python base class into Character C++ base class. This much improves the performance of modelling animals, and means that player characters, and NPCs get hungry and need to eat. Reduced the speed at which animals consume energy so they don't starve quite as quickly. * Added collision prediction functions that handle both entities having velocity. * Added combine functionality to Stackable. Divide comes next. Once functional, this will become the base class for any items which will commonly be used as stacks. Al
2001-03-07 11:49:43 +00:00
}
void BaseMind::UnseenOperation(const Operation & op, OpVector & res)
{
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
debug( std::cout << " no args!" << std::endl << std::flush;);
return;
}
const Root & arg = args.front();
if (arg->isDefaultId()) {
log(ERROR, "BaseMind: Unseen op has no arg ID");
return;
}
m_map.del(arg->getId());
}
void BaseMind::operation(const Operation & op, OpVector & res)
{
// This might end up being quite tricky to do
// In the python the following happens here:
// Find out if the op refers to any ids we don't know about.
// If so create look operations to those ids
// Set the minds time and date
debug(std::cout << "BaseMind::operation("
<< op->getParents().front() << ")"
<< std::endl << std::flush;);
int op_no = op->getClassNo();
m_time.update((int)op->getSeconds());
m_map.check(op->getSeconds());
//Unless it's an Unseen op, we should add the entity the op was from.
if (op_no != Atlas::Objects::Operation::UNSEEN_NO) {
m_map.getAdd(op->getFrom());
}
m_map.sendLooks(res);
if (m_script) {
m_script->operation("call_triggers", op, res);
if (m_script->operation(op->getParents().front(), op, res) != 0) {
return;
}
}
switch (op_no) {
case Atlas::Objects::Operation::SIGHT_NO:
SightOperation(op, res);
break;
case Atlas::Objects::Operation::SOUND_NO:
SoundOperation(op, res);
break;
case Atlas::Objects::Operation::APPEARANCE_NO:
AppearanceOperation(op, res);
break;
case Atlas::Objects::Operation::DISAPPEARANCE_NO:
DisappearanceOperation(op, res);
break;
default:
if (op_no == Atlas::Objects::Operation::UNSEEN_NO) {
UnseenOperation(op, res);
} else if (op_no == Atlas::Objects::Operation::THINK_NO) {
ThinkOperation(op, res);
}
// ERROR
break;
}
}
void BaseMind::callSightOperation(const Operation & op,
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
OpVector & res)
{
m_map.getAdd(op->getFrom());
2013-02-28 15:39:59 +00:00
auto op_no = op->getClassNo();
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
if (debug_flag && (op_no == OP_INVALID)) {
debug(std::cout << getId() << " could not deliver sight of "
<< op->getParents().front()
<< std::endl << std::flush;);
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
}
SUB_OP_SWITCH(op, op_no, res, sight)
}
void BaseMind::callSoundOperation(const Operation & op,
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
OpVector & res)
{
// This function essentially does nothing now, except add the source
// of the sound op to the map.
m_map.getAdd(op->getFrom());
2013-02-28 15:39:59 +00:00
auto op_no = op->getClassNo();
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
if (debug_flag && (op_no == OP_INVALID)) {
debug(std::cout << getId() << " could not deliver sound of "
<< op->getParents().front()
<< std::endl << std::flush;);
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
}
#if 0
const MemEntityDict & ents = m_map.getEntities();
MemEntityDict::const_iterator Iend = ents.end();
for (MemEntityDict::const_iterator I = ents.begin(); I != Iend; ++I) {
std::cout << I->second->getId() << ":" << I->second->getType() << " is "
<< ( I->second->isVisible() ? "visible " : "hid " )
<< I->second->lastSeen()
<< std::endl << std::flush;
}
#endif
// SUB_OP_SWITCH(op, op_no, res, sound)
}