Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Effect - File.c
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/* == Effects =========================================================================================================================================================== */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Functions and Data                                                                                                                                         */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

static TgVOID                               tgFX_Cache_Unload( C_TgFX_CACHE_ID );




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgFX__Client__PreLoad ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgFX__Client__PreLoad( C_TgFX_EFFECT_ID tiEffect )
{
    TgUINTXX                            uiMaterial;
    TgUINTXX                            uiMesh_Set;

    if (TgTRUE != tgEQ_FX_EFFECT_ID( g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiEffect, tiEffect ))
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Attempt to cache effect failed - id not equal.\n" ), TgT("FX"), TgT("tgFX_Cache_Effect_Id") );
        return (KTgE_FAIL);
    };

    TgERROR( nullptr != g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data );
    uiMaterial = KTgEMPTY_HASH;
    uiMesh_Set = KTgEMPTY_HASH;
    switch (g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_enEffect)
    {
        case ETgFX__SOUND:
            /* #FIX: g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sSound.m_tiSound_Bank = tgSN_Instance_Sound_Bank( g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sSound.m_uiHash_Sound_Bank ); */
            /* #FIX: g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sSound.m_tiSound = tgSN_Instance_Sound( g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sSound.m_uiHash_Sound ); */
            break;

        case ETgFX__BEAM:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sBeam.m_uiHash_Material;
            break;
        case ETgFX__BILLBOARD:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sBillboard.m_uiHash_Material;
            break;
        case ETgFX__DECAL:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sDecal.m_uiHash_Material;
            break;
        case ETgFX__EMITTER:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sEmitter.m_uiHash_Material;
            break;
        case ETgFX__POST:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sPost.m_uiHash_Material;
            break;
        case ETgFX__TRAIL:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sTrail.m_uiHash_Material;
            break;
        case ETgFX__GIB:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sGIB.m_uiHash_Material;
            break;
        case ETgFX__GLASS:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sGlass.m_uiHash_Material;
            break;
        case ETgFX__LIQUID:
            uiMaterial = g_asFX_KN_File__Effect[tiEffect.m.iI].m_psFile_Data->m_sData.m_sLiquid.m_uiHash_Material;
            break;

        case ETgFX__GROUP:
        case ETgFX__LIGHT:
            break;
        case ETgFX__INVALID:
        case ETgFX__EFFECT_MAX:
        default:
            TgS_NO_DEFAULT( break );
    };

    if (KTgEMPTY_HASH != uiMaterial)
    {
        TgRN_MATERIAL_ID                    tiMaterial;

        tiMaterial = tgRN_Hash_Instance_Material( uiMaterial, ETgRN_VERTEX_PARTICLE_00 );
        if (TgTRUE == tgRN_MATERIAL_ID_Is_Valid( tiMaterial ))
        {
            g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sRender.m_tiMaterial = tiMaterial;
            g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sRender.m_enVertex = ETgRN_VERTEX_PARTICLE_00;
        }
        else
        {
            tiMaterial = tgRN_Hash_Instance_Material( uiMaterial, ETgRN_VERTEX_PARTICLE_01 );
            if (TgTRUE == tgRN_MATERIAL_ID_Is_Valid( tiMaterial ))
            {
                g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sRender.m_tiMaterial = tiMaterial;
                g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sRender.m_enVertex = ETgRN_VERTEX_PARTICLE_01;
            }
            else
            {
                g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sRender.m_tiMaterial = KTgRN_MATERIAL_ID__INVALID;
                g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sRender.m_enVertex = ETgRN_VERTEX_MAX;
            };
        };
    };

    if (KTgEMPTY_HASH != uiMesh_Set)
    {
        TgRN_MESH_SET_ID                    tiMesh_Set;

        tiMesh_Set = tgRN_Hash_Instance_Mesh_Set( uiMesh_Set );
        g_asFX_Cache__Effect[tiEffect.m.iI].m_sData.m_sRender.m_tiMesh_Set = tiMesh_Set;
    };

    return (KTgS_OK);
}


