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-09-10 10:28:45 +00:00
|
|
|
// Copyright (C) 2000-2005 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2009-03-12 00:50:25 +00:00
|
|
|
#include "EntityBuilder.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2006-07-03 01:29:07 +00:00
|
|
|
#include "CorePropertyManager.h"
|
2009-03-22 15:30:23 +00:00
|
|
|
#include "EntityFactory.h"
|
2013-10-04 14:26:16 +02:00
|
|
|
#include "ArchetypeFactory.h"
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
2013-01-18 19:43:53 +00:00
|
|
|
#include "rulesets/LocatedEntity.h"
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
#include "common/BaseWorld.h"
|
2005-11-19 13:15:04 +00:00
|
|
|
#include "common/id.h"
|
2005-09-10 10:28:45 +00:00
|
|
|
#include "common/log.h"
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/debug.h"
|
2009-03-20 15:31:38 +00:00
|
|
|
#include "common/Inheritance.h"
|
2004-06-21 06:37:01 +00:00
|
|
|
#include "common/random.h"
|
2005-09-13 23:29:42 +00:00
|
|
|
#include "common/compose.hpp"
|
2008-09-01 17:45:59 +00:00
|
|
|
#include "common/Monitors.h"
|
2011-12-15 14:03:56 +00:00
|
|
|
#include "common/ScriptKit.h"
|
2011-12-20 15:33:31 +00:00
|
|
|
#include "common/TaskKit.h"
|
2008-09-08 Al Riddoch <alriddoch@googlemail.com>
* rulesets/ActivePropertyFactory_impl.h: Re-work the active property
factories so they just pass handler information to the property
classes rather than installing it themselves, so the property
can now handle installing the handlers each time they are installed
on an entity, making class default properties work.
* client/ClientPropertyManager.cpp, client/ClientPropertyManager.h,
common/PropertyFactory.h, common/PropertyFactory_impl.h,
common/PropertyManager.h, rulesets/ActivePropertyFactory.h,
server/CorePropertyManager.cpp, server/CorePropertyManager.h:
Modify the property manager and property factory interfaces so they
do not take a pointer to the owner, as this is never required any
more.
* rulesets/Character.cpp, rulesets/Entity.cpp: Modify code that uses
property managers to use the new interface.
* rulesets/SolidProperty.cpp, rulesets/SolidProperty.h: Make use of
the bool flag to implement this, preventing it from being tied to
having a pointer to the owner at creation time.
* rulesets/StatusProperty.cpp, rulesets/StatusProperty.h: Remove
the need for an owner pointer at construction time by using the
apply method.
* rulesets/TerrainModProperty.cpp, rulesets/TerrainModProperty.h:
Use new MultiActivePropertyManager and install method to handle
installing handlers rather than relying on the factory to do it.
* server/CorePropertyManager.cpp: Change many of the property
factories now that none get get an owner pointer.
* server/EntityFactory.cpp: Set up default properties on all type
nodes when a new class is installed, and don't apply instance
properties based on class defaults, relying on class properties.
* rulesets/Entity.cpp: Remove hard coded BBox property now that the
functionality is handled by a more special property.
2008-09-08 00:17:08 +00:00
|
|
|
#include "common/TypeNode.h"
|
2009-09-03 00:27:59 +01:00
|
|
|
#include "common/Variable.h"
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
#include <Atlas/Message/Element.h>
|
2005-08-27 14:52:12 +00:00
|
|
|
#include <Atlas/Objects/Entity.h>
|
|
|
|
|
#include <Atlas/Objects/RootOperation.h>
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2004-12-03 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.h, common/custom.cpp,
common/inheritance.cpp, common/inheritance.h,
common/inheritance_impl.h, common/op_switch.h, common/type_utils.h,
common/types.h, common/utility.cpp, common/utility.h,
modules/Location.cpp, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Creator.cpp,
rulesets/Creator.h, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/Entity_getLocation.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/Missile.h, rulesets/Pedestrian.cpp,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Operation.h, rulesets/Py_Thing.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h server/Admin.cpp, server/Admin.h,
server/CommClient.cpp, server/Connection.cpp, server/Connection.h,
server/EntityFactory.cpp, server/EntityFactory.h, server/Lobby.cpp,
server/Lobby.h, server/Persistance.cpp, server/Persistance.h,
server/Persistor.cpp, server/Player.cpp, server/Player.h,
server/ServerRouting.cpp, server/ServerRouting.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Areatest.cpp,
tests/Charactertest.cpp, tests/Creatortest.cpp,
tests/EntityExerciser.h, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/IGEntityExerciser.h, tests/Linetest.cpp, tests/Planttest.cpp,
tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp,
tests/Worldtest.cpp, tests/allOperations.h, tests/inheritancetest.cpp,
tests/utilitytest.cpp, tools/cycmd.cpp:
Modify the entity interface so that all Operation methods
take references to RootOperation, as its cleaner, and requires
less nasty casts. Clean up operations in headers generally.
2004-12-03 14:49:13 +00:00
|
|
|
using Atlas::Message::MapType;
|
2006-04-24 12:37:33 +00:00
|
|
|
using Atlas::Objects::Root;
|
2005-09-08 Al Riddoch <alriddoch@zepler.org>
* rulesets/Entity.cpp: Update copyright date.
* rulesets/BaseMind.cpp, rulesets/Entity_getLocation.h,
rulesets/Entity.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Py_Map.cpp, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp,
client/BaseClient.cpp, client/CreatorClient.cpp:
Change various methods to pass entity information
around as RootEntity rather than MapType.
2005-09-08 15:03:31 +00:00
|
|
|
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
|
|
|
|
2008-11-17 15:45:43 +00:00
|
|
|
using String::compose;
|
|
|
|
|
|
2012-12-14 18:40:51 +00:00
|
|
|
class Character;
|
|
|
|
|
class Creator;
|
|
|
|
|
class Entity;
|
|
|
|
|
class Plant;
|
|
|
|
|
class Stackable;
|
|
|
|
|
class Thing;
|
|
|
|
|
class World;
|
|
|
|
|
|
|
|
|
|
extern template class EntityFactory<Character>;
|
|
|
|
|
extern template class EntityFactory<Creator>;
|
|
|
|
|
extern template class EntityFactory<Thing>;
|
|
|
|
|
extern template class EntityFactory<Plant>;
|
|
|
|
|
extern template class EntityFactory<Stackable>;
|
|
|
|
|
extern template class EntityFactory<World>;
|
|
|
|
|
|
2007-07-24 00:27:49 +00:00
|
|
|
static const bool debug_flag = false;
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
EntityBuilder * EntityBuilder::m_instance = NULL;
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
2011-09-21 12:45:18 +01:00
|
|
|
EntityBuilder::EntityBuilder()
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
{
|
2011-09-18 17:26:26 +01:00
|
|
|
installBaseFactory("world", "game_entity", new EntityFactory<World>());
|
2009-03-22 15:18:10 +00:00
|
|
|
EntityFactory<Thing> * tft = new EntityFactory<Thing>();
|
2011-09-18 17:26:26 +01:00
|
|
|
installBaseFactory("thing", "game_entity", tft);
|
|
|
|
|
installBaseFactory("character", "thing", new EntityFactory<Character>());
|
|
|
|
|
installBaseFactory("creator", "character", new EntityFactory<Creator>());
|
|
|
|
|
installBaseFactory("plant", "thing", new EntityFactory<Plant>());
|
|
|
|
|
installBaseFactory("stackable", "thing", new EntityFactory<Stackable>());
|
2013-10-07 23:01:30 +02:00
|
|
|
installBaseFactory("archetype", "root_entity", new ArchetypeFactory());
|
2006-01-10 17:51:32 +00:00
|
|
|
|
2007-02-20 00:52:41 +00:00
|
|
|
// The property manager instance installs itself at construction time.
|
2006-07-03 01:29:07 +00:00
|
|
|
new CorePropertyManager();
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
EntityBuilder::~EntityBuilder()
|
2006-07-03 11:25:28 +00:00
|
|
|
{
|
2011-09-30 22:25:05 +01:00
|
|
|
FactoryDict::const_iterator I = m_entityFactories.begin();
|
|
|
|
|
FactoryDict::const_iterator Iend = m_entityFactories.end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
delete I->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TaskFactoryDict::const_iterator J = m_taskFactories.begin();
|
|
|
|
|
TaskFactoryDict::const_iterator Jend = m_taskFactories.end();
|
|
|
|
|
for (; J != Jend; ++J) {
|
|
|
|
|
delete J->second;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-03 11:25:28 +00:00
|
|
|
delete PropertyManager::instance();
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-03 14:12:56 +00:00
|
|
|
/// \brief Build and populate a new entity object.
|
|
|
|
|
///
|
|
|
|
|
/// A factory is found for the type of entity, and invoked to create the object
|
|
|
|
|
/// instance. If the type has a script factory, this is invoked to create the
|
|
|
|
|
/// associates script object which is attached to the entity instance.
|
|
|
|
|
/// The attribute values are then set on the instance, taking into account
|
|
|
|
|
/// the defaults for the class, and those inherited from parent classes, and
|
|
|
|
|
/// the values specified for this instance. The essential location data for
|
2013-10-04 08:50:29 +02:00
|
|
|
/// this instance is then set up.
|
2008-06-03 14:12:56 +00:00
|
|
|
/// @param id The string identifier of the new entity.
|
|
|
|
|
/// @param intId The integer identifier of the new entity.
|
|
|
|
|
/// @param type The string specifying the type of entity.
|
|
|
|
|
/// @param attributes A mapping of attribute values to set on the entity.
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * EntityBuilder::newEntity(const std::string & id, long intId,
|
|
|
|
|
const std::string & type,
|
|
|
|
|
const RootEntity & attributes,
|
|
|
|
|
const BaseWorld & world) const
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
{
|
2013-10-04 08:50:29 +02:00
|
|
|
LocatedEntity* loc = nullptr;
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
// Get location from entity, if it is present
|
2004-07-12 10:58:20 +00:00
|
|
|
// The default attributes cannot contain info on location
|
2014-09-12 23:27:36 +02:00
|
|
|
if (attributes.isValid() && attributes->hasAttrFlag(Atlas::Objects::Entity::LOC_FLAG)) {
|
2005-09-11 01:43:29 +00:00
|
|
|
const std::string & loc_id = attributes->getLoc();
|
2013-10-04 08:50:29 +02:00
|
|
|
loc = world.getEntity(loc_id);
|
2005-09-11 01:43:29 +00:00
|
|
|
}
|
2013-10-04 08:50:29 +02:00
|
|
|
if (loc == 0) {
|
2014-08-27 22:17:09 +02:00
|
|
|
// If no info was provided, put the entity in the default location world
|
|
|
|
|
loc = &world.getDefaultLocation();
|
2005-09-19 20:07:30 +00:00
|
|
|
}
|
2010-09-12 19:09:25 +01:00
|
|
|
|
2013-10-23 23:52:31 +02:00
|
|
|
try {
|
|
|
|
|
return newChildEntity(id, intId, type, attributes, *loc);
|
|
|
|
|
} catch (const std::exception& ex) {
|
|
|
|
|
log(ERROR, String::compose("Error when creating entity of type %1."
|
|
|
|
|
" Message: %2", type, ex.what()));
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2013-10-04 14:26:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocatedEntity * EntityBuilder::newChildEntity(const std::string & id,
|
|
|
|
|
long intId,
|
|
|
|
|
const std::string & type,
|
|
|
|
|
const Atlas::Objects::Entity::RootEntity & attributes,
|
|
|
|
|
LocatedEntity & parentEntity) const
|
|
|
|
|
{
|
|
|
|
|
debug(std::cout << "EntityFactor::newEntity()" << std::endl << std::flush;);
|
|
|
|
|
FactoryDict::const_iterator I = m_entityFactories.find(type);
|
|
|
|
|
if (I == m_entityFactories.end()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-10-04 08:50:29 +02:00
|
|
|
|
|
|
|
|
EntityKit * factory = I->second;
|
|
|
|
|
debug( std::cout << "[" << type << "]"
|
|
|
|
|
<< std::endl << std::flush;);
|
2013-10-04 14:26:16 +02:00
|
|
|
return factory->newEntity(id, intId, attributes, &parentEntity);
|
|
|
|
|
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-04 14:26:16 +02:00
|
|
|
|
2011-12-02 23:42:24 +00:00
|
|
|
Task * EntityBuilder::buildTask(TaskKit * factory, LocatedEntity & owner) const
|
2009-08-20 22:58:11 +01:00
|
|
|
{
|
|
|
|
|
Task * task = factory->newTask(owner);
|
|
|
|
|
|
2011-12-20 15:41:08 +00:00
|
|
|
if (task != 0 && factory->m_scriptFactory != 0) {
|
|
|
|
|
if (factory->m_scriptFactory->addScript(task) != 0) {
|
2009-08-20 22:58:11 +01:00
|
|
|
log(ERROR, "Assigning script to task failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return task;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-03 14:12:56 +00:00
|
|
|
/// \brief Build and populate a new task object.
|
|
|
|
|
///
|
|
|
|
|
/// @param name The name of the task type.
|
|
|
|
|
/// @param owner The character entity that owns the task.
|
2011-12-02 23:42:24 +00:00
|
|
|
Task * EntityBuilder::newTask(const std::string & name, LocatedEntity & owner) const
|
2005-12-08 03:04:04 +00:00
|
|
|
{
|
|
|
|
|
TaskFactoryDict::const_iterator I = m_taskFactories.find(name);
|
|
|
|
|
if (I == m_taskFactories.end()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2009-08-20 22:58:11 +01:00
|
|
|
return buildTask(I->second, owner);
|
2006-04-05 01:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-19 02:47:15 +01:00
|
|
|
void EntityBuilder::installTaskFactory(const std::string & class_name,
|
|
|
|
|
TaskKit * factory)
|
|
|
|
|
{
|
|
|
|
|
m_taskFactories.insert(std::make_pair(class_name, factory));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TaskKit * EntityBuilder::getTaskFactory(const std::string & class_name)
|
|
|
|
|
{
|
|
|
|
|
TaskFactoryDict::const_iterator I = m_taskFactories.find(class_name);
|
|
|
|
|
if (I == m_taskFactories.end()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return I->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EntityBuilder::addTaskActivation(const std::string & tool,
|
|
|
|
|
const std::string & op,
|
|
|
|
|
TaskKit * factory)
|
|
|
|
|
{
|
|
|
|
|
m_taskActivations[tool].insert(std::make_pair(op, factory));
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-03 14:12:56 +00:00
|
|
|
/// \brief Build a new task object activated by the described event.
|
|
|
|
|
///
|
|
|
|
|
/// An event is described in terms of the tool type used to cause it,
|
|
|
|
|
/// the type of operation being performed using the tool and the type of
|
|
|
|
|
/// the target object the tool is being used on. If a match is found for
|
|
|
|
|
/// this event, a task object is instanced to track the progress of the
|
|
|
|
|
/// result of the event.
|
|
|
|
|
/// @param tool The type of tool activating the event.
|
|
|
|
|
/// @param op The type of operation being performed with the tool.
|
|
|
|
|
/// @param target The type of entity the operation is being performed on.
|
|
|
|
|
/// @param owner The character entity activating the task.
|
2007-12-20 19:27:12 +00:00
|
|
|
Task * EntityBuilder::activateTask(const std::string & tool,
|
2006-04-05 01:21:40 +00:00
|
|
|
const std::string & op,
|
2011-12-06 10:07:25 +00:00
|
|
|
LocatedEntity * target,
|
2011-12-02 23:42:24 +00:00
|
|
|
LocatedEntity & owner) const
|
2006-04-05 01:21:40 +00:00
|
|
|
{
|
|
|
|
|
TaskFactoryActivationDict::const_iterator I = m_taskActivations.find(tool);
|
|
|
|
|
if (I == m_taskActivations.end()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2006-04-25 00:32:58 +00:00
|
|
|
const TaskFactoryMultimap & dict = I->second;
|
|
|
|
|
TaskFactoryMultimap::const_iterator J = dict.lower_bound(op);
|
2006-04-05 01:21:40 +00:00
|
|
|
if (J == dict.end()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2006-04-25 00:32:58 +00:00
|
|
|
TaskFactoryMultimap::const_iterator Jend = dict.upper_bound(op);
|
|
|
|
|
for (; J != Jend; ++J) {
|
2011-12-06 10:07:25 +00:00
|
|
|
if (J->second->checkTarget(target) == -1) {
|
|
|
|
|
continue;
|
2006-04-24 19:51:54 +00:00
|
|
|
}
|
2009-08-20 22:58:11 +01:00
|
|
|
return buildTask(J->second, owner);
|
2006-04-24 19:51:54 +00:00
|
|
|
}
|
2006-04-25 00:32:58 +00:00
|
|
|
return 0;
|
2005-12-08 03:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
2008-06-03 14:12:56 +00:00
|
|
|
/// \brief Clear out all the factory objects owned by the entity builder.
|
2007-12-20 19:27:12 +00:00
|
|
|
void EntityBuilder::flushFactories()
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
{
|
2007-11-22 00:56:48 +00:00
|
|
|
FactoryDict::const_iterator Iend = m_entityFactories.end();
|
|
|
|
|
for (FactoryDict::const_iterator I = m_entityFactories.begin(); I != Iend; ++I) {
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
delete I->second;
|
|
|
|
|
}
|
2007-11-22 00:56:48 +00:00
|
|
|
m_entityFactories.clear();
|
2006-04-29 02:27:15 +00:00
|
|
|
TaskFactoryDict::const_iterator K = m_taskFactories.begin();
|
|
|
|
|
TaskFactoryDict::const_iterator Kend = m_taskFactories.end();
|
|
|
|
|
for (; K != Kend; ++K) {
|
|
|
|
|
delete K->second;
|
|
|
|
|
}
|
|
|
|
|
m_taskFactories.clear();
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
bool EntityBuilder::isTask(const std::string & class_name)
|
2006-07-10 01:45:28 +00:00
|
|
|
{
|
2007-07-29 20:35:47 +00:00
|
|
|
if (class_name == "task") {
|
2006-07-10 01:45:28 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2007-07-29 20:35:47 +00:00
|
|
|
return (m_taskFactories.find(class_name) != m_taskFactories.end());
|
2006-07-10 01:45:28 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-19 02:47:15 +01:00
|
|
|
bool EntityBuilder::hasTask(const std::string & class_name)
|
|
|
|
|
{
|
|
|
|
|
return (m_taskFactories.find(class_name) != m_taskFactories.end());
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-18 17:26:26 +01:00
|
|
|
void EntityBuilder::installBaseFactory(const std::string & class_name,
|
|
|
|
|
const std::string & parent,
|
|
|
|
|
EntityKit * factory)
|
|
|
|
|
{
|
2011-12-18 03:48:30 +00:00
|
|
|
installFactory(class_name, atlasClass(class_name, parent), factory);
|
2011-09-18 17:26:26 +01:00
|
|
|
}
|
|
|
|
|
|
2013-02-21 21:53:11 +00:00
|
|
|
int EntityBuilder::installFactory(const std::string & class_name,
|
|
|
|
|
const Root & class_desc,
|
|
|
|
|
EntityKit * factory)
|
2011-12-17 18:37:28 +00:00
|
|
|
{
|
2013-02-21 21:53:11 +00:00
|
|
|
Inheritance & i = Inheritance::instance();
|
|
|
|
|
factory->m_type = i.addChild(class_desc);
|
|
|
|
|
|
|
|
|
|
if (factory->m_type == 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-03 23:37:30 +00:00
|
|
|
m_entityFactories.insert(std::make_pair(class_name, factory));
|
2013-02-21 21:53:11 +00:00
|
|
|
|
2015-04-05 22:17:25 +02:00
|
|
|
Monitors::instance()->watch(compose("created_count{type=\"%1\"}", class_name),
|
2009-09-03 00:38:50 +01:00
|
|
|
new Variable<int>(factory->m_createdCount));
|
2013-02-21 21:53:11 +00:00
|
|
|
return 0;
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-19 02:47:15 +01:00
|
|
|
EntityKit * EntityBuilder::getClassFactory(const std::string & class_name)
|
|
|
|
|
{
|
|
|
|
|
FactoryDict::const_iterator I = m_entityFactories.find(class_name);
|
|
|
|
|
if (I == m_entityFactories.end()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return I->second;
|
|
|
|
|
}
|