Ejemplo n.º 1
0
// TODO: Use this whereever it should be used
void LogicSystem::setUniqueId(extentity* staticEntity, int uniqueId)
{
    if (getUniqueId(staticEntity) >= 0)
    {
        logger::log(logger::ERROR, "Trying to set to %d a unique Id that has already been set, to %d (S)",
                                     uniqueId,
                                     getUniqueId(staticEntity));
        assert(0);
    }

    staticEntity->uid = uniqueId;
}
Ejemplo n.º 2
0
// TODO: Use this whereever it should be used
void LogicSystem::setUniqueId(physent* dynamicEntity, int uniqueId)
{
    logger::log(logger::DEBUG, "Setting a unique ID: %d (of addr: %d)", uniqueId, dynamicEntity != NULL);

    if (getUniqueId(dynamicEntity) >= 0)
    {
        logger::log(logger::ERROR, "Trying to set to %d a unique Id that has already been set, to %d (D)",
                                     uniqueId,
                                     getUniqueId(dynamicEntity));
        assert(0);
    }

    ((gameent*)dynamicEntity)->uid = uniqueId;
}
Ejemplo n.º 3
0
void Texture::swap(Texture& right)
{
    std::swap(m_size,          right.m_size);
    std::swap(m_actualSize,    right.m_actualSize);
    std::swap(m_texture,       right.m_texture);
    std::swap(m_isSmooth,      right.m_isSmooth);
    std::swap(m_sRgb,          right.m_sRgb);
    std::swap(m_isRepeated,    right.m_isRepeated);
    std::swap(m_pixelsFlipped, right.m_pixelsFlipped);
    std::swap(m_fboAttachment, right.m_fboAttachment);
    std::swap(m_hasMipmap,     right.m_hasMipmap);

    m_cacheId = getUniqueId();
    right.m_cacheId = getUniqueId();
}
Ejemplo n.º 4
0
std::string Item::getXRayDescription() const
{
	std::stringstream ret;
	ret << "ID: " << getID() << std::endl;
	uint16_t actionId = getActionId();
	uint16_t uniqueId = getUniqueId();

	if (actionId > 0)
	{
		ret << "Action ID: " << actionId << std::endl;
	}

	if (uniqueId > 0)
	{
		ret << "Unique ID: " << uniqueId << std::endl;
	}

#ifdef __DEBUG__

	if (getContainer())
	{
		ret << "There are " << getContainer()->getTotalAmountOfItemsInside() - 1 << " things inside of this." << std::endl;
	}

#endif
	ret << Thing::getXRayDescription();
	return ret.str();
}
Ejemplo n.º 5
0
void
TileSystem::addTile(Tile *tile)
{
    if (getProjectData())
    {
        // Id //
        //
        QString name = tile->getName();
        QString id = getUniqueId(tile->getID(), name);
        if (id != tile->getID())
        {
            tile->setID(id);
            if (name != tile->getName())
            {
                tile->setName(name);
            }
        }
    }

    // Insert //
    //
    tile->setTileSystem(this);

    tiles_.insert(tile->getID(), tile);
    addTileSystemChanges(TileSystem::CTS_TileChange);

    setCurrentTile(tile);
}
Ejemplo n.º 6
0
Texture::Texture(const Texture& copy) :
m_size         (0, 0),
m_actualSize   (0, 0),
m_texture      (0),
m_isSmooth     (copy.m_isSmooth),
m_sRgb         (copy.m_sRgb),
m_isRepeated   (copy.m_isRepeated),
m_pixelsFlipped(false),
m_fboAttachment(false),
m_hasMipmap    (false),
m_cacheId      (getUniqueId())
{
    if (copy.m_texture)
    {
        if (create(copy.getSize().x, copy.getSize().y))
        {
            update(copy);

            // Force an OpenGL flush, so that the texture will appear updated
            // in all contexts immediately (solves problems in multi-threaded apps)
            glCheck(glFlush());
        }
        else
        {
            err() << "Failed to copy texture, failed to create new texture" << std::endl;
        }
    }
}
Ejemplo n.º 7
0
void Texture::update(const Window& window, unsigned int x, unsigned int y)
{
    assert(x + window.getSize().x <= m_size.x);
    assert(y + window.getSize().y <= m_size.y);

    if (m_texture && window.setActive(true))
    {
        TransientContextLock lock;

        // Make sure that the current texture binding will be preserved
        priv::TextureSaver save;

        // Copy pixels from the back-buffer to the texture
        glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
        glCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, window.getSize().x, window.getSize().y));
        glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
        m_hasMipmap = false;
        m_pixelsFlipped = true;
        m_cacheId = getUniqueId();

        // Force an OpenGL flush, so that the texture will appear updated
        // in all contexts immediately (solves problems in multi-threaded apps)
        glCheck(glFlush());
    }
}
Ejemplo n.º 8
0
void Texture::update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y)
{
    assert(x + width <= m_size.x);
    assert(y + height <= m_size.y);

    if (pixels && m_texture)
    {
        TransientContextLock lock;

        // Make sure that the current texture binding will be preserved
        priv::TextureSaver save;

        // Copy pixels from the given array to the texture
        glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
        glCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
        glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
        m_hasMipmap = false;
        m_pixelsFlipped = false;
        m_cacheId = getUniqueId();

        // Force an OpenGL flush, so that the texture data will appear updated
        // in all contexts immediately (solves problems in multi-threaded apps)
        glCheck(glFlush());
    }
}
		dtn::security::SecurityKey KeyExchangeSession::getKey(const dtn::security::SecurityKey::KeyType type) const throw (SecurityKey::KeyNotFoundException)
		{
			unsigned int id = getUniqueId();
			std::string prefix((char*)&id, sizeof id);

			return SecurityKeyManager::getInstance().get(prefix, _peer, type);
		}
 //-----------------------------
 bool RootParser15::begin__technique____technique_type ( const COLLADASaxFWL15::technique____technique_type__AttributeData& attributeData )
 {
     SaxVirtualFunctionTest15(begin__technique____technique_type(attributeData));
     technique__AttributeData attr;
     attr.profile = attributeData.profile;
     return base__begin__technique ( attr, getUniqueId () );
 }