/* ---- tgFX__Client__Query_Id ------------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgFX_EFFECT_ID tgFX__Client__Query_Id( C_TgUINTXX uiHash_Effect )
{
    TgSINT32                            iIndex;

    /* #FIX: Synchronization */
    for (iIndex = 0; iIndex < ETgFX_DATA__EFFECT_MAX; ++iIndex)
    {
        if (uiHash_Effect == g_auiFX_KN_File__Effect_Hash[iIndex])
        {
            return (g_asFX_KN_File__Effect[iIndex].m_tiEffect);
        };
    };

    return (KTgFX_EFFECT_ID__INVALID);
}




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private Functions                                                                                                                                                     */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgFX_Effect__Increment_Reference -------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgFX_Effect__Increment_Reference( C_TgFX_EFFECT_ID tiEffect )
{
    if (TgTRUE != tgFX_EFFECT_ID_Is_Valid( tiEffect ))
    {
        return;
    };

    if (TgTRUE != tgEQ_FX_EFFECT_ID( tiEffect, g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiEffect ))
    {
        return;
    };

    ++g_asFX_KN_File__Effect[tiEffect.m.iI].m_nuiReference;
}


/* ---- tgFX_Effect__Decrement_Reference -------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgFX_Effect__Decrement_Reference( C_TgFX_EFFECT_ID tiEffect )
{
    if (TgTRUE != tgFX_EFFECT_ID_Is_Valid( tiEffect ))
    {
        return;
    };

    if (TgTRUE != tgEQ_FX_EFFECT_ID( tiEffect, g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiEffect ))
    {
        return;
    };

    if (0 == g_asFX_KN_File__Effect[tiEffect.m.iI].m_nuiReference)
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Attempting to reduce reference count past zero.\n" ), TgT("FX"), TgT("tgFX_Cache_Effect__Decrement_Reference") );
    }
    else
    {
        --g_asFX_KN_File__Effect[tiEffect.m.iI].m_nuiReference;
    };
}


/* ---- tgFX__File__Bind_Effect ----------------------------------------------------------------------------------------------------------------------------------------- */
/* Used on file section coded "FXFX", can happen asynchronously                                                                                                           */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSINT64 tgFX__File__Bind_Effect( C_TgKN_FILE_ID tiFile, PC_STg2_Input_MEM psIN_MEM )
{
    P_STg2_File_Data                    psFile_Data;
    P_STg2_File_Data__FXFX              psFile_Data__FXFX;
    TgSINT32                            iIndex;
    TgSINT32                            iFirst_Free;

    TgVERIFY(sizeof( STg2_File_Data ) == psIN_MEM->m_pfnBind( (PP_TgVOID)&psFile_Data, sizeof( STg2_File_Data ), psIN_MEM, 0 ));

    TgERROR( psFile_Data->m_uiFourCC == TgMAKE_4CC('F','X','F','X') );
    TgERROR( psFile_Data->m_iOffset >= (TgSINT32)sizeof( STg2_File_Data ) );
    TgERROR( psFile_Data->m_uiVersion == 1 );

    psIN_MEM->m_pfnBind( (PP_TgVOID)&psFile_Data__FXFX, sizeof( STg2_File_Data__FXFX ), psIN_MEM, (TgSIZE)psFile_Data->m_iOffset );

    /* #FIX: Make thread safe */
    iFirst_Free = -1;
    for (iIndex = 0; iIndex < ETgFX_DATA__EFFECT_MAX; ++iIndex)
    {
        if (psFile_Data__FXFX->m_uiHash == g_auiFX_KN_File__Effect_Hash[iIndex])
        {
            /* Hash already exists - assume effect is the same, and warn the developer */
            TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Effect already loaded.\n" ), TgT("FX"), TgT("tgFX_Load_File__Bind_Effect") );
            return (KTgFX_EFFECT_ID__INVALID.m_iKI);
        }
        else if ((iFirst_Free < 0) && (KTgEMPTY_HASH == g_auiFX_KN_File__Effect_Hash[iIndex]))
        {
            iFirst_Free = iIndex;
            break;
        };
    };

    for (; iIndex < ETgFX_DATA__EFFECT_MAX; ++iIndex)
    {
        if (psFile_Data__FXFX->m_uiHash == g_auiFX_KN_File__Effect_Hash[iIndex])
        {
            /* Hash already exists - assume effect is the same, and warn the developer */
            TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Effect already loaded.\n" ), TgT("FX"), TgT("tgFX_Load_File__Bind_Effect") );
            return (KTgFX_EFFECT_ID__INVALID.m_iKI);
        }
    };

    if (iFirst_Free < 0)
    {
        /* No room in the inn */
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): No room for additional files.\n" ), TgT("FX"), TgT("tgFX_Load_File__Bind_Effect") );
        return (KTgFX_EFFECT_ID__INVALID.m_iKI);
    };

    g_auiFX_KN_File__Effect_Hash[iFirst_Free] = psFile_Data__FXFX->m_uiHash;
    tgInit_FX_EFFECT_ID( &g_asFX_KN_File__Effect[iFirst_Free].m_tiEffect, iFirst_Free );
    g_asFX_KN_File__Effect[iFirst_Free].m_tiFile = tiFile;
    g_asFX_KN_File__Effect[iFirst_Free].m_tiCache = KTgFX_CACHE_ID__INVALID;
    g_asFX_KN_File__Effect[iFirst_Free].m_psFile_Data = psFile_Data__FXFX;
    g_asFX_KN_File__Effect[iFirst_Free].m_nuiReference = 0;

    switch (psFile_Data__FXFX->m_enEffect)
    {
        case ETgFX__GROUP: tgFX__File__Group_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sGroup ); break;
        case ETgFX__LIGHT: tgFX__File__Light_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sLight ); break;
        case ETgFX__SOUND: tgFX__File__Sound_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sSound ); break;
        case ETgFX__BEAM: tgFX__File__Beam_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sBeam ); break;
        case ETgFX__BILLBOARD: tgFX__File__Billboard_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sBillboard ); break;
        case ETgFX__DECAL: tgFX__File__Decal_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sDecal ); break;
        case ETgFX__EMITTER: tgFX__File__Emitter_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sEmitter ); break;
        case ETgFX__POST: tgFX__File__Post_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sPost ); break;
        case ETgFX__TRAIL: tgFX__File__Trail_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sTrail ); break;
        case ETgFX__GIB: tgFX__File__GIB_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sGIB ); break;
        case ETgFX__GLASS: tgFX__File__Glass_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sGlass ); break;
        case ETgFX__LIQUID: tgFX__File__Liquid_Patch_File_Data( &psFile_Data__FXFX->m_sData.m_sLiquid ); break;

        case ETgFX__INVALID:
        case ETgFX__EFFECT_MAX:
        default:
            TgS_NO_DEFAULT( break );
    };

    return (g_asFX_KN_File__Effect[iFirst_Free].m_tiFile.m_iKI);
}


