// Cyphesis Online RPG Server and AI Engine // Copyright (C) 2006 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 #include "CorePropertyManager.h" #include "server/Juncture.h" #include "server/ServerRouting.h" #include "server/TeleportProperty.h" #include "rulesets/LineProperty.h" #include "rulesets/OutfitProperty.h" #include "rulesets/SolidProperty.h" #include "rulesets/StatusProperty.h" #include "rulesets/StatisticsProperty.h" #include "rulesets/TerrainModProperty.h" #include "rulesets/TerrainProperty.h" #include "rulesets/TransientProperty.h" #include "rulesets/BBoxProperty.h" #include "rulesets/BiomassProperty.h" #include "rulesets/BurnSpeedProperty.h" #include "rulesets/DecaysProperty.h" #include "rulesets/MindProperty.h" #include "rulesets/InternalProperties.h" #include "rulesets/SpawnProperty.h" #include "rulesets/AreaProperty.h" #include "rulesets/VisibilityProperty.h" #include "rulesets/SuspendedProperty.h" #include "rulesets/TasksProperty.h" #include "rulesets/EntityProperty.h" #include "rulesets/SpawnerProperty.h" #include "rulesets/ImmortalProperty.h" #include "rulesets/RespawningProperty.h" #include "rulesets/DefaultLocationProperty.h" #include "rulesets/DomainProperty.h" #include "rulesets/LimboProperty.h" #include "rulesets/TransformsProperty.h" #include "rulesets/ModeProperty.h" #include "rulesets/ModeSpecProperty.h" #include "rulesets/ForcesProperty.h" #include "rulesets/PropelProperty.h" #include "common/Eat.h" #include "common/Burn.h" #include "common/Teleport.h" #include "common/types.h" #include "common/Inheritance.h" #include "common/PropertyFactory_impl.h" #include "common/debug.h" #include #include using Atlas::Message::Element; using Atlas::Message::ListType; using Atlas::Message::MapType; using Atlas::Objects::Root; static const bool debug_flag = false; template void CorePropertyManager::installBaseProperty(const std::string & type_name, const std::string & parent) { installFactory(type_name, atlasType(type_name, parent, true), new PropertyFactory>); } template void CorePropertyManager::installProperty(const std::string & type_name, const std::string & parent) { installFactory(type_name, atlasType(type_name, parent), new PropertyFactory); } template void CorePropertyManager::installProperty(const std::string & parent) { this->installProperty(PropertyT::property_name, parent); } template void CorePropertyManager::installProperty() { this->installProperty(PropertyT::property_name, PropertyT::property_atlastype); } CorePropertyManager::CorePropertyManager() { // Core types, for inheritence only generally. installBaseProperty("int", "root_type"); installBaseProperty("float", "root_type"); installBaseProperty("string", "root_type"); installBaseProperty("list", "root_type"); installBaseProperty("map", "root_type"); installProperty>("stamina", "float"); installProperty("mode", "string"); installProperty("coords", "list"); installProperty("points", "list"); installProperty >("start_intersections", "list"); installProperty >("end_intersections", "list"); installProperty("decays", "string"); installProperty("outfit", "map"); installProperty("solid", "int"); installProperty("simple", "int"); installProperty("status", "float"); installProperty("biomass", "float"); installProperty("burn_speed", "float"); installProperty("transient", "float"); installProperty >("food", "float"); installProperty >("mass", "float"); installProperty("bbox", "list"); installProperty("mind", "map"); installProperty("init", "int"); installProperty("ticks", "float"); installProperty("statistics", "map"); installProperty("spawn", "map"); installProperty("area", "map"); installProperty("visibility", "float"); installProperty("terrainmod", "map"); installProperty("terrain", "map"); installProperty("linked", "string"); installProperty("suspended", "int"); installProperty("tasks", "map"); installProperty("right_hand_wield", "string"); installProperty("spawner", "map"); installProperty("immortal", "int"); installProperty("respawning", "string"); installProperty("default_location", "int"); installProperty("domain", "int"); installProperty("limbo", "int"); installProperty("map"); installProperty("string"); installProperty("mode-fixed", "map"); installProperty("mode-standing", "map"); installProperty("mode-planted", "map"); installProperty("map"); installProperty(); } CorePropertyManager::~CorePropertyManager() { } int CorePropertyManager::installFactory(const std::string & type_name, const Root & type_desc, PropertyKit * factory) { Inheritance & i = Inheritance::instance(); if (i.addChild(type_desc) == 0) { return -1; } PropertyManager::installFactory(type_name, factory); return 0; } PropertyBase * CorePropertyManager::addProperty(const std::string & name, int type) { assert(!name.empty()); assert(name != "objtype"); PropertyBase * p = 0; PropertyFactoryDict::const_iterator I = m_propertyFactories.find(name); if (I == m_propertyFactories.end()) { switch (type) { case Element::TYPE_INT: p = new Property; break; case Element::TYPE_FLOAT: p = new Property; break; case Element::TYPE_STRING: p = new Property; break; default: p = new SoftProperty; break; } } else { p = I->second->newProperty(); } debug(std::cout << name << " property found. " << std::endl << std::flush;); return p; }