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
|
2006-01-20 02:11:40 +00:00
|
|
|
// Copyright (C) 2000-2006 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-01-26 16:38:23 +00:00
|
|
|
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2002-07-14 21:04:50 +00:00
|
|
|
#include "Thing.h"
|
2005-04-21 00:28:25 +00:00
|
|
|
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/simulation/PropelProperty.h"
|
|
|
|
|
#include "rules/Domain.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/simulation/BaseWorld.h"
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/debug.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2018-10-30 20:12:45 +01:00
|
|
|
#include "common/operations/Burn.h"
|
|
|
|
|
#include "common/operations/Nourish.h"
|
|
|
|
|
#include "common/operations/Update.h"
|
|
|
|
|
#include "common/operations/Pickup.h"
|
|
|
|
|
#include "common/operations/Drop.h"
|
|
|
|
|
#include "common/operations/Unseen.h"
|
2016-03-11 15:36:47 +01:00
|
|
|
#include "common/TypeNode.h"
|
2018-03-24 17:06:02 +01:00
|
|
|
#include "EntityProperty.h"
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/simulation/PlantedOnProperty.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2003-07-18 00:43:53 +00:00
|
|
|
#include <wfmath/atlasconv.h>
|
|
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
#include <Atlas/Objects/Operation.h>
|
|
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
|
|
|
|
|
|
|
|
|
using Atlas::Objects::smart_dynamic_cast;
|
2000-08-21 11:31:18 +00:00
|
|
|
|
2005-06-03 14:56:17 +00:00
|
|
|
using Atlas::Message::Element;
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
using Atlas::Message::MapType;
|
2005-08-27 14:52:12 +00:00
|
|
|
using Atlas::Objects::Root;
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
using Atlas::Objects::Operation::Set;
|
|
|
|
|
using Atlas::Objects::Operation::Sight;
|
2018-08-09 21:30:10 +02:00
|
|
|
using Atlas::Objects::Operation::Sound;
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
using Atlas::Objects::Operation::Delete;
|
2006-01-20 02:11:40 +00:00
|
|
|
using Atlas::Objects::Operation::Drop;
|
2012-06-29 14:53:15 -07:00
|
|
|
using Atlas::Objects::Operation::Info;
|
2006-05-31 17:43:39 +00:00
|
|
|
using Atlas::Objects::Operation::Move;
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
using Atlas::Objects::Operation::Nourish;
|
2006-01-20 02:11:40 +00:00
|
|
|
using Atlas::Objects::Operation::Pickup;
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
using Atlas::Objects::Operation::Appearance;
|
|
|
|
|
using Atlas::Objects::Operation::Disappearance;
|
2006-05-31 17:43:39 +00:00
|
|
|
using Atlas::Objects::Operation::Update;
|
2006-02-05 01:39:46 +00:00
|
|
|
using Atlas::Objects::Operation::Wield;
|
2015-04-15 23:06:33 +02:00
|
|
|
using Atlas::Objects::Operation::Unseen;
|
2005-08-27 14:52:12 +00:00
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
|
|
|
|
using Atlas::Objects::Entity::RootEntity;
|
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
|
|
|
|
2016-03-11 15:36:47 +01:00
|
|
|
static const bool debug_flag = false;
|
2000-08-21 11:31:18 +00:00
|
|
|
|
2013-11-24 00:59:35 +01:00
|
|
|
/// \brief Constructor for physical or tangible entities.
|
2017-06-27 18:33:13 +02:00
|
|
|
Thing::Thing(const std::string& id, long intId) :
|
|
|
|
|
Entity(id, intId)
|
2000-08-21 11:31:18 +00:00
|
|
|
{
|
2000-10-24 12:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
void Thing::DeleteOperation(const Operation& op, OpVector& res)
|
2000-08-21 11:31:18 +00:00
|
|
|
{
|
2018-08-17 22:04:07 +02:00
|
|
|
if (m_location.m_parent == nullptr) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Deleting %1(%2) when it is not "
|
2017-06-27 18:33:13 +02:00
|
|
|
"in the world.", getType(), getId()));
|
2018-08-17 22:04:07 +02:00
|
|
|
assert(m_location.m_parent != nullptr);
|
2007-07-06 14:58:28 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2001-05-14 17:25:32 +00:00
|
|
|
// The actual destruction and removal of this entity will be handled
|
|
|
|
|
// by the WorldRouter
|
2013-08-05 11:21:39 +02:00
|
|
|
|
2013-11-24 00:59:35 +01:00
|
|
|
if (isPerceptive()) {
|
|
|
|
|
//We need to send a sight operation directly to the entity.
|
|
|
|
|
//The reason is that else the entity will be deleted before it can receive the broadcast Sight
|
|
|
|
|
//of the Delete op, which will leave any external clients hanging.
|
|
|
|
|
Sight sToEntity;
|
|
|
|
|
sToEntity->setArgs1(op);
|
|
|
|
|
sToEntity->setTo(getId());
|
|
|
|
|
operation(sToEntity, res);
|
|
|
|
|
}
|
2013-08-05 11:21:39 +02:00
|
|
|
|
2005-08-29 02:28:53 +00:00
|
|
|
Sight s;
|
2005-08-27 14:52:12 +00:00
|
|
|
s->setArgs1(op);
|
2018-07-30 13:07:43 +02:00
|
|
|
broadcast(s, res, Visibility::PUBLIC);
|
2016-09-03 22:38:16 +02:00
|
|
|
|
2017-06-24 21:47:43 +02:00
|
|
|
// //Important to send directly before this entity is deleted, so that broadcasts gets right.
|
|
|
|
|
// sendWorld(s);
|
2013-11-24 00:59:35 +01:00
|
|
|
|
2013-11-15 22:55:17 +01:00
|
|
|
Entity::DeleteOperation(op, res);
|
2000-08-21 11:31:18 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
void Thing::MoveOperation(const Operation& op, OpVector& res)
|
2000-08-21 11:31:18 +00:00
|
|
|
{
|
2017-06-27 18:33:13 +02:00
|
|
|
debug(std::cout << "Thing::move_operation" << std::endl << std::flush;);
|
2006-05-31 16:31:52 +00:00
|
|
|
|
2018-08-17 22:04:07 +02:00
|
|
|
if (m_location.m_parent == nullptr) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Moving %1(%2) when it is not in the world.",
|
|
|
|
|
getType(), getId()));
|
2018-08-17 22:04:07 +02:00
|
|
|
assert(m_location.m_parent != nullptr);
|
2007-07-06 15:09:39 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-31 16:31:52 +00:00
|
|
|
// Check the validity of the operation.
|
2017-06-27 18:33:13 +02:00
|
|
|
const std::vector<Root>& args = op->getArgs();
|
2002-03-06 Al Riddoch <alriddoch@zepler.org>
* tools/cycmd.cpp, server/WorldRouter.cpp, server/EntityFactory.cpp,
server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/Thing.cpp, rulesets/Py_Operation.cpp,
rulesets/MemMap_methods.h, rulesets/MemMap.cpp, rulesets/Entity.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Use empty() instead of size() == 0 for STL sequence types.
* rulesets/ThingFactory.h, server/EntityFactory.cpp: Modified the
way adding classes to the inheritance tree is handled, so types
no longer have to inherit directly from a C++ class.
* server/WorldRouter.cpp: Modified the way broadcast operations are
handled to make them more efficient, and catch NULL pointers in
the world dictionary.
2002-03-06 00:23:28 +00:00
|
|
|
if (args.empty()) {
|
2004-09-03 Al Riddoch <alriddoch@zepler.org>
* client/CharacterClient.cpp, client/CharacterClient.h,
client/CommClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/OOGThing.cpp,
common/OOGThing.h, common/op_switch.h,
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/Food.cpp, rulesets/Food.h,
rulesets/Missile.h, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
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/ExternalMind.cpp, server/ExternalMind.h,
server/Lobby.cpp, server/Lobby.h, server/Player.cpp,
server/Player.h, server/WorldRouter.cpp:
Re-work basic op dispatch mechanism so result is passed by
a reference argument rather than returning by value.
2004-09-03 00:33:19 +00:00
|
|
|
error(op, "Move has no argument", res, getId());
|
|
|
|
|
return;
|
2004-05-12 23:45:02 +00:00
|
|
|
}
|
2005-08-29 00:44:56 +00:00
|
|
|
RootEntity ent = smart_dynamic_cast<RootEntity>(args.front());
|
2005-08-29 03:34:24 +00:00
|
|
|
if (!ent.isValid()) {
|
|
|
|
|
error(op, "Move op arg is malformed", res, getId());
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 14:52:12 +00:00
|
|
|
if (getId() != ent->getId()) {
|
|
|
|
|
error(op, "Move op does not have correct id in argument", res, getId());
|
2005-08-29 03:34:24 +00:00
|
|
|
return;
|
2004-11-14 02:43:29 +00:00
|
|
|
}
|
2005-11-02 02:06:38 +00:00
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
Ref<LocatedEntity> new_loc = nullptr;
|
2016-07-15 22:02:01 +02:00
|
|
|
if (ent->hasAttrFlag(Atlas::Objects::Entity::LOC_FLAG)) {
|
2017-06-27 18:33:13 +02:00
|
|
|
const std::string& new_loc_id = ent->getLoc();
|
2018-08-17 22:04:07 +02:00
|
|
|
if (new_loc_id != m_location.m_parent->getId()) {
|
2016-07-15 22:02:01 +02:00
|
|
|
// If the LOC has not changed, we don't need to look it up, or do
|
|
|
|
|
// any of the following checks.
|
|
|
|
|
new_loc = BaseWorld::instance().getEntity(new_loc_id);
|
2017-06-27 18:33:13 +02:00
|
|
|
if (new_loc == nullptr) {
|
2016-07-15 22:02:01 +02:00
|
|
|
error(op, "Move op loc does not exist", res, getId());
|
2005-11-02 02:06:38 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2016-07-15 22:02:01 +02:00
|
|
|
debug(std::cout << "LOC: " << new_loc_id << std::endl << std::flush;);
|
2018-08-05 20:47:09 +02:00
|
|
|
auto test_loc = new_loc;
|
2018-08-17 22:04:07 +02:00
|
|
|
for (; test_loc != nullptr; test_loc = test_loc->m_location.m_parent) {
|
2016-07-15 22:02:01 +02:00
|
|
|
if (test_loc == this) {
|
|
|
|
|
error(op, "Attempt to move into itself", res, getId());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-27 18:33:13 +02:00
|
|
|
assert(new_loc != nullptr);
|
2018-08-17 22:04:07 +02:00
|
|
|
assert(m_location.m_parent != new_loc);
|
2005-11-02 02:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
2000-08-30 17:49:11 +00:00
|
|
|
}
|
2002-12-01 22:54:12 +00:00
|
|
|
|
2016-07-15 22:02:01 +02:00
|
|
|
|
2004-05-12 23:45:02 +00:00
|
|
|
// Up until this point nothing should have changed, but the changes
|
|
|
|
|
// have all now been checked for validity.
|
2001-04-16 16:26:44 +00:00
|
|
|
|
2014-09-18 22:41:23 +02:00
|
|
|
const Location old_loc = m_location;
|
|
|
|
|
|
2000-08-30 17:49:11 +00:00
|
|
|
|
2005-06-03 14:56:17 +00:00
|
|
|
std::string mode;
|
|
|
|
|
|
2006-07-03 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, rulesets/Character.cpp,
rulesets/Entity.cpp, rulesets/Entity.h, rulesets/Food.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Thing.cpp, server/WorldRouter.cpp:
Rename Entity members get(), set() and has() to getAttr(), setAttr()
and hasAttr().
2006-07-03 01:41:29 +00:00
|
|
|
if (hasAttr("mode")) {
|
2005-06-03 14:56:17 +00:00
|
|
|
Element mode_attr;
|
2006-07-03 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, rulesets/Character.cpp,
rulesets/Entity.cpp, rulesets/Entity.h, rulesets/Food.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Thing.cpp, server/WorldRouter.cpp:
Rename Entity members get(), set() and has() to getAttr(), setAttr()
and hasAttr().
2006-07-03 01:41:29 +00:00
|
|
|
getAttr("mode", mode_attr);
|
2005-06-03 14:56:17 +00:00
|
|
|
if (mode_attr.isString()) {
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
mode = mode_attr.String();
|
2005-06-03 14:56:17 +00:00
|
|
|
} else {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Mode on entity is a \"%1\" in "
|
2017-06-27 18:33:13 +02:00
|
|
|
"Thing::MoveOperation",
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
Element::typeName(mode_attr.getType())));
|
2005-06-03 14:56:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Move ops often include a mode change, so we handle it here, even
|
|
|
|
|
// though it is not a special attribute for efficiency. Otherwise
|
|
|
|
|
// an additional Set op would be required.
|
2005-08-27 14:52:12 +00:00
|
|
|
Element attr_mode;
|
2005-08-30 23:53:34 +00:00
|
|
|
if (ent->copyAttr("mode", attr_mode) == 0) {
|
2005-08-27 14:52:12 +00:00
|
|
|
if (!attr_mode.isString()) {
|
2018-03-03 15:19:13 +01:00
|
|
|
log(ERROR, "Non string 'mode' set in Thing::MoveOperation");
|
2005-06-03 14:56:17 +00:00
|
|
|
} else {
|
2005-07-02 12:06:23 +00:00
|
|
|
// Update the mode
|
2006-07-03 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, rulesets/Character.cpp,
rulesets/Entity.cpp, rulesets/Entity.h, rulesets/Food.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Thing.cpp, server/WorldRouter.cpp:
Rename Entity members get(), set() and has() to getAttr(), setAttr()
and hasAttr().
2006-07-03 01:41:29 +00:00
|
|
|
setAttr("mode", attr_mode);
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
mode = attr_mode.String();
|
2005-06-03 14:56:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 22:50:41 +02:00
|
|
|
//If a Move op contains a planted_on prop it should be used.
|
|
|
|
|
//It's expected that only admins should ever send a "planted_on" as Move ops (to build the world).
|
|
|
|
|
//In all other cases we want to let regular Domain rules apply
|
|
|
|
|
Element attr_plantedOn;
|
2018-08-14 21:32:06 +02:00
|
|
|
PlantedOnProperty::Data plantedOn;
|
|
|
|
|
if (ent->copyAttr(PlantedOnProperty::property_name, attr_plantedOn) == 0) {
|
|
|
|
|
plantedOn = PlantedOnProperty::parse(attr_plantedOn);
|
2018-05-20 23:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-30 13:35:51 +02:00
|
|
|
//Move ops can also alter the "planted_offset" property
|
2018-03-03 15:19:13 +01:00
|
|
|
Element attr_plantedOffset;
|
2018-07-30 13:35:51 +02:00
|
|
|
if (ent->copyAttr("planted_offset", attr_plantedOffset) == 0) {
|
|
|
|
|
setAttr("planted_offset", attr_plantedOffset);
|
2018-03-03 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
const double& current_time = BaseWorld::instance().getTime();
|
2006-06-01 01:26:17 +00:00
|
|
|
|
2014-09-18 11:06:05 +02:00
|
|
|
//We can only move if there's a domain
|
2016-06-10 17:25:25 +02:00
|
|
|
Domain* domain = nullptr;
|
2018-08-17 22:04:07 +02:00
|
|
|
if (m_location.m_parent) {
|
|
|
|
|
domain = m_location.m_parent->getDomain();
|
2016-06-10 17:25:25 +02:00
|
|
|
}
|
2014-09-22 20:14:41 +02:00
|
|
|
|
|
|
|
|
|
2016-03-11 15:36:47 +01:00
|
|
|
if (domain) {
|
|
|
|
|
|
2016-07-15 22:02:01 +02:00
|
|
|
WFMath::Vector<3> newVelocity;
|
|
|
|
|
WFMath::Point<3> newPos;
|
|
|
|
|
WFMath::Quaternion newOrientation;
|
|
|
|
|
|
2016-03-11 15:36:47 +01:00
|
|
|
bool updatedTransform = false;
|
|
|
|
|
|
2016-07-15 22:02:01 +02:00
|
|
|
if (ent->hasAttrFlag(Atlas::Objects::Entity::POS_FLAG)) {
|
|
|
|
|
// Update pos
|
2017-06-27 18:33:13 +02:00
|
|
|
if (fromStdVector(newPos, ent->getPos()) == 0) {
|
2016-07-15 22:02:01 +02:00
|
|
|
updatedTransform = true;
|
|
|
|
|
}
|
2014-09-22 20:14:41 +02:00
|
|
|
}
|
2016-01-17 17:02:50 +01:00
|
|
|
Element attr_orientation;
|
|
|
|
|
if (ent->copyAttr("orientation", attr_orientation) == 0) {
|
|
|
|
|
// Update orientation
|
2016-07-15 22:02:01 +02:00
|
|
|
newOrientation.fromAtlas(attr_orientation.asList());
|
2016-03-11 15:36:47 +01:00
|
|
|
updatedTransform = true;
|
2016-01-17 17:02:50 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-11 21:15:35 +01:00
|
|
|
Element attr_propel;
|
|
|
|
|
if (ent->copyAttr("propel", attr_propel) == 0) {
|
|
|
|
|
auto propelProp = requirePropertyClassFixed<PropelProperty>();
|
|
|
|
|
try {
|
|
|
|
|
newVelocity.fromAtlas(attr_propel);
|
2016-09-25 22:01:16 +02:00
|
|
|
if (!newVelocity.isEqualTo(propelProp->data())) {
|
|
|
|
|
propelProp->data() = newVelocity;
|
|
|
|
|
// Velocity is not persistent so has no flag
|
|
|
|
|
updatedTransform = true;
|
|
|
|
|
} else {
|
|
|
|
|
//Velocity wasn't changed, so we can make newVelocity invalid and it won't be applied.
|
|
|
|
|
newVelocity.setValid(false);
|
|
|
|
|
}
|
2018-02-11 21:15:35 +01:00
|
|
|
} catch (...) {
|
|
|
|
|
//just ignore malformed data
|
2016-09-02 23:38:02 +02:00
|
|
|
}
|
2014-09-18 11:06:05 +02:00
|
|
|
}
|
2018-02-11 21:15:35 +01:00
|
|
|
//TODO: allow for setting of impact velocity as well as propel velocity
|
|
|
|
|
// else {
|
|
|
|
|
// if (ent->hasAttrFlag(Atlas::Objects::Entity::VELOCITY_FLAG)) {
|
|
|
|
|
// // Update velocity
|
|
|
|
|
// if (fromStdVector(newVelocity, ent->getVelocity()) == 0) {
|
|
|
|
|
// auto propelProp = requirePropertyClassFixed<PropelProperty>();
|
|
|
|
|
// if (!newVelocity.isEqualTo(propelProp->data())) {
|
|
|
|
|
// propelProp->data() = newVelocity;
|
|
|
|
|
// // Velocity is not persistent so has no flag
|
|
|
|
|
// updatedTransform = true;
|
|
|
|
|
// } else {
|
|
|
|
|
// //Velocity wasn't changed, so we can make newVelocity invalid and it won't be applied.
|
|
|
|
|
// newVelocity.setValid(false);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
2018-03-09 14:37:11 +01:00
|
|
|
std::set<LocatedEntity*> transformedEntities;
|
2005-08-27 14:52:12 +00:00
|
|
|
|
2016-07-15 22:02:01 +02:00
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
// Check if the location has changed
|
|
|
|
|
if (new_loc != nullptr) {
|
|
|
|
|
// new_loc should only be non-null if the LOC specified is
|
|
|
|
|
// different from the current LOC
|
2018-08-17 22:04:07 +02:00
|
|
|
assert(m_location.m_parent != new_loc);
|
2017-06-27 18:33:13 +02:00
|
|
|
// Check for pickup, ie if the new LOC is the actor, and the
|
|
|
|
|
// previous LOC is the actor's LOC.
|
|
|
|
|
if (new_loc->getId() == op->getFrom() &&
|
2018-08-17 22:04:07 +02:00
|
|
|
m_location.m_parent == new_loc->m_location.m_parent) {
|
2017-06-27 18:33:13 +02:00
|
|
|
|
|
|
|
|
//Send Pickup to those entities which are currently observing
|
2018-08-17 22:04:07 +02:00
|
|
|
if (m_location.m_parent) {
|
2017-06-27 18:33:13 +02:00
|
|
|
|
|
|
|
|
Pickup p;
|
|
|
|
|
p->setFrom(op->getFrom());
|
|
|
|
|
p->setTo(getId());
|
|
|
|
|
|
|
|
|
|
Sight s;
|
|
|
|
|
s->setArgs1(p);
|
2018-08-17 22:04:07 +02:00
|
|
|
m_location.m_parent->broadcast(s, res, Visibility::PUBLIC);
|
2017-06-27 18:33:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Anonymous wield_arg;
|
|
|
|
|
wield_arg->setId(getId());
|
|
|
|
|
Wield w;
|
|
|
|
|
w->setTo(op->getFrom());
|
|
|
|
|
w->setArgs1(wield_arg);
|
|
|
|
|
res.push_back(w);
|
|
|
|
|
}
|
|
|
|
|
// Check for drop, ie if the old LOC is the actor, and the
|
|
|
|
|
// new LOC is the actor's LOC.
|
2018-08-17 22:04:07 +02:00
|
|
|
if (m_location.m_parent->getId() == op->getFrom() &&
|
|
|
|
|
new_loc == m_location.m_parent->m_location.m_parent) {
|
2017-06-27 18:33:13 +02:00
|
|
|
|
|
|
|
|
Drop d;
|
|
|
|
|
d->setFrom(op->getFrom());
|
|
|
|
|
d->setTo(getId());
|
|
|
|
|
Sight s;
|
|
|
|
|
s->setArgs1(d);
|
2018-08-17 22:04:07 +02:00
|
|
|
m_location.m_parent->broadcast(s, res, Visibility::PUBLIC);
|
2017-06-27 18:33:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update loc
|
|
|
|
|
|
|
|
|
|
std::set<const LocatedEntity*> previousObserving;
|
|
|
|
|
collectObservers(previousObserving);
|
|
|
|
|
|
|
|
|
|
if (updatedTransform) {
|
|
|
|
|
if (newOrientation.isValid()) {
|
|
|
|
|
m_location.m_orientation = newOrientation;
|
|
|
|
|
}
|
|
|
|
|
if (newPos.isValid()) {
|
|
|
|
|
m_location.m_pos = newPos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
changeContainer(new_loc);
|
|
|
|
|
processAppearDisappear(std::move(previousObserving), res);
|
|
|
|
|
} else {
|
|
|
|
|
if (updatedTransform) {
|
2018-08-14 21:32:06 +02:00
|
|
|
Domain::TransformData transformData{newOrientation, newPos, newVelocity, plantedOn.entity.get(), plantedOn.attachment};
|
2018-05-23 22:50:41 +02:00
|
|
|
domain->applyTransform(*this, transformData, transformedEntities);
|
2017-06-27 18:33:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-07-15 22:02:01 +02:00
|
|
|
|
2016-01-17 17:02:50 +01:00
|
|
|
|
|
|
|
|
m_location.update(current_time);
|
2018-04-25 12:21:44 +02:00
|
|
|
removeFlags(entity_clean);
|
2004-05-12 23:45:02 +00:00
|
|
|
|
2014-09-18 11:06:05 +02:00
|
|
|
// At this point the Location data for this entity has been updated.
|
2005-04-03 16:36:13 +00:00
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
Operation m = op.copy();
|
2014-09-18 11:06:05 +02:00
|
|
|
RootEntity marg = smart_dynamic_cast<RootEntity>(m->getArgs().front());
|
|
|
|
|
assert(marg.isValid());
|
|
|
|
|
m_location.addToEntity(marg);
|
2018-03-24 17:06:02 +01:00
|
|
|
{
|
2018-08-14 21:32:06 +02:00
|
|
|
auto plantedOnProp = getPropertyClassFixed<PlantedOnProperty>();
|
2018-03-24 17:06:02 +01:00
|
|
|
if (plantedOnProp) {
|
|
|
|
|
if (plantedOnProp->hasFlags(flag_unsent)) {
|
|
|
|
|
Element plantedOnElem;
|
|
|
|
|
if (plantedOnProp->get(plantedOnElem) == 0) {
|
2018-08-14 21:32:06 +02:00
|
|
|
marg->setAttr(PlantedOnProperty::property_name, plantedOnElem);
|
2018-03-24 17:06:02 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-02-17 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/types.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Thing.cpp,
rulesets/Thing.h: Add core op handling for update operation, used
to handle move ops better.
2005-02-17 01:47:32 +00:00
|
|
|
|
2016-09-23 22:32:33 +02:00
|
|
|
if (!m->hasAttrFlag(Atlas::Objects::Operation::SECONDS_FLAG)) {
|
|
|
|
|
m->setSeconds(current_time);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-18 11:06:05 +02:00
|
|
|
Sight s;
|
|
|
|
|
s->setArgs1(m);
|
2018-07-30 13:07:43 +02:00
|
|
|
broadcast(s, res, Visibility::PUBLIC);
|
2014-09-18 11:06:05 +02:00
|
|
|
|
2018-03-09 14:37:11 +01:00
|
|
|
//Check if there are any other transformed entities, and send move ops for those.
|
|
|
|
|
//However, with this setup the Sight ops for the resting entities will be sent _before_ the Sight
|
|
|
|
|
//op for this entity is sent. It's a bit backwards.
|
|
|
|
|
//TODO: send resting sights after main sight
|
|
|
|
|
if (transformedEntities.size() > 1) {
|
|
|
|
|
for (auto& transformedEntity : transformedEntities) {
|
|
|
|
|
if (transformedEntity != this) {
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Entity::Anonymous movedArg;
|
|
|
|
|
movedArg->setId(transformedEntity->getId());
|
|
|
|
|
transformedEntity->m_location.addToEntity(movedArg);
|
2018-03-24 17:06:02 +01:00
|
|
|
|
2018-08-14 21:32:06 +02:00
|
|
|
auto plantedOnProp = transformedEntity->getPropertyClassFixed<PlantedOnProperty>();
|
2018-03-24 17:06:02 +01:00
|
|
|
if (plantedOnProp) {
|
|
|
|
|
if (plantedOnProp->hasFlags(flag_unsent)) {
|
|
|
|
|
Element plantedOnElem;
|
|
|
|
|
if (plantedOnProp->get(plantedOnElem) == 0) {
|
2018-08-14 21:32:06 +02:00
|
|
|
movedArg->setAttr(PlantedOnProperty::property_name, plantedOnElem);
|
2018-03-24 17:06:02 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 14:37:11 +01:00
|
|
|
Move movedOp;
|
|
|
|
|
movedOp->setArgs1(movedArg);
|
|
|
|
|
|
|
|
|
|
Sight sight;
|
|
|
|
|
sight->setArgs1(movedOp);
|
|
|
|
|
OpVector childRes;
|
2018-07-30 13:07:43 +02:00
|
|
|
transformedEntity->broadcast(sight, childRes, Visibility::PUBLIC);
|
2018-03-09 14:37:11 +01:00
|
|
|
for (auto& childOp : childRes) {
|
|
|
|
|
transformedEntity->sendWorld(childOp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-05-30 00:57:27 +00:00
|
|
|
}
|
2016-03-11 15:36:47 +01:00
|
|
|
|
2006-07-23 00:43:11 +00:00
|
|
|
m_seq++;
|
2008-08-16 23:21:06 +00:00
|
|
|
|
|
|
|
|
onUpdated();
|
2006-05-30 00:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
2000-08-21 11:31:18 +00:00
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
void Thing::SetOperation(const Operation& op, OpVector& res)
|
2000-08-21 11:31:18 +00:00
|
|
|
{
|
2017-06-27 18:33:13 +02:00
|
|
|
const std::vector<Root>& args = op->getArgs();
|
2005-08-27 14:52:12 +00:00
|
|
|
if (args.empty()) {
|
|
|
|
|
error(op, "Set has no argument", res, getId());
|
2004-09-03 Al Riddoch <alriddoch@zepler.org>
* client/CharacterClient.cpp, client/CharacterClient.h,
client/CommClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/OOGThing.cpp,
common/OOGThing.h, common/op_switch.h,
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/Food.cpp, rulesets/Food.h,
rulesets/Missile.h, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
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/ExternalMind.cpp, server/ExternalMind.h,
server/Lobby.cpp, server/Lobby.h, server/Player.cpp,
server/Player.h, server/WorldRouter.cpp:
Re-work basic op dispatch mechanism so result is passed by
a reference argument rather than returning by value.
2004-09-03 00:33:19 +00:00
|
|
|
return;
|
2000-10-24 12:50:22 +00:00
|
|
|
}
|
2017-06-27 18:33:13 +02:00
|
|
|
const Root& ent = args.front();
|
2005-08-27 14:52:12 +00:00
|
|
|
merge(ent->asMessage());
|
2016-01-19 15:38:03 +01:00
|
|
|
|
2018-10-04 17:59:16 +02:00
|
|
|
//If there's a serial number we should return a sight here already.
|
|
|
|
|
if (!op->isDefaultSerialno() && !op->isDefaultFrom()) {
|
|
|
|
|
Sight sight;
|
|
|
|
|
sight->setTo(op->getFrom());
|
|
|
|
|
sight->setRefno(op->getSerialno());
|
|
|
|
|
sight->setArgs1(op);
|
|
|
|
|
res.emplace_back(std::move(sight));
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-11 15:22:03 +02:00
|
|
|
Update update;
|
|
|
|
|
update->setTo(getId());
|
|
|
|
|
res.push_back(std::move(update));
|
2000-08-21 11:31:18 +00:00
|
|
|
}
|
2005-02-17 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/types.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Thing.cpp,
rulesets/Thing.h: Add core op handling for update operation, used
to handle move ops better.
2005-02-17 01:47:32 +00:00
|
|
|
|
2006-12-29 01:00:07 +00:00
|
|
|
/// \brief Generate a Sight(Set) operation giving an update on named attributes
|
|
|
|
|
///
|
|
|
|
|
/// When another operation causes the properties of an entity to be changed,
|
|
|
|
|
/// it can trigger propagation of this change by sending an Update operation
|
|
|
|
|
/// nameing the attributes or properties that need to be updated. This
|
|
|
|
|
/// member function handles the Operation, sending a Sight(Set) for
|
|
|
|
|
/// any perceptible changes, and will in future handle persisting those
|
|
|
|
|
/// changes. Should this also handle side effects?
|
|
|
|
|
/// The main reason for this up is that if other ops need to generate a
|
|
|
|
|
/// Set op to update attributes, there are race conditions all over the
|
|
|
|
|
/// place.
|
|
|
|
|
/// @param op Update operation that notifies of the changes.
|
|
|
|
|
/// @param res The result of the operation is returned here.
|
2017-06-27 18:33:13 +02:00
|
|
|
void Thing::updateProperties(const Operation& op, OpVector& res)
|
2006-12-29 01:00:07 +00:00
|
|
|
{
|
2007-01-08 23:30:04 +00:00
|
|
|
debug(std::cout << "Generating property update" << std::endl << std::flush;);
|
2006-12-29 18:48:04 +00:00
|
|
|
|
2006-12-29 01:00:07 +00:00
|
|
|
Anonymous set_arg;
|
2018-07-30 13:07:43 +02:00
|
|
|
Anonymous set_arg_protected;
|
|
|
|
|
Anonymous set_arg_private;
|
2006-12-29 01:00:07 +00:00
|
|
|
|
2016-01-19 15:38:03 +01:00
|
|
|
bool hadChanges = false;
|
2018-07-30 10:22:50 +02:00
|
|
|
bool hadPublicChanges = false;
|
|
|
|
|
bool hadProtectedChanges = false;
|
2018-07-30 13:07:43 +02:00
|
|
|
bool hadPrivateChanges = false;
|
2016-01-19 15:38:03 +01:00
|
|
|
|
|
|
|
|
for (auto entry : m_properties) {
|
2017-06-27 18:33:13 +02:00
|
|
|
PropertyBase* prop = entry.second;
|
2018-07-30 10:22:50 +02:00
|
|
|
assert(prop != nullptr);
|
|
|
|
|
if (prop->hasFlags(flag_unsent)) {
|
2016-01-19 15:38:03 +01:00
|
|
|
debug(std::cout << "UPDATE: " << flag_unsent << " " << entry.first
|
2008-09-22 23:47:04 +00:00
|
|
|
<< std::endl << std::flush;);
|
2018-07-30 10:22:50 +02:00
|
|
|
if (entry.second->hasFlags(vis_private)) {
|
2018-07-30 13:07:43 +02:00
|
|
|
prop->add(entry.first, set_arg_private);
|
|
|
|
|
hadPrivateChanges = true;
|
2018-07-30 10:22:50 +02:00
|
|
|
} else if (entry.second->hasFlags(vis_protected)) {
|
2018-07-30 13:07:43 +02:00
|
|
|
prop->add(entry.first, set_arg_protected);
|
2018-07-30 10:22:50 +02:00
|
|
|
hadProtectedChanges = true;
|
|
|
|
|
} else {
|
|
|
|
|
prop->add(entry.first, set_arg);
|
|
|
|
|
hadPublicChanges = true;
|
|
|
|
|
}
|
2018-04-25 12:21:44 +02:00
|
|
|
prop->removeFlags(flag_unsent | per_clean);
|
2016-01-19 15:38:03 +01:00
|
|
|
hadChanges = true;
|
2006-12-29 01:00:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-19 15:38:03 +01:00
|
|
|
if (hadChanges) {
|
2016-09-25 22:03:15 +02:00
|
|
|
//Mark that entity needs to be written to storage.
|
2018-04-25 12:21:44 +02:00
|
|
|
removeFlags(entity_clean);
|
2018-07-30 10:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hadPublicChanges) {
|
2016-09-25 22:03:15 +02:00
|
|
|
|
2018-08-14 21:32:06 +02:00
|
|
|
set_arg->setId(getId());
|
|
|
|
|
|
2016-01-19 15:38:03 +01:00
|
|
|
Set set;
|
|
|
|
|
set->setTo(getId());
|
|
|
|
|
set->setFrom(getId());
|
|
|
|
|
set->setSeconds(op->getSeconds());
|
|
|
|
|
set->setArgs1(set_arg);
|
|
|
|
|
|
|
|
|
|
Sight sight;
|
|
|
|
|
sight->setArgs1(set);
|
2018-07-30 13:07:43 +02:00
|
|
|
broadcast(sight, res, Visibility::PUBLIC);
|
2016-01-19 15:38:03 +01:00
|
|
|
}
|
|
|
|
|
|
2018-07-30 10:22:50 +02:00
|
|
|
if (hadProtectedChanges) {
|
2018-08-14 21:32:06 +02:00
|
|
|
set_arg_protected->setId(getId());
|
2018-07-30 10:22:50 +02:00
|
|
|
|
|
|
|
|
Set set;
|
|
|
|
|
set->setTo(getId());
|
|
|
|
|
set->setFrom(getId());
|
|
|
|
|
set->setSeconds(op->getSeconds());
|
2018-07-30 13:07:43 +02:00
|
|
|
set->setArgs1(set_arg_protected);
|
2018-07-30 10:22:50 +02:00
|
|
|
|
|
|
|
|
Sight sight;
|
|
|
|
|
sight->setArgs1(set);
|
2018-07-30 13:07:43 +02:00
|
|
|
broadcast(sight, res, Visibility::PROTECTED);
|
2018-07-30 10:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-30 13:07:43 +02:00
|
|
|
if (hadPrivateChanges) {
|
2018-08-14 21:32:06 +02:00
|
|
|
set_arg_private->setId(getId());
|
2018-07-30 13:07:43 +02:00
|
|
|
|
|
|
|
|
Set set;
|
|
|
|
|
set->setTo(getId());
|
|
|
|
|
set->setFrom(getId());
|
|
|
|
|
set->setSeconds(op->getSeconds());
|
|
|
|
|
set->setArgs1(set_arg_private);
|
|
|
|
|
|
|
|
|
|
Sight sight;
|
|
|
|
|
sight->setArgs1(set);
|
|
|
|
|
broadcast(sight, res, Visibility::PRIVATE);
|
|
|
|
|
}
|
2016-01-19 15:38:03 +01:00
|
|
|
|
|
|
|
|
//Location changes must be communicated through a Move op.
|
2018-07-30 13:07:43 +02:00
|
|
|
if (m_flags.hasFlags(entity_dirty_location)) {
|
2016-01-19 15:38:03 +01:00
|
|
|
Move m;
|
|
|
|
|
Anonymous move_arg;
|
|
|
|
|
move_arg->setId(getId());
|
|
|
|
|
m_location.addToEntity(move_arg);
|
|
|
|
|
m->setArgs1(move_arg);
|
|
|
|
|
m->setFrom(getId());
|
|
|
|
|
m->setTo(getId());
|
2016-09-23 22:32:33 +02:00
|
|
|
m->setSeconds(op->getSeconds());
|
2016-01-19 15:38:03 +01:00
|
|
|
|
|
|
|
|
Sight s;
|
|
|
|
|
s->setArgs1(m);
|
|
|
|
|
|
2018-07-30 13:07:43 +02:00
|
|
|
broadcast(s, res, Visibility::PUBLIC);
|
2018-04-25 12:21:44 +02:00
|
|
|
removeFlags(entity_dirty_location);
|
2016-01-19 15:38:03 +01:00
|
|
|
hadChanges = true;
|
2008-10-01 10:47:53 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-29 01:00:07 +00:00
|
|
|
|
2016-01-19 15:38:03 +01:00
|
|
|
//Only change sequence number and call onUpdated if something actually changed.
|
|
|
|
|
if (hadChanges) {
|
|
|
|
|
m_seq++;
|
2018-07-30 13:07:43 +02:00
|
|
|
if (!hasFlags(entity_clean)) {
|
2016-01-19 15:38:03 +01:00
|
|
|
onUpdated();
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-12-29 01:00:07 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
void Thing::UpdateOperation(const Operation& op, OpVector& res)
|
2005-02-17 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/types.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Thing.cpp,
rulesets/Thing.h: Add core op handling for update operation, used
to handle move ops better.
2005-02-17 01:47:32 +00:00
|
|
|
{
|
2006-12-30 23:13:32 +00:00
|
|
|
// If it has no refno, then it is a generic request to broadcast
|
|
|
|
|
// an update of some properties which have changed.
|
|
|
|
|
if (op->isDefaultRefno()) {
|
2006-12-29 01:00:07 +00:00
|
|
|
updateProperties(op, res);
|
2006-06-05 01:01:02 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-16 23:21:06 +00:00
|
|
|
onUpdated();
|
2005-02-17 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/types.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Thing.cpp,
rulesets/Thing.h: Add core op handling for update operation, used
to handle move ops better.
2005-02-17 01:47:32 +00:00
|
|
|
}
|
2006-07-22 18:13:29 +00:00
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
bool Thing::lookAtEntity(const Operation& op, OpVector& res, const LocatedEntity* watcher) const
|
|
|
|
|
{
|
2016-06-26 13:17:32 +02:00
|
|
|
|
2016-06-26 14:18:37 +02:00
|
|
|
if (isVisibleForOtherEntity(watcher)) {
|
|
|
|
|
generateSightOp(*watcher, op, res);
|
2016-06-26 13:17:32 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2016-06-26 14:18:37 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-06-26 13:17:32 +02:00
|
|
|
|
2016-06-17 22:25:38 +02:00
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
void Thing::generateSightOp(const LocatedEntity& observingEntity, const Operation& originalLookOp, OpVector& res) const
|
2016-06-22 16:46:01 +02:00
|
|
|
{
|
|
|
|
|
debug_print("Thing::generateSightOp() observer " << observingEntity.describeEntity() << " observed " << this->describeEntity());
|
2016-06-17 22:25:38 +02:00
|
|
|
|
2016-06-22 16:46:01 +02:00
|
|
|
Sight s;
|
2016-06-17 22:25:38 +02:00
|
|
|
|
2016-06-22 16:46:01 +02:00
|
|
|
Anonymous sarg;
|
2018-07-30 10:22:50 +02:00
|
|
|
|
2018-10-06 13:25:53 +02:00
|
|
|
//Admin entities can see all properties
|
|
|
|
|
if (observingEntity.hasFlags(entity_admin)) {
|
|
|
|
|
for (auto& entry : m_properties) {
|
|
|
|
|
entry.second->add(entry.first, sarg);
|
|
|
|
|
}
|
|
|
|
|
} else if (observingEntity.getIntId() == getIntId()) {
|
|
|
|
|
//Our own entity can see both public and protected, but not private properties.
|
2018-07-30 10:22:50 +02:00
|
|
|
for (auto& entry : m_properties) {
|
|
|
|
|
if (!entry.second->hasFlags(vis_private)) {
|
|
|
|
|
entry.second->add(entry.first, sarg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2018-10-06 13:25:53 +02:00
|
|
|
//Other entities can only see public properties.
|
2018-07-30 10:22:50 +02:00
|
|
|
for (auto& entry : m_properties) {
|
|
|
|
|
if (!entry.second->hasFlags(vis_non_public)) {
|
|
|
|
|
entry.second->add(entry.first, sarg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sarg->setStamp(m_seq);
|
|
|
|
|
if (m_type) {
|
|
|
|
|
sarg->setParent(m_type->name());
|
|
|
|
|
}
|
|
|
|
|
m_location.addToEntity(sarg);
|
|
|
|
|
sarg->setObjtype("obj");
|
|
|
|
|
|
2016-06-22 16:46:01 +02:00
|
|
|
s->setArgs1(sarg);
|
|
|
|
|
|
|
|
|
|
if (m_contains != nullptr) {
|
|
|
|
|
|
|
|
|
|
//If the observed entity has a domain, let it decide child visibility.
|
|
|
|
|
//Otherwise show all children.
|
2017-07-01 15:26:47 +02:00
|
|
|
const Domain* observedEntityDomain = getDomain();
|
2017-06-27 18:33:13 +02:00
|
|
|
std::list<std::string>& contlist = sarg->modifyContains();
|
2016-06-22 16:46:01 +02:00
|
|
|
if (observedEntityDomain) {
|
|
|
|
|
contlist.clear();
|
2016-09-03 23:14:06 +02:00
|
|
|
std::list<LocatedEntity*> entityList;
|
|
|
|
|
observedEntityDomain->getVisibleEntitiesFor(observingEntity, entityList);
|
|
|
|
|
for (auto& entity : entityList) {
|
|
|
|
|
contlist.push_back(entity->getId());
|
|
|
|
|
}
|
2016-06-22 16:46:01 +02:00
|
|
|
}
|
|
|
|
|
// if (contlist.empty()) {
|
|
|
|
|
// sarg->removeAttr("contains");
|
|
|
|
|
// }
|
|
|
|
|
}
|
2016-06-17 22:25:38 +02:00
|
|
|
|
2018-08-17 22:04:07 +02:00
|
|
|
if (m_location.m_parent) {
|
|
|
|
|
if (!m_location.m_parent->isVisibleForOtherEntity(&observingEntity)) {
|
2016-06-26 14:18:37 +02:00
|
|
|
sarg->removeAttr("loc");
|
|
|
|
|
}
|
2016-06-22 16:46:01 +02:00
|
|
|
}
|
2016-06-17 22:25:38 +02:00
|
|
|
|
2016-06-22 16:46:01 +02:00
|
|
|
s->setTo(originalLookOp->getFrom());
|
|
|
|
|
if (!originalLookOp->isDefaultSerialno()) {
|
|
|
|
|
s->setRefno(originalLookOp->getSerialno());
|
|
|
|
|
}
|
|
|
|
|
res.push_back(s);
|
2016-06-17 22:25:38 +02:00
|
|
|
|
2016-06-22 16:46:01 +02:00
|
|
|
}
|
2016-06-17 22:25:38 +02:00
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
void Thing::LookOperation(const Operation& op, OpVector& res)
|
2016-06-22 16:46:01 +02:00
|
|
|
{
|
2018-08-05 20:47:09 +02:00
|
|
|
auto from = BaseWorld::instance().getEntity(op->getFrom());
|
|
|
|
|
if (!from) {
|
2016-06-26 14:27:24 +02:00
|
|
|
log(ERROR, String::compose("Look op has invalid from %1. %2", op->getFrom(), describeEntity()));
|
2016-06-22 16:46:01 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2018-04-25 12:21:44 +02:00
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
bool result = lookAtEntity(op, res, from.get());
|
2016-06-17 22:25:38 +02:00
|
|
|
|
2016-06-22 16:46:01 +02:00
|
|
|
if (!result) {
|
2015-04-15 23:06:33 +02:00
|
|
|
Unseen u;
|
|
|
|
|
u->setTo(op->getFrom());
|
|
|
|
|
u->setArgs(op->getArgs());
|
|
|
|
|
if (!op->isDefaultSerialno()) {
|
|
|
|
|
u->setRefno(op->getSerialno());
|
|
|
|
|
}
|
|
|
|
|
res.push_back(u);
|
2012-06-09 18:39:45 -07:00
|
|
|
}
|
2006-07-22 18:13:29 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-27 18:33:13 +02:00
|
|
|
void Thing::CreateOperation(const Operation& op, OpVector& res)
|
2006-07-22 18:13:29 +00:00
|
|
|
{
|
2017-06-27 18:33:13 +02:00
|
|
|
const std::vector<Root>& args = op->getArgs();
|
2006-07-22 18:13:29 +00:00
|
|
|
if (args.empty()) {
|
2017-06-27 18:33:13 +02:00
|
|
|
return;
|
2006-07-22 18:13:29 +00:00
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
RootEntity ent = smart_dynamic_cast<RootEntity>(args.front());
|
|
|
|
|
if (!ent.isValid()) {
|
|
|
|
|
error(op, "Entity to be created is malformed", res, getId());
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-07-24 13:39:22 +02:00
|
|
|
const std::string& type = ent->getParent();
|
2017-07-25 14:10:37 +02:00
|
|
|
if (type.empty()) {
|
2017-07-24 13:39:22 +02:00
|
|
|
error(op, "Entity to be created has empty parent", res, getId());
|
2006-07-22 18:13:29 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2016-01-17 17:02:50 +01:00
|
|
|
|
|
|
|
|
//If there's no location set we'll use the same one as the current entity.
|
2018-08-17 22:04:07 +02:00
|
|
|
if (!ent->hasAttrFlag(Atlas::Objects::Entity::LOC_FLAG) && (m_location.m_parent)) {
|
|
|
|
|
ent->setLoc(m_location.m_parent->getId());
|
2006-07-22 18:13:29 +00:00
|
|
|
}
|
2016-09-03 23:21:17 +02:00
|
|
|
debug_print(getId() << " creating " << type);
|
2006-07-22 18:13:29 +00:00
|
|
|
|
2018-07-25 19:48:40 +02:00
|
|
|
auto obj = BaseWorld::instance().addNewEntity(type, ent);
|
2006-07-22 18:13:29 +00:00
|
|
|
|
2018-07-25 19:48:40 +02:00
|
|
|
if (!obj) {
|
2006-07-22 18:13:29 +00:00
|
|
|
error(op, "Create op failed.", res, op->getFrom());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Anonymous new_ent;
|
|
|
|
|
obj->addToEntity(new_ent);
|
2012-06-29 14:53:15 -07:00
|
|
|
|
|
|
|
|
if (!op->isDefaultSerialno()) {
|
|
|
|
|
Info i;
|
|
|
|
|
i->setArgs1(new_ent);
|
|
|
|
|
i->setTo(op->getFrom());
|
|
|
|
|
res.push_back(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Operation c(op.copy());
|
2006-07-22 18:13:29 +00:00
|
|
|
c->setArgs1(new_ent);
|
|
|
|
|
|
|
|
|
|
Sight s;
|
|
|
|
|
s->setArgs1(c);
|
2018-07-30 13:07:43 +02:00
|
|
|
//TODO: perhaps check that we don't send private and protected properties?
|
|
|
|
|
broadcast(s, res, Visibility::PUBLIC);
|
2006-07-22 18:13:29 +00:00
|
|
|
}
|
|
|
|
|
catch (Atlas::Message::WrongTypeException&) {
|
|
|
|
|
log(ERROR, "EXCEPTION: Malformed object to be created");
|
|
|
|
|
error(op, "Malformed object to be created", res, getId());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-09 21:30:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void Thing::ImaginaryOperation(const Operation & op, OpVector & res)
|
|
|
|
|
{
|
|
|
|
|
Sight s{};
|
|
|
|
|
s->setArgs1(op);
|
|
|
|
|
res.push_back(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Thing::TalkOperation(const Operation & op, OpVector & res)
|
|
|
|
|
{
|
|
|
|
|
Sound s{};
|
|
|
|
|
s->setArgs1(op);
|
|
|
|
|
res.push_back(s);
|
|
|
|
|
}
|