Ejemplo n.º 11
0
Item::Item(const ItemAttributes& attr) : Renderable(ViewObject(*attr.viewId, ViewLayer::ITEM, capitalFirst(*attr.name))),
    attributes(attr), fire(attr.burnTime), canEquipCache(!!attributes->equipmentSlot),
    classCache(*attributes->itemClass) {
  if (!attributes->prefixes.empty())
    modViewObject().setModifier(ViewObject::Modifier::AURA);
  modViewObject().setGenericId(getUniqueId().getGenericId());
}
Ejemplo n.º 12
0
int main(int argc, char** argv)
{
   const char* path = "/etc/epgd/epg.dat";

   if (argc > 1)
      path = argv[1];

   // read deictionary

   dbDict.setFilterFromNameFct(toFieldFilter);

   if (dbDict.in(path, ffEpgd) != success)
   {
      tell(0, "Invalid dictionary configuration, aborting!");
      return 1;
   }

   dbDict.show();

   return 0;

   initConnection();

   // demoStatement();
   // joinDemo();
   // insertDemo();

   tell(0, "uuid: '%s'", getUniqueId());

   exitConnection();

   return 0;
}
Ejemplo n.º 13
0
bool Texture::create(unsigned int width, unsigned int height)
{
    // Check if texture parameters are valid before creating it
    if ((width == 0) || (height == 0))
    {
        err() << "Failed to create texture, invalid size (" << width << "x" << height << ")" << std::endl;
        return false;
    }

    // Compute the internal texture dimensions depending on NPOT textures support
    Vector2u actualSize(getValidSize(width), getValidSize(height));

    // Check the maximum texture size
    unsigned int maxSize = getMaximumSize();
    if ((actualSize.x > maxSize) || (actualSize.y > maxSize))
    {
        err() << "Failed to create texture, its internal size is too high "
              << "(" << actualSize.x << "x" << actualSize.y << ", "
              << "maximum is " << maxSize << "x" << maxSize << ")"
              << std::endl;
        return false;
    }

    // All the validity checks passed, we can store the new texture settings
    m_size.x        = width;
    m_size.y        = height;
    m_actualSize    = actualSize;
    m_pixelsFlipped = false;

   

    // Create the OpenGL texture if it doesn't exist yet
    if (!m_texture)
    {
        GLuint texture;
        glCheck(glGenTextures(1, &texture));
        m_texture = static_cast<unsigned int>(texture);
    }

  

    // Make sure that the current texture binding will be preserved
    priv::TextureSaver save;



    // Initialize the texture
    glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
    glCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_actualSize.x, m_actualSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
	glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_isRepeated ? GL_REPEAT : GL_CLAMP));
	glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT :GL_CLAMP));
    glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
    glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
    m_cacheId = getUniqueId();



    return true;
}
Ejemplo n.º 14
0
void Item::setUniqueId(uint16_t n)
{
	if(getUniqueId() != 0)
		return;

	ItemAttributes::setUniqueId(n);
	ScriptEnviroment::addUniqueThing(this);
}
Ejemplo n.º 15
0
/**
 * Saves the craft's unique identifiers to a YAML file.
 * @return YAML node.
 */
