// Cyphesis Online RPG Server and AI Engine // Copyright (C) 2010 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 #ifdef NDEBUG #undef NDEBUG #endif #ifndef DEBUG #define DEBUG #endif #include "server/StorageManager.h" #include "server/WorldRouter.h" #include "server/MindInspector.h" #include "rulesets/Entity.h" #include "rulesets/Character.h" #include "rulesets/MindProperty.h" #include "common/SystemTime.h" #include using Atlas::Message::Element; class TestStorageManager : public StorageManager { public: TestStorageManager(WorldRouter&w) : StorageManager(w) { } void test_entityInserted(LocatedEntity * e) { entityInserted(e); } void test_entityUpdated(LocatedEntity * e) { entityUpdated(e); } void test_encodeProperty(PropertyBase * p, std::string & s) { encodeProperty(p, s); } void test_restoreProperties(LocatedEntity * e) { restorePropertiesRecursively(e); } void test_insertEntity(LocatedEntity * e) { insertEntity(e); } void test_updateEntity(LocatedEntity * e) { updateEntity(e); } void test_restoreChildren(LocatedEntity * e) { restoreChildren(e); } }; int main() { { SystemTime time; WorldRouter world(time); StorageManager store(world); } { SystemTime time; WorldRouter world(time); StorageManager store(world); store.initWorld(); } { SystemTime time; WorldRouter world(time); StorageManager store(world); store.restoreWorld(); } { SystemTime time; WorldRouter world(time); StorageManager store(world); store.tick(); } { SystemTime time; WorldRouter world(time); TestStorageManager store(world); store.test_entityInserted(new Entity("1", 1)); } { SystemTime time; WorldRouter world(time); TestStorageManager store(world); store.test_entityUpdated(new Entity("1", 1)); } { SystemTime time; WorldRouter world(time); TestStorageManager store(world); std::string val; // store.test_encodeProperty(0, val); } { SystemTime time; WorldRouter world(time); TestStorageManager store(world); store.test_restoreProperties(new Entity("1", 1)); } { SystemTime time; WorldRouter world(time); TestStorageManager store(world); store.test_insertEntity(new Entity("1", 1)); } { SystemTime time; WorldRouter world(time); TestStorageManager store(world); store.test_updateEntity(new Entity("1", 1)); } { SystemTime time; WorldRouter world(time); TestStorageManager store(world); store.test_restoreChildren(new Entity("1", 1)); } return 0; } // stubs #include "server/CorePropertyManager.h" #include "server/EntityBuilder.h" #include "rulesets/Script.h" #include "modules/EntityRef.h" #include "modules/Location.h" #include "common/const.h" #include "common/Database.h" #include "common/globals.h" #include "common/log.h" #include "common/Monitors.h" #include "common/PropertyManager.h" #include "common/SystemTime.h" #include "common/Variable.h" #include "stubs/server/stubWorldRouter.h" #include "stubs/modules/stubLocation.h" #include "stubs/rulesets/stubEntity.h" #include "stubs/rulesets/stubCharacter.h" #include "stubs/rulesets/stubThing.h" #include "stubs/common/stubBaseWorld.h" #include #include #include #include using Atlas::Message::MapType; using Atlas::Objects::Entity::RootEntity; EntityBuilder * EntityBuilder::m_instance = nullptr; EntityBuilder::EntityBuilder() { } EntityBuilder::~EntityBuilder() { } LocatedEntity * EntityBuilder::newEntity(const std::string & id, long intId, const std::string & type, const RootEntity & attributes, const BaseWorld &) const { return 0; } #include "stubs/rulesets/stubLocatedEntity.h" #include "stubs/common/stubRouter.h" #include "stubs/common/stubDatabase.h" #include "stubs/server/stubPersistence.h" #include "stubs/common/stubPropertyManager.h" bool Script::operation(const std::string & opname, const Atlas::Objects::Operation::RootOperation & op, OpVector & res) { return false; } void Script::hook(const std::string & function, LocatedEntity * entity) { } EntityRef::EntityRef(LocatedEntity* e) : m_inner(e) { } EntityRef::EntityRef(const EntityRef& ref) : m_inner(ref.m_inner) { } EntityRef& EntityRef::operator=(const EntityRef& ref) { m_inner = ref.m_inner; return *this; } void EntityRef::onEntityDeleted() { } const char * DatabaseResult::const_iterator::column(const char * column) const { return ""; } VariableBase::~VariableBase() { } template Variable::Variable(const T & variable) : m_variable(variable) { } template Variable::~Variable() { } template void Variable::send(std::ostream & o) { o << m_variable; } template bool Variable::isNumeric() const { return false; } template class Variable; template class Variable; template class Variable; #include "stubs/common/stubMonitors.h" #include "stubs/common/stubOperationsDispatcher.h" MindInspector::MindInspector() : m_serial(0) { } MindInspector::~MindInspector() { } void MindInspector::queryEntityForThoughts(const std::string& entityId) { } void MindInspector::relayResponseReceived(const Operation& op, const std::string& entityId) { } PropertyBase::PropertyBase(unsigned int flags) : m_flags(flags) { } void PropertyBase::install(LocatedEntity *, const std::string & name) { } void PropertyBase::install(TypeNode *, const std::string & name) { } void PropertyBase::remove(LocatedEntity *, const std::string & name) { } void PropertyBase::apply(LocatedEntity *) { } void PropertyBase::add(const std::string & s, Atlas::Message::MapType & ent) const { get(ent[s]); } void PropertyBase::add(const std::string & s, const Atlas::Objects::Entity::RootEntity & ent) const { } HandlerResult PropertyBase::operation(LocatedEntity *, const Operation &, OpVector &) { return OPERATION_IGNORED; } template Property::Property(unsigned int flags) : PropertyBase(flags) { } template int Property::get(Atlas::Message::Element & e) const { return 0; } // The following two are obsolete. template void Property::add(const std::string & s, Atlas::Message::MapType & ent) const { } template void Property::add(const std::string & s, const Atlas::Objects::Entity::RootEntity & ent) const { } template void Property::set(const Atlas::Message::Element & e) { } template Property * Property::copy() const { return new Property(*this); } template class Property; bool MindProperty::isMindEnabled() const { return false; } void MindProperty::set(const Element & val) { } MindProperty * MindProperty::copy() const { return 0; } void MindProperty::apply(LocatedEntity * ent) { } long forceIntegerId(const std::string & id) { long intId = strtol(id.c_str(), 0, 10); if (intId == 0 && id != "0") { abort(); } return intId; } void log(LogLevel lvl, const std::string & msg) { } bool database_flag = true; namespace consts { // Id of root world entity const char * rootWorldId = "0"; // Integer id of root world entity const long rootWorldIntId = 0L; } namespace Atlas { namespace Objects { namespace Operation { int THINK_NO = -1; } } }