2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2005-11-18 01:11:42 +00:00
|
|
|
// Copyright (C) 2005 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-11-18 01:11:42 +00:00
|
|
|
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2011-02-15 09:30:46 +00:00
|
|
|
#ifdef NDEBUG
|
|
|
|
|
#undef NDEBUG
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
|
#define DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-03-03 22:37:11 +00:00
|
|
|
#include "TestBase.h"
|
2005-11-18 01:11:42 +00:00
|
|
|
#include "TestWorld.h"
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
#include "server/CorePropertyManager.h"
|
2009-03-14 04:21:31 +00:00
|
|
|
#include "server/EntityBuilder.h"
|
2009-03-22 15:30:23 +00:00
|
|
|
#include "server/EntityFactory.h"
|
2013-10-23 22:36:55 +02:00
|
|
|
#include "server/ArchetypeFactory.h"
|
2005-11-18 01:11:42 +00:00
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/Thing.h"
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/simulation/Entity.h"
|
|
|
|
|
#include "rules/Script.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/Task.h"
|
2010-07-15 23:46:06 +01:00
|
|
|
|
|
|
|
|
#include "common/compose.hpp"
|
|
|
|
|
#include "common/id.h"
|
2009-03-20 15:31:38 +00:00
|
|
|
#include "common/Inheritance.h"
|
2010-07-15 23:46:06 +01:00
|
|
|
#include "common/log.h"
|
|
|
|
|
#include "common/Monitors.h"
|
|
|
|
|
#include "common/Property_impl.h"
|
2009-08-21 00:23:47 +01:00
|
|
|
#include "common/TypeNode.h"
|
2010-07-15 23:46:06 +01:00
|
|
|
#include "common/Variable.h"
|
2011-12-16 08:14:36 +00:00
|
|
|
#include "common/ScriptKit.h"
|
2008-09-08 11:49:22 +00:00
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubEntity.h"
|
|
|
|
|
#include "stubs/rules/stubLocation.h"
|
2015-04-09 14:50:45 +02:00
|
|
|
#include "stubs/common/stubVariable.h"
|
|
|
|
|
#include "stubs/common/stubMonitors.h"
|
2014-08-27 22:17:09 +02:00
|
|
|
|
2005-11-18 01:11:42 +00:00
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
2010-10-20 22:51:42 +01:00
|
|
|
#include <Atlas/Objects/RootOperation.h>
|
2005-11-18 01:11:42 +00:00
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
#include <cstdlib>
|
|
|
|
|
|
2005-11-18 01:11:42 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
using Atlas::Message::Element;
|
|
|
|
|
using Atlas::Message::ListType;
|
2005-11-18 01:11:42 +00:00
|
|
|
using Atlas::Message::MapType;
|
|
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
2007-11-22 02:06:52 +00:00
|
|
|
using Atlas::Objects::Root;
|
2005-11-18 01:11:42 +00:00
|
|
|
|
2013-03-03 22:37:11 +00:00
|
|
|
class EntityBuildertest : public Cyphesis::TestBase
|
|
|
|
|
{
|
2013-03-03 23:16:44 +00:00
|
|
|
private:
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> e;
|
2013-03-03 23:16:44 +00:00
|
|
|
BaseWorld * test_world;
|
2018-08-04 01:12:45 +02:00
|
|
|
EntityBuilder* eb;
|
2013-03-03 22:37:11 +00:00
|
|
|
public:
|
|
|
|
|
EntityBuildertest();
|
|
|
|
|
|
|
|
|
|
void setup();
|
|
|
|
|
void teardown();
|
|
|
|
|
|
2013-03-03 23:04:15 +00:00
|
|
|
void test_sequence1();
|
|
|
|
|
void test_sequence2();
|
|
|
|
|
void test_sequence3();
|
|
|
|
|
void test_sequence4();
|
|
|
|
|
void test_sequence5();
|
2013-03-03 23:35:03 +00:00
|
|
|
void test_installFactory_duplicate();
|
2018-04-25 20:09:14 +02:00
|
|
|
|
|
|
|
|
Inheritance* inheritance;
|
2013-03-03 22:37:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
EntityBuildertest::EntityBuildertest()
|
|
|
|
|
{
|
2013-03-03 23:04:15 +00:00
|
|
|
ADD_TEST(EntityBuildertest::test_sequence1);
|
|
|
|
|
ADD_TEST(EntityBuildertest::test_sequence2);
|
|
|
|
|
ADD_TEST(EntityBuildertest::test_sequence3);
|
|
|
|
|
ADD_TEST(EntityBuildertest::test_sequence4);
|
|
|
|
|
ADD_TEST(EntityBuildertest::test_sequence5);
|
2013-03-03 23:35:03 +00:00
|
|
|
ADD_TEST(EntityBuildertest::test_installFactory_duplicate);
|
2013-03-03 22:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EntityBuildertest::setup()
|
|
|
|
|
{
|
2018-04-25 20:09:14 +02:00
|
|
|
inheritance = new Inheritance();
|
2013-03-03 23:16:44 +00:00
|
|
|
e = new Entity("1", 1);
|
2018-08-05 14:31:04 +02:00
|
|
|
test_world = new TestWorld(e);
|
2018-08-04 01:12:45 +02:00
|
|
|
eb = new EntityBuilder();
|
2018-01-19 21:35:48 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
EntityBuilder::instance().installBaseFactory("thing", "game_entity", new EntityFactory<Thing>());
|
2013-03-03 22:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EntityBuildertest::teardown()
|
|
|
|
|
{
|
2013-03-03 23:16:44 +00:00
|
|
|
delete test_world;
|
2018-08-05 14:31:04 +02:00
|
|
|
e = nullptr;
|
2018-08-04 01:12:45 +02:00
|
|
|
delete eb;
|
|
|
|
|
assert(!EntityBuilder::hasInstance());
|
2018-04-25 20:09:14 +02:00
|
|
|
delete inheritance;
|
2013-03-03 22:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 02:12:53 +01:00
|
|
|
enum action {
|
|
|
|
|
DO_NOTHING,
|
|
|
|
|
SET_POS,
|
|
|
|
|
SET_VELOCITY } LocatedEntity_merge_action = DO_NOTHING;
|
|
|
|
|
|
2013-03-03 23:04:15 +00:00
|
|
|
void EntityBuildertest::test_sequence1()
|
2005-11-18 01:11:42 +00:00
|
|
|
{
|
2013-03-03 23:19:39 +00:00
|
|
|
Anonymous attributes;
|
2013-03-03 22:55:15 +00:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
assert(EntityBuilder::instance().newEntity("1", 1, "world", attributes, BaseWorld::instance()) == nullptr);
|
|
|
|
|
assert(EntityBuilder::instance().newEntity("1", 1, "nonexistant", attributes, BaseWorld::instance()) == nullptr);
|
|
|
|
|
assert(EntityBuilder::instance().newEntity("1", 1, "thing", attributes, BaseWorld::instance()) != nullptr);
|
2013-03-03 23:04:15 +00:00
|
|
|
}
|
2005-11-18 01:11:42 +00:00
|
|
|
|
2013-03-03 23:04:15 +00:00
|
|
|
void EntityBuildertest::test_sequence2()
|
|
|
|
|
{
|
2013-03-03 23:19:39 +00:00
|
|
|
Anonymous attributes;
|
2013-03-03 22:55:15 +00:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Create a normal Entity
|
2018-08-05 20:47:09 +02:00
|
|
|
auto test_ent = EntityBuilder::instance().newEntity("1", 1, "thing", attributes, BaseWorld::instance());
|
|
|
|
|
assert(test_ent);
|
2005-11-18 01:11:42 +00:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Create an entity specifying an attrbute
|
|
|
|
|
attributes->setAttr("funky", "true");
|
2005-11-18 01:11:42 +00:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
test_ent = EntityBuilder::instance().newEntity("1", 1, "thing", attributes, BaseWorld::instance());
|
2018-08-05 20:47:09 +02:00
|
|
|
assert(test_ent);
|
2005-11-18 01:11:42 +00:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Create an entity causing VELOCITY to be set
|
|
|
|
|
attributes = Anonymous();
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
attributes->setVelocity(std::vector<double>(3, 1.5));
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
LocatedEntity_merge_action = SET_VELOCITY;
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
test_ent = EntityBuilder::instance().newEntity("1", 1, "thing", attributes, BaseWorld::instance());
|
2018-08-05 20:47:09 +02:00
|
|
|
assert(test_ent);
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
LocatedEntity_merge_action = DO_NOTHING;
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Create an entity causing VELOCITY to be set for no obvious reason
|
|
|
|
|
attributes = Anonymous();
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
LocatedEntity_merge_action = SET_VELOCITY;
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
test_ent = EntityBuilder::instance().newEntity("1", 1, "thing", attributes, BaseWorld::instance());
|
2018-08-05 20:47:09 +02:00
|
|
|
assert(test_ent);
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
LocatedEntity_merge_action = DO_NOTHING;
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Create an entity specifying a LOC
|
|
|
|
|
attributes = Anonymous();
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
attributes->setLoc("1");
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
test_ent = EntityBuilder::instance().newEntity("1", 1, "thing", attributes, BaseWorld::instance());
|
2018-08-05 20:47:09 +02:00
|
|
|
assert(test_ent);
|
2013-03-03 23:04:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EntityBuildertest::test_sequence3()
|
|
|
|
|
{
|
2018-08-04 01:12:45 +02:00
|
|
|
EntityBuilder & entity_factory = EntityBuilder::instance();
|
2005-11-18 15:09:08 +00:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Attributes for test entities being created
|
|
|
|
|
Anonymous attributes;
|
2005-11-18 15:09:08 +00:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Create an entity which is an instance of one of the core classes
|
2018-08-05 20:47:09 +02:00
|
|
|
auto test_ent = entity_factory.newEntity("1", 1, "thing", attributes, BaseWorld::instance());
|
|
|
|
|
assert(test_ent);
|
2013-03-03 23:04:15 +00:00
|
|
|
}
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:04:15 +00:00
|
|
|
void EntityBuildertest::test_sequence4()
|
|
|
|
|
{
|
2018-08-04 01:12:45 +02:00
|
|
|
EntityBuilder & entity_factory = EntityBuilder::instance();
|
2013-03-03 23:19:39 +00:00
|
|
|
// Attributes for test entities being created
|
|
|
|
|
Anonymous attributes;
|
|
|
|
|
|
|
|
|
|
// Check that creating an entity of a type we know we have not yet
|
|
|
|
|
// installed results in a null pointer.
|
2018-07-24 21:18:50 +02:00
|
|
|
assert(entity_factory.newEntity("1", 1, "custom_type", attributes, BaseWorld::instance()) == nullptr);
|
2013-03-03 23:19:39 +00:00
|
|
|
|
|
|
|
|
// Get a reference to the internal dictionary of entity factories.
|
|
|
|
|
const FactoryDict & factory_dict = entity_factory.m_entityFactories;
|
|
|
|
|
|
|
|
|
|
// Make sure it has some factories in it already.
|
|
|
|
|
assert(!factory_dict.empty());
|
|
|
|
|
|
|
|
|
|
// Assert the dictionary does not contain the factory we know we have
|
|
|
|
|
// have not yet installed.
|
|
|
|
|
assert(factory_dict.find("custom_type") == factory_dict.end());
|
|
|
|
|
|
|
|
|
|
// Set up a type description for a new type, and install it
|
2013-10-23 22:36:55 +02:00
|
|
|
EntityFactoryBase * custom_type_factory = new EntityFactory<Entity>();
|
2013-03-03 23:19:39 +00:00
|
|
|
custom_type_factory->m_attributes["test_custom_type_attr"] =
|
|
|
|
|
"test_value";
|
2010-07-16 02:12:53 +01:00
|
|
|
{
|
2013-03-03 23:38:37 +00:00
|
|
|
int ret;
|
|
|
|
|
ret = entity_factory.installFactory("custom_type",
|
|
|
|
|
atlasClass("custom_type", "thing"),
|
|
|
|
|
custom_type_factory);
|
2013-03-03 23:19:39 +00:00
|
|
|
custom_type_factory->m_type = new TypeNode("custom_type");
|
2013-03-03 23:38:37 +00:00
|
|
|
|
|
|
|
|
ASSERT_EQUAL(ret, 0);
|
2010-07-16 02:12:53 +01:00
|
|
|
}
|
2013-03-03 23:19:39 +00:00
|
|
|
|
2018-01-28 21:25:12 +01:00
|
|
|
PropertyBase * p = new Property<std::string>;
|
|
|
|
|
custom_type_factory->m_type->injectProperty("test_custom_type_attr", p);
|
2013-03-03 23:19:39 +00:00
|
|
|
p->set("test_value");
|
|
|
|
|
|
|
|
|
|
// Check that the factory dictionary now contains a factory for
|
|
|
|
|
// the custom type we just installed.
|
|
|
|
|
FactoryDict::const_iterator I = factory_dict.find("custom_type");
|
|
|
|
|
assert(I != factory_dict.end());
|
|
|
|
|
assert(custom_type_factory == I->second);
|
|
|
|
|
|
|
|
|
|
MapType::const_iterator J;
|
|
|
|
|
// Check the factory has the attributes we described on the custom
|
|
|
|
|
// type.
|
|
|
|
|
J = custom_type_factory->m_attributes.find("test_custom_type_attr");
|
|
|
|
|
assert(J != custom_type_factory->m_attributes.end());
|
|
|
|
|
assert(J->second.isString());
|
|
|
|
|
assert(J->second.String() == "test_value");
|
|
|
|
|
|
|
|
|
|
// Create an instance of our custom type, ensuring that it works.
|
2018-08-05 20:47:09 +02:00
|
|
|
auto test_ent = entity_factory.newEntity("1", 1, "custom_type", attributes, BaseWorld::instance());
|
|
|
|
|
assert(test_ent);
|
2013-03-03 23:19:39 +00:00
|
|
|
|
|
|
|
|
assert(test_ent->getType() == custom_type_factory->m_type);
|
|
|
|
|
|
|
|
|
|
// Check that creating an entity of a type we know we have not yet
|
|
|
|
|
// installed results in a null pointer.
|
2018-07-24 21:18:50 +02:00
|
|
|
assert(entity_factory.newEntity("1", 1, "custom_inherited_type", attributes, BaseWorld::instance()) == nullptr);
|
2013-03-03 23:19:39 +00:00
|
|
|
|
|
|
|
|
// Assert the dictionary does not contain the factory we know we have
|
|
|
|
|
// have not yet installed.
|
|
|
|
|
assert(factory_dict.find("custom_inherited_type") == factory_dict.end());
|
2013-03-03 23:04:15 +00:00
|
|
|
}
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:04:15 +00:00
|
|
|
void EntityBuildertest::test_sequence5()
|
|
|
|
|
{
|
2018-08-04 01:12:45 +02:00
|
|
|
EntityBuilder & entity_factory = EntityBuilder::instance();
|
2013-03-03 23:19:39 +00:00
|
|
|
Anonymous attributes;
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Get a reference to the internal dictionary of entity factories.
|
|
|
|
|
const FactoryDict & factory_dict = entity_factory.m_entityFactories;
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Make sure it has some factories in it already.
|
|
|
|
|
assert(!factory_dict.empty());
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Assert the dictionary does not contain the factory we know we have
|
|
|
|
|
// have not yet installed.
|
|
|
|
|
assert(factory_dict.find("custom_scripted_type") == factory_dict.end());
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Set up a type description for a new type, and install it
|
2013-10-23 22:36:55 +02:00
|
|
|
EntityFactoryBase * custom_type_factory = new EntityFactory<Entity>();
|
2013-03-03 23:19:39 +00:00
|
|
|
custom_type_factory->m_attributes["test_custom_type_attr"] =
|
|
|
|
|
"test_value";
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
{
|
|
|
|
|
entity_factory.installFactory("custom_scripted_type",
|
|
|
|
|
atlasClass("custom_scripted_type", "thing"),
|
|
|
|
|
custom_type_factory);
|
|
|
|
|
custom_type_factory->m_type = new TypeNode("custom_scripted_type");
|
|
|
|
|
}
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Check that the factory dictionary now contains a factory for
|
|
|
|
|
// the custom type we just installed.
|
|
|
|
|
FactoryDict::const_iterator I = factory_dict.find("custom_scripted_type");
|
|
|
|
|
assert(I != factory_dict.end());
|
|
|
|
|
assert(custom_type_factory == I->second);
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
// Create an instance of our custom type, ensuring that it works.
|
2018-08-05 20:47:09 +02:00
|
|
|
auto test_ent = entity_factory.newEntity("1", 1, "custom_scripted_type", attributes, BaseWorld::instance());
|
|
|
|
|
assert(test_ent);
|
2010-07-16 02:12:53 +01:00
|
|
|
|
2013-03-03 23:19:39 +00:00
|
|
|
assert(test_ent->getType() == custom_type_factory->m_type);
|
2005-11-18 01:11:42 +00:00
|
|
|
}
|
2010-07-15 23:46:06 +01:00
|
|
|
|
2013-03-03 23:35:03 +00:00
|
|
|
void EntityBuildertest::test_installFactory_duplicate()
|
|
|
|
|
{
|
2018-08-04 01:12:45 +02:00
|
|
|
EntityBuilder & entity_factory = EntityBuilder::instance();
|
2013-03-03 23:35:03 +00:00
|
|
|
FactoryDict & factories = entity_factory.m_entityFactories;
|
|
|
|
|
|
2013-10-23 22:36:55 +02:00
|
|
|
EntityFactoryBase * custom_type_factory = new EntityFactory<Entity>();
|
2013-03-03 23:35:03 +00:00
|
|
|
|
|
|
|
|
int ret = entity_factory.installFactory("custom_type",
|
|
|
|
|
atlasClass("custom_type", "thing"),
|
|
|
|
|
custom_type_factory);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(ret, 0);
|
|
|
|
|
ASSERT_TRUE(factories.find("custom_type") != factories.end());
|
|
|
|
|
ASSERT_EQUAL(factories.find("custom_type")->second, custom_type_factory);
|
|
|
|
|
|
2013-10-23 22:36:55 +02:00
|
|
|
EntityFactoryBase * custom_type_factory2 = new EntityFactory<Entity>();
|
2013-03-03 23:35:03 +00:00
|
|
|
|
|
|
|
|
ret = entity_factory.installFactory("custom_type",
|
|
|
|
|
atlasClass("custom_type", "thing"),
|
|
|
|
|
custom_type_factory2);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(ret, -1);
|
|
|
|
|
ASSERT_TRUE(factories.find("custom_type") != factories.end());
|
|
|
|
|
ASSERT_EQUAL(factories.find("custom_type")->second, custom_type_factory);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-03 22:37:11 +00:00
|
|
|
int main(int argc, char ** argv)
|
|
|
|
|
{
|
|
|
|
|
EntityBuildertest t;
|
|
|
|
|
|
|
|
|
|
return t.run();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
// stubs
|
|
|
|
|
|
2012-09-11 22:53:15 +01:00
|
|
|
|
2012-09-06 13:48:40 +01:00
|
|
|
|
2018-04-29 16:26:32 +02:00
|
|
|
#include "stubs/common/stubEntityKit.h"
|
2010-07-15 23:46:06 +01:00
|
|
|
|
|
|
|
|
|
2018-04-29 16:26:32 +02:00
|
|
|
#define STUB_EntityFactory_newEntity
|
|
|
|
|
template <class T>
|
2018-07-24 21:18:50 +02:00
|
|
|
Ref<LocatedEntity> EntityFactory<T>::newEntity(const std::string & id, long intId,
|
2018-04-29 16:26:32 +02:00
|
|
|
const Atlas::Objects::Entity::RootEntity & attributes, LocatedEntity* location)
|
2013-10-23 22:36:55 +02:00
|
|
|
{
|
2018-04-29 16:26:32 +02:00
|
|
|
++m_createdCount;
|
|
|
|
|
Entity* e = new Entity(id, intId);
|
|
|
|
|
e->setType(m_type);
|
|
|
|
|
return e;
|
2013-10-23 22:36:55 +02:00
|
|
|
}
|
|
|
|
|
|
2018-04-29 16:26:32 +02:00
|
|
|
#define STUB_EntityFactory_duplicateFactory
|
|
|
|
|
template <typename T>
|
|
|
|
|
EntityFactoryBase* EntityFactory<T>::duplicateFactory()
|
2013-10-23 22:36:55 +02:00
|
|
|
{
|
2018-04-29 16:26:32 +02:00
|
|
|
EntityFactoryBase * f = new EntityFactory<T>(*this);
|
|
|
|
|
f->m_parent = this;
|
|
|
|
|
return f;
|
2013-10-23 22:36:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-04-29 16:26:32 +02:00
|
|
|
#include "stubs/server/stubEntityFactory.h"
|
2013-10-23 22:36:55 +02:00
|
|
|
|
2018-04-29 16:26:32 +02:00
|
|
|
#define STUB_ArchetypeFactory_duplicateFactory
|
|
|
|
|
ArchetypeFactory* ArchetypeFactory::duplicateFactory()
|
2013-10-23 22:36:55 +02:00
|
|
|
{
|
|
|
|
|
ArchetypeFactory * f = new ArchetypeFactory(*this);
|
|
|
|
|
f->m_parent = this;
|
|
|
|
|
return f;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 16:26:32 +02:00
|
|
|
|
|
|
|
|
#include "stubs/server/stubArchetypeFactory.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/python/stubScriptsProperty.h"
|
2013-10-23 22:36:55 +02:00
|
|
|
|
|
|
|
|
|
2012-12-14 18:50:13 +00:00
|
|
|
class World;
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
template <>
|
2018-07-24 21:18:50 +02:00
|
|
|
Ref<LocatedEntity> EntityFactory<World>::newEntity(const std::string & id, long intId,
|
2013-10-23 22:36:55 +02:00
|
|
|
const Atlas::Objects::Entity::RootEntity & attributes, LocatedEntity* location)
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-14 18:50:13 +00:00
|
|
|
class Thing;
|
|
|
|
|
class Character;
|
|
|
|
|
class Creator;
|
|
|
|
|
class Plant;
|
|
|
|
|
class Stackable;
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
template class EntityFactory<Entity>;
|
|
|
|
|
template class EntityFactory<Thing>;
|
|
|
|
|
template class EntityFactory<Character>;
|
|
|
|
|
template class EntityFactory<Creator>;
|
|
|
|
|
template class EntityFactory<Plant>;
|
|
|
|
|
template class EntityFactory<Stackable>;
|
|
|
|
|
template class EntityFactory<World>;
|
|
|
|
|
|
2018-02-26 12:05:10 +01:00
|
|
|
#define STUB_LocatedEntity_makeContainer
|
2010-07-15 23:46:06 +01:00
|
|
|
void LocatedEntity::makeContainer()
|
|
|
|
|
{
|
|
|
|
|
if (m_contains == 0) {
|
|
|
|
|
m_contains = new LocatedEntitySet;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-26 12:05:10 +01:00
|
|
|
#define STUB_LocatedEntity_merge
|
2010-07-15 23:46:06 +01:00
|
|
|
void LocatedEntity::merge(const MapType & ent)
|
|
|
|
|
{
|
2010-07-16 02:12:53 +01:00
|
|
|
switch (LocatedEntity_merge_action) {
|
|
|
|
|
case SET_POS:
|
|
|
|
|
this->m_location.m_pos.setValid();
|
|
|
|
|
break;
|
|
|
|
|
case SET_VELOCITY:
|
|
|
|
|
this->m_location.m_velocity.setValid();
|
|
|
|
|
break;
|
|
|
|
|
case DO_NOTHING:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
};
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/stubLocatedEntity.h"
|
2015-04-09 14:50:45 +02:00
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
void log(LogLevel lvl, const std::string & msg)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-25 20:09:14 +02:00
|
|
|
#ifndef STUB_Inheritance_Inheritance
|
|
|
|
|
#define STUB_Inheritance_Inheritance
|
2012-09-18 08:49:50 +01:00
|
|
|
Inheritance::Inheritance() : noClass(0)
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
|
|
|
|
Atlas::Objects::Entity::Anonymous root_desc;
|
|
|
|
|
|
|
|
|
|
root_desc->setObjtype("meta");
|
|
|
|
|
root_desc->setId("root");
|
|
|
|
|
|
2011-09-17 18:54:37 +01:00
|
|
|
TypeNode * root = new TypeNode("root", root_desc);
|
2010-07-15 23:46:06 +01:00
|
|
|
|
|
|
|
|
atlasObjects["root"] = root;
|
2018-04-25 20:09:14 +02:00
|
|
|
installStandardObjects(*this);
|
2010-07-15 23:46:06 +01:00
|
|
|
}
|
2018-04-25 20:09:14 +02:00
|
|
|
#endif //STUB_Inheritance_Inheritance
|
2010-07-15 23:46:06 +01:00
|
|
|
|
2018-04-25 20:09:14 +02:00
|
|
|
#ifndef STUB_Inheritance_getType
|
|
|
|
|
#define STUB_Inheritance_getType
|
2018-10-27 13:13:45 +02:00
|
|
|
const TypeNode* Inheritance::getType(const std::string & parent) const
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
2018-10-27 13:13:45 +02:00
|
|
|
auto I = atlasObjects.find(parent);
|
2010-07-15 23:46:06 +01:00
|
|
|
if (I == atlasObjects.end()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2018-04-25 20:09:14 +02:00
|
|
|
return I->second;}
|
|
|
|
|
#endif //STUB_Inheritance_getType
|
2010-07-15 23:46:06 +01:00
|
|
|
|
2018-04-25 20:09:14 +02:00
|
|
|
#ifndef STUB_Inheritance_addChild
|
|
|
|
|
#define STUB_Inheritance_addChild
|
|
|
|
|
TypeNode* Inheritance::addChild(const Atlas::Objects::Root & obj)
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
|
|
|
|
const std::string & child = obj->getId();
|
2017-07-24 13:39:22 +02:00
|
|
|
const std::string & parent = obj->getParent();
|
2010-07-15 23:46:06 +01:00
|
|
|
if (atlasObjects.find(child) != atlasObjects.end()) {
|
|
|
|
|
std::cerr << String::compose("Installing type \"%1\"(\"%2\") "
|
2018-04-25 20:09:14 +02:00
|
|
|
"which was already installed",
|
|
|
|
|
child, parent) << std::endl;
|
2010-07-15 23:46:06 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
2018-10-27 13:13:45 +02:00
|
|
|
auto I = atlasObjects.find(parent);
|
2010-07-15 23:46:06 +01:00
|
|
|
if (I == atlasObjects.end()) {
|
|
|
|
|
std::cerr << String::compose("Installing type \"%1\" "
|
2018-04-25 20:09:14 +02:00
|
|
|
"which has unknown parent \"%2\".",
|
|
|
|
|
child, parent) << std::endl;
|
2010-07-15 23:46:06 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
Element children(ListType(1, child));
|
2018-10-27 13:13:45 +02:00
|
|
|
if (I->second->description(Visibility::PRIVATE)->copyAttr("children", children) == 0) {
|
2010-07-15 23:46:06 +01:00
|
|
|
assert(children.isList());
|
|
|
|
|
children.asList().push_back(child);
|
|
|
|
|
}
|
2018-10-27 13:13:45 +02:00
|
|
|
I->second->description(Visibility::PRIVATE)->setAttr("children", children);
|
2010-07-15 23:46:06 +01:00
|
|
|
|
2011-09-17 18:54:37 +01:00
|
|
|
TypeNode * type = new TypeNode(child, obj);
|
2010-07-15 23:46:06 +01:00
|
|
|
type->setParent(I->second);
|
|
|
|
|
|
|
|
|
|
atlasObjects[child] = type;
|
|
|
|
|
|
2018-04-25 20:09:14 +02:00
|
|
|
return type;}
|
|
|
|
|
#endif //STUB_Inheritance_addChild
|
|
|
|
|
|
|
|
|
|
#include "stubs/common/stubInheritance.h"
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
void installStandardObjects(TypeStore& i)
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
2018-04-25 20:09:14 +02:00
|
|
|
|
|
|
|
|
i.addChild(atlasClass("root_entity", "root"));
|
|
|
|
|
i.addChild(atlasClass("admin_entity", "root_entity"));
|
|
|
|
|
i.addChild(atlasClass("account", "admin_entity"));
|
|
|
|
|
i.addChild(atlasClass("player", "account"));
|
|
|
|
|
i.addChild(atlasClass("admin", "account"));
|
|
|
|
|
i.addChild(atlasClass("game", "admin_entity"));
|
|
|
|
|
i.addChild(atlasClass("game_entity", "root_entity"));
|
2010-07-15 23:46:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
#define STUB_TypeNode_injectProperty
|
2018-01-28 21:25:12 +01:00
|
|
|
void TypeNode::injectProperty(const std::string& name,
|
|
|
|
|
PropertyBase* p)
|
2011-09-16 16:52:45 +01:00
|
|
|
{
|
|
|
|
|
m_defaults[name] = p;
|
|
|
|
|
}
|
2018-10-27 13:13:45 +02:00
|
|
|
#include "stubs/common/stubTypeNode.h"
|
2011-09-16 16:52:45 +01:00
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
PropertyBase::PropertyBase(unsigned int flags) : m_flags(flags)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-28 22:05:56 +01:00
|
|
|
void PropertyBase::install(LocatedEntity *, const std::string & name)
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-28 22:05:56 +01:00
|
|
|
void PropertyBase::install(TypeNode *, const std::string & name)
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-25 22:42:00 +02:00
|
|
|
void PropertyBase::remove(LocatedEntity *, const std::string & name)
|
2013-11-24 20:07:56 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
void PropertyBase::apply(LocatedEntity *)
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertyBase::add(const std::string & s,
|
|
|
|
|
Atlas::Message::MapType & ent) const
|
|
|
|
|
{
|
|
|
|
|
get(ent[s]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertyBase::add(const std::string & s,
|
|
|
|
|
const Atlas::Objects::Entity::RootEntity & ent) const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
HandlerResult PropertyBase::operation(LocatedEntity *,
|
2013-01-03 23:17:51 +00:00
|
|
|
const Operation &,
|
|
|
|
|
OpVector &)
|
|
|
|
|
{
|
|
|
|
|
return OPERATION_IGNORED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
template<>
|
|
|
|
|
void Property<int>::set(const Atlas::Message::Element & e)
|
|
|
|
|
{
|
|
|
|
|
if (e.isInt()) {
|
|
|
|
|
this->m_data = e.asInt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
void Property<double>::set(const Atlas::Message::Element & e)
|
|
|
|
|
{
|
|
|
|
|
if (e.isNum()) {
|
|
|
|
|
this->m_data = e.asNum();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
void Property<std::string>::set(const Atlas::Message::Element & e)
|
|
|
|
|
{
|
|
|
|
|
if (e.isString()) {
|
|
|
|
|
this->m_data = e.String();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-04 19:18:03 +02:00
|
|
|
template<>
|
|
|
|
|
void Property<Atlas::Message::ListType>::set(const Atlas::Message::Element & e)
|
|
|
|
|
{
|
|
|
|
|
if (e.isList()) {
|
|
|
|
|
this->m_data = e.List();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
template class Property<int>;
|
|
|
|
|
template class Property<double>;
|
|
|
|
|
template class Property<std::string>;
|
2018-07-04 19:18:03 +02:00
|
|
|
template class Property<Atlas::Message::ListType>;
|
2010-07-15 23:46:06 +01:00
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
#include "stubs/common/stubRouter.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/stubScript.h"
|
|
|
|
|
#include "stubs/rules/simulation/stubTask.h"
|
2018-07-25 00:16:09 +02:00
|
|
|
#ifndef STUB_BaseWorld_getEntity
|
|
|
|
|
#define STUB_BaseWorld_getEntity
|
2018-08-05 20:47:09 +02:00
|
|
|
Ref<LocatedEntity> BaseWorld::getEntity(const std::string & id) const
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
2018-07-25 00:16:09 +02:00
|
|
|
return getEntity(integerId(id));
|
2010-07-15 23:46:06 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
Ref<LocatedEntity> BaseWorld::getEntity(long id) const
|
2010-07-15 23:46:06 +01:00
|
|
|
{
|
2018-07-25 00:16:09 +02:00
|
|
|
auto I = m_eobjects.find(id);
|
2010-07-15 23:46:06 +01:00
|
|
|
if (I != m_eobjects.end()) {
|
2018-07-25 00:16:09 +02:00
|
|
|
assert(I->second);
|
2010-07-15 23:46:06 +01:00
|
|
|
return I->second;
|
|
|
|
|
} else {
|
2018-07-25 00:16:09 +02:00
|
|
|
return nullptr;
|
2010-07-15 23:46:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
2018-07-25 00:16:09 +02:00
|
|
|
#endif //STUB_BaseWorld_getEntity
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubBaseWorld.h"
|
2018-10-30 19:31:27 +01:00
|
|
|
#include "stubs/server/stubCorePropertyManager.h"
|
2018-04-25 20:09:14 +02:00
|
|
|
#include "stubs/common/stubPropertyManager.h"
|
2013-02-22 09:57:10 +00:00
|
|
|
|
2010-07-15 23:46:06 +01:00
|
|
|
long integerId(const std::string & id)
|
|
|
|
|
{
|
|
|
|
|
long intId = strtol(id.c_str(), 0, 10);
|
|
|
|
|
if (intId == 0 && id != "0") {
|
|
|
|
|
intId = -1L;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return intId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Root atlasClass(const std::string & name, const std::string & parent)
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Entity::Anonymous r;
|
2017-07-24 13:39:22 +02:00
|
|
|
r->setParent(parent);
|
2010-07-15 23:46:06 +01:00
|
|
|
r->setObjtype("class");
|
|
|
|
|
r->setId(name);
|
|
|
|
|
return r;
|
|
|
|
|
}
|
2018-04-30 23:34:58 +02:00
|
|
|
sigc::signal<void> python_reload_scripts;
|