2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2006-04-25 17:11:35 +00:00
|
|
|
// Copyright (C) 2000-2006 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-01-26 16:38:23 +00:00
|
|
|
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2000-08-13 20:36:18 +00:00
|
|
|
#include "WorldRouter.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2010-07-13 16:23:46 +01:00
|
|
|
#include "ArithmeticBuilder.h"
|
2009-03-12 00:50:25 +00:00
|
|
|
#include "EntityBuilder.h"
|
2009-12-30 01:45:16 +00:00
|
|
|
#include "SpawnEntity.h"
|
2000-08-13 20:36:18 +00:00
|
|
|
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "rulesets/World.h"
|
2009-05-12 23:30:19 +01:00
|
|
|
#include "rulesets/Domain.h"
|
2016-01-17 17:02:50 +01:00
|
|
|
#include "rulesets/TransformsProperty.h"
|
2002-05-18 Al Riddoch <alriddoch@zepler.org>
* client/ObserverClient.cpp, server/Account.cpp, server/Connection.h,
server/Routing.h: Formatting cleanup
* client/Py_CreatorClient.cpp, rulesets/Area.cpp, rulesets/Area.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/Line.cpp, rulesets/Line.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h:
Replace operator[] with get() method for querying attributes.
Make this get() method const, and re-write the internals so
that it more cleanly handles attributes.
* common/BaseWorld.h: Re-write world.getObject() so that it
no longer uses std::map::operator[], as the old method was
inserting NULLs into the world dictionary when non-existant
entities were queried.
* rulesets/Character.cpp: Clean up outstanding issues when movement
position is supplied, and is very close to being correct, and
clarify comments about movement when neither destination nor
source are provided.
* rulesets/Character.cpp: Modify mind2body interface so that setting
the TO of ops is done in the individual handlers, and copying
the operation globally is avoided.
* rulesets/MemMap_methods.h: Remove dodgy debug code.
* rulesets/Pedestrian.cpp: Clarify movement fixme.
* rulesets/Py_Operation.cpp: Clarify operation time handler fixme.
* rulesets/Stackable.cpp: Clarify fixme's in combine and divide
handlers.
* server/CommServer.cpp: Remove redundant fixme.
* server/Connection.cpp, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/server.cpp:
Move inline ServerRouting::getObject into class header.
* server/WorldRouter.cpp, server/WorldRouter.h:
Clean up includes, and move updateTime into the main body of the
file. Clean up code formatting when handling maps and dictionaries.
Clarify error output and comments about NULL objects in the world
dictionary.
2002-05-18 18:09:14 +00:00
|
|
|
|
2005-01-13 00:38:41 +00:00
|
|
|
#include "common/id.h"
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/log.h"
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
|
#include "common/const.h"
|
|
|
|
|
#include "common/globals.h"
|
2004-06-21 00:44:54 +00:00
|
|
|
#include "common/random.h"
|
2006-11-02 05:14:54 +00:00
|
|
|
#include "common/system.h"
|
2007-12-27 Al Riddoch <alriddoch@zepler.org>
* common/TypeNode.h, common/TypeNode.cpp: Move TypeNode into
its own files.
* common/Makefile.am, common/inheritance.cpp, common/inheritance.h:
Add the new files to the build and remove the old implementation.
* client/Py_CreatorClient.cpp, rulesets/Character.cpp,
rulesets/Entity.cpp, rulesets/MemMap.cpp,
rulesets/MindFactory.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Stackable.cpp,
server/WorldRouter.cpp: Fix up the includes for all code that
uses TypeNode.
2007-12-27 03:31:47 +00:00
|
|
|
#include "common/TypeNode.h"
|
2004-12-06 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseWorld.h, common/refno.h,
common/serialno.h, rulesets/Character.cpp, rulesets/Creator.cpp,
rulesets/World.h, server/Account.cpp, server/Admin.cpp,
server/Connection.cpp, server/Lobby.cpp, server/ServerRouting.h,
server/WorldRouter.cpp, server/WorldRouter.h, tests/Creatortest.cpp,
tests/Worldtest.cpp: Simplify the way operation refnos and serialnos
are handled, getting rid of some unnecessary virtual methods and
functions.
2004-12-06 21:56:47 +00:00
|
|
|
#include "common/serialno.h"
|
2005-09-11 21:53:17 +00:00
|
|
|
#include "common/compose.hpp"
|
2009-03-20 15:31:38 +00:00
|
|
|
#include "common/Inheritance.h"
|
2008-08-30 16:29:11 +00:00
|
|
|
#include "common/Monitors.h"
|
2011-10-31 11:19:33 +01:00
|
|
|
#include "common/SystemTime.h"
|
2009-09-03 00:27:59 +01:00
|
|
|
#include "common/Variable.h"
|
2010-02-15 23:18:04 +01:00
|
|
|
#include "common/Tick.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
#include <Atlas/Objects/Operation.h>
|
2006-07-20 23:02:39 +00:00
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
2005-08-27 14:52:12 +00:00
|
|
|
|
2004-11-16 12:27:27 +00:00
|
|
|
#include <sstream>
|
2005-06-03 14:56:17 +00:00
|
|
|
#include <algorithm>
|
2004-11-16 12:27:27 +00:00
|
|
|
|
2005-06-03 14:56:17 +00:00
|
|
|
using Atlas::Message::Element;
|
2009-12-30 01:45:16 +00:00
|
|
|
using Atlas::Message::MapType;
|
2006-07-20 23:02:39 +00:00
|
|
|
using Atlas::Objects::Operation::Appearance;
|
2005-08-27 14:52:12 +00:00
|
|
|
using Atlas::Objects::Entity::RootEntity;
|
2006-07-20 23:02:39 +00:00
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
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
|
|
|
|
2001-02-04 07:08:07 +00:00
|
|
|
static const bool debug_flag = false;
|
2000-11-10 20:41:24 +00:00
|
|
|
|
2013-11-20 15:09:09 +01:00
|
|
|
/**
|
|
|
|
|
* \brief Acts as a RAII scoped guard for an entity.
|
|
|
|
|
*/
|
|
|
|
|
struct EntityScopedRef {
|
|
|
|
|
LocatedEntity& entity;
|
|
|
|
|
explicit EntityScopedRef(LocatedEntity& e);
|
|
|
|
|
~EntityScopedRef();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline EntityScopedRef::EntityScopedRef(LocatedEntity & e) : entity(e)
|
|
|
|
|
{
|
|
|
|
|
entity.incRef();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline EntityScopedRef::~EntityScopedRef()
|
|
|
|
|
{
|
|
|
|
|
entity.decRef();
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
|
2005-01-13 23:35:36 +00:00
|
|
|
|
2004-08-05 12:29:11 +00:00
|
|
|
/// \brief Constructor for the world object.
|
|
|
|
|
///
|
2014-02-01 20:35:26 +01:00
|
|
|
/// The Entity representing the world is implicitly constructed.
|
2004-08-05 12:29:11 +00:00
|
|
|
/// Currently the world entity is included in the perceptives list,
|
|
|
|
|
/// but I am not clear why. Need to look into why.
|
2011-10-31 11:19:33 +01:00
|
|
|
WorldRouter::WorldRouter(const SystemTime & time) :
|
|
|
|
|
BaseWorld(*new World(consts::rootWorldId, consts::rootWorldIntId)),
|
2015-05-05 22:01:11 +02:00
|
|
|
m_operationsDispatcher([&](const Operation & op, LocatedEntity & from){this->operation(op, from);}, [&]()->double {return getTime();}),
|
2014-06-04 13:03:38 +02:00
|
|
|
m_entityCount(1)
|
2008-09-01 16:14:42 +00:00
|
|
|
|
2000-08-13 20:36:18 +00:00
|
|
|
{
|
2011-10-31 11:19:33 +01:00
|
|
|
m_initTime = time.seconds();
|
2005-01-13 23:35:36 +00:00
|
|
|
m_gameWorld.incRef();
|
2011-09-21 12:45:18 +01:00
|
|
|
EntityBuilder::init();
|
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
|
|
|
m_gameWorld.setType(Inheritance::instance().getType("world"));
|
2005-11-11 Al Riddoch <alriddoch@zepler.org>
* common/types.h, server/Persistance.h, common/BaseWorld.h,
common/BaseWorld.cpp, server/WorldRouter.cpp:
Switch core world map to reference by integer ID rather than string.
Add version of getEntity() which converts from string to integer
automatically.
* rulesets/Character.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/EntityFactory.cpp,
Use getEntity() when looking up an entity, so that conversion of
ID from string to integer is automatic.
* rulesets/BaseMind.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h:
Switch to using integer IDs in MemMap's core mapping.
* server/Account.cpp, server/Account.h: Switch a few function
parameters to use integer ID values, making the code cleaner.
* server/Account.cpp, server/Admin.cpp, server/Persistance.cpp:
Handle string ID to integer conversions as required.
2005-11-11 02:04:56 +00:00
|
|
|
m_eobjects[m_gameWorld.getIntId()] = &m_gameWorld;
|
2003-05-04 18:31:38 +00:00
|
|
|
m_perceptives.insert(&m_gameWorld);
|
2000-08-13 20:36:18 +00:00
|
|
|
//WorldTime tmp_date("612-1-1 08:57:00");
|
2009-09-03 00:38:50 +01:00
|
|
|
Monitors::instance()->watch("entities", new Variable<int>(m_entityCount));
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-05 12:29:11 +00:00
|
|
|
/// \brief Destructor for the world object.
|
|
|
|
|
///
|
|
|
|
|
/// Destruction of the world object implicity deletes all IG objects in
|
|
|
|
|
/// the server, clears the operation queue
|
2001-04-16 16:26:44 +00:00
|
|
|
WorldRouter::~WorldRouter()
|
|
|
|
|
{
|
2004-05-15 17:43:14 +00:00
|
|
|
{
|
2004-05-28 14:34:33 +00:00
|
|
|
debug(std::cout << "Flushing world with " << m_eobjects.size()
|
|
|
|
|
<< " entities" << std::endl << std::flush;);
|
2004-05-15 17:43:14 +00:00
|
|
|
}
|
2014-01-21 21:05:49 +01:00
|
|
|
|
|
|
|
|
//Make sure to clear the queues first so that there's nothing referencing entities
|
|
|
|
|
//in them.
|
2014-06-04 13:03:38 +02:00
|
|
|
m_operationsDispatcher.clearQueues();
|
2014-01-31 23:20:22 +01:00
|
|
|
m_suspendedQueue = OpQueue();
|
2014-01-21 21:05:49 +01:00
|
|
|
|
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
|
|
|
EntityDict::const_iterator Jend = m_eobjects.end();
|
|
|
|
|
for (EntityDict::const_iterator J = m_eobjects.begin(); J != Jend; ++J) {
|
2005-01-13 17:24:39 +00:00
|
|
|
J->second->decRef();
|
2002-03-19 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp, server/ServerRouting_methods.h,
server/ServerRouting.h, server/ServerRouting.cpp,
server/Routing.h, server/Routing.cpp, server/Connection.h,
server/Admin.cpp:
Removed inheritance from Routing by Connection and ServerRouting,
as there is almost no functionality in common. Get rid of global
idDict in ServerRouting is it serves little or no useful purpose.
IG objects are now managed in WorldRouter, and OOG objects in
ServerRouting.
* common/BaseWorld.h: Made accessor method const, as it should be.
2002-03-19 09:26:40 +00:00
|
|
|
}
|
2013-11-24 15:01:38 +01:00
|
|
|
for (auto entry : m_spawns) {
|
|
|
|
|
delete entry.second.first;
|
2010-01-03 00:44:10 +00:00
|
|
|
}
|
2014-01-21 21:05:49 +01:00
|
|
|
m_spawns.clear();
|
2002-03-08 14:58:40 +00:00
|
|
|
// This should be deleted here rather than in the base class because
|
|
|
|
|
// we created it, and BaseWorld should not even know what it is.
|
2005-01-13 23:35:36 +00:00
|
|
|
m_gameWorld.decRef();
|
2001-04-16 16:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-01 20:35:26 +01:00
|
|
|
bool WorldRouter::isQueueDirty() const
|
|
|
|
|
{
|
2014-06-04 13:03:38 +02:00
|
|
|
return m_operationsDispatcher.isQueueDirty();
|
2014-02-01 20:35:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WorldRouter::markQueueAsClean()
|
|
|
|
|
{
|
2014-06-04 13:03:38 +02:00
|
|
|
m_operationsDispatcher.markQueueAsClean();
|
2014-02-01 20:35:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-12-12 13:10:17 +00:00
|
|
|
|
2004-08-05 12:29:11 +00:00
|
|
|
/// \brief Add a new entity to the world.
|
|
|
|
|
///
|
|
|
|
|
/// Adds a new entity to the lists maintained by the WorldRouter.
|
|
|
|
|
/// Verify that the entity has a valid location, setting to
|
|
|
|
|
/// the default spawn area if necessary. Handle inserting the
|
|
|
|
|
/// entity into the loc/contains tree maintained by the Entity
|
2006-07-08 21:05:34 +00:00
|
|
|
/// class. Send a Setup op to the entity.
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * WorldRouter::addEntity(LocatedEntity * ent)
|
2000-08-13 20:36:18 +00:00
|
|
|
{
|
2010-01-03 02:14:52 +00:00
|
|
|
debug(std::cout << "WorldRouter::addEntity(" << ent->getIntId() << ")" << std::endl
|
2001-08-14 17:52:50 +00:00
|
|
|
<< std::flush;);
|
2007-12-02 18:30:18 +00:00
|
|
|
assert(ent->getIntId() != 0);
|
2005-11-11 Al Riddoch <alriddoch@zepler.org>
* common/types.h, server/Persistance.h, common/BaseWorld.h,
common/BaseWorld.cpp, server/WorldRouter.cpp:
Switch core world map to reference by integer ID rather than string.
Add version of getEntity() which converts from string to integer
automatically.
* rulesets/Character.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/EntityFactory.cpp,
Use getEntity() when looking up an entity, so that conversion of
ID from string to integer is automatic.
* rulesets/BaseMind.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h:
Switch to using integer IDs in MemMap's core mapping.
* server/Account.cpp, server/Account.h: Switch a few function
parameters to use integer ID values, making the code cleaner.
* server/Account.cpp, server/Admin.cpp, server/Persistance.cpp:
Handle string ID to integer conversions as required.
2005-11-11 02:04:56 +00:00
|
|
|
m_eobjects[ent->getIntId()] = ent;
|
2008-09-01 16:14:42 +00:00
|
|
|
++m_entityCount;
|
2005-01-13 23:35:36 +00:00
|
|
|
assert(ent->m_location.isValid());
|
2004-06-21 06:37:01 +00:00
|
|
|
|
2016-01-18 15:37:05 +01:00
|
|
|
TransformsProperty* transProp = ent->requirePropertyClassFixed<TransformsProperty>();
|
2005-01-13 23:35:36 +00:00
|
|
|
if (!ent->m_location.isValid()) {
|
2016-01-17 17:02:50 +01:00
|
|
|
log(ERROR, String::compose("Entity %1 of type %2 added to world with invalid location!", ent->getId(), ent->getType()->name()));
|
2014-08-27 22:17:09 +02:00
|
|
|
debug(std::cout << "set loc " << &getDefaultLocation() << std::endl
|
2001-08-14 17:52:50 +00:00
|
|
|
<< std::flush;);
|
2014-08-27 22:17:09 +02:00
|
|
|
ent->m_location.m_loc = &getDefaultLocation();
|
2016-01-17 17:02:50 +01:00
|
|
|
transProp->getTranslate() = Vector3D(uniform(-8,8), uniform(-8,8), 0);
|
|
|
|
|
transProp->apply(ent);
|
2005-01-13 23:35:36 +00:00
|
|
|
debug(std::cout << "loc set with loc " << ent->m_location.m_loc->getId()
|
2001-08-14 17:52:50 +00:00
|
|
|
<< std::endl << std::flush;);
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
2005-06-09 21:50:25 +00:00
|
|
|
ent->m_location.update(getTime());
|
2005-06-03 14:56:17 +00:00
|
|
|
// FIXME
|
|
|
|
|
std::string mode;
|
2009-08-05 19:00:14 +01:00
|
|
|
Element mode_attr;
|
2011-09-29 17:36:26 +01:00
|
|
|
if (ent->getAttrType("mode", mode_attr, Element::TYPE_STRING) == 0) {
|
2009-08-05 19:00:14 +01:00
|
|
|
mode = mode_attr.String();
|
2005-06-03 14:56:17 +00:00
|
|
|
}
|
2016-06-10 17:25:25 +02:00
|
|
|
if (ent->m_location.m_loc) {
|
|
|
|
|
Domain* movementDomain = ent->m_location.m_loc->getMovementDomain();
|
|
|
|
|
if (movementDomain) {
|
2016-01-17 17:02:50 +01:00
|
|
|
float height = movementDomain->
|
2015-07-09 23:04:43 +02:00
|
|
|
constrainHeight(*ent, ent->m_location.m_loc,
|
2016-06-10 17:25:25 +02:00
|
|
|
ent->m_location.pos(),
|
|
|
|
|
mode);
|
2016-01-18 14:59:12 +01:00
|
|
|
transProp->getTranslate().z() = height;
|
2016-01-17 17:02:50 +01:00
|
|
|
transProp->apply(ent);
|
2016-06-10 17:25:25 +02:00
|
|
|
}
|
2014-09-13 10:34:30 +02:00
|
|
|
}
|
2008-01-05 Al Riddoch <alriddoch@googlemail.com>
* rulesets/LocatedEntity.cpp, rulesets/LocatedEntity.h:
Don't allocated storage for m_contains by default, only
on demand. Add a convenience method which checks, and
allocates the storage if required. Set up the ID property
on this base class rather then Entity.
* rulesets/Py_Thing.cpp: Remove special handling of ID attribute
as it is now handled by the property.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/MemMap.cpp,
rulesets/Motion.cpp, rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/WorldRouter.cpp:
Make sure all parts of the code where contains is used have
the right checks, as it could be null.
2008-01-05 14:05:05 +00:00
|
|
|
ent->m_location.m_loc->makeContainer();
|
2007-12-31 Al Riddoch <alriddoch@googlemail.com>
* rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/LocatedEntity.cpp, rulesets/LocatedEntity.h,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/WorldRouter.cpp: Change LocatedEntity::m_contains into
a pointer so that the majority of entities that can not contain
anything don't waste the storage.
2007-12-31 17:39:25 +00:00
|
|
|
bool cont_change = ent->m_location.m_loc->m_contains->empty();
|
2013-10-04 14:26:16 +02:00
|
|
|
bool child_inserted = ent->m_location.m_loc->m_contains->insert(ent).second;
|
|
|
|
|
//check that the child wasn't already present
|
|
|
|
|
if (child_inserted) {
|
|
|
|
|
ent->m_location.m_loc->incRef();
|
|
|
|
|
}
|
|
|
|
|
// FIXME Should we call this every time a new child is inserted (now it's just called if the container is empty first
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
if (cont_change) {
|
2008-08-16 23:21:06 +00:00
|
|
|
// FIXME Mark the entity as dirty?
|
|
|
|
|
ent->onUpdated();
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
}
|
2005-01-13 23:35:36 +00:00
|
|
|
debug(std::cout << "Entity loc " << ent->m_location << std::endl
|
2001-08-14 17:52:50 +00:00
|
|
|
<< std::flush;);
|
2008-08-17 21:17:35 +00:00
|
|
|
|
2013-10-04 14:26:16 +02:00
|
|
|
if (ent->m_contains != nullptr) {
|
|
|
|
|
for (auto& child : *ent->m_contains) {
|
|
|
|
|
addEntity(child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-17 21:17:35 +00:00
|
|
|
Anonymous arg;
|
|
|
|
|
Appearance app;
|
|
|
|
|
arg->setId(ent->getId());
|
|
|
|
|
arg->setStamp(ent->getSeq());
|
|
|
|
|
app->setArgs1(arg);
|
|
|
|
|
message(app, *ent);
|
|
|
|
|
|
|
|
|
|
inserted.emit(ent);
|
|
|
|
|
|
2005-01-13 23:35:36 +00:00
|
|
|
return ent;
|
2000-08-21 11:31:18 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-05 12:29:11 +00:00
|
|
|
/// \brief Create a new entity and add to the world.
|
|
|
|
|
///
|
|
|
|
|
/// Construct a new entity using the entity description provided,
|
2004-01-17 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, rulesets/Character.cpp, rulesets/Py_World.cpp,
rulesets/PythonThingScript.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/Restoration.cpp, server/WorldRouter.cpp, server/WorldRouter.h:
Rename some functions in the World interface so they make more
sense.
* rulesets/Entity.cpp, rulesets/Entity.h: Add destroyed flag to
Entity so we can tell if its no longer in the world.
* server/WorldRouter.cpp: Cut down the special case handling of
delete ops as we can now broadcast ops from entities that
have been removed from the world.
2005-01-17 01:42:25 +00:00
|
|
|
/// and pass it to addEntity().
|
2004-08-05 12:29:11 +00:00
|
|
|
/// @return a pointer to the new entity.
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * WorldRouter::addNewEntity(const std::string & typestr,
|
|
|
|
|
const RootEntity & attrs)
|
2000-08-21 11:31:18 +00:00
|
|
|
{
|
2004-01-17 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, rulesets/Character.cpp, rulesets/Py_World.cpp,
rulesets/PythonThingScript.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/Restoration.cpp, server/WorldRouter.cpp, server/WorldRouter.h:
Rename some functions in the World interface so they make more
sense.
* rulesets/Entity.cpp, rulesets/Entity.h: Add destroyed flag to
Entity so we can tell if its no longer in the world.
* server/WorldRouter.cpp: Cut down the special case handling of
delete ops as we can now broadcast ops from entities that
have been removed from the world.
2005-01-17 01:42:25 +00:00
|
|
|
debug(std::cout << "WorldRouter::addNewEntity(\"" << typestr << "\", attrs)"
|
2003-09-17 01:22:53 +00:00
|
|
|
<< std::endl << std::flush;);
|
2003-07-21 09:37:58 +00:00
|
|
|
std::string id;
|
2005-11-12 01:40:37 +00:00
|
|
|
long intId = newId(id);
|
2006-04-25 17:11:35 +00:00
|
|
|
|
|
|
|
|
if (intId < 0) {
|
|
|
|
|
log(ERROR, "Unable to get ID for new Entity");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2005-11-10 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, common/BaseEntity.cpp: Add an integer ID
member variable, and accessor, and require it to be initialised
along with string ID in constructor.
* common/const.cpp, common/const.h: Add a const for the integer value
of the world ID.
* rulesets/Area.cpp, rulesets/Area.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/Food.cpp, rulesets/Food.h,
rulesets/Line.cpp, rulesets/Line.h, rulesets/MemEntity.cpp,
rulesets/MemEntity.h, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Stackable.cpp, rulesets/Stackable.h, rulesets/Structure.cpp,
rulesets/Structure.h, rulesets/Thing.cpp, rulesets/Thing.h,
rulesets/World.cpp, rulesets/World.h: Add integer ID handling to
constructors of all in-game entity classes.
* rulesets/MemMap.cpp: Initialise integer ID of entities in the mind
map.
* rulesets/MindFactory.cpp, rulesets/MindFactory.h: Handle integer
ID when constructing mind objects.
* server/EntityFactory.cpp, server/EntityFactory.h,
server/PersistantThingFactory_impl.h: Handle integer
ID when contructing entity objects.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.h,
server/Restorer_impl.h: Handle integer ID when restoring from
database.
* server/WorldRouter.cpp: Assign integer ID when constructing the
world.
2005-11-11 00:06:48 +00:00
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * ent = EntityBuilder::instance()->newEntity(id, intId, typestr, attrs, *this);
|
2005-01-13 23:35:36 +00:00
|
|
|
if (ent == 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, String::compose("Attempt to create an entity of type \"%1\" "
|
|
|
|
|
"but type is unknown or forbidden",
|
|
|
|
|
typestr));
|
2003-09-17 01:22:53 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
2004-01-17 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, rulesets/Character.cpp, rulesets/Py_World.cpp,
rulesets/PythonThingScript.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/Restoration.cpp, server/WorldRouter.cpp, server/WorldRouter.h:
Rename some functions in the World interface so they make more
sense.
* rulesets/Entity.cpp, rulesets/Entity.h: Add destroyed flag to
Entity so we can tell if its no longer in the world.
* server/WorldRouter.cpp: Cut down the special case handling of
delete ops as we can now broadcast ops from entities that
have been removed from the world.
2005-01-17 01:42:25 +00:00
|
|
|
return addEntity(ent);
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
int WorldRouter::createSpawnPoint(const MapType & data, LocatedEntity * ent)
|
2009-12-29 17:48:34 +00:00
|
|
|
{
|
2009-12-30 01:45:16 +00:00
|
|
|
MapType::const_iterator I = data.find("name");
|
|
|
|
|
if (I == data.end() || !I->second.isString()) {
|
|
|
|
|
log(ERROR, "No name on spawn point");
|
2010-01-03 21:06:24 +00:00
|
|
|
return -1;
|
2009-12-30 01:45:16 +00:00
|
|
|
}
|
2012-12-27 23:06:16 +00:00
|
|
|
SpawnEntity * new_spawn = new SpawnEntity(ent);
|
|
|
|
|
if (new_spawn->setup(data) != 0) {
|
2012-12-28 13:38:50 +00:00
|
|
|
delete new_spawn;
|
2012-12-27 23:06:16 +00:00
|
|
|
log(ERROR, "Error setting up spawn point");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-30 01:45:16 +00:00
|
|
|
const std::string & name = I->second.String();
|
2010-01-03 00:44:10 +00:00
|
|
|
SpawnDict::iterator J = m_spawns.find(name);
|
|
|
|
|
if (J != m_spawns.end()) {
|
2013-11-24 15:01:38 +01:00
|
|
|
Spawn * old = J->second.first;
|
|
|
|
|
J->second.first = new_spawn;
|
|
|
|
|
J->second.second = ent->getId();
|
2012-12-24 10:50:44 +00:00
|
|
|
delete old;
|
2010-01-03 00:44:10 +00:00
|
|
|
} else {
|
2013-11-24 15:01:38 +01:00
|
|
|
m_spawns.insert(std::make_pair(name, std::make_pair(new_spawn, ent->getId())));
|
2010-01-03 00:44:10 +00:00
|
|
|
}
|
2009-12-29 17:48:34 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-24 15:01:38 +01:00
|
|
|
int WorldRouter::removeSpawnPoint(LocatedEntity * ent)
|
|
|
|
|
{
|
|
|
|
|
for (auto I = m_spawns.begin(); I != m_spawns.end(); ++I) {
|
|
|
|
|
if (I->second.second == ent->getId()) {
|
2014-01-20 18:38:36 +01:00
|
|
|
delete I->second.first;
|
2013-11-24 15:01:38 +01:00
|
|
|
m_spawns.erase(I);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-12-29 19:11:31 +00:00
|
|
|
int WorldRouter::getSpawnList(Atlas::Message::ListType & data)
|
|
|
|
|
{
|
2013-11-24 15:01:38 +01:00
|
|
|
for (auto entry : m_spawns) {
|
2009-12-30 01:45:16 +00:00
|
|
|
MapType spawn;
|
2013-11-24 15:01:38 +01:00
|
|
|
spawn.insert(std::make_pair("name", entry.first));
|
|
|
|
|
entry.second.first->addToMessage(spawn);
|
2014-01-24 12:29:25 +01:00
|
|
|
data.push_back(spawn);
|
2009-12-30 01:45:16 +00:00
|
|
|
}
|
2009-12-29 19:11:31 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * WorldRouter::spawnNewEntity(const std::string & name,
|
|
|
|
|
const std::string & type,
|
|
|
|
|
const RootEntity & desc)
|
2009-12-29 17:48:34 +00:00
|
|
|
{
|
2009-12-30 01:45:16 +00:00
|
|
|
SpawnDict::const_iterator I = m_spawns.find(name);
|
|
|
|
|
if (I == m_spawns.end()) {
|
2009-12-30 15:09:26 +00:00
|
|
|
log(ERROR, String::compose("Spawn not found %1", name));
|
2009-12-30 10:01:49 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
2013-11-24 15:01:38 +01:00
|
|
|
Spawn * s = I->second.first;
|
2009-12-30 11:12:33 +00:00
|
|
|
int ret = s->spawnEntity(type, desc);
|
2009-12-30 10:01:49 +00:00
|
|
|
if (ret != 0) {
|
2009-12-30 15:09:26 +00:00
|
|
|
log(ERROR, String::compose("Spawn not permitting %1", type));
|
2009-12-30 10:01:49 +00:00
|
|
|
return 0;
|
2009-12-30 01:45:16 +00:00
|
|
|
}
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * e = addNewEntity(type, desc);
|
2009-12-30 11:12:33 +00:00
|
|
|
if (e == 0) {
|
2009-12-30 15:09:26 +00:00
|
|
|
log(ERROR, String::compose("Entity creation failed %1", type));
|
2009-12-30 11:12:33 +00:00
|
|
|
return e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return e;
|
2009-12-29 17:48:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-16 21:05:45 +01:00
|
|
|
int WorldRouter::moveToSpawn(const std::string & name, Location& location)
|
|
|
|
|
{
|
|
|
|
|
auto I = m_spawns.find(name);
|
|
|
|
|
if (I == m_spawns.end()) {
|
|
|
|
|
log(ERROR, String::compose("Spawn not found %1", name));
|
|
|
|
|
return -10;
|
|
|
|
|
}
|
2013-11-24 15:01:38 +01:00
|
|
|
return I->second.first->placeInSpawn(location);
|
2013-11-16 21:05:45 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-29 17:48:34 +00:00
|
|
|
|
2005-12-26 23:05:16 +00:00
|
|
|
/// \brief Create a new task
|
|
|
|
|
///
|
2011-12-02 23:42:24 +00:00
|
|
|
/// Construct a new task linked to the LocatedEntity provided.
|
2005-12-26 23:05:16 +00:00
|
|
|
/// @param name the name of the task type to be instantiated
|
|
|
|
|
/// @param owner the character who will own the task
|
|
|
|
|
/// @return a pointer to the new task
|
2011-12-02 23:42:24 +00:00
|
|
|
Task * WorldRouter::newTask(const std::string & name, LocatedEntity & owner)
|
2005-12-26 23:05:16 +00:00
|
|
|
{
|
2007-12-20 19:27:12 +00:00
|
|
|
Task * task = EntityBuilder::instance()->newTask(name, owner);
|
2005-12-26 23:05:16 +00:00
|
|
|
if (task == 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, String::compose("Attempt to create a task of type \"%1\" "
|
|
|
|
|
"but type is unknown or forbidden", name));
|
2005-12-26 23:05:16 +00:00
|
|
|
}
|
|
|
|
|
return task;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-05 01:21:40 +00:00
|
|
|
/// \brief Activate a new task
|
|
|
|
|
///
|
2011-12-02 23:42:24 +00:00
|
|
|
/// Construct a task linked to the LocatedEntity provided, activated by the
|
2006-04-05 01:21:40 +00:00
|
|
|
/// tool and operation class given.
|
|
|
|
|
/// @param tool the type of tool activating the task
|
|
|
|
|
/// @param op the type of operation acitivating the task
|
2006-12-10 17:53:52 +00:00
|
|
|
/// @param target the entity that the task uses as its target
|
2006-04-05 01:21:40 +00:00
|
|
|
/// @param owner the character who will own the task
|
|
|
|
|
/// @return a pointer to the new task
|
|
|
|
|
Task * WorldRouter::activateTask(const std::string & tool,
|
|
|
|
|
const std::string & op,
|
2011-12-06 10:07:25 +00:00
|
|
|
LocatedEntity * target,
|
2011-12-02 23:42:24 +00:00
|
|
|
LocatedEntity & owner)
|
2006-04-05 01:21:40 +00:00
|
|
|
{
|
2007-12-20 19:27:12 +00:00
|
|
|
return EntityBuilder::instance()->activateTask(tool, op, target, owner);
|
2006-04-05 01:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-13 16:23:46 +01:00
|
|
|
ArithmeticScript * WorldRouter::newArithmetic(const std::string & name,
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * owner)
|
2010-07-13 16:23:46 +01:00
|
|
|
{
|
|
|
|
|
return ArithmeticBuilder::instance()->newArithmetic(name, owner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-08-05 12:29:11 +00:00
|
|
|
/// \brief Remove an entity from the world.
|
|
|
|
|
///
|
|
|
|
|
/// Remove an entity from the various lists in which it is stored.
|
2005-01-17 02:48:45 +00:00
|
|
|
/// The entity is removed from the LOC/CONTAINS tree, and the
|
|
|
|
|
/// reference held by the world is decremented. There may still be
|
|
|
|
|
/// a reference held by an operation in the queue from the removed
|
|
|
|
|
/// entity.
|
2013-01-17 10:17:07 +00:00
|
|
|
void WorldRouter::delEntity(LocatedEntity * ent)
|
2000-08-13 20:36:18 +00:00
|
|
|
{
|
2005-01-17 02:48:45 +00:00
|
|
|
if (ent == &m_gameWorld) {
|
|
|
|
|
log(WARNING, "Attempt to delete game world");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-12-02 18:30:18 +00:00
|
|
|
assert(ent->getIntId() != 0);
|
2005-01-13 23:35:36 +00:00
|
|
|
m_perceptives.erase(ent);
|
2005-11-11 Al Riddoch <alriddoch@zepler.org>
* common/types.h, server/Persistance.h, common/BaseWorld.h,
common/BaseWorld.cpp, server/WorldRouter.cpp:
Switch core world map to reference by integer ID rather than string.
Add version of getEntity() which converts from string to integer
automatically.
* rulesets/Character.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/EntityFactory.cpp,
Use getEntity() when looking up an entity, so that conversion of
ID from string to integer is automatic.
* rulesets/BaseMind.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h:
Switch to using integer IDs in MemMap's core mapping.
* server/Account.cpp, server/Account.h: Switch a few function
parameters to use integer ID values, making the code cleaner.
* server/Account.cpp, server/Admin.cpp, server/Persistance.cpp:
Handle string ID to integer conversions as required.
2005-11-11 02:04:56 +00:00
|
|
|
m_eobjects.erase(ent->getIntId());
|
2008-09-01 16:14:42 +00:00
|
|
|
--m_entityCount;
|
2005-01-17 02:48:45 +00:00
|
|
|
ent->destroy();
|
2008-09-04 09:34:55 +00:00
|
|
|
ent->updated.emit();
|
2005-01-17 02:48:45 +00:00
|
|
|
ent->decRef();
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-15 23:18:04 +01:00
|
|
|
void WorldRouter::resumeWorld()
|
|
|
|
|
{
|
|
|
|
|
//Take all suspended operations and add them to be executed.
|
2014-01-31 23:20:22 +01:00
|
|
|
while (!m_suspendedQueue.empty()) {
|
|
|
|
|
auto& ope = m_suspendedQueue.front();
|
2014-06-04 13:03:38 +02:00
|
|
|
m_operationsDispatcher.addOperationToQueue(ope.op, *ope.from);
|
2014-01-31 23:20:22 +01:00
|
|
|
m_suspendedQueue.pop();
|
2010-02-15 23:18:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-08-05 12:29:11 +00:00
|
|
|
/// \brief Pass an operation to the World.
|
|
|
|
|
///
|
2004-08-28 01:01:49 +00:00
|
|
|
/// Pass an operation to addOperationToQueue()
|
2004-08-05 12:29:11 +00:00
|
|
|
/// so it gets added to the queue for dispatch.
|
2013-01-17 10:17:07 +00:00
|
|
|
void WorldRouter::message(const Operation & op, LocatedEntity & ent)
|
2000-08-25 17:54:30 +00:00
|
|
|
{
|
2014-06-04 13:03:38 +02:00
|
|
|
m_operationsDispatcher.addOperationToQueue(op, ent);
|
2004-07-31 18:56:03 +00:00
|
|
|
debug(std::cout << "WorldRouter::message {"
|
2005-08-27 14:52:12 +00:00
|
|
|
<< op->getParents().front() << ":"
|
|
|
|
|
<< op->getFrom() << ":" << op->getTo() << "}" << std::endl
|
2004-07-31 18:56:03 +00:00
|
|
|
<< std::flush;);
|
2000-08-25 17:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-05 12:29:11 +00:00
|
|
|
/// \brief Determine the broadcast list to be used to broadcast an operation.
|
|
|
|
|
///
|
|
|
|
|
/// Check the type of operation, and work out which list of entities
|
|
|
|
|
/// it should be broadcast to. This will be perceptives in case
|
|
|
|
|
/// a perception operation, or all entities in any other case.
|
|
|
|
|
/// This should probably go, as there is essentially no sane reason
|
|
|
|
|
/// for broadcasting a random op to all entities.
|
|
|
|
|
/// @return a reference to the list of entities to be used for braodcast.
|
2006-07-08 22:36:31 +00:00
|
|
|
bool WorldRouter::broadcastPerception(const Operation & op) const
|
2000-12-03 23:17:52 +00:00
|
|
|
{
|
2006-07-08 22:16:04 +00:00
|
|
|
int op_class = op->getClassNo();
|
|
|
|
|
if (op_class == Atlas::Objects::Operation::SIGHT_NO ||
|
|
|
|
|
op_class == Atlas::Objects::Operation::SOUND_NO ||
|
|
|
|
|
op_class == Atlas::Objects::Operation::APPEARANCE_NO ||
|
|
|
|
|
op_class == Atlas::Objects::Operation::DISAPPEARANCE_NO) {
|
2006-07-08 22:36:31 +00:00
|
|
|
return true;
|
2000-12-03 23:17:52 +00:00
|
|
|
}
|
2006-07-08 22:16:04 +00:00
|
|
|
log(WARNING, String::compose("Broadcasting %1 op from %2",
|
|
|
|
|
op->getParents().front(),
|
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
|
|
|
op->getFrom()));
|
2006-07-08 22:36:31 +00:00
|
|
|
return false;
|
2000-12-03 23:17:52 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-04 21:25:19 +00:00
|
|
|
/// \brief Deliver an operation to its target.
|
|
|
|
|
///
|
2004-08-07 11:25:30 +00:00
|
|
|
/// Pass the operation to the target entity. The resulting operations
|
|
|
|
|
/// have their ref numbers set, and are added to the queue for
|
|
|
|
|
/// dispatch.
|
2013-01-17 10:17:07 +00:00
|
|
|
void WorldRouter::deliverTo(const Operation & op, LocatedEntity & ent)
|
2002-03-12 18:08:56 +00:00
|
|
|
{
|
2013-11-20 15:09:09 +01:00
|
|
|
//Make sure the entity isn't dereferenced while in this loop.
|
|
|
|
|
//This is mainly in place to handle relayed deletion ops.
|
|
|
|
|
EntityScopedRef referenceGuard(ent);
|
2010-02-15 23:18:04 +01:00
|
|
|
//If the world is suspended and the op is a tick, we should store it
|
|
|
|
|
//(to be resent when the world is resumed) and not process it now.
|
|
|
|
|
if (m_isSuspended) {
|
|
|
|
|
if (op->getClassNo() == Atlas::Objects::Operation::TICK_NO) {
|
2014-01-31 23:20:22 +01:00
|
|
|
m_suspendedQueue.push(OpQueEntry(op, ent));
|
2010-02-15 23:18:04 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-09-03 Al Riddoch <alriddoch@zepler.org>
* client/CharacterClient.cpp, client/CharacterClient.h,
client/CommClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/OOGThing.cpp,
common/OOGThing.h, common/op_switch.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/Food.cpp, rulesets/Food.h,
rulesets/Missile.h, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Stackable.cpp, rulesets/Stackable.h, rulesets/Thing.cpp,
rulesets/Thing.h, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/Connection.cpp,
server/Connection.h, server/ExternalMind.cpp, server/ExternalMind.h,
server/Lobby.cpp, server/Lobby.h, server/Player.cpp,
server/Player.h, server/WorldRouter.cpp:
Re-work basic op dispatch mechanism so result is passed by
a reference argument rather than returning by value.
2004-09-03 00:33:19 +00:00
|
|
|
OpVector res;
|
2015-04-06 21:43:24 +02:00
|
|
|
debug(std::cout << "WorldRouter::deliverTo begin {"
|
|
|
|
|
<< op->getParents().front() << ":"
|
|
|
|
|
<< op->getFrom() << ":" << op->getTo() << "}" << std::endl
|
|
|
|
|
<< std::flush;);
|
2005-01-13 23:35:36 +00:00
|
|
|
ent.operation(op, res);
|
2015-04-06 21:43:24 +02:00
|
|
|
debug(std::cout << "WorldRouter::deliverTo done {"
|
|
|
|
|
<< op->getParents().front() << ":"
|
|
|
|
|
<< op->getFrom() << ":" << op->getTo() << "}" << std::endl
|
|
|
|
|
<< std::flush;);
|
2015-04-08 19:13:23 +02:00
|
|
|
for(auto& resOp : res) {
|
|
|
|
|
if (op->getFrom() == resOp->getTo()) {
|
|
|
|
|
if (!op->isDefaultSerialno() && resOp->isDefaultRefno()) {
|
|
|
|
|
resOp->setRefno(op->getSerialno());
|
2006-06-05 12:28:14 +00:00
|
|
|
}
|
2005-04-11 21:51:41 +00:00
|
|
|
}
|
2015-04-08 19:13:23 +02:00
|
|
|
message(resOp, ent);
|
2002-05-14 Al Riddoch <alriddoch@zepler.org>
* server/Account.cpp, server/Connection.cpp: Switched to using
USERNAME of accounts rather that ID for login and account creation.
Toughened up the connection code, so invalid login/create ops
are handled.
* server/Connection.h: Removed unused getObject method.
* rulesets/Character.cpp, rulesets/Character.h: Get rid of
inefficiency handling ops from internal and external mind. Fix
leak of some ops.
* common/BaseWorld.h, server/WorldRouter.cpp, server/WorldRouter.h:
Add method for getting a new serialno.
* rulesets/Thing.cpp, rulesets/Thing.h, server/WorldRouter.cpp:
Set refno on ops as they come back from entities. Set serialnos
on same ops at the same time, but do not set serialnos
on ops that come in from elsewhere, as those are now handled at
source.
* rulesets/Creator.cpp, rulesets/Character.cpp:
Ensure that ops from external client preserve their serialno,
and assign new serialnos to other ops created at the same time.
2002-05-14 19:17:52 +00:00
|
|
|
}
|
2002-03-12 18:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-17 02:48:45 +00:00
|
|
|
/// \brief Main in-game operation dispatch function.
|
2004-09-04 21:25:19 +00:00
|
|
|
///
|
2004-08-07 11:25:30 +00:00
|
|
|
/// Operations are passed here when they are due for dispatch.
|
|
|
|
|
/// Determine the target of the operation and deliver it directly,
|
|
|
|
|
/// or broadcast if broadcast is required. This function implements
|
|
|
|
|
/// sight ranges for perception operations.
|
2004-11-07 01:29:23 +00:00
|
|
|
/// @param op operation to be dispatched to the world. This is non-const
|
|
|
|
|
/// so that broadcast ops can have their TO set correctly for each target.
|
2006-12-10 17:53:52 +00:00
|
|
|
/// @param from entity the operation to be dispatched was send from. Note
|
|
|
|
|
/// that it is possible that this entity has been destroyed, but it
|
|
|
|
|
/// should still have a valid location, so can be used for range
|
|
|
|
|
/// calculations.
|
2013-01-17 10:17:07 +00:00
|
|
|
void WorldRouter::operation(const Operation & op, LocatedEntity & from)
|
2000-08-13 20:36:18 +00:00
|
|
|
{
|
2002-03-11 Al Riddoch <alriddoch@zepler.org>
* server/WorldRouter.cpp: Eliminate unnecessary call to opEnumerate()
and enhance debugging output.
* server/Player.cpp: Correct the use of string.compare() in older
versions of libstdc++.
* common/types.h: Added enumeration for other operations, not
handled by the core, but considered valid. Added new type
for storing mapping between operation parents and their
enumerated type.
* common/op_switch.h: Separate handling of operations known to
be invalid from operations which are valid, but not explicitly
added to the core.
* common/inheritance.h, common/inheritance.cpp, common/custom.cpp:
Provide global operation mapping where enumeration of operations
can be looked up. Install all types handled by the core, and
types known to be used in scripts.
* common/BaseEntity.h, common/BaseEntity.cpp: Add object specific
operation mapping where operation types each object is subscribed
to can be enumerated, and others are rejected. Add mechanism
so that objects can add to the mapping, this subscribing to
operations. This makes enumerating operations much cheaper, and
eliminates the overhead of handling ops an object has no interest
in.
* rulesets/Thing.h, rulesets/Thing.cpp: Add mechanism so scripts
can subscribe to operations.
* rulesets/Character.h, rulesets/Character.cpp:
Add subscription mechanism for ops going to and from
the mind.
* rulesets/BaseMind.h, rulesets/BaseMind.cpp:
Add subscription mechanism for sight and sound perception
operations sub operations, and provide an interface to it
for scripts.
* server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/World.h, rulesets/Thing.cpp,
rulesets/Stackable.cpp, rulesets/Plant.cpp, rulesets/Food.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Add subscriptions to operations for all core base classes.
* rulesets/Python_API.cpp: When script is created, go through
methods, and subscribe to the operations which are handled by
them.
* rulesets/Character.cpp: When calculating orientation of a walking
character, assume it is standing upright.
* physics/Vector3D.h: Add versions of mag() and distance() which
omit the square root calculations, so that when their values
are only used for comparison, the expensive square root
calculations can be ommited. Add new version of collision
and range checking functions which provide the optimal
interface to the application. Add versions of methods which
modify this rather than creating a new operation to eliminate
wasted copies.
* physics/Quaternion.cpp: Make use of faster interface provided
by Vector3D.
* physics/BBox.h: Add new version of collision checking function
which provides optimal interface to the application.
* modules/Location.h, modules/Location.cpp: Add new functions
to optimally calculate the distance between any two entities.
* modules/Location.h: Re-write collision and range functions to
make much more optimal use of Vector3D, BBox and distance
functionality.
* rulesets/Py_Vector3D.cpp, rulesets/Pedestrian.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp, rulesets/Character.cpp:
Eliminate implicit copies from vector arithmetic.
* rulesets/Pedestrian.cpp, rulesets/MemMap.cpp, common/const.h:
Re-write code which uses magnitude of vectors to use the square
of the magnitude instead, as it is much cheaper to calculate.
2002-03-11 18:24:19 +00:00
|
|
|
debug(std::cout << "WorldRouter::operation {"
|
2005-08-27 14:52:12 +00:00
|
|
|
<< op->getParents().front() << ":"
|
2006-07-11 14:33:30 +00:00
|
|
|
<< op->getFrom() << ":" << op->getTo() << "}"
|
|
|
|
|
<< std::endl << std::flush;);
|
2006-07-08 21:57:01 +00:00
|
|
|
assert(op->getFrom() == from.getId());
|
2006-07-08 22:16:04 +00:00
|
|
|
assert(!op->getParents().empty());
|
2000-08-25 17:54:30 +00:00
|
|
|
|
2014-06-04 13:03:38 +02:00
|
|
|
Dispatching.emit(op);
|
|
|
|
|
|
2006-07-11 14:33:30 +00:00
|
|
|
if (!op->isDefaultTo()) {
|
|
|
|
|
const std::string & to = op->getTo();
|
|
|
|
|
assert(!to.empty());
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * to_entity = 0;
|
2005-10-20 00:21:45 +00:00
|
|
|
|
|
|
|
|
if (to == from.getId()) {
|
|
|
|
|
if (from.isDestroyed()) {
|
|
|
|
|
// Entity no longer exists
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
to_entity = &from;
|
|
|
|
|
} else {
|
2005-11-11 Al Riddoch <alriddoch@zepler.org>
* common/types.h, server/Persistance.h, common/BaseWorld.h,
common/BaseWorld.cpp, server/WorldRouter.cpp:
Switch core world map to reference by integer ID rather than string.
Add version of getEntity() which converts from string to integer
automatically.
* rulesets/Character.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/EntityFactory.cpp,
Use getEntity() when looking up an entity, so that conversion of
ID from string to integer is automatic.
* rulesets/BaseMind.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h:
Switch to using integer IDs in MemMap's core mapping.
* server/Account.cpp, server/Account.h: Switch a few function
parameters to use integer ID values, making the code cleaner.
* server/Account.cpp, server/Admin.cpp, server/Persistance.cpp:
Handle string ID to integer conversions as required.
2005-11-11 02:04:56 +00:00
|
|
|
to_entity = getEntity(to);
|
|
|
|
|
|
|
|
|
|
if (to_entity == 0) {
|
2005-10-20 00:21:45 +00:00
|
|
|
debug(std::cerr << "WARNING: Op to=\"" << to << "\""
|
|
|
|
|
<< " does not exist"
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
2004-07-13 01:37:00 +00:00
|
|
|
|
|
|
|
|
assert(to_entity != 0);
|
|
|
|
|
|
2005-01-17 02:48:45 +00:00
|
|
|
deliverTo(op, *to_entity);
|
2013-11-15 22:55:17 +01:00
|
|
|
|
2006-07-08 22:36:31 +00:00
|
|
|
} else if (broadcastPerception(op)) {
|
2016-06-10 17:25:25 +02:00
|
|
|
if (from.m_location.m_loc) {
|
2016-06-22 16:51:07 +02:00
|
|
|
// Where broadcasts go depends on type of op
|
|
|
|
|
for (auto& entity : m_perceptives) {
|
|
|
|
|
if (entity->m_location.m_loc) {
|
|
|
|
|
Domain* entityDomain = entity->m_location.m_loc->getMovementDomain();
|
|
|
|
|
if (entityDomain && entityDomain->isEntityVisibleFor(*entity, from)) {
|
2016-06-10 17:25:25 +02:00
|
|
|
op->setTo(entity->getId());
|
|
|
|
|
deliverTo(op, *entity);
|
|
|
|
|
}
|
2016-06-22 16:51:07 +02:00
|
|
|
|
2014-09-15 18:45:35 +02:00
|
|
|
}
|
2001-02-19 06:13:31 +00:00
|
|
|
}
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
2006-07-08 22:36:31 +00:00
|
|
|
} else {
|
|
|
|
|
EntityDict::const_iterator I = m_eobjects.begin();
|
|
|
|
|
EntityDict::const_iterator Iend = m_eobjects.end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
op->setTo(I->second->getId());
|
|
|
|
|
deliverTo(op, *I->second);
|
|
|
|
|
}
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-24 Al Riddoch <alriddoch@zepler.org>
* index.dox, common/BaseWorld.cpp, common/BaseWorld.h,
common/PropertyFactory.h, common/PropertyManager.h, common/const.h,
rulesets/ActivePropertyFactory.h, rulesets/Entity.h,
rulesets/Py_Vector3D.h, rulesets/Py_World.h, rulesets/Py_WorldTime.h,
rulesets/PythonMindScript.cpp, rulesets/PythonMindScript.h,
rulesets/PythonScript.h,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Script.cpp, rulesets/Script.h,
server/ArithmeticFactory.h, server/CommServer.h, server/CommSocket.h,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/TaskFactory.h, server/WorldRouter.cpp, tools/AdminClient.h,
tools/cyaddrules.cpp, tools/cycmd.cpp, tools/cyconfig.cpp,
tools/cydumprules.cpp, tools/cyloadrules.cpp:
Add a truck load of inline docs.
* tools/cywatchdog.cpp: Mark obsolete file as removed from the build.
* tools/cyloadrules.cpp, tools/cyconfig.cpp, tools/cyaddrules.cpp:
Rename some overly generic types so they have more indicative
and unique names.
* FIXME, server/ScriptFactory.cpp, server/TaskFactory.h: Add a couple
of formal FIXMEs to sort out the code for loading modules and
classes.
* rulesets/PythonThingScript.h: Remove some commented out code.
2006-12-24 14:42:05 +00:00
|
|
|
/// Add entity provided to the list of perceptive entities.
|
2004-08-07 11:25:30 +00:00
|
|
|
/// Look up the entity with the id provided, and add a pointer
|
|
|
|
|
/// to the entity to the set of perceptive entities. This method is
|
|
|
|
|
/// called when key events occur that indicate that the entity in
|
2006-07-08 22:16:04 +00:00
|
|
|
/// question can receive broadcast perception operations.
|
2013-01-17 10:17:07 +00:00
|
|
|
void WorldRouter::addPerceptive(LocatedEntity * perceptive)
|
2000-08-25 17:54:30 +00:00
|
|
|
{
|
2004-07-14 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, rulesets/Creator.cpp, rulesets/Thing.h,
rulesets/World.cpp, server/WorldRouter.cpp, server/WorldRouter.h:
Modify the world interface to get rid of some pointless
infeffiencies.
* server/Account.cpp, server/Admin.cpp, server/Connection.cpp,
server/Lobby.cpp, server/ServerRouting.h, server/WorldRouter.cpp,
server/WorldRouter.h: Change getSerialNo to newSerialNo to make it
clear what it does.
2004-07-14 12:03:53 +00:00
|
|
|
debug(std::cout << "WorldRouter::addPerceptive" << std::endl << std::flush;);
|
2006-05-18 01:43:09 +00:00
|
|
|
m_perceptives.insert(perceptive);
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-07 11:25:30 +00:00
|
|
|
/// Main world loop function.
|
|
|
|
|
/// This function is called whenever the communications code is idle.
|
|
|
|
|
/// It updates the in-game time, and dispatches operations that are
|
|
|
|
|
/// now due for dispatch. The number of operations dispatched is limited
|
|
|
|
|
/// to 10 to ensure that client communications are always handled in a timely
|
|
|
|
|
/// manner. If the maximum number of operations are dispatched, the return
|
|
|
|
|
/// value indicates that this is the case, and the communications code
|
|
|
|
|
/// will call this function again as soon as possible rather than sleeping.
|
|
|
|
|
/// This ensures that the maximum possible number of operations are dispatched
|
|
|
|
|
/// without becoming unresponsive to client communications traffic.
|
2014-02-01 20:35:26 +01:00
|
|
|
bool WorldRouter::idle()
|
2000-08-13 20:36:18 +00:00
|
|
|
{
|
2014-06-04 13:03:38 +02:00
|
|
|
return m_operationsDispatcher.idle();
|
2014-02-01 20:35:26 +01:00
|
|
|
}
|
|
|
|
|
|
2015-04-09 10:57:45 +02:00
|
|
|
|
2014-02-01 20:35:26 +01:00
|
|
|
double WorldRouter::secondsUntilNextOp() const {
|
2014-06-04 13:03:38 +02:00
|
|
|
return m_operationsDispatcher.secondsUntilNextOp();
|
2014-01-31 23:12:27 +01:00
|
|
|
}
|
|
|
|
|
|
2004-08-07 11:25:30 +00:00
|
|
|
/// Find an entity of the given name. This is provided to allow administrators
|
|
|
|
|
/// to perform certain admin tasks. It finds and returns the first instance
|
|
|
|
|
/// with the name provided in the game world.
|
|
|
|
|
/// @param name string specifying name of the instance required.
|
|
|
|
|
/// @return a pointer to an entity with the type required, or zero if an
|
|
|
|
|
/// instance with this name was not found.
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * WorldRouter::findByName(const std::string & name)
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
{
|
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
|
|
|
Element name_attr;
|
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
|
|
|
EntityDict::const_iterator Iend = m_eobjects.end();
|
|
|
|
|
for (EntityDict::const_iterator I = m_eobjects.begin(); I != Iend; ++I) {
|
2011-09-29 17:36:26 +01:00
|
|
|
if (I->second->getAttr("name", name_attr) == 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
|
|
|
if (name_attr == name) {
|
|
|
|
|
return I->second;
|
|
|
|
|
}
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-07 11:25:30 +00:00
|
|
|
/// Find an entity of the given type. This is provided to allow administrators
|
|
|
|
|
/// to perform certain admin tasks. It finds and returns the first instance
|
|
|
|
|
/// of the type provided in the game world.
|
|
|
|
|
/// @param type string specifying the class name of the instance required.
|
|
|
|
|
/// @return a pointer to an entity of the type required, or zero if no
|
|
|
|
|
/// instance was found.
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * WorldRouter::findByType(const std::string & type)
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
{
|
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
|
|
|
EntityDict::const_iterator Iend = m_eobjects.end();
|
|
|
|
|
for(EntityDict::const_iterator I = m_eobjects.begin(); I != Iend; ++I) {
|
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->second->getType()->name() == type) {
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
return I->second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|