Пример #1
0
// Free the textures associated with a model if nobody else is using them
// Note : This assumes that the model textures aren't being used by
// anything other than models!
void CClientMgr::FreeUnusedModelTextures(LTObject *pObject) {
    ModelInstance *pInstance = pObject->ToModel();

    LTLink *pCur, *pListHead;
    SharedTexture *pTexture;
    uint32 nTextureLoop;

    // Handle the case where there are duplicate entries in the skins..
    for (nTextureLoop = 0; nTextureLoop < MAX_MODEL_TEXTURES; ++nTextureLoop)
    {
        for (uint32 nDupeLoop = nTextureLoop + 1; nDupeLoop < MAX_MODEL_TEXTURES; ++nDupeLoop)
        {
            if ((pInstance->m_pSkins[nTextureLoop] == pInstance->m_pSkins[nDupeLoop]) && (pInstance->m_pSkins[nTextureLoop]))
            {
                pInstance->m_pSkins[nDupeLoop] = LTNULL;
            }
        }
    }

    // Untag the textures used by this model
    for (nTextureLoop = 0; nTextureLoop < MAX_MODEL_TEXTURES; ++nTextureLoop)
    {
        pTexture = pInstance->m_pSkins[nTextureLoop];
        if (!pTexture)
            continue;
        // Make sure sprites don't get unloaded
        if (pInstance->m_pSprites[nTextureLoop])
            pTexture->SetFlags(pTexture->GetFlags() | ST_TAGGED);
        else
            pTexture->SetFlags(pTexture->GetFlags() & ~ST_TAGGED);
    }

    // Mark all client side model object textures as touched
    pListHead = &m_ObjectMgr.m_ObjectLists[OT_MODEL].m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        ModelInstance *pFlagInstance = (ModelInstance*)pCur->m_pData;

        if (pFlagInstance == pInstance)
            continue;

        for (nTextureLoop = 0; nTextureLoop < MAX_MODEL_TEXTURES; ++nTextureLoop)
        {
            TagTexture(pFlagInstance->m_pSkins[nTextureLoop]);
        }
    }

    // Get rid of the model's textures if they haven't been tagged
    for (nTextureLoop = 0; nTextureLoop < MAX_MODEL_TEXTURES; ++nTextureLoop)
    {
        pTexture = pInstance->m_pSkins[nTextureLoop];
        if (!pTexture)
            continue;
        if ((pTexture->GetFlags() & ST_TAGGED) == 0)
        {
            FreeSharedTexture(pTexture);
            pInstance->m_pSkins[nTextureLoop] = LTNULL;
        }
    }
}
Пример #2
0
void CClientMgr::UntagAllTextures() {
    LTLink *pListHead, *pCur;
    SharedTexture *pTexture;

    pListHead = &m_SharedTextures.m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        pTexture = ((SharedTexture*)pCur->m_pData);
        pTexture->SetFlags(pTexture->GetFlags() & ~ST_TAGGED);
    }
}
Пример #3
0
void CClientMgr::FreeUnusedSharedTextures() {
    LTLink *pCur, *pNext, *pListHead;
    SharedTexture *pTexture;

    // Get rid of untagged ones.
    pListHead = &m_SharedTextures.m_Head;
    pCur = pListHead->m_pNext;
    while (pCur != pListHead)
    {
        pNext = pCur->m_pNext;

        pTexture = (SharedTexture*)pCur->m_pData;

        if (!(pTexture->GetFlags() & ST_TAGGED))
        {
            FreeSharedTexture(pTexture);
        }

        pCur = pNext;
    }
}