示例#1
0
void ServerInfo::processServer(const RootEntity &svr)
{
    Atlas::Message::Element element;

    if (!svr->copyAttr("ruleset", element) && element.isString()) {
        _ruleset = element.String();
    } else {
        return;
    }

    _name = svr->getName();
    if (!svr->copyAttr("clients", element) && element.isInt()) {
        _clients = (int)element.Int();
    } else {
        return;
    }
    if (!svr->copyAttr("server", element) && element.isString()) {
        _server = element.String();
    } else {
        return;
    }
    if (!svr->copyAttr("uptime", element) && element.isFloat()) {
        _uptime = element.Float();
    } else {
        return;
    }

    m_status = VALID;

    if (!svr->copyAttr("entities", element) && element.isInt()) {
        _entities = element.Int();
    }
    
    if (!svr->copyAttr("version", element) && element.isString()) {
        m_version = element.String();
    }
    
    if (!svr->copyAttr("builddate", element) && element.isString()) {
        m_buildDate = element.String();
    }

	if (!svr->copyAttr("assets", element) && element.isList()) {
		for (auto& url : element.List()) {
			if (url.isString()) {
				m_assets.emplace_back(url.String());
			}
		}
	}

}
示例#2
0
void Tasktest::test_sequence()
{
    m_task->nextTick(1.5);

    Atlas::Message::Element val;
    m_task->getAttr("foo", val);
    assert(val.isNone());
    m_task->setAttr("foo", 1);
    m_task->getAttr("foo", val);
    assert(val.isInt());

    assert(!m_task->obsolete());

    OpVector res;

    assert(res.empty());

    Atlas::Objects::Operation::Generic c;
    c->setParents(std::list<std::string>(1, "generic"));

    m_task->initTask(c, res);

    Operation op;

    m_task->operation(op, res);

    m_task->irrelevant();

    assert(m_task->obsolete());
}
示例#3
0
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.
    }
}
示例#4
0
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();
    }
}
示例#5
0
int main()
{
    int ret = 0;

    Operation op;

    {
        Task * task;
        OpVector res;

        if (0) {
            task->TickOperation(op, res);
        }
    }

    Entity ent1("1", 1), ent2("2", 2);
    Character chr("3", 3);

    {
        Fell fell(chr, ent1, ent2);

        fell.nextTick(1.5);

        Atlas::Message::Element val;
        fell.getAttr("foo", val);
        assert(val.isNone());
        fell.setAttr("foo", 1);
        fell.getAttr("foo", val);
        assert(val.isInt());

        assert(!fell.obsolete());

        OpVector res;

        assert(res.empty());

        Atlas::Objects::Operation::Generic c;

        fell.initTask(c, res);

        assert(!res.empty());

        fell.TickOperation(op, res);

        fell.irrelevant();

        assert(fell.obsolete());
    }

    return ret;
}
示例#6
0
Py::Object CyPy_Element::wrap(Atlas::Message::Element value)
{
    if (value.isNone()) {
        return Py::None();
    } else if (value.isString()) {
        return Py::String(value.String());
    } else if (value.isInt()) {
        return Py::Long(value.Int());
    } else if (value.isFloat()) {
        return Py::Float(value.Float());
    } else if (value.isList()) {
        return CyPy_ElementList::wrap(value.List());
    } else {
        return CyPy_ElementMap::wrap(value.Map());
    }
}
示例#7
0
void Property<int>::set(const Atlas::Message::Element & e)
{
    if (e.isInt()) {
        this->m_data = e.asInt();
    }
}