YAML::Node Craft::saveId() const
{
	YAML::Node node = MovingTarget::saveId();
	CraftId uniqueId = getUniqueId();
	node["type"] = uniqueId.first;
	node["id"] = uniqueId.second;
	return node;
}
Ejemplo n.º 16
0
void Item::onRemoved()
{
	ScriptEnvironment::removeTempItem(this);

	if (getUniqueId() != 0) {
		ScriptEnvironment::removeUniqueThing(this);
	}
}
Ejemplo n.º 17
0
Item::~Item()
{
	//std::cout << "Item destructor " << this << std::endl;

	if(getUniqueId() != 0){
		ScriptEnviroment::removeUniqueThing(this);
	}
}
Ejemplo n.º 18
0
void Item::setUniqueId(int32_t uid)
{
	if(getUniqueId())
		return;

	setAttribute("uid", uid);
	ScriptEnviroment::addUniqueThing(this);
}
Ejemplo n.º 19
0
void Item::setUniqueId(uint16_t n)
{
	if (getUniqueId() != 0) {
		return;
	}

	getAttributes()->setUniqueId(n);
	ScriptEnvironment::addUniqueThing(this);
}
Ejemplo n.º 20
0
// Query Server
int Samba_QueryServerList(long *Handle,int *num,char *domain)
{
    int ret=-1;
    if(domain)
    {
        int id;
        char inFile[FILE_SIZE],outFile[FILE_SIZE],executeCmd[CMD_SIZE];
        Rtk_Ini *inIniObj=new Rtk_Ini();
        Rtk_Ini *outIniObj=new Rtk_Ini();
        id=getUniqueId();
        sprintf(inFile,"%s/%d.in",FILE_PATH,id);
        sprintf(outFile,"%s/%d.out",FILE_PATH,id);
        sprintf(executeCmd,"%s %s %s",SMB_EXE,inFile,outFile);
    // prepare infile    
        char *domain_withmark;
        inIniObj->setIntValue(MAIN, COMMAND,3);
        if(!inIniObj->addStrMark_needfree(domain, &domain_withmark))
        {
            inIniObj->setStrValue(MAIN, P1,domain_withmark);
            FREE(domain_withmark);
        }
        else
            inIniObj->setStrValue(MAIN, P1,domain);
        inIniObj->saveFile(inFile);
        delete inIniObj;
    // execute
        system(executeCmd);
    // get ip
        *Handle=0;
        if(!outIniObj->loadFile(outFile))
        {
            int rec_num;
            if(!outIniObj->getIntValue(MAIN,NUMBER,&rec_num))
            {
                if(rec_num<0)
                    delete outIniObj;
                else
                {
                    *num=rec_num;
                    *Handle=(long)outIniObj;
                    outIniObj->removeInsideValueStrMark();
                    ret=0;
                }
            }
            else
                delete outIniObj;
        }
        else
            delete outIniObj;
#ifndef DEBUG
        unlink(inFile);
        unlink(outFile);
#endif    
    }
    return ret;
}
Ejemplo n.º 21
0
Texture::Texture() :
    m_size         (0, 0),
    m_actualSize   (0, 0),
    m_texture      (0),
    m_isSmooth     (false),
    m_isRepeated   (false),
    m_pixelsFlipped(false),
    m_cacheId      (getUniqueId())
{
}
Ejemplo n.º 22
0
void Item::setUniqueId(const uint16_t& n)
{
	if (getUniqueId() != 0)
	{
		return;
	}

	ItemAttributes::setUniqueId(n);
	ScriptEnviroment::addUniqueThing(this);
}
Ejemplo n.º 23
0
  OutputDirectory::OutputDirectory (const boost::filesystem::path& parentDirectory) {
    parentDirectory_ = parentDirectory;
    boost::filesystem::create_directories (parentDirectory);

    cuint64_t id = getUniqueId (parentDirectory / "counter");
    name_ = "output_" + boost::lexical_cast<std::string> (id);

    path_ = parentDirectory / name_;
    ASSERT (!boost::filesystem::exists (path_));
    boost::filesystem::create_directory (path_);
  }