/* ---- tgFX__File__UnBind_Effect --------------------------------------------------------------------------------------------------------------------------------------- */
/* Used on file section coded "FXFX"                                                                                                                                      */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgFX__File__UnBind_Effect( C_TgSINT64 UNUSED_PARAM iKI, C_TgKN_FILE_ID UNUSED_PARAM tiFile )
{
    /* #FIX: Create unbind command to client */
}


/* ---- tgFX__Client__UnBind_Effect ------------------------------------------------------------------------------------------------------------------------------------- */
/* Used on file section coded "FXFX"                                                                                                                                      */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSINT64 tgFX__Client__UnBind_Effect( C_TgSINT64 iKI, C_TgKN_FILE_ID tiFile )
{
    TgFX_EFFECT_ID                      tiEffect;

    tiEffect.m_iKI = iKI;
    TgPARAM_CHECK_INDEX( tiEffect.m.iI, g_asFX_KN_File__Effect );

    if (TgTRUE != tgEQ_FX_EFFECT_ID( tiEffect, g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiEffect ))
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Attempt to unbind failed - cache effect id not equal.\n" ), TgT("FX"), TgT("tgFX_Load_File__UnBind_Effect") );
        return (KTgE_FAIL);
    };

    if (TgTRUE != tgEQ_KN_FILE_ID( tiFile, g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiFile ))
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Attempt to unbind failed - kernel file id not equal.\n" ), TgT("FX"), TgT("tgFX_Load_File__UnBind_Effect") );
        return (KTgE_FAIL);
    };

    if (0 != g_asFX_KN_File__Effect[tiEffect.m.iI].m_nuiReference)
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Unbinding effect with active instances.\n" ), TgT("FX"), TgT("tgFX_Load_File__UnBind_Effect") );
    };

    g_auiFX_KN_File__Effect_Hash[tiEffect.m.iI] = KTgEMPTY_HASH;

    if (tgFX_CACHE_ID_Is_Valid( g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiCache ))
    {
        tgFX_Cache_Unload( g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiCache );
    };

    g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiFile = KTgKN_FILE_ID__INVALID;
    g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiCache = KTgFX_CACHE_ID__INVALID;
    g_asFX_KN_File__Effect[tiEffect.m.iI].m_tiEffect = KTgFX_EFFECT_ID__INVALID;
    return (KTgS_OK);
}




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Functions                                                                                                                                                  */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgFX_Cache_Unload ----------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgVOID tgFX_Cache_Unload( C_TgFX_CACHE_ID tiCache )
{
    TgSINT32                            iEffect;

    if (TgTRUE != tgEQ_FX_CACHE_ID( tiCache, g_asFX_Cache__Effect[tiCache.m.iI].m_tiCache ))
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Attempt to unload cache failed - id not equal.\n" ), TgT("FX"), TgT("tgFX_Cache_Unload") );
        return;
    };

    iEffect = g_asFX_Cache__Effect[tiCache.m.iI].m_tiEffect.m.iI;
    if (TgTRUE != tgEQ_FX_EFFECT_ID( g_asFX_KN_File__Effect[iEffect].m_tiEffect, g_asFX_Cache__Effect[tiCache.m.iI].m_tiEffect ))
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Attempt to unload cache failed - id not equal.\n" ), TgT("FX"), TgT("tgFX_Cache_Unload") );
        return;
    };

    TgERROR( nullptr != g_asFX_KN_File__Effect[iEffect].m_psFile_Data );
    switch (g_asFX_KN_File__Effect[iEffect].m_psFile_Data->m_enEffect)
    {
        case ETgFX__SOUND:
            if (tgSN_ID_Is_Valid( g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sSound.m_tiSound ))
            {
                tgSN_Sound__Release( g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sSound.m_tiSound );
                g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sSound.m_tiSound = KTgSN_ID__INVALID;
            };
            if (tgSN_BANK_ID_Is_Valid( g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sSound.m_tiSound_Bank ))
            {
                tgSN_Sound_Bank__Release( g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sSound.m_tiSound_Bank );
                g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sSound.m_tiSound_Bank = KTgSN_BANK_ID__INVALID;
            };
            break;

        case ETgFX__BEAM:
        case ETgFX__BILLBOARD:
        case ETgFX__DECAL:
        case ETgFX__EMITTER:
        case ETgFX__POST:
        case ETgFX__TRAIL:
        case ETgFX__GIB:
        case ETgFX__GLASS:
        case ETgFX__LIQUID:
            if (tgRN_MESH_SET_ID_Is_Valid( g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sRender.m_tiMesh_Set ))
            {
                tgRN_Release_Mesh_Set( g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sRender.m_tiMesh_Set );
                g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sRender.m_tiMesh_Set = KTgRN_MESH_SET_ID__INVALID;
            };
            if (tgRN_MATERIAL_ID_Is_Valid( g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sRender.m_tiMaterial ))
            {
                tgRN_Release_Material( g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sRender.m_tiMaterial );
                g_asFX_Cache__Effect[tiCache.m.iI].m_sData.m_sRender.m_tiMaterial = KTgRN_MATERIAL_ID__INVALID;
            };
            break;

        case ETgFX__GROUP:
        case ETgFX__LIGHT:
            break;

        case ETgFX__INVALID:
        case ETgFX__EFFECT_MAX:
        default:
            TgS_NO_DEFAULT( break );
    };

    g_asFX_Cache__Effect[tiCache.m.iI].m_tiEffect = KTgFX_EFFECT_ID__INVALID;
    g_asFX_Cache__Effect[tiCache.m.iI].m_tiCache = KTgFX_CACHE_ID__INVALID;
}