Exemple #1
0
bool LoggedInState::createCharacter(const std::string& name, const std::string& sex, const std::string& type, const std::string& description, const std::string& spawnName, const Atlas::Message::MapType& extraProperties)
{
	ConsoleBackend::getSingleton().pushMessage("Creating char...", "important");
	std::string msg;
	msg = "Creating character of type '" + type + "' with name '" + name + "' and sex '" + sex + "'.";
	ConsoleBackend::getSingleton().pushMessage(msg, "info");

	S_LOG_INFO("Creating character.");
	Atlas::Objects::Entity::RootEntity character;
	for (auto& property : extraProperties) {
		character->setAttr(property.first, property.second);
	}

	character->setParentsAsList(Atlas::Message::ListType(1, type));
	character->setName(name);
	character->setAttr("sex", sex);
	character->setAttr("description", description);
	if (spawnName != "") {
		character->setAttr("spawn_name", spawnName);
	}


	try {
		mAccount.createCharacter(character);
	} catch (const std::exception& except) {
		S_LOG_WARNING("Got Eris error on character creation." << except);
		return false;
	} catch (...) {
		S_LOG_WARNING("Got unknown error on character creation.");
		return false;
	}
	S_LOG_INFO("Done creating character.");

	return true;
}
Exemple #2
0
void Location::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
    if (m_loc!=NULL) {
        ent->setLoc(m_loc->getId());
    }
    if (pos().isValid()) {
        ::addToEntity(pos(), ent->modifyPos());
    }
    if (velocity().isValid()) {
        ::addToEntity(velocity(), ent->modifyVelocity());
    }
    if (orientation().isValid()) {
        ent->setAttr("orientation", orientation().toAtlas());
    }
    if (bBox().isValid()) {
        ent->setAttr("bbox", bBox().toAtlas());
    }
}
Exemple #3
0
void Admin::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
    Account::addToEntity(ent);
    ListType typeList;
    Root character_type = Inheritance::instance().getClass("character");
    if (character_type.isValid()) {
        addTypeToList(character_type, typeList);
    }
    ent->setAttr("character_types", typeList);
}
Exemple #4
0
void StdContainer::addToEntity(const std::string & key,
                               const Atlas::Objects::Entity::RootEntity & ent) const
{
    Atlas::Message::Element v = Atlas::Message::ListType();
    Atlas::Message::ListType & contlist = v.asList();
    EntitySet::const_iterator Iend = m_entities.end();
    for (EntitySet::const_iterator I = m_entities.begin(); I != Iend; ++I) {
        contlist.push_back((*I)->getId());
    }
    ent->setAttr(key, v);
}
Exemple #5
0
void Player::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
    Account::addToEntity(ent);
    ListType typeList;
    std::set<std::string>::const_iterator I = Player::playableTypes.begin();
    std::set<std::string>::const_iterator Iend = Player::playableTypes.end();
    for (; I != Iend; ++I) {
        typeList.push_back(Element(*I));
    }
    ent->setAttr("character_types", typeList);
}
Exemple #6
0
/// \brief Copy the attribute values of this object to an Atlas Entity
void Router::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
    ent->setObjtype("obj");
    ent->setId(getId());
}
void Entity::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
    ent->setId(getId());
}
void ExternalProperty::add(const std::string & s,
                           const Atlas::Objects::Entity::RootEntity & ent) const
{
    ent->setAttr(s, (m_data == 0) ? 0 : 1);
}
int main()
{
    CommServer comm_server;

    {
        new TestCommClient(comm_server);
    }

    {
        new TestCommClient(comm_server, 0);
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setEncoder();

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->setup(0);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_negotiate();

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnection(new TestLink(*cs));

        cs->test_setNegotiateState(Atlas::Negotiate::SUCCEEDED);

        cs->test_negotiate();

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setNegotiateState(Atlas::Negotiate::FAILED);

        cs->test_negotiate();

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnectTime(0);
        cs->test_idle(0);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnection(new TestLink(*cs));

        cs->test_setNegotiateState(Atlas::Negotiate::SUCCEEDED);
        cs->test_negotiate();

        cs->test_setConnectTime(0);
        cs->test_idle(0);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnectTime(0);
        cs->test_idle(20);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->read();

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setEncoder();
        cs->read();

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        Atlas::Objects::Operation::RootOperation op;
        cs->send(op);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_openSocket();

        Atlas::Objects::Operation::RootOperation op;
        cs->send(op);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_openSocket();
        cs->test_setEncoder();

        Atlas::Objects::Operation::RootOperation op;
        cs->send(op);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnection(new TestLink(*cs));

        Atlas::Objects::Operation::RootOperation op;
        cs->test_operation(op);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnection(new TestLink(*cs, 1));

        Atlas::Objects::Operation::RootOperation op;
        cs->test_operation(op);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnection(new TestLink(*cs, 1));

        Atlas::Objects::Operation::RootOperation op;
        op->setSerialno(23);
        cs->test_operation(op);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnection(new TestLink(*cs, 1));

        cs->dispatch();

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        cs->test_setConnection(new TestLink(*cs, 1));

        cs->test_setupQueue();
        cs->dispatch();

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        Atlas::Objects::Entity::RootEntity ent;
        cs->test_objectArrived(ent);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        Atlas::Objects::Entity::RootEntity ent;
        ent->setParents(std::list<std::string>());
        cs->test_objectArrived(ent);

        delete cs;
    }

    {
        TestCommClient * cs = new TestCommClient(comm_server);

        Atlas::Objects::Operation::RootOperation op;
        cs->test_objectArrived(op);

        delete cs;
    }

    return 0;
}