Ejemplo n.º 24
0
bool Item::canDecay()
{
	if(isRemoved())
		return false;

	if(loadedFromMap && (getUniqueId() || (getActionId() && getContainer())))
		return false;

	const ItemType& it = Item::items[id];
	return it.decayTo >= 0 && it.decayTime;
}
Ejemplo n.º 25
0
Texture::Texture(const Texture& copy) :
m_size         (0, 0),
m_actualSize   (0, 0),
m_texture      (0),
m_isSmooth     (copy.m_isSmooth),
m_isRepeated   (copy.m_isRepeated),
m_pixelsFlipped(false),
m_cacheId      (getUniqueId())
{
    if (copy.m_texture)
        loadFromImage(copy.copyToImage());
}
Ejemplo n.º 26
0
void Item::onRemoved()
{
	if(raid)
	{
		raid->unRef();
		raid = NULL;
	}

	ScriptEnviroment::removeTempItem(this);
	if(getUniqueId())
		ScriptEnviroment::removeUniqueThing(this);
}
Ejemplo n.º 27
0
BufferQueueCore::BufferQueueCore() :
    mMutex(),
    mIsAbandoned(false),
    mConsumerControlledByApp(false),
    mConsumerName(getUniqueName()),
    mConsumerListener(),
    mConsumerUsageBits(0),
    mConsumerIsProtected(false),
    mConnectedApi(NO_CONNECTED_API),
    mLinkedToDeath(),
    mConnectedProducerListener(),
    mSlots(),
    mQueue(),
    mFreeSlots(),
    mFreeBuffers(),
    mUnusedSlots(),
    mActiveBuffers(),
    mDequeueCondition(),
    mDequeueBufferCannotBlock(false),
    mDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888),
    mDefaultWidth(1),
    mDefaultHeight(1),
    mDefaultBufferDataSpace(HAL_DATASPACE_UNKNOWN),
    mMaxBufferCount(BufferQueueDefs::NUM_BUFFER_SLOTS),
    mMaxAcquiredBufferCount(1),
    mMaxDequeuedBufferCount(1),
    mBufferHasBeenQueued(false),
    mFrameCounter(0),
    mTransformHint(0),
    mIsAllocating(false),
    mIsAllocatingCondition(),
    mAllowAllocation(true),
    mBufferAge(0),
    mGenerationNumber(0),
    mAsyncMode(false),
    mSharedBufferMode(false),
    mAutoRefresh(false),
    mSharedBufferSlot(INVALID_BUFFER_SLOT),
    mSharedBufferCache(Rect::INVALID_RECT, 0, NATIVE_WINDOW_SCALING_MODE_FREEZE,
            HAL_DATASPACE_UNKNOWN),
    mLastQueuedSlot(INVALID_BUFFER_SLOT),
    mUniqueId(getUniqueId())
{
    int numStartingBuffers = getMaxBufferCountLocked();
    for (int s = 0; s < numStartingBuffers; s++) {
        mFreeSlots.insert(s);
    }
    for (int s = numStartingBuffers; s < BufferQueueDefs::NUM_BUFFER_SLOTS;
            s++) {
        mUnusedSlots.push_front(s);
    }
}
Ejemplo n.º 28
0
void zmfTests::testInstance() {

    auto moduleA = std::make_shared<DummyModule>(zmf::data::ModuleUniqueId(13, 37));
    auto moduleB = std::make_shared<DummyModule>(zmf::data::ModuleUniqueId(44, 20));

    auto coreA = zmf::instance::ZmfInstance::startInstance(moduleA, {});
    auto coreB = zmf::instance::ZmfInstance::startInstance(moduleB, {});

    std::this_thread::sleep_for(std::chrono::milliseconds(1000));

    moduleA->doPublish();
    moduleB->doPublish();

    moduleA->doRequest(moduleA->getUniqueId());
    moduleA->doRequest(moduleB->getUniqueId());

    moduleB->doRequest(moduleB->getUniqueId());
    moduleB->doRequest(moduleA->getUniqueId());

    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

}
Ejemplo n.º 29
0
Texture::Texture() :
m_size         (0, 0),
m_actualSize   (0, 0),
m_texture      (0),
m_isSmooth     (false),
m_sRgb         (false),
m_isRepeated   (false),
m_pixelsFlipped(false),
m_fboAttachment(false),
m_hasMipmap    (false),
m_cacheId      (getUniqueId())
{
}
Ejemplo n.º 30
0
Texture& Texture::operator =(const Texture& right)
{
    Texture temp(right);

    std::swap(m_size,          temp.m_size);
    std::swap(m_actualSize,    temp.m_actualSize);
    std::swap(m_texture,       temp.m_texture);
    std::swap(m_isSmooth,      temp.m_isSmooth);
    std::swap(m_isRepeated,    temp.m_isRepeated);
    std::swap(m_pixelsFlipped, temp.m_pixelsFlipped);
    m_cacheId = getUniqueId();

    return *this;
}