void World::DeleteOperation(const Operation & op, OpVector & res) { //A delete operation with an argument sent to the world indicates that an //entity should be deleted forcefully (whereas a Delete operation sent to //an entity directly, which is the norm, always can be overridden by the entity). auto& args = op->getArgs(); if (!args.empty()) { auto arg = args.front(); if (!arg->isDefaultId()) { auto entity = BaseWorld::instance().getEntity(arg->getId()); if (entity) { if (entity == this) { Atlas::Message::Element force; if (arg->copyAttr("force", force) == 0 && force.isInt() && force.asInt() == 1) { clearWorld(res); } else { log(ERROR, "World::DeleteOperation cannot delete world unless 'force' flag is set."); } } else { BaseWorld::instance().delEntity(entity.get()); } } else { log(NOTICE, String::compose("Tried to delete non existent entity with id %1", arg->getId())); } } else { log(ERROR, "World::DeleteOperation got delete op with arg but no id."); } } else { assert(m_location.m_parent == nullptr); // Deleting has no effect. } }
void ServerInfo::processServer(const RootEntity &svr) { Atlas::Message::Element element; if (!svr->copyAttr("ruleset", element) && element.isString()) { _ruleset = element.asString(); } else { return; } _name = svr->getName(); if (!svr->copyAttr("clients", element) && element.isInt()) { _clients = element.asInt(); } else { return; } if (!svr->copyAttr("server", element) && element.isString()) { _server = element.asString(); } else { return; } if (!svr->copyAttr("uptime", element) && element.isFloat()) { _uptime = element.asFloat(); } else { return; } m_status = VALID; if (!svr->copyAttr("entities", element) && element.isInt()) { _entities = element.asInt(); } if (!svr->copyAttr("version", element) && element.isString()) { m_version = element.asString(); } if (!svr->copyAttr("builddate", element) && element.isString()) { m_buildDate = element.asString(); } }
void Property<int>::set(const Atlas::Message::Element & e) { if (e.isInt()) { this->m_data = e.asInt(); } }