The world, i.e. the root entity, is a little special in that its
properties can be seen by all other entities, but not its children
(unless it's a Domain entity).
This follows earlier work where we've moved more and more functionality
out of the entity classes and into properties. One of the goals of this
change is to allow for the "terrain" property to be added to arbitrary
entities.
The world can be reset, i.e. all entities deleted and properties of the
root cleared, by sending a Delete to the world itself. It must have an
argument with both the world id and an int "force" attribute with the
value 1.
If a Delete op is sent to the World with an arg with an id set the
entity with that id is instantly deleted.
This provides an override mechanism whereby an entity can be deleted
directly, by an administrator. This in contrast to the regular delete
flow where a Delete op is sent to the entity itself, and thus can be
intercepted and cancelled.
Since the World entity is special, in that it always exists, it's
suitable as a point through which out of game instances can relay
operations to in-game entities.
All IG code should use the interface of LocatedEntity when dealing
with any entity, rather than sometimes requiring Entity. Add virtual
functions to the interface where required, and modify all other interfaces
to stop them using Entity. This makes the code way cleaner, and much better
de-coupled.
* common/Identified.cpp, common/Identified.h:
Flatten down the base classes into one called Router.
* client/CharacterClient.cpp, client/CreatorClient.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp,
rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/LocatedEntity.cpp, rulesets/MemEntity.cpp,
rulesets/Plant.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp,
server/Connection.cpp, server/ExternalMind.cpp,
server/Lobby.cpp, server/Master.cpp,
server/Peer.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/SlaveClientConnection.cpp,
server/TrustedConnection.cpp, tests/LocatedEntitytest.cpp,
tests/ThingupdatePropertiestest.cpp: Update all the operation
routing classes to use the modified base class correctly.
* rulesets/attributes.h: Remove old attribute flags used for
persistence from the build.
* rulesets/Entity.h: Replace obsolete update flags with a more
general flags field, and define three needed to track the
cleanness of basic location data.
* rulesets/Plant.cpp, rulesets/World.cpp: Remove now unused update
flags from property initialisation.
* rulesets/Entity.cpp, rulesets/Thing.cpp, server/EntityFactory.cpp:
Replace code which updated update flags with simpler changes to
the new flags field.
* rulesets/TerrainProperty.cpp, rulesets/World.cpp: Fix the code
to take account of the modified semantics of Segment member
variable xref and yref.
* configure.ac: Add a requirement for the latest version of
Mercator.
* 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.
* 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.
* data/animals.xml: Give all the animals BIOMASS.
* data/characters.xml: Add mass to some character classes that were
missing it.
* rulesets/Character.cpp, rulesets/Character.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/Plant.cpp, rulesets/Statistics.cpp,
rulesets/World.cpp, server/CorePropertyManager.cpp,
server/Persistor.cpp, server/Persistor_impl.h,
server/Restorer_impl.h: Remove the hard coded mass property from
Entity.
* rulesets/mason/world/statistics/Statistics.py: Fix scripts which
assume entities will have mass.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseWorld.h, common/types.h,
modules/Location.cpp, modules/Location.h,
rulesets/AtlasProperties.cpp, rulesets/AtlasProperties.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/LocatedEntity.cpp,
rulesets/LocatedEntity.h, rulesets/MemEntity.cpp,
rulesets/MemEntity.h, rulesets/MemMap.cpp, rulesets/Motion.cpp,
rulesets/Motion.h, rulesets/Py_Location.h, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Script.cpp, rulesets/Script.h,
rulesets/Thing.cpp, rulesets/World.cpp, server/WorldRouter.cpp,
server/WorldRouter.h: Refactor all the entity code so there is now
a new base class for entities in the world simulation, and in the
mind which only contains things which are trully common to both.
This moves a lot of functionality which should not have been
present in mind entities away, and makes that code safer and more
efficient.
* tests/TestWorld.h: Update the test world API to match the base
class.
* 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.
* 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.
* rulesets/Character.cpp, rulesets/MemMap.cpp, rulesets/Motion.cpp,
rulesets/Python_API.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp: Don't use camel casing for
local variables or function arguments.
* data/basic.xml: Strip entity scripts off pickaxe and shovel.
* rulesets/World.h, rulesets/World.cpp: Remove handlers used to
to implement pickaxe and shovel, which are now handled as tasks.
* common/Delve.h, common/Dig.h, common/Mow.h, common/custom.cpp,
common/operations.cpp: Remove a bunch of operations from the build
which were only used to do things in an over simple hard coded way.
* data/basic.xml: Remove the script for scythe as it is no longer
used.
* rulesets/World.cpp: Remove mow operation from World, as this is now
handled by a task.
* common/BaseEntity.cpp, common/BaseEntity.h, common/op_switch.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Food.cpp,
rulesets/Food.h, rulesets/World.cpp, rulesets/World.h,
tests/EntityExerciser.h: Purge the burn operation from the core
operation handling code. One down, many still to go.
* rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/Pedestrian.cpp, rulesets/Py_Thing.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Remove m_world member variable from all Entity classes, and
access the world manager object as a singleton.
* rulesets/World.cpp, rulesets/World.h, rulesets/mason/define_world.py:
Remove the special handling of Set ops in world which prevented
setting status below zero from generating a Delete op. Add a test
function to define_world which attempts to destroy the world by
setting its status to -1.
* common/const.h: Remove obsolete config option to disable
range checks and calculations.
* client/ObserverClient.cpp, rulesets/Movement.cpp,
server/Admin.cpp, tools/AdminClient.h, tools/cycmd.cpp:
Remove const.h from files which no longer require it.
* rulesets/Python_API.cpp: Remove python bindings for obsolete
constants.
* rulesets/Thing.cpp, rulesets/World.cpp, server/WorldRouter.cpp:
Remove obsolete rotten code for handling sight without ranges.
* tests/consttest.cpp: Remove tests for removed constants.
* common/BaseWorld.h, rulesets/Creator.cpp, rulesets/World.cpp,
server/WorldRouter.cpp, server/WorldRouter.h, tests/TestWorld.h:
Pass perceptive entities to the world by pointer rather than
by ID, avoiding a lookup in the dictionary.
* rulesets/World.cpp: Remove commented out code. Make use of the
fact that CONTAINS is directly supported by RootEntity to
make handling it much more efficient.
* rulesets/World.cpp: Re-write look handling to use existing
addToEntity() to create an atlas representation of the entity
rather than doing most by hand. This ensures that properties
and attributes now work on the world.
* rulesets/Entity.cpp: Ensure that the best use is made of static
attributes on RootEntity.