예제 #1
0
void EntityCreatorCreationInstance::finalizeCreation()
{
	// Final position
	mEntityMessage["pos"] = Convert::toWF<WFMath::Point<3>>(mEntityNode->getPosition()).toAtlas();
	mEntityMessage["orientation"] = Convert::toWF(mEntityNode->getOrientation()).toAtlas();

	// Making create operation message
	Atlas::Objects::Operation::Create c;
	EmberEntity& avatar = mWorld.getAvatar()->getEmberEntity();
	c->setFrom(avatar.getId());
	//if the avatar is a "creator", i.e. and admin, we will set the TO property
	//this will bypass all of the server's filtering, allowing us to create any entity and have it have a working mind too
	if (avatar.getType()->isA(mTypeService.getTypeByName("creator"))) {
		c->setTo(avatar.getId());
	}

	c->setArgsAsList(Atlas::Message::ListType(1, mEntityMessage));
	mWorld.getView().getAvatar()->getConnection()->send(c);

	std::stringstream ss;
	ss << mPos;
	S_LOG_INFO("Trying to create entity at position " << ss.str());
	S_LOG_VERBOSE("Sending entity data to server: " << AtlasHelper::serialize(c, "xml"));

}
예제 #2
0
void EntityImporterBase::createRule(const Atlas::Objects::Root & obj, OpVector & res)
{
    m_state = RULE_CREATING;
    Atlas::Objects::Operation::Create createOp;
    createOp->setFrom(mAccountId);
    createOp->setArgs1(obj);

    createOp->setSerialno(newSerialNumber());
    S_LOG_INFO("Creating new rule '" << obj->getId() << "' on server.");
    res.push_back(createOp);
}
예제 #3
0
void ConnectedAdapter::createTypeInfo(const Atlas::Objects::Root& typeInfo)
{
	try {
		Atlas::Objects::Operation::Create createOp;
		createOp->setFrom(mAccount.getId());
		createOp->setArgs1(typeInfo);

		S_LOG_INFO("Sending new type info data.");
		mConnection.send(createOp);
	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on sending new type info data." << ex);
	}
}
예제 #4
0
void EntityMaker::createEntityOfType(Eris::TypeInfo* typeinfo, const std::string& parentEntityId, const std::string& name) {
	Atlas::Objects::Operation::Create c;
	c->setFrom(mAvatar.getId());
	//if the avatar is a "creator", i.e. and admin, we will set the TO property
	//this will bypass all of the server's filtering, allowing us to create any entity and have it have a working mind too
	if (mAvatar.getIsAdmin()) {
		c->setTo(mAvatar.getEntityId());
	}

	Atlas::Message::MapType msg;
	msg["loc"] = parentEntityId;

	WFMath::Point<3> pos = WFMath::Point<3>::ZERO();
	WFMath::Quaternion orientation = WFMath::Quaternion::Identity();

	//Only place it if we're creating the new entity in the same location as the avatar
	if (parentEntityId == mAvatar.getEntity()->getLocation()->getId()) {
		//Place the new entity two meters in front of the avatar.
		WFMath::Vector<3> vector(0, 0, 2);

		//We need to constraint the orientation to only around the y axis.
		WFMath::Vector<3> rotator(0.0, 0.0, 1.0f);
		rotator.rotate(mAvatar.getEntity()->getOrientation());
		auto atan = std::atan2(rotator.x(), rotator.z());
		orientation.rotation(1, atan);

		pos = mAvatar.getEntity()->getPosition() + (vector.rotate(orientation));
	}

	msg["pos"] = pos.toAtlas();
	msg["orientation"] = orientation.toAtlas();

	if (!name.empty()) {
		msg["name"] = name;
	}
	msg["parent"] = typeinfo->getName();

	c->setArgsAsList(Atlas::Message::ListType(1, msg));
	mConnection.send(c);
	std::stringstream ss;
	ss << pos;
	S_LOG_INFO("Trying to create entity of type " << typeinfo->getName() << " at position " << ss.str());

}
예제 #5
0
void Admintest::test_createObject_fallthrough()
{
    Account_createObject_called = 0;

    std::string parent("unimportant_string");
    Root arg;
    Atlas::Objects::Operation::Create op;
    op->setSerialno(m_id_counter++);
    OpVector res;

    arg->setObjtype("obj");

    m_account->createObject(parent, arg, op, res);

    ASSERT_EQUAL(res.size(), 0u);

    ASSERT_EQUAL(Account_createObject_called,
                 m_account);
}
예제 #6
0
void Admintest::test_createObject_juncture_serialno()
{
    newId_fail = false;

    std::string parent("juncture");
    Root arg;
    Atlas::Objects::Operation::Create op;
    op->setSerialno(m_id_counter++);
    OpVector res;

    arg->setObjtype("obj");

    m_account->createObject(parent, arg, op, res);

    ASSERT_EQUAL(res.size(), 1u);
    ASSERT_EQUAL(res.front()->getClassNo(),
                 Atlas::Objects::Operation::INFO_NO);
    ASSERT_TRUE(!res.front()->isDefaultRefno());
}