Beispiel #1
0
	virtual content_t set(const std::string &name,
			const ContentFeatures &def)
	{
		assert(name == def.name);
		u16 id = CONTENT_IGNORE;
		bool found = m_name_id_mapping.getId(name, id);  // ignore aliases
		if(!found){
			// Determine if full param2 is required
			bool require_full_param2 = (
				def.param_type_2 == CPT2_FULL
				||
				def.param_type_2 == CPT2_FLOWINGLIQUID
				||
				def.legacy_wallmounted
			);
			// Get some id
			id = getFreeId(require_full_param2);
			if(id == CONTENT_IGNORE)
				return CONTENT_IGNORE;
			if(name != "")
				addNameIdMapping(id, name);
		}
		set(id, def);
		return id;
	}
Beispiel #2
0
// clang-format off
bool ActiveObjectMgr::registerObject(ClientActiveObject *obj)
{
	assert(obj); // Pre-condition
	if (obj->getId() == 0) {
		u16 new_id = getFreeId();
		if (new_id == 0) {
			infostream << "Client::ActiveObjectMgr::registerObject(): "
					<< "no free id available" << std::endl;

			delete obj;
			return false;
		}
		obj->setId(new_id);
	}

	if (!isFreeId(obj->getId())) {
		infostream << "Client::ActiveObjectMgr::registerObject(): "
				<< "id is not free (" << obj->getId() << ")" << std::endl;
		delete obj;
		return false;
	}
	infostream << "Client::ActiveObjectMgr::registerObject(): "
			<< "added (id=" << obj->getId() << ")" << std::endl;
	m_active_objects[obj->getId()] = obj;
	return true;
}
int QNearFieldManagerPrivateVirtualBase::registerNdefMessageHandler(QObject *object,
                                                                    const QMetaMethod &method)
{
    int id = getFreeId();

    Callback &callback = m_registeredHandlers[id];

    callback.filter = QNdefFilter();
    callback.object = object;
    callback.method = method;

    return id;
}
Beispiel #4
0
	virtual content_t set(const std::string &name,
			const ContentFeatures &def)
	{
		assert(name == def.name);
		u16 id = CONTENT_IGNORE;
		bool found = m_name_id_mapping.getId(name, id);  // ignore aliases
		if(!found){
			// Get some id
			id = getFreeId();
			if(id == CONTENT_IGNORE)
				return CONTENT_IGNORE;
			if(name != "")
				addNameIdMapping(id, name);
		}
		set(id, def);
		return id;
	}
Beispiel #5
0
void MapBlockObjectList::add(MapBlockObject *object)
		throw(ContainerFullException, AlreadyExistsException)
{
	if(object == NULL)
	{
		dstream<<"MapBlockObjectList::add(): NULL object"<<std::endl;
		return;
	}

	JMutexAutoLock lock(m_mutex);

	// Create unique id if id==-1
	if(object->m_id == -1)
	{
		object->m_id = getFreeId();
	}

	if(m_objects.find(object->m_id) != NULL)
	{
		dstream<<"MapBlockObjectList::add(): "
				"object with same id already exists"<<std::endl;
		throw AlreadyExistsException
				("MapBlockObjectList already has given id");
	}
	
	object->m_block = m_block;
	object->setBlockChanged();

	/*v3f p = object->m_pos;
	dstream<<"MapBlockObjectList::add(): "
			<<"m_block->getPos()=("
			<<m_block->getPos().X<<","
			<<m_block->getPos().Y<<","
			<<m_block->getPos().Z<<")"
			<<" inserting object with id="<<object->m_id
			<<" pos="
			<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
			<<std::endl;*/
	
	m_objects.insert(object->m_id, object);
}