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
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2007 Alistair Riddoch
|
|
|
|
|
//
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef COMMON_TYPE_NODE_H
|
|
|
|
|
#define COMMON_TYPE_NODE_H
|
|
|
|
|
|
|
|
|
|
#include <Atlas/Objects/Root.h>
|
|
|
|
|
#include <Atlas/Objects/SmartPtr.h>
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
2018-01-28 21:25:12 +01:00
|
|
|
#include <map>
|
2018-04-29 16:26:32 +02:00
|
|
|
#include <set>
|
|
|
|
|
#include <string>
|
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
|
|
|
|
2008-01-13 Al Riddoch <alriddoch@googlemail.com>
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/BaseWorld.h, common/OperationRouter.h, common/TypeNode.h,
common/inheritance.cpp, common/inheritance.h, common/types.h,
rulesets/ActivePropertyFactory.h, rulesets/AtlasProperties.h,
rulesets/EntityPropertyFactory.h, rulesets/LocatedEntity.h,
rulesets/MemMap.h, rulesets/Motion.h, rulesets/Movement.h,
rulesets/Pedestrian.h, rulesets/PythonThingScript.cpp,
rulesets/Statistics.h, rulesets/Task.h, server/Account.h,
server/Connection.h, server/Player.h, server/ServerRouting.h,
server/WorldRouter.h, tests/OperationExerciser.h, tools/cycmd.cpp:
A major clean up and re-work in internal headers.
2008-01-13 01:32:54 +00:00
|
|
|
class PropertyBase;
|
|
|
|
|
|
|
|
|
|
typedef std::map<std::string, PropertyBase *> PropertyDict;
|
|
|
|
|
|
2009-08-24 02:54:43 +01:00
|
|
|
/// \brief Entry in the type hierarchy for in-game entity classes.
|
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
|
|
|
class TypeNode {
|
|
|
|
|
protected:
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief name
|
2011-09-16 18:37:41 +01:00
|
|
|
const std::string m_name;
|
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
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief property defaults
|
2007-12-29 01:50:39 +00:00
|
|
|
PropertyDict m_defaults;
|
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
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief type description
|
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
|
|
|
Atlas::Objects::Root m_description;
|
|
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief parent node
|
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
|
|
|
const TypeNode * m_parent;
|
|
|
|
|
public:
|
2018-04-29 16:26:32 +02:00
|
|
|
|
|
|
|
|
struct PropertiesUpdate {
|
|
|
|
|
std::set<std::string> newProps;
|
|
|
|
|
std::set<std::string> removedProps;
|
|
|
|
|
std::set<std::string> changedProps;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2018-01-28 21:25:12 +01:00
|
|
|
explicit TypeNode(const std::string &);
|
2011-09-17 18:45:33 +01:00
|
|
|
TypeNode(const std::string &, const Atlas::Objects::Root &);
|
2008-10-22 16:08:59 +00:00
|
|
|
~TypeNode();
|
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
|
|
|
|
2018-01-28 21:25:12 +01:00
|
|
|
/// \brief injects a new property and updated the m_description
|
|
|
|
|
void injectProperty(const std::string&, PropertyBase*);
|
2011-09-16 16:42:42 +01:00
|
|
|
|
2011-09-16 10:43:01 +01:00
|
|
|
/// \brief add the class properties for this type from Atlas attributes
|
|
|
|
|
void addProperties(const Atlas::Message::MapType & attributes);
|
|
|
|
|
|
2011-09-15 23:40:26 +01:00
|
|
|
/// \brief update the class properties for this type from Atlas attributes
|
2018-04-29 16:26:32 +02:00
|
|
|
TypeNode::PropertiesUpdate updateProperties(const Atlas::Message::MapType & attributes);
|
2011-09-15 23:40:26 +01:00
|
|
|
|
2011-12-09 00:13:18 +00:00
|
|
|
/// \brief check if this type inherits from another
|
|
|
|
|
bool isTypeOf(const std::string & base_type) const;
|
|
|
|
|
|
|
|
|
|
/// \brief check if this type inherits from another
|
|
|
|
|
bool isTypeOf(const TypeNode * base_type) const;
|
|
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief const accessor for name
|
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
|
|
|
const std::string & name() const {
|
|
|
|
|
return m_name;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief const accessor for property defaults
|
2007-12-29 01:50:39 +00:00
|
|
|
const PropertyDict & defaults() const {
|
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
|
|
|
return m_defaults;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief accessor for type description
|
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
|
|
|
Atlas::Objects::Root & description() {
|
|
|
|
|
return m_description;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief const accessor for type description
|
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
|
|
|
const Atlas::Objects::Root & description() const {
|
|
|
|
|
return m_description;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief const accessor for parent node
|
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
|
|
|
const TypeNode * parent() const {
|
|
|
|
|
return m_parent;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-25 00:58:17 +01:00
|
|
|
/// \brief set the parent node
|
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
|
|
|
void setParent(const TypeNode * parent) {
|
|
|
|
|
m_parent = parent;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // COMMON_TYPE_NODE_H
|