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
|
|
|
|
2008-08-25 15:42:57 +00:00
|
|
|
// $Id$
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2005-05-14 23:02:02 +00:00
|
|
|
#include <Python.h>
|
|
|
|
|
|
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"
|
2005-05-15 00:54:08 +00:00
|
|
|
#include "ScriptFactory.h"
|
2005-12-08 03:04:04 +00:00
|
|
|
#include "TaskFactory.h"
|
2009-03-24 03:08:45 +00:00
|
|
|
#include "Persistence.h"
|
2002-04-12 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.cpp,
common/Database.cpp, common/accountbase.h, modules/WorldTime.h,
rulesets/Py_World.cpp, server/Admin.cpp, server/Persistance.cpp,
server/Persistance.h:
Clean up includes.
* rulesets/Entity.cpp, rulesets/Entity.h: Write improved way of
handling immutable object attributes.
* server/EntityFactory.cpp, server/Player.cpp, server/Player.h:
Implement a character_types attribute on the player account,
by adding "playable" tag to rules database, and setting
up a set of character types when rules are read from database.
2002-04-12 21:54:44 +00:00
|
|
|
#include "Player.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-03-07 00:22:12 +00:00
|
|
|
#include "rulesets/Thing.h"
|
|
|
|
|
#include "rulesets/MindFactory.h"
|
|
|
|
|
#include "rulesets/Character.h"
|
|
|
|
|
#include "rulesets/Creator.h"
|
|
|
|
|
#include "rulesets/Plant.h"
|
|
|
|
|
#include "rulesets/Stackable.h"
|
|
|
|
|
#include "rulesets/World.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
|
|
|
|
2005-05-14 23:02:02 +00:00
|
|
|
#include "rulesets/Python_Script_Utils.h"
|
2002-12-19 14:52:05 +00:00
|
|
|
|
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"
|
|
|
|
|
#include "common/globals.h"
|
2004-04-27 11:23:38 +00:00
|
|
|
#include "common/const.h"
|
2009-03-20 15:31:38 +00:00
|
|
|
#include "common/Inheritance.h"
|
2005-01-13 00:38:41 +00:00
|
|
|
#include "common/AtlasFileLoader.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"
|
2008-09-27 16:25:50 +00:00
|
|
|
#include "common/Property.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"
|
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
|
|
|
|
2007-06-15 15:18:55 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
|
#include <dirent.h>
|
|
|
|
|
#endif // HAS_DIRENT_H
|
|
|
|
|
|
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::Element;
|
|
|
|
|
using Atlas::Message::MapType;
|
|
|
|
|
using Atlas::Message::ListType;
|
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;
|
|
|
|
|
|
2007-12-27 03:19:52 +00:00
|
|
|
typedef std::map<std::string, Atlas::Objects::Root> RootDict;
|
|
|
|
|
|
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
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
EntityBuilder::EntityBuilder(BaseWorld & w) : m_world(w)
|
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-03-22 15:18:10 +00:00
|
|
|
installFactory("world", "game_entity", new EntityFactory<World>());
|
|
|
|
|
EntityFactory<Thing> * tft = new EntityFactory<Thing>();
|
2008-09-11 16:55:25 +00:00
|
|
|
installFactory("thing", "game_entity", tft);
|
2009-03-22 15:18:10 +00:00
|
|
|
installFactory("character", "thing", new EntityFactory<Character>());
|
|
|
|
|
installFactory("creator", "character", new EntityFactory<Creator>());
|
|
|
|
|
installFactory("plant", "thing", new EntityFactory<Plant>());
|
|
|
|
|
installFactory("stackable", "thing", new EntityFactory<Stackable>());
|
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
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
/// this instance is then set up. The final block of code relating to
|
|
|
|
|
/// persistence is legacy, and should never be invoked.
|
|
|
|
|
/// @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.
|
2007-12-20 19:27:12 +00:00
|
|
|
Entity * EntityBuilder::newEntity(const std::string & id, long intId,
|
2002-12-15 03:22:33 +00:00
|
|
|
const std::string & type,
|
2005-12-08 03:04:04 +00:00
|
|
|
const RootEntity & attributes) 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
|
|
|
{
|
2003-07-19 22:48:04 +00:00
|
|
|
debug(std::cout << "EntityFactor::newEntity()" << std::endl << std::flush;);
|
2002-12-10 01:25:18 +00:00
|
|
|
Entity * thing = 0;
|
2007-11-22 00:56:48 +00:00
|
|
|
FactoryDict::const_iterator I = m_entityFactories.find(type);
|
|
|
|
|
if (I == m_entityFactories.end()) {
|
2003-09-17 01:22:53 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
2007-12-20 19:33:38 +00:00
|
|
|
EntityKit * factory = I->second;
|
2009-03-22 15:18:10 +00:00
|
|
|
thing = factory->newEntity(id, intId);
|
2005-04-25 00:10:37 +00:00
|
|
|
if (thing == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-11-28 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/CharacterClient.cpp,
client/CharacterClient.h, client/CreatorClient.cpp,
client/CreatorClient.h, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Persistor.cpp,
server/Persistor_impl.h, server/Restorer_impl.h,
server/WorldRouter.cpp: Remove the hard name attribute, now that
most entities don't set it.
2007-11-28 20:22:42 +00:00
|
|
|
debug( std::cout << "[" << type << "]"
|
2004-07-12 10:58:20 +00:00
|
|
|
<< std::endl << std::flush;);
|
2007-11-26 Al Riddoch <alriddoch@zepler.org>
* common/inheritance.cpp, common/inheritance.h: Introduce a type
node class as a carrier for all information, including default
values for a type.
* rulesets/Entity.h, rulesets/Entity.cpp, rulesets/Character.cpp:
Use a TypeNode pointer rather than a string giving the type
of an entity.
* client/Py_CreatorClient.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h,
rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp, rulesets/Stackable.cpp,
rulesets/World.cpp, server/PersistantThingFactory.h,
server/Restorer_impl.h, server/WorldRouter.cpp:
Adapt all the code that deals with types. Set the type pointer
up correctly in BaseMind.
* server/EntityFactory.cpp: Initialise the TypeNode pointer on new
entities.
* tests/inheritancetest.cpp: Adapt the test to cope with TypeNode.
2007-11-26 02:57:04 +00:00
|
|
|
thing->setType(factory->m_type);
|
2003-09-17 01:22:53 +00:00
|
|
|
// Sort out python object
|
2005-05-15 00:54:08 +00:00
|
|
|
if (factory->m_scriptFactory != 0) {
|
2003-09-17 01:22:53 +00:00
|
|
|
debug(std::cout << "Class " << type << " has a python class"
|
|
|
|
|
<< std::endl << std::flush;);
|
2005-05-15 00:54:08 +00:00
|
|
|
factory->m_scriptFactory->addScript(thing);
|
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-01-10 15:28:50 +00:00
|
|
|
//
|
|
|
|
|
factory->populate(*thing);
|
2004-07-12 10:58:20 +00:00
|
|
|
|
2008-09-12 14:01:35 +00:00
|
|
|
MapType attrs = attributes->asMessage();
|
|
|
|
|
// Apply the attribute values
|
|
|
|
|
thing->merge(attrs);
|
|
|
|
|
// Then set up the default class properties
|
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
|
|
|
PropertyDict::const_iterator J = factory->m_type->defaults().begin();
|
|
|
|
|
PropertyDict::const_iterator Jend = factory->m_type->defaults().end();
|
|
|
|
|
for (; J != Jend; ++J) {
|
|
|
|
|
PropertyBase * prop = J->second;
|
2008-09-12 14:01:35 +00:00
|
|
|
// If a property is in the class it won't have been installed
|
|
|
|
|
// as setAttr() checks
|
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
|
|
|
prop->install(thing);
|
2008-09-12 14:01:35 +00:00
|
|
|
// The property will have been applied if it has an overriden
|
|
|
|
|
// value, so we only apply it the value is still default.
|
|
|
|
|
if (attrs.find(J->first) == attrs.end()) {
|
|
|
|
|
prop->apply(thing);
|
|
|
|
|
}
|
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
|
|
|
}
|
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
|
2005-09-11 01:43:29 +00:00
|
|
|
if (attributes->hasAttrFlag(Atlas::Objects::Entity::LOC_FLAG)) {
|
|
|
|
|
const std::string & loc_id = attributes->getLoc();
|
2005-11-23 11:55:08 +00:00
|
|
|
thing->m_location.m_loc = m_world.getEntity(loc_id);
|
2005-09-11 01:43:29 +00:00
|
|
|
}
|
|
|
|
|
if (thing->m_location.m_loc == 0) {
|
2004-07-12 10:58:20 +00:00
|
|
|
// If no info was provided, put the entity in the game world
|
2003-05-04 18:31:38 +00:00
|
|
|
thing->m_location.m_loc = &m_world.m_gameWorld;
|
2002-12-15 03:22:33 +00:00
|
|
|
}
|
2005-09-11 01:43:29 +00:00
|
|
|
thing->m_location.readFromEntity(attributes);
|
2005-09-28 Al Riddoch <alriddoch@zepler.org>
* modules/Location.cpp, modules/Location.h:
Add const accessors for location data, in preparation for
adding cached collision data which must be updated every
time data is modified.
* physics/Collision.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/MemMap.cpp, rulesets/Movement.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Location.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/EntityFactory.cpp, server/Persistor.cpp,
server/Persistor_impl.h, server/Restorer_impl.h,
server/WorldRouter.cpp, tests/Locationtest.cpp:
Use the const accessors whenver reading data from Location.
2005-09-28 23:02:50 +00:00
|
|
|
if (!thing->m_location.pos().isValid()) {
|
2004-07-12 10:58:20 +00:00
|
|
|
// If no position coords were provided, put it somewhere near origin
|
2004-09-20 Al Riddoch <alriddoch@zepler.org>
* physics/Vector3D.h, physics/Vector3D.cpp, modules/Location.h,
modules/Location.cpp: Convert to using WFMath::Point instead of
WFMath::Vector for position.
* physics/Collision.h, physics/Collision.cpp: Update collision code
to use new pos type.
* rulesets/Py_Point3D.h, rulesets/Py_Point3D.cpp: New python
wrappers for WFMath::Point.
* rulesets/Py_Location.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp:
Update python wrappers to take into account new pos type.
Ensure that only apropriate functionality is available for
point and vector.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Line.cpp, rulesets/Movement.cpp, rulesets/Movement.h,
rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
server/WorldRouter.h: Update the rest of the code for new pos
type, converting all places where entity parenting is changed
to use WFMath toParentCoords() and toLocalCoords() methods,
so that orientation is handled correctly.
* tests/transformtest.cpp: New test to ensure that toParentCoords()
and toLocalCoords() perform as expected.
* tests/Creatortest.cpp, tests/Locationtest.cpp, tests/Worldtest.cpp,
tests/collisiontest.cpp, tests/emergencetest.cpp:
Update the rest of the tests.
2004-09-20 10:16:04 +00:00
|
|
|
thing->m_location.m_pos = Point3D(uniform(-8,8), uniform(-8,8), 0);
|
2002-12-15 03:22:33 +00:00
|
|
|
}
|
2005-09-28 Al Riddoch <alriddoch@zepler.org>
* modules/Location.cpp, modules/Location.h:
Add const accessors for location data, in preparation for
adding cached collision data which must be updated every
time data is modified.
* physics/Collision.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/MemMap.cpp, rulesets/Movement.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Location.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/EntityFactory.cpp, server/Persistor.cpp,
server/Persistor_impl.h, server/Restorer_impl.h,
server/WorldRouter.cpp, tests/Locationtest.cpp:
Use the const accessors whenver reading data from Location.
2005-09-28 23:02:50 +00:00
|
|
|
if (thing->m_location.velocity().isValid()) {
|
2005-10-19 20:44:41 +00:00
|
|
|
if (attributes->hasAttrFlag(Atlas::Objects::Entity::VELOCITY_FLAG)) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("EntityBuilder::newEntity(%1, %2): "
|
|
|
|
|
"Entity has velocity set from the attributes "
|
|
|
|
|
"given by the creator", id, type));
|
2005-10-19 20:44:41 +00:00
|
|
|
} else {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("EntityBuilder::newEntity(%1, %2): Entity has "
|
|
|
|
|
"velocity set from an unknown source",
|
|
|
|
|
id, type));
|
2005-10-19 20:44:41 +00:00
|
|
|
}
|
|
|
|
|
thing->m_location.m_velocity.setValid(false);
|
2005-09-19 20:07:30 +00:00
|
|
|
}
|
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
|
|
|
return thing;
|
|
|
|
|
}
|
|
|
|
|
|
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.
|
2007-12-20 19:27:12 +00:00
|
|
|
Task * EntityBuilder::newTask(const std::string & name, Character & 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;
|
|
|
|
|
}
|
2006-04-05 01:21:40 +00:00
|
|
|
return I->second->newTask(owner);
|
|
|
|
|
}
|
|
|
|
|
|
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,
|
2006-04-24 19:51:54 +00:00
|
|
|
const std::string & target,
|
2006-04-05 01:21:40 +00:00
|
|
|
Character & owner) const
|
|
|
|
|
{
|
|
|
|
|
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) {
|
|
|
|
|
if (!J->second->m_target.empty()) {
|
|
|
|
|
if (!Inheritance::instance().isTypeOf(target, J->second->m_target)) {
|
2006-04-30 01:37:59 +00:00
|
|
|
debug( std::cout << target << " is not a " << J->second->m_target
|
|
|
|
|
<< std::endl << std::flush; );
|
2006-04-25 00:32:58 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2006-04-24 19:51:54 +00:00
|
|
|
}
|
2006-04-25 00:32:58 +00:00
|
|
|
return J->second->newTask(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
|
|
|
int EntityBuilder::populateEntityFactory(const std::string & class_name,
|
2007-12-20 19:33:38 +00:00
|
|
|
EntityKit * factory,
|
2007-11-22 01:05:10 +00:00
|
|
|
const MapType & class_desc)
|
2003-09-17 08:20:50 +00:00
|
|
|
{
|
2007-11-22 01:05:10 +00:00
|
|
|
// assert(class_name == class_desc->getId());
|
2003-09-17 08:20:50 +00:00
|
|
|
// Establish whether this rule has an associated script, and
|
|
|
|
|
// if so, use it.
|
2007-07-29 20:35:47 +00:00
|
|
|
MapType::const_iterator J = class_desc.find("script");
|
|
|
|
|
MapType::const_iterator Jend = class_desc.end();
|
2007-07-30 01:54:25 +00:00
|
|
|
if (J != Jend && J->second.isMap()) {
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, 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/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const MapType & script = J->second.asMap();
|
2003-09-17 08:20:50 +00:00
|
|
|
J = script.find("name");
|
2007-07-30 01:54:25 +00:00
|
|
|
if (J == script.end() || !J->second.isString()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Entity \"%1\" script has no name.",
|
|
|
|
|
class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
const std::string & script_name = J->second.String();
|
|
|
|
|
J = script.find("language");
|
|
|
|
|
if (J == script.end() || !J->second.isString()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Entity \"%1\" script has no language.",
|
|
|
|
|
class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
const std::string & script_language = J->second.String();
|
|
|
|
|
if (script_language != "python") {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Entity \"%1\" script has unknown language "
|
|
|
|
|
"\"%2\".", class_name, script_language));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2008-08-27 16:42:38 +00:00
|
|
|
std::string::size_type ptr = script_name.rfind(".");
|
|
|
|
|
if (ptr == std::string::npos) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Entity \"%1\" python script has a bad class "
|
|
|
|
|
"name \"%2\".", class_name, script_name));
|
2008-08-27 16:42:38 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
std::string script_package = script_name.substr(0, ptr);
|
|
|
|
|
std::string script_class = script_name.substr(ptr + 1);
|
2007-07-30 01:54:25 +00:00
|
|
|
if (factory->m_scriptFactory != 0) {
|
|
|
|
|
if (factory->m_scriptFactory->package() != script_name) {
|
|
|
|
|
delete factory->m_scriptFactory;
|
|
|
|
|
factory->m_scriptFactory = 0;
|
2003-09-17 08:20:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-07-30 01:54:25 +00:00
|
|
|
if (factory->m_scriptFactory == 0) {
|
2008-08-27 16:42:38 +00:00
|
|
|
factory->m_scriptFactory = new PythonScriptFactory(script_package,
|
|
|
|
|
script_class);
|
2007-07-30 01:54:25 +00:00
|
|
|
}
|
2003-09-17 08:20:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Establish whether this rule has an associated mind rule,
|
|
|
|
|
// and handle it.
|
2007-07-29 20:35:47 +00:00
|
|
|
J = class_desc.find("mind");
|
2007-07-30 01:54:25 +00:00
|
|
|
if (J != Jend && J->second.isMap()) {
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, 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/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const MapType & script = J->second.asMap();
|
2003-09-17 08:20:50 +00:00
|
|
|
J = script.find("name");
|
2007-07-30 01:54:25 +00:00
|
|
|
if (J != script.end() && J->second.isString()) {
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
const std::string & mindType = J->second.String();
|
2003-09-17 08:20:50 +00:00
|
|
|
// language is unused. might need it one day
|
|
|
|
|
// J = script.find("language");
|
2007-07-30 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, common/Database.cpp,
common/accountbase.cpp, common/system.cpp, rulesets/Character.cpp,
rulesets/Motion.cpp, rulesets/Plant.cpp, rulesets/Py_Location.cpp,
rulesets/Py_Mind.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Point3D.cpp, rulesets/Py_Statistics.cpp,
rulesets/Py_Task.cpp, rulesets/Py_TerrainProperty.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Py_WorldTime.cpp, rulesets/Python_API.cpp,
rulesets/TerrainProperty.cpp, server/Admin.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/WorldRouter.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cyctrl.cpp:
Remove unnecessary () from conditional expressions, where operator
binding is clear.
2007-07-30 18:12:50 +00:00
|
|
|
// if (J != script.end() && J->second.isString()) {
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
// const std::string & mindLang = J->second.String();
|
2003-09-17 08:20:50 +00:00
|
|
|
// }
|
2007-07-29 20:35:47 +00:00
|
|
|
MindFactory::instance()->addMindType(class_name, mindType);
|
2003-09-17 08:20:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Store the default attribute for entities create by this rule.
|
2007-07-29 20:35:47 +00:00
|
|
|
J = class_desc.find("attributes");
|
2007-07-30 01:54:25 +00:00
|
|
|
if (J != Jend && J->second.isMap()) {
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, 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/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const MapType & attrs = J->second.asMap();
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
MapType::const_iterator Kend = attrs.end();
|
|
|
|
|
for (MapType::const_iterator K = attrs.begin(); K != Kend; ++K) {
|
2004-07-12 10:58:20 +00:00
|
|
|
if (!K->second.isMap()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Attribute description in rule %1 is not a "
|
|
|
|
|
"map.", class_name));
|
2004-07-12 10:58:20 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, 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/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const MapType & attr = K->second.asMap();
|
|
|
|
|
MapType::const_iterator L = attr.find("default");
|
2004-07-12 10:58:20 +00:00
|
|
|
if (L != attr.end()) {
|
2005-11-18 01:52:10 +00:00
|
|
|
// Store this value in the defaults for this class
|
|
|
|
|
factory->m_classAttributes[K->first] = L->second;
|
|
|
|
|
// and merge it with the defaults inherited from the parent
|
2005-05-15 00:54:08 +00:00
|
|
|
factory->m_attributes[K->first] = L->second;
|
2004-07-12 10:58:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-09-17 08:20:50 +00:00
|
|
|
}
|
2005-05-15 12:43:02 +00:00
|
|
|
|
|
|
|
|
// Check whether it should be available to players as a playable character.
|
2007-07-29 20:35:47 +00:00
|
|
|
J = class_desc.find("playable");
|
2007-07-30 01:54:25 +00:00
|
|
|
if (J != Jend && J->second.isInt()) {
|
2007-07-29 20:35:47 +00:00
|
|
|
Player::playableTypes.insert(class_name);
|
2003-09-17 08:20:50 +00:00
|
|
|
}
|
2007-07-30 01:54:25 +00:00
|
|
|
|
|
|
|
|
return 0;
|
2005-05-15 22:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::populateTaskFactory(const std::string & class_name,
|
2007-11-22 01:05:10 +00:00
|
|
|
TaskFactory * factory,
|
|
|
|
|
const MapType & class_desc)
|
|
|
|
|
{
|
|
|
|
|
// assert(class_name == class_desc->getId());
|
|
|
|
|
|
2007-11-28 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/CharacterClient.cpp,
client/CharacterClient.h, client/CreatorClient.cpp,
client/CreatorClient.h, rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Persistor.cpp,
server/Persistor_impl.h, server/Restorer_impl.h,
server/WorldRouter.cpp: Remove the hard name attribute, now that
most entities don't set it.
2007-11-28 20:22:42 +00:00
|
|
|
return 0;
|
2007-11-22 01:05:10 +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
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:33:38 +00:00
|
|
|
static void updateChildren(EntityKit * factory)
|
2007-07-17 17:13:25 +00:00
|
|
|
{
|
2007-12-20 19:33:38 +00:00
|
|
|
std::set<EntityKit *>::const_iterator I = factory->m_children.begin();
|
|
|
|
|
std::set<EntityKit *>::const_iterator Iend = factory->m_children.end();
|
2007-07-17 17:13:25 +00:00
|
|
|
for (; I != Iend; ++I) {
|
2007-12-20 19:33:38 +00:00
|
|
|
EntityKit * child_factory = *I;
|
2007-07-17 17:13:25 +00:00
|
|
|
child_factory->m_attributes = factory->m_attributes;
|
|
|
|
|
MapType::const_iterator J = child_factory->m_classAttributes.begin();
|
|
|
|
|
MapType::const_iterator Jend = child_factory->m_classAttributes.end();
|
|
|
|
|
for (; J != Jend; ++J) {
|
|
|
|
|
child_factory->m_attributes[J->first] = J->second;
|
|
|
|
|
}
|
|
|
|
|
updateChildren(child_factory);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-09 11:34:03 +00:00
|
|
|
static void updateChildrenProperties(EntityKit * factory)
|
|
|
|
|
{
|
|
|
|
|
// Discover the default attributes which are no longer
|
|
|
|
|
// present after the update.
|
|
|
|
|
std::set<std::string> removed_properties;
|
|
|
|
|
PropertyDict & defaults = factory->m_type->defaults();
|
|
|
|
|
PropertyDict::const_iterator I = defaults.begin();
|
|
|
|
|
PropertyDict::const_iterator Iend = defaults.end();
|
|
|
|
|
MapType::const_iterator Jend = factory->m_attributes.end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
if (factory->m_attributes.find(I->first) == Jend) {
|
|
|
|
|
debug( std::cout << I->first << " removed" << std::endl; );
|
|
|
|
|
removed_properties.insert(I->first);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove the class properties for the default attributes that
|
|
|
|
|
// no longer exist
|
|
|
|
|
std::set<std::string>::const_iterator L = removed_properties.begin();
|
|
|
|
|
std::set<std::string>::const_iterator Lend = removed_properties.end();
|
|
|
|
|
for (; L != Lend; ++L) {
|
|
|
|
|
PropertyDict::iterator M = defaults.find(*L);
|
|
|
|
|
delete M->second;
|
|
|
|
|
defaults.erase(M);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the values of existing class properties, and add new class
|
|
|
|
|
// properties for added default attributes.
|
|
|
|
|
MapType::const_iterator J = factory->m_attributes.begin();
|
|
|
|
|
PropertyBase * p;
|
|
|
|
|
for (; J != Jend; ++J) {
|
|
|
|
|
PropertyDict::const_iterator I = defaults.find(J->first);
|
|
|
|
|
if (I == Iend) {
|
2008-09-27 16:25:50 +00:00
|
|
|
p = PropertyManager::instance()->addProperty(J->first,
|
|
|
|
|
J->second.getType());
|
|
|
|
|
assert(p != 0);
|
2008-09-10 14:18:10 +00:00
|
|
|
p->setFlags(flag_class);
|
2008-09-09 11:34:03 +00:00
|
|
|
defaults[J->first] = p;
|
|
|
|
|
} else {
|
|
|
|
|
p = I->second;
|
|
|
|
|
}
|
|
|
|
|
p->set(J->second);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Propagate the changes to all child factories
|
|
|
|
|
std::set<EntityKit *>::const_iterator K = factory->m_children.begin();
|
|
|
|
|
std::set<EntityKit *>::const_iterator Kend = factory->m_children.end();
|
|
|
|
|
for (; K != Kend; ++K) {
|
|
|
|
|
EntityKit * child_factory = *K;
|
|
|
|
|
updateChildrenProperties(child_factory);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::installTaskClass(const std::string & class_name,
|
2005-12-05 21:23:50 +00:00
|
|
|
const std::string & parent,
|
2007-11-15 02:07:04 +00:00
|
|
|
const Root & class_desc)
|
2005-12-05 21:23:50 +00:00
|
|
|
{
|
2007-11-22 01:05:10 +00:00
|
|
|
assert(class_name == class_desc->getId());
|
|
|
|
|
|
2007-07-29 20:35:47 +00:00
|
|
|
TaskFactoryDict::const_iterator I = m_taskFactories.find(class_name);
|
2005-12-08 03:04:04 +00:00
|
|
|
if (I != m_taskFactories.end()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Attempt to install task \"%1\" which is already "
|
|
|
|
|
"installed.", class_name));
|
2005-12-08 03:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-30 01:54:25 +00:00
|
|
|
// Establish that this rule has an associated script.
|
2007-11-15 02:07:04 +00:00
|
|
|
Element script_attr;
|
|
|
|
|
if (class_desc->copyAttr("script", script_attr) != 0 ||
|
|
|
|
|
!script_attr.isMap()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task \"%1\" has no script.", class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
2005-12-08 03:04:04 +00:00
|
|
|
}
|
2007-11-15 02:07:04 +00:00
|
|
|
const MapType & script = script_attr.Map();
|
2005-12-08 03:04:04 +00:00
|
|
|
|
2007-11-15 02:07:04 +00:00
|
|
|
MapType::const_iterator J = script.find("name");
|
|
|
|
|
MapType::const_iterator script_end = script.end();
|
|
|
|
|
if (J == script_end || !J->second.isString()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task \"%1\" script has no name.", class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
const std::string & script_name = J->second.String();
|
|
|
|
|
|
|
|
|
|
J = script.find("language");
|
2007-11-15 02:07:04 +00:00
|
|
|
if (J == script_end || !J->second.isString()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task \"%1\" script has no language.", class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
const std::string & script_language = J->second.String();
|
|
|
|
|
|
|
|
|
|
if (script_language != "python") {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task \"%1\" script has unknown language \"%2\".",
|
|
|
|
|
class_name, script_language));
|
2005-12-08 03:04:04 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2009-07-02 15:55:29 +01:00
|
|
|
std::string::size_type ptr = script_name.rfind(".");
|
|
|
|
|
if (ptr == std::string::npos) {
|
|
|
|
|
log(ERROR, compose("Task \"%1\" python script has a bad class "
|
|
|
|
|
"name \"%2\".", class_name, script_name));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
std::string script_package = script_name.substr(0, ptr);
|
|
|
|
|
std::string script_class = script_name.substr(ptr + 1);
|
2005-12-08 03:04:04 +00:00
|
|
|
|
2009-07-02 16:57:00 +01:00
|
|
|
TaskFactory * factory = new PythonTaskScriptFactory(class_name,
|
|
|
|
|
script_package,
|
2009-07-02 15:55:29 +01:00
|
|
|
script_class);
|
2007-07-30 01:54:25 +00:00
|
|
|
|
2007-11-15 02:07:04 +00:00
|
|
|
Element activation_attr;
|
|
|
|
|
if (class_desc->copyAttr("activation", activation_attr) != 0 ||
|
|
|
|
|
!activation_attr.isMap()) {
|
2007-07-30 01:54:25 +00:00
|
|
|
delete factory;
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task \"%1\" has no activation.", class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2007-11-15 02:07:04 +00:00
|
|
|
const MapType & activation = activation_attr.Map();
|
2007-07-30 01:54:25 +00:00
|
|
|
|
|
|
|
|
MapType::const_iterator act_end = activation.end();
|
|
|
|
|
J = activation.find("tool");
|
|
|
|
|
if (J == act_end || !J->second.isString()) {
|
|
|
|
|
delete factory;
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task \"%1\" activation has no tool.", class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
const std::string & activation_tool = J->second.String();
|
|
|
|
|
|
2007-11-15 02:07:04 +00:00
|
|
|
Inheritance & i = Inheritance::instance();
|
|
|
|
|
|
2007-07-30 01:54:25 +00:00
|
|
|
if (!i.hasClass(activation_tool)) {
|
|
|
|
|
delete factory;
|
|
|
|
|
waitForRule(class_name, class_desc, activation_tool,
|
2008-11-17 15:45:43 +00:00
|
|
|
compose("Task \"%1\" is activated by tool \"%2\" which "
|
|
|
|
|
"does not exist.", class_name, activation_tool));
|
2007-07-30 01:54:25 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2007-11-22 00:56:48 +00:00
|
|
|
FactoryDict::const_iterator K = m_entityFactories.find(activation_tool);
|
|
|
|
|
if (K == m_entityFactories.end()) {
|
2007-07-30 01:54:25 +00:00
|
|
|
delete factory;
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task class \"%1\" is activated by tool \"%2\" "
|
|
|
|
|
"which is not an entity class.", class_name,
|
|
|
|
|
activation_tool));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2007-12-20 19:33:38 +00:00
|
|
|
EntityKit * tool_factory = K->second;
|
2007-07-30 01:54:25 +00:00
|
|
|
|
|
|
|
|
J = activation.find("operation");
|
|
|
|
|
if (J == act_end || !J->second.isString()) {
|
|
|
|
|
delete factory;
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task \"%1\" activation has no operation.",
|
|
|
|
|
class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::string & activation_op = J->second.String();
|
|
|
|
|
if (!i.hasClass(activation_op)) {
|
|
|
|
|
delete factory;
|
|
|
|
|
waitForRule(class_name, class_desc, activation_op,
|
2008-11-17 15:45:43 +00:00
|
|
|
compose("Task \"%1\" is activated by operation \"%2\" "
|
|
|
|
|
"which does not exist.", class_name,
|
|
|
|
|
activation_op));
|
2007-07-30 01:54:25 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
J = activation.find("target");
|
|
|
|
|
if (J != act_end) {
|
|
|
|
|
if (!J->second.isString()) {
|
|
|
|
|
delete factory;
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Task \"%1\" activation has \"%2\" target.",
|
|
|
|
|
class_name,
|
|
|
|
|
Element::typeName(J->second.getType())));
|
2007-07-30 01:54:25 +00:00
|
|
|
return -1;
|
2006-04-05 01:21:40 +00:00
|
|
|
}
|
2007-07-30 01:54:25 +00:00
|
|
|
const std::string & target_base = J->second.String();
|
|
|
|
|
if (!i.hasClass(target_base)) {
|
|
|
|
|
delete factory;
|
|
|
|
|
waitForRule(class_name, class_desc, target_base,
|
2008-11-17 15:45:43 +00:00
|
|
|
compose("Task \"%1\" is activated on target \"%2\" "
|
|
|
|
|
"which does not exist.", class_name,
|
|
|
|
|
target_base));
|
2007-07-30 01:54:25 +00:00
|
|
|
return 1;
|
2006-04-24 19:51:54 +00:00
|
|
|
}
|
2007-07-30 01:54:25 +00:00
|
|
|
factory->m_target = target_base;
|
2006-04-05 01:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-30 01:54:25 +00:00
|
|
|
m_taskActivations[activation_tool].insert(std::make_pair(activation_op, factory));
|
|
|
|
|
MapType::iterator L = tool_factory->m_classAttributes.find("operations");
|
|
|
|
|
if (L == tool_factory->m_classAttributes.end()) {
|
|
|
|
|
tool_factory->m_classAttributes["operations"] = ListType(1, activation_op);
|
|
|
|
|
tool_factory->m_attributes["operations"] = ListType(1, activation_op);
|
|
|
|
|
updateChildren(tool_factory);
|
2008-09-11 00:44:45 +00:00
|
|
|
updateChildrenProperties(tool_factory);
|
2007-07-30 01:54:25 +00:00
|
|
|
} else {
|
|
|
|
|
if (L->second.isList()) {
|
|
|
|
|
ListType::const_iterator M = L->second.List().begin();
|
|
|
|
|
for (; M != L->second.List().end() && *M != activation_op; ++M);
|
|
|
|
|
if (M == L->second.List().end()) {
|
|
|
|
|
L->second.List().push_back(activation_op);
|
|
|
|
|
tool_factory->m_attributes[L->first] = L->second.List();
|
|
|
|
|
updateChildren(tool_factory);
|
2008-09-11 00:44:45 +00:00
|
|
|
updateChildrenProperties(tool_factory);
|
2007-07-30 01:54:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-29 20:35:47 +00:00
|
|
|
m_taskFactories.insert(std::make_pair(class_name, factory));
|
2006-04-24 12:37:33 +00:00
|
|
|
|
2007-11-15 02:07:04 +00:00
|
|
|
i.addChild(class_desc);
|
2006-04-24 12:37:33 +00:00
|
|
|
|
2005-12-08 03:04:04 +00:00
|
|
|
return 0;
|
2005-12-05 21:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::installEntityClass(const std::string & class_name,
|
2005-05-17 23:51:26 +00:00
|
|
|
const std::string & parent,
|
2007-11-15 02:07:04 +00:00
|
|
|
const Root & class_desc)
|
2005-05-17 23:51:26 +00:00
|
|
|
{
|
2007-11-22 01:05:10 +00:00
|
|
|
assert(class_name == class_desc->getId());
|
|
|
|
|
|
2005-05-17 23:51:26 +00:00
|
|
|
// Get the new factory for this rule
|
2007-11-22 00:56:48 +00:00
|
|
|
FactoryDict::const_iterator I = m_entityFactories.find(parent);
|
|
|
|
|
if (I == m_entityFactories.end()) {
|
2007-07-29 20:35:47 +00:00
|
|
|
debug(std::cout << "class \"" << class_name
|
2005-05-17 23:51:26 +00:00
|
|
|
<< "\" has non existant parent \"" << parent
|
|
|
|
|
<< "\". Waiting." << std::endl << std::flush;);
|
2007-07-29 20:35:47 +00:00
|
|
|
waitForRule(class_name, class_desc, parent,
|
2008-11-17 15:45:43 +00:00
|
|
|
compose("Entity rule \"%1\" has parent \"%2\" which does "
|
|
|
|
|
"not exist.", class_name, parent));
|
2005-05-17 23:51:26 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2007-12-20 19:33:38 +00:00
|
|
|
EntityKit * parent_factory = I->second;
|
|
|
|
|
EntityKit * factory = parent_factory->duplicateFactory();
|
2005-11-18 01:52:10 +00:00
|
|
|
if (factory == 0) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR,
|
2008-11-17 15:45:43 +00:00
|
|
|
compose("Attempt to install rule \"%1\" which has parent \"%2\" "
|
|
|
|
|
"which cannot be instantiated", class_name, parent));
|
2005-11-18 01:52:10 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(factory->m_parent == parent_factory);
|
|
|
|
|
|
2007-11-22 01:05:10 +00:00
|
|
|
// Copy the defaults from the parent. In populateEntityFactory this may be
|
2005-11-18 01:52:10 +00:00
|
|
|
// overriden with the defaults for this class.
|
|
|
|
|
factory->m_attributes = parent_factory->m_attributes;
|
2005-05-17 23:51:26 +00:00
|
|
|
|
2007-11-22 01:05:10 +00:00
|
|
|
if (populateEntityFactory(class_name, factory,
|
|
|
|
|
class_desc->asMessage()) != 0) {
|
2007-07-30 01:54:25 +00:00
|
|
|
delete factory;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2005-05-17 23:51:26 +00:00
|
|
|
|
2007-07-29 20:35:47 +00:00
|
|
|
debug(std::cout << "INSTALLING " << class_name << ":" << parent
|
2005-05-17 23:51:26 +00:00
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
|
|
|
|
|
// Install the factory in place.
|
2007-11-21 22:45:32 +00:00
|
|
|
installFactory(class_name, parent, factory, class_desc);
|
2005-05-17 23:51:26 +00:00
|
|
|
|
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
|
|
|
MapType::const_iterator J = factory->m_attributes.begin();
|
|
|
|
|
MapType::const_iterator Jend = factory->m_attributes.end();
|
|
|
|
|
PropertyBase * p;
|
|
|
|
|
for (; J != Jend; ++J) {
|
2008-09-27 16:25:50 +00:00
|
|
|
p = PropertyManager::instance()->addProperty(J->first,
|
|
|
|
|
J->second.getType());
|
|
|
|
|
assert(p != 0);
|
|
|
|
|
p->set(J->second);
|
2008-09-10 14:18:10 +00:00
|
|
|
p->setFlags(flag_class);
|
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
|
|
|
factory->m_type->defaults()[J->first] = p;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-18 01:52:10 +00:00
|
|
|
// Add it as a child to its parent.
|
|
|
|
|
parent_factory->m_children.insert(factory);
|
|
|
|
|
|
2005-05-17 23:51:26 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::installOpDefinition(const std::string & class_name,
|
2005-05-17 23:51:26 +00:00
|
|
|
const std::string & parent,
|
2007-11-15 02:07:04 +00:00
|
|
|
const Root & class_desc)
|
2005-05-17 23:51:26 +00:00
|
|
|
{
|
2007-11-22 01:05:10 +00:00
|
|
|
assert(class_name == class_desc->getId());
|
|
|
|
|
|
2005-05-17 23:51:26 +00:00
|
|
|
Inheritance & i = Inheritance::instance();
|
|
|
|
|
|
2005-09-13 23:29:42 +00:00
|
|
|
if (!i.hasClass(parent)) {
|
2007-07-29 20:35:47 +00:00
|
|
|
debug(std::cout << "op_definition \"" << class_name
|
2005-05-17 23:51:26 +00:00
|
|
|
<< "\" has non existant parent \"" << parent
|
|
|
|
|
<< "\". Waiting." << std::endl << std::flush;);
|
2007-07-29 20:35:47 +00:00
|
|
|
waitForRule(class_name, class_desc, parent,
|
2008-11-17 15:45:43 +00:00
|
|
|
compose("Operation \"%1\" has parent \"%2\" which does "
|
|
|
|
|
"not exist.", class_name, parent));
|
2005-05-17 23:51:26 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-29 20:35:47 +00:00
|
|
|
Atlas::Objects::Root r = atlasOpDefinition(class_name, parent);
|
2005-05-17 23:51:26 +00:00
|
|
|
|
2007-11-26 Al Riddoch <alriddoch@zepler.org>
* common/inheritance.cpp, common/inheritance.h: Introduce a type
node class as a carrier for all information, including default
values for a type.
* rulesets/Entity.h, rulesets/Entity.cpp, rulesets/Character.cpp:
Use a TypeNode pointer rather than a string giving the type
of an entity.
* client/Py_CreatorClient.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h,
rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp, rulesets/Stackable.cpp,
rulesets/World.cpp, server/PersistantThingFactory.h,
server/Restorer_impl.h, server/WorldRouter.cpp:
Adapt all the code that deals with types. Set the type pointer
up correctly in BaseMind.
* server/EntityFactory.cpp: Initialise the TypeNode pointer on new
entities.
* tests/inheritancetest.cpp: Adapt the test to cope with TypeNode.
2007-11-26 02:57:04 +00:00
|
|
|
if (i.addChild(class_desc) == 0) {
|
2005-05-17 23:51:26 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-29 20:35:47 +00:00
|
|
|
int op_no = Atlas::Objects::Factories::instance()->addFactory(class_name, &Atlas::Objects::generic_factory);
|
|
|
|
|
i.opInstall(class_name, op_no);
|
2005-05-17 23:51:26 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::installRule(const std::string & class_name,
|
2007-11-15 02:07:04 +00:00
|
|
|
const Root & class_desc)
|
2005-05-15 22:52:13 +00:00
|
|
|
{
|
2007-11-22 01:05:10 +00:00
|
|
|
assert(class_name == class_desc->getId());
|
|
|
|
|
|
2008-11-13 03:36:43 +00:00
|
|
|
if (class_name.size() > consts::id_len) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Rule \"%1\" has name longer than %2 characters. "
|
|
|
|
|
"Skipping.", class_name, consts::id_len));
|
2008-11-13 03:13:41 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-15 02:07:04 +00:00
|
|
|
const std::string & objtype = class_desc->getObjtype();
|
|
|
|
|
const std::list<std::string> & parents = class_desc->getParents();
|
2005-05-15 22:52:13 +00:00
|
|
|
if (parents.empty()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Rule \"%1\" has empty parents. Skipping.",
|
|
|
|
|
class_name));
|
2005-05-15 22:52:13 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2007-11-15 02:07:04 +00:00
|
|
|
const std::string & parent = parents.front();
|
|
|
|
|
if (parent.empty()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Rule \"%1\" has empty first parent. Skipping.",
|
|
|
|
|
class_name));
|
2005-05-15 22:52:13 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2005-05-17 23:51:26 +00:00
|
|
|
if (objtype == "class") {
|
2006-07-10 01:45:28 +00:00
|
|
|
if (isTask(parent)) {
|
2007-07-29 20:35:47 +00:00
|
|
|
int ret = installTaskClass(class_name, parent, class_desc);
|
2005-12-05 21:23:50 +00:00
|
|
|
if (ret != 0) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2007-07-29 20:35:47 +00:00
|
|
|
int ret = installEntityClass(class_name, parent, class_desc);
|
2005-12-05 21:23:50 +00:00
|
|
|
if (ret != 0) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2005-05-17 23:51:26 +00:00
|
|
|
}
|
|
|
|
|
} else if (objtype == "op_definition") {
|
2007-07-29 20:35:47 +00:00
|
|
|
int ret = installOpDefinition(class_name, parent, class_desc);
|
2005-05-17 23:51:26 +00:00
|
|
|
if (ret != 0) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Rule \"%1\" has unknown objtype=\"%2\". Skipping.",
|
|
|
|
|
class_name, objtype));
|
2005-05-17 23:51:26 +00:00
|
|
|
return -1;
|
2005-05-15 22:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
2005-05-15 12:43:02 +00:00
|
|
|
// Install any rules that were waiting for this rule before they
|
|
|
|
|
// could be installed
|
2007-07-29 20:35:47 +00:00
|
|
|
RuleWaitList::iterator I = m_waitingRules.lower_bound(class_name);
|
|
|
|
|
RuleWaitList::iterator Iend = m_waitingRules.upper_bound(class_name);
|
2007-11-15 02:07:04 +00:00
|
|
|
std::map<std::string, Root> readyRules;
|
2006-07-31 17:36:18 +00:00
|
|
|
for (; I != Iend; ++I) {
|
2007-07-26 00:15:52 +00:00
|
|
|
const std::string & wClassName = I->second.name;
|
2007-11-15 02:07:04 +00:00
|
|
|
const Root & wClassDesc = I->second.desc;
|
2007-07-16 22:56:34 +00:00
|
|
|
readyRules.insert(std::make_pair(wClassName, wClassDesc));
|
2003-09-17 08:20:50 +00:00
|
|
|
debug(std::cout << "WAITING rule " << wClassName
|
2007-07-29 20:35:47 +00:00
|
|
|
<< " now ready from " << class_name
|
2007-07-16 22:56:34 +00:00
|
|
|
<< std::endl << std::flush;);
|
2003-09-17 08:20:50 +00:00
|
|
|
}
|
2007-07-29 20:35:47 +00:00
|
|
|
m_waitingRules.erase(class_name);
|
2007-07-16 22:56:34 +00:00
|
|
|
|
2007-11-15 02:07:04 +00:00
|
|
|
std::map<std::string, Root>::const_iterator K = readyRules.begin();
|
|
|
|
|
std::map<std::string, Root>::const_iterator Kend = readyRules.end();
|
2007-07-16 22:56:34 +00:00
|
|
|
for (; K != Kend; ++K) {
|
|
|
|
|
const std::string & rClassName = K->first;
|
2007-11-15 02:07:04 +00:00
|
|
|
const Root & rClassDesc = K->second;
|
2007-07-16 22:56:34 +00:00
|
|
|
installRule(rClassName, rClassDesc);
|
|
|
|
|
}
|
2005-05-15 12:43:02 +00:00
|
|
|
return 0;
|
2003-09-17 08:20:50 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::modifyEntityClass(const std::string & class_name,
|
2007-07-29 20:35:47 +00:00
|
|
|
const Root & class_desc)
|
2005-05-15 18:29:52 +00:00
|
|
|
{
|
2007-11-22 01:05:10 +00:00
|
|
|
assert(class_name == class_desc->getId());
|
|
|
|
|
|
2007-11-22 00:56:48 +00:00
|
|
|
FactoryDict::const_iterator I = m_entityFactories.find(class_name);
|
|
|
|
|
if (I == m_entityFactories.end()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Could not find factory for existing entity class "
|
|
|
|
|
"\"%1\".", class_name));
|
2005-05-15 20:32:29 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
2007-12-20 19:33:38 +00:00
|
|
|
EntityKit * factory = I->second;
|
2005-05-15 20:32:29 +00:00
|
|
|
assert(factory != 0);
|
|
|
|
|
|
|
|
|
|
ScriptFactory * script_factory = factory->m_scriptFactory;
|
|
|
|
|
if (script_factory != 0) {
|
|
|
|
|
script_factory->refreshClass();
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-30 01:54:25 +00:00
|
|
|
MapType backup_attributes = factory->m_attributes,
|
|
|
|
|
backup_class_attributes = factory->m_classAttributes;
|
|
|
|
|
|
2007-11-22 01:05:10 +00:00
|
|
|
// Copy the defaults from the parent. In populateEntityFactory this may be
|
2005-11-18 01:52:10 +00:00
|
|
|
// overriden with the defaults for this class.
|
2006-04-25 01:50:17 +00:00
|
|
|
if (factory->m_parent != 0) {
|
|
|
|
|
factory->m_attributes = factory->m_parent->m_attributes;
|
|
|
|
|
} else {
|
|
|
|
|
// This is non fatal, but nice to know it has happened.
|
|
|
|
|
// This should only happen if the client attempted to modify the
|
|
|
|
|
// type data for a core hard coded type.
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("EntityBuilder::modifyEntityClass: \"%1\" modified "
|
|
|
|
|
"by client, but has no parent factory.",
|
|
|
|
|
class_name));
|
2007-07-30 01:54:25 +00:00
|
|
|
factory->m_attributes = MapType();
|
2006-04-25 01:50:17 +00:00
|
|
|
}
|
2005-11-20 02:03:08 +00:00
|
|
|
factory->m_classAttributes = MapType();
|
2005-11-18 01:52:10 +00:00
|
|
|
|
2007-11-22 01:05:10 +00:00
|
|
|
if (populateEntityFactory(class_name, factory,
|
|
|
|
|
class_desc->asMessage()) != 0) {
|
2007-07-30 01:54:25 +00:00
|
|
|
factory->m_attributes = backup_attributes;
|
|
|
|
|
factory->m_classAttributes = backup_class_attributes;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2005-05-16 01:23:17 +00:00
|
|
|
|
2005-11-18 01:52:10 +00:00
|
|
|
updateChildren(factory);
|
2008-09-09 11:34:03 +00:00
|
|
|
updateChildrenProperties(factory);
|
2005-11-18 01:52:10 +00:00
|
|
|
|
2005-05-15 20:32:29 +00:00
|
|
|
return 0;
|
2005-05-15 18:29:52 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::modifyTaskClass(const std::string & class_name,
|
2007-07-29 20:35:47 +00:00
|
|
|
const Root & class_desc)
|
2006-04-24 12:37:33 +00:00
|
|
|
{
|
2007-11-22 01:05:10 +00:00
|
|
|
assert(class_name == class_desc->getId());
|
|
|
|
|
|
2006-04-24 12:37:33 +00:00
|
|
|
TaskFactoryDict::const_iterator I = m_taskFactories.find(class_name);
|
|
|
|
|
if (I == m_taskFactories.end()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Could not find factory for existing task class "
|
|
|
|
|
"\"%1\"", class_name));
|
2006-04-24 12:37:33 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
// FIXME Actually update the task factory.
|
2008-11-07 01:25:17 +00:00
|
|
|
// TaskFactory * factory = I->second;
|
|
|
|
|
// assert(factory != 0);
|
2006-05-09 10:19:33 +00:00
|
|
|
|
2006-04-24 12:37:33 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::modifyOpDefinition(const std::string & class_name,
|
2007-07-29 20:35:47 +00:00
|
|
|
const Root & class_desc)
|
2006-04-25 01:50:17 +00:00
|
|
|
{
|
|
|
|
|
// Nothing to actually do
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
int EntityBuilder::modifyRule(const std::string & class_name,
|
2007-07-29 20:35:47 +00:00
|
|
|
const Root & class_desc)
|
2006-04-24 12:37:33 +00:00
|
|
|
{
|
2007-11-22 01:05:10 +00:00
|
|
|
assert(class_name == class_desc->getId());
|
|
|
|
|
|
2006-04-24 12:37:33 +00:00
|
|
|
Root o = Inheritance::instance().getClass(class_name);
|
|
|
|
|
if (!o.isValid()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Could not find existing type \"%1\" in "
|
|
|
|
|
"inheritance", class_name));
|
2006-04-24 12:37:33 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (o->getParents().front() == "task") {
|
2007-07-29 20:35:47 +00:00
|
|
|
return modifyTaskClass(class_name, class_desc);
|
|
|
|
|
} else if (class_desc->getObjtype() == "op_definition") {
|
|
|
|
|
return modifyOpDefinition(class_name, class_desc);
|
2006-04-24 12:37:33 +00:00
|
|
|
} else {
|
2007-07-29 20:35:47 +00:00
|
|
|
return modifyEntityClass(class_name, class_desc);
|
2006-04-24 12:37:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-26 00:15:52 +00:00
|
|
|
/// \brief Mark a rule down as waiting for another.
|
|
|
|
|
///
|
|
|
|
|
/// Note that a rule cannot yet be installed because it depends on something
|
|
|
|
|
/// that has not yet occured, or a more fatal condition has occured.
|
2007-12-20 19:27:12 +00:00
|
|
|
void EntityBuilder::waitForRule(const std::string & rulename,
|
2007-11-15 02:07:04 +00:00
|
|
|
const Root & ruledesc,
|
2007-07-26 00:15:52 +00:00
|
|
|
const std::string & dependent,
|
|
|
|
|
const std::string & reason)
|
|
|
|
|
{
|
|
|
|
|
RuleWaiting rule;
|
|
|
|
|
rule.name = rulename;
|
|
|
|
|
rule.desc = ruledesc;
|
|
|
|
|
rule.reason = reason;
|
|
|
|
|
|
|
|
|
|
m_waitingRules.insert(std::make_pair(dependent, rule));
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
void EntityBuilder::getRulesFromFiles(std::map<std::string, Root> & rules)
|
2005-01-13 00:38:41 +00:00
|
|
|
{
|
2007-06-19 13:19:57 +00:00
|
|
|
std::string filename;
|
|
|
|
|
|
|
|
|
|
std::string dirname = etc_directory + "/cyphesis/" + ruleset + ".d";
|
|
|
|
|
DIR * rules_dir = ::opendir(dirname.c_str());
|
|
|
|
|
if (rules_dir == 0) {
|
|
|
|
|
filename = etc_directory + "/cyphesis/" + ruleset + ".xml";
|
|
|
|
|
AtlasFileLoader f(filename, rules);
|
|
|
|
|
if (f.isOpen()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(WARNING, compose("Reading legacy rule data from \"%1\".",
|
|
|
|
|
filename));
|
2007-06-19 13:19:57 +00:00
|
|
|
f.read();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
while (struct dirent * rules_entry = ::readdir(rules_dir)) {
|
|
|
|
|
if (rules_entry->d_name[0] == '.') {
|
2007-06-15 15:18:55 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2007-06-19 13:19:57 +00:00
|
|
|
filename = dirname + "/" + rules_entry->d_name;
|
|
|
|
|
|
|
|
|
|
AtlasFileLoader f(filename, rules);
|
|
|
|
|
if (!f.isOpen()) {
|
2008-11-17 15:45:43 +00:00
|
|
|
log(ERROR, compose("Unable to open rule file \"%1\".", filename));
|
2007-06-19 13:19:57 +00:00
|
|
|
} else {
|
|
|
|
|
f.read();
|
2005-01-13 00:38:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-07-29 18:03:56 +00:00
|
|
|
::closedir(rules_dir);
|
2005-01-13 00:38:41 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-20 19:27:12 +00:00
|
|
|
void EntityBuilder::installRules()
|
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-15 02:07:04 +00:00
|
|
|
std::map<std::string, Root> ruleTable;
|
2005-01-13 00:38:41 +00:00
|
|
|
|
2007-02-20 00:52:41 +00:00
|
|
|
if (database_flag) {
|
2009-03-24 03:08:45 +00:00
|
|
|
Persistence * p = Persistence::instance();
|
2007-12-07 17:42:58 +00:00
|
|
|
p->getRules(ruleTable);
|
2005-01-13 00:38:41 +00:00
|
|
|
} else {
|
|
|
|
|
getRulesFromFiles(ruleTable);
|
|
|
|
|
}
|
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
|
|
|
|
2005-02-12 20:38:33 +00:00
|
|
|
if (ruleTable.empty()) {
|
|
|
|
|
log(ERROR, "Rule database table contains no rules.");
|
2007-10-01 03:31:34 +00:00
|
|
|
if (database_flag) {
|
2005-02-12 20:38:33 +00:00
|
|
|
log(NOTICE, "Attempting to load temporary ruleset from files.");
|
|
|
|
|
getRulesFromFiles(ruleTable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-15 02:07:04 +00:00
|
|
|
RootDict::const_iterator Iend = ruleTable.end();
|
|
|
|
|
for (RootDict::const_iterator I = ruleTable.begin(); I != Iend; ++I) {
|
2007-07-29 20:35:47 +00:00
|
|
|
const std::string & class_name = I->first;
|
2007-11-15 02:07:04 +00:00
|
|
|
const Root & class_desc = I->second;
|
2007-07-29 20:35:47 +00:00
|
|
|
installRule(class_name, class_desc);
|
2003-09-17 08:20:50 +00:00
|
|
|
}
|
|
|
|
|
// Report on the non-cleared rules.
|
|
|
|
|
// Perhaps we can keep them too?
|
|
|
|
|
// m_waitingRules.clear();
|
|
|
|
|
RuleWaitList::const_iterator J = m_waitingRules.begin();
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
RuleWaitList::const_iterator Jend = m_waitingRules.end();
|
|
|
|
|
for (; J != Jend; ++J) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, J->second.reason);
|
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
|
|
|
void EntityBuilder::installFactory(const std::string & class_name,
|
2007-11-21 22:45:32 +00:00
|
|
|
const std::string & parent,
|
2007-12-20 19:33:38 +00:00
|
|
|
EntityKit * factory,
|
2007-11-15 15:56:30 +00:00
|
|
|
Root class_desc)
|
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
|
|
|
{
|
2004-09-18 13:36:00 +00:00
|
|
|
assert(factory != 0);
|
|
|
|
|
|
2007-11-22 00:56:48 +00:00
|
|
|
m_entityFactories[class_name] = factory;
|
2008-11-17 15:45:43 +00:00
|
|
|
Monitors::instance()->watch(compose("created_count{type=%1}", class_name),
|
2008-09-01 17:45:59 +00:00
|
|
|
new Monitor<int>(factory->m_createdCount));
|
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
|
|
|
|
|
|
|
|
Inheritance & i = Inheritance::instance();
|
|
|
|
|
|
2007-11-15 15:56:30 +00:00
|
|
|
if (class_desc.isValid()) {
|
|
|
|
|
assert(class_desc->getId() == class_name);
|
|
|
|
|
assert(class_desc->getParents().front() == parent);
|
2007-11-26 Al Riddoch <alriddoch@zepler.org>
* common/inheritance.cpp, common/inheritance.h: Introduce a type
node class as a carrier for all information, including default
values for a type.
* rulesets/Entity.h, rulesets/Entity.cpp, rulesets/Character.cpp:
Use a TypeNode pointer rather than a string giving the type
of an entity.
* client/Py_CreatorClient.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h,
rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp, rulesets/Stackable.cpp,
rulesets/World.cpp, server/PersistantThingFactory.h,
server/Restorer_impl.h, server/WorldRouter.cpp:
Adapt all the code that deals with types. Set the type pointer
up correctly in BaseMind.
* server/EntityFactory.cpp: Initialise the TypeNode pointer on new
entities.
* tests/inheritancetest.cpp: Adapt the test to cope with TypeNode.
2007-11-26 02:57:04 +00:00
|
|
|
factory->m_type = i.addChild(class_desc);
|
2007-11-15 15:56:30 +00:00
|
|
|
} else {
|
2007-11-26 Al Riddoch <alriddoch@zepler.org>
* common/inheritance.cpp, common/inheritance.h: Introduce a type
node class as a carrier for all information, including default
values for a type.
* rulesets/Entity.h, rulesets/Entity.cpp, rulesets/Character.cpp:
Use a TypeNode pointer rather than a string giving the type
of an entity.
* client/Py_CreatorClient.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h,
rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp, rulesets/Stackable.cpp,
rulesets/World.cpp, server/PersistantThingFactory.h,
server/Restorer_impl.h, server/WorldRouter.cpp:
Adapt all the code that deals with types. Set the type pointer
up correctly in BaseMind.
* server/EntityFactory.cpp: Initialise the TypeNode pointer on new
entities.
* tests/inheritancetest.cpp: Adapt the test to cope with TypeNode.
2007-11-26 02:57:04 +00:00
|
|
|
factory->m_type = i.addChild(atlasClass(class_name, parent));
|
2007-11-15 15:56:30 +00:00
|
|
|
}
|
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:33:38 +00:00
|
|
|
EntityKit * EntityBuilder::getNewFactory(const std::string & parent)
|
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 I = m_entityFactories.find(parent);
|
|
|
|
|
if (I == m_entityFactories.end()) {
|
2003-09-17 01:22:53 +00:00
|
|
|
return 0;
|
2002-03-06 Al Riddoch <alriddoch@zepler.org>
* tools/cycmd.cpp, server/WorldRouter.cpp, server/EntityFactory.cpp,
server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/Thing.cpp, rulesets/Py_Operation.cpp,
rulesets/MemMap_methods.h, rulesets/MemMap.cpp, rulesets/Entity.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Use empty() instead of size() == 0 for STL sequence types.
* rulesets/ThingFactory.h, server/EntityFactory.cpp: Modified the
way adding classes to the inheritance tree is handled, so types
no longer have to inherit directly from a C++ class.
* server/WorldRouter.cpp: Modified the way broadcast operations are
handled to make them more efficient, and catch NULL pointers in
the world dictionary.
2002-03-06 00:23:28 +00:00
|
|
|
}
|
2002-12-11 01:11:43 +00:00
|
|
|
return I->second->duplicateFactory();
|
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
|
|
|
}
|