Exemplo n.º 1
0
///////////////////////////////////////////////////////////////////////////
//
// CSimPlayerManager::RemoveSimPlayer
//
// Thread:              main
// CS should be locked: no
//
// Delete matching sim player object
//
///////////////////////////////////////////////////////////////////////////
void CSimPlayerManager::RemoveSimPlayer ( CPlayer* pPlayer )
{
    LockSimSystem ();     // Prevent any sim activity on the sync thread

    // Check
    assert ( pPlayer->m_pSimPlayer->m_pRealPlayer == pPlayer );
    CSimPlayer* pSim = pPlayer->m_pSimPlayer;

    // Uninterlnk
    pSim->m_pRealPlayer = NULL;
    pPlayer->m_pSimPlayer = NULL;

    // Move from lists
    MapRemove ( m_AllSimPlayerMap, pSim );
    MapRemove ( m_SocketSimMap, pSim->m_PlayerSocket );

    // Remove outgoing sim from all dist lists
    for ( std::set < CSimPlayer* > ::const_iterator iter = m_AllSimPlayerMap.begin () ; iter != m_AllSimPlayerMap.end (); ++iter )
    {
        CSimPlayer* pOtherSim = *iter;
        ListRemove ( pOtherSim->m_PuresyncSendListFlat, pSim );
        pOtherSim->m_bSendListChanged = true;
    }

    SAFE_DELETE( pSim );
    UnlockSimSystem ();
}
Exemplo n.º 2
0
void CPerPlayerEntity::OnPlayerDelete(CPlayer* pPlayer)
{
    /* Caz - Debug code disabled because it is being fixed by removing them from the map and the error is misleading users*/
    // SString strStatus;
    if (MapContains(m_Players, pPlayer))
    {
        // strStatus += "m_Players ";
        MapRemove(m_Players, pPlayer);
    }

    if (MapContains(m_PlayersAdded, pPlayer))
    {
        // strStatus += "m_PlayersAdded ";
        MapRemove(m_PlayersAdded, pPlayer);
    }

    if (MapContains(m_PlayersRemoved, pPlayer))
    {
        // strStatus += "m_PlayersRemoved ";
        MapRemove(m_PlayersRemoved, pPlayer);
    }

    /*if ( !strStatus.empty() )
    {
        CLogger::ErrorPrintf( "CPerPlayerEntity problem: %s\n", *strStatus );
    }*/
}
Exemplo n.º 3
0
void CEntitySA::SetCollidableWith( CEntity *entity, bool enabled )
{
    CEntitySA *intEnt = dynamic_cast <CEntitySA*> ( entity );

    if ( intEnt == this )
        return;

    // quit if no change
    if ( MapContains( m_disabledColl, intEnt->GetInterface() ) != enabled )
        return;

    if ( enabled )
    {
        MapRemove( m_disabledColl, intEnt->GetInterface() );

        if ( m_disabledColl.empty() )
            MapRemove( pGame->m_disabledColl, this );
    }
    else
    {
        MapSet( m_disabledColl, intEnt->GetInterface(), true );
        MapSet( pGame->m_disabledColl, this, true );
    }

    // Set in the other entity as well
    intEnt->SetCollidableWith( this, enabled );
}
Exemplo n.º 4
0
///////////////////////////////////////////////////////////////
//
// CModelCacheManagerImpl::OnRestreamModel
//
// Uncache here, now.
//
///////////////////////////////////////////////////////////////
void CModelCacheManagerImpl::OnRestreamModel ( ushort usModelId )
{
    std::map < ushort, SModelCacheInfo >* mapList[] = { &m_PedModelCacheInfoMap, &m_VehicleModelCacheInfoMap };

    for ( uint i = 0 ; i < NUMELMS( mapList ) ; i++ )
    {
        std::map < ushort, SModelCacheInfo >& cacheInfoMap = *mapList[i];

        SModelCacheInfo* pInfo = MapFind ( cacheInfoMap, usModelId );
        if ( pInfo )
        {
            if ( pInfo->bIsModelCachedHere )
            {
                SubModelRefCount ( usModelId );
                pInfo->bIsModelCachedHere = false;
                MapRemove ( cacheInfoMap, usModelId );
                OutputDebugLine ( SString ( "[Cache] End caching model %d  (OnRestreamModel)", usModelId ) );
            }
        }
    }

    // Also check the permo list
    if ( MapContains ( m_PermoLoadedModels, usModelId ) )
    {
        SubModelRefCount ( usModelId );
        MapRemove ( m_PermoLoadedModels, usModelId );
        OutputDebugLine ( SString ( "[Cache] End permo-caching model %d  (OnRestreamModel)", usModelId ) );
    }
}
Exemplo n.º 5
0
///////////////////////////////////////////////////////////////
//
// CSpatialDatabaseImpl::RemoveEntity
//
// Remove an entity from the database
//
///////////////////////////////////////////////////////////////
void CSpatialDatabaseImpl::RemoveEntity ( CElement* pEntity )
{
    // Remove from the tree and info map
    SEntityInfo* pInfo = MapFind ( m_InfoMap, pEntity );
    if ( pInfo )
    {
        m_Tree.Remove ( &pInfo->box.vecMin.fX, &pInfo->box.vecMax.fX, pEntity );
        MapRemove ( m_InfoMap, pEntity );
    }
    // Remove from the update queue
    MapRemove ( m_UpdateQueue, pEntity );
}
Exemplo n.º 6
0
////////////////////////////////////////////////////////////////
//
// CRenderWareSA::OnDestroyTexInfo
//
//
//
////////////////////////////////////////////////////////////////
void CRenderWareSA::OnDestroyTexInfo ( STexInfo* pTexInfo )
{
    // Remove from lookup maps
    SString strUniqueKey ( "%d_%s", pTexInfo->usTxdId, *pTexInfo->strTextureName );
    if ( !MapContains ( m_UniqueTexInfoMap, strUniqueKey ) )
        AddReportLog ( 5133, SString ( "OnDestroyTexInfo missing %s", *strUniqueKey ) );
    MapRemove ( m_UniqueTexInfoMap, strUniqueKey );

	// This assert fails when using engine txd replace functions - TODO find out why
    //assert ( MapContains ( m_D3DDataTexInfoMap, pTexInfo->pD3DData ) );
    MapRemove ( m_D3DDataTexInfoMap, pTexInfo->pD3DData );
}
///////////////////////////////////////////////////////////////
//
// CCameraSpatialDatabaseImpl::RemoveItem
//
// Remove an item from the database
//
///////////////////////////////////////////////////////////////
void CCameraSpatialDatabaseImpl::RemoveItem ( CPlayerCamera* pCamera )
{
    // Remove from the tree and info map
    SItemInfo* pInfo = MapFind ( m_InfoMap, pCamera );
    if ( pInfo )
    {
        m_Tree.Remove ( &pInfo->box.vecMin.fX, &pInfo->box.vecMax.fX, pCamera );
        MapRemove ( m_InfoMap, pCamera );
    }
    // Remove from the update queue
    MapRemove ( m_UpdateQueue, pCamera );
}
///////////////////////////////////////////////////////////////
//
// CGameEntityXRefManagerImpl::RemoveEntityXRef
//
// Remove an existing reference between a game entity and a client entity
//
///////////////////////////////////////////////////////////////
void CGameEntityXRefManagerImpl::RemoveEntityXRef ( CClientEntity* pEntity, CEntity* pEntitySA )
{
    CEntitySAInterface* pEntitySAInterface = pEntitySA->GetInterface ();

    assert ( MapFindRef ( m_ClientToGameMap, pEntity ) == pEntitySA );
    assert ( MapFindRef ( m_GameToClientMap, pEntitySA ) == pEntity );
    assert ( MapFindRef ( m_InterfaceToClientMap, pEntitySAInterface ) == pEntity );

    MapRemove ( m_ClientToGameMap, pEntity );
    MapRemove ( m_GameToClientMap, pEntitySA );
    MapRemove ( m_InterfaceToClientMap, pEntitySAInterface );
}
Exemplo n.º 9
0
int main() {
	Stack st;
	int val;
	st.top = NULL;

	/* Stack test */

	StackPush(&st, 1);
	StackPush(&st, 2);
	StackPush(&st, 3);
	StackPush(&st, 4);
	StackPush(&st, 5);
	StackPush(&st, 6);
	StackPush(&st, 7);

	while ((val = StackPop(&st)) != -1)
		printf("%d\n", val);

	/* Hashmap test */

	Map map;
	MapInit(&map);
	MapInsert(&map, "1>", 1);
	MapInsert(&map, "2>", 2);
	MapInsert(&map, "3>", 3);
	MapInsert(&map, "4>", 4);
	MapInsert(&map, "5>", 5);
	MapInsert(&map, "6>", 6);
	MapInsert(&map, "7>", 7);
	MapInsert(&map, "8>", 8);
	MapInsert(&map, "9>", 9);

	printf("%d\n", MapGet(&map, "1>"));
	printf("%d\n", MapGet(&map, "2>"));
	printf("%d\n", MapGet(&map, "3>"));
	printf("%d\n", MapGet(&map, "4>"));
	printf("%d\n", MapGet(&map, "5>"));
	printf("%d\n", MapGet(&map, "6>"));
	printf("%d\n", MapGet(&map, "7>"));
	printf("%d\n", MapGet(&map, "8>"));
	printf("%d\n", MapGet(&map, "9>"));

	MapRemove(&map, "1>");
	printf("%d\n", MapGet(&map, "1>"));

	MapInsert(&map, "2>", 22);
	printf("%d\n", MapGet(&map, "2>"));
	MapRemove(&map, "2>");
	printf("%d\n", MapGet(&map, "2>"));

	return 0;
}
Exemplo n.º 10
0
//
// Set hiddeness of a debug tag
//
void SharedUtil::SetDebugTagHidden ( const SString& strTag, bool bHidden  )
{
    if ( bHidden )
        MapInsert ( ms_debugTagInvisibleMap, strTag.ToLower () );
    else
        MapRemove ( ms_debugTagInvisibleMap, strTag.ToLower () );
}
Exemplo n.º 11
0
void CPlayer::MovePlayerToFarList ( CPlayer* pOther )
{
    dassert ( MapContains ( m_NearPlayerList, pOther ) && !MapContains ( m_FarPlayerList, pOther ) );
    SNearInfo* pInfo = MapFind ( m_NearPlayerList, pOther );
    MapSet ( m_FarPlayerList, pOther, *pInfo );
    MapRemove ( m_NearPlayerList, pOther );
}
Exemplo n.º 12
0
void CPerPlayerEntity::RemoveIdenticalEntries(std::set<CPlayer*>& List1, std::set<CPlayer*>& List2)
{
    std::vector<CPlayer*> dupList;

    // Make list of dups
    for (std::set<CPlayer*>::iterator it = List1.begin(); it != List1.end(); it++)
        if (MapContains(List2, *it))
            dupList.push_back(*it);

    // Remove dups from both lists
    for (std::vector<CPlayer*>::iterator it = dupList.begin(); it != dupList.end(); it++)
    {
        MapRemove(List1, *it);
        MapRemove(List2, *it);
    }
}
Exemplo n.º 13
0
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::NotifyShaderItemUsesDepthBuffer
//
//
//
////////////////////////////////////////////////////////////////
void CRenderItemManager::NotifyShaderItemUsesDepthBuffer ( CShaderItem* pShaderItem, bool bUsesDepthBuffer )
{
    if ( bUsesDepthBuffer )
        MapInsert ( m_ShadersUsingDepthBuffer, pShaderItem );
    else
        MapRemove ( m_ShadersUsingDepthBuffer, pShaderItem );
}
Exemplo n.º 14
0
///////////////////////////////////////////////////////////////
//
// CDatabaseManagerImpl::Disconnect
//
//
//
///////////////////////////////////////////////////////////////
bool CDatabaseManagerImpl::Disconnect ( uint hConnection )
{
    ClearLastErrorMessage ();

    // Check connection
    if ( !MapContains ( m_ConnectionTypeMap, hConnection ) )
    {
        SetLastErrorMessage ( "Invalid connection" );
        return false;
    }

    // Start disconnect
    CDbJobData* pJobData = m_JobQueue->AddCommand ( EJobCommand::DISCONNECT, hConnection, "" );

    // Complete disconnect
    m_JobQueue->PollCommand ( pJobData, -1 );

    // Check for problems
    if ( pJobData->result.status == EJobResult::FAIL )
    {
        SetLastErrorMessage ( pJobData->result.strReason );
        return false;
    }

    // Remove connection refs
    MapRemove ( m_ConnectionTypeMap, hConnection );
    m_JobQueue->IgnoreConnectionResults ( hConnection );
    return true;
}
Exemplo n.º 15
0
///////////////////////////////////////////////////////////////
//
// CCompressorJobQueueImpl::RemoveUnwantedResults
//
// Check result queue items for match with ignore list items.
// * Must be called from inside a locked section *
//
///////////////////////////////////////////////////////////////
void CCompressorJobQueueImpl::RemoveUnwantedResults ( void )
{
    if ( m_IgnoreResultList.empty () )
        return;

again:
    for ( std::list < CCompressJobData* >::iterator iter = shared.m_ResultQueue.begin () ; iter != shared.m_ResultQueue.end () ; )
    {
        CCompressJobData* pJobData = *iter;
        if ( MapContains ( m_IgnoreResultList, pJobData ) )
        {
            // Found result to ignore, remove from result and ignore lists, add to finished list
            iter = shared.m_ResultQueue.erase ( iter );
            MapRemove ( m_IgnoreResultList, pJobData );
            pJobData->stage = EJobStage::FINISHED;
            MapInsert ( m_FinishedList, pJobData );

            // Do callback incase any cleanup is needed
            if ( pJobData->HasCallback () )
            {
                shared.m_Mutex.Unlock ();
                pJobData->ProcessCallback ();
                shared.m_Mutex.Lock ();
                goto again;
            }
        }
        else
            ++iter;
    }
}
Exemplo n.º 16
0
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::NotifyShaderItemUsesMultipleRenderTargets
//
//
//
////////////////////////////////////////////////////////////////
void CRenderItemManager::NotifyShaderItemUsesMultipleRenderTargets ( CShaderItem* pShaderItem, bool bUsesMultipleRenderTargets )
{
    if ( bUsesMultipleRenderTargets )
        MapInsert ( m_ShadersUsingMultipleRenderTargets, pShaderItem );
    else
        MapRemove ( m_ShadersUsingMultipleRenderTargets, pShaderItem );
}
Exemplo n.º 17
0
void CPlayer::RemovePlayerFromDistLists ( CPlayer* pOther )
{
    dassert ( MapContains ( m_NearPlayerList, pOther ) || MapContains ( m_FarPlayerList, pOther ) );

#ifdef MTA_DEBUG
    SViewerInfo info;
    SViewerInfo* pInfo = MapFind ( m_NearPlayerList, pOther );
    if ( pInfo )
        info = *pInfo;
    dassert ( MapContains ( m_PureSyncSimSendList, pOther ) == info.bInPureSyncSimSendList );
#endif
    MapRemove ( m_PureSyncSimSendList, pOther );
    m_bPureSyncSimSendListDirty = true;

    MapRemove ( m_NearPlayerList, pOther );
    MapRemove ( m_FarPlayerList, pOther );
}
Exemplo n.º 18
0
void CPlayer::MovePlayerToNearList ( CPlayer* pOther )
{
    OutputDebugLine ( SString ( "[Sync] ++ %s: Move %s to nearlist", GetNick (), pOther->GetNick () ) );

    dassert ( !MapContains ( m_NearPlayerList, pOther ) && MapContains ( m_FarPlayerList, pOther ) );
    SViewerInfo* pInfo = MapFind ( m_FarPlayerList, pOther );
    MapSet ( m_NearPlayerList, pOther, *pInfo );
    MapRemove ( m_FarPlayerList, pOther );
}
Exemplo n.º 19
0
///////////////////////////////////////////////////////////////
//
// CDatabaseJobQueueImpl::RemoveHandleForConnection
//
//
//
///////////////////////////////////////////////////////////////
void CDatabaseJobQueueImpl::RemoveHandleForConnection ( SConnectionHandle connectionHandle, CDatabaseConnection* pConnection )
{
    shared.m_Mutex.Lock();
    if ( !MapContains ( shared.m_HandleConnectionMap, connectionHandle ) )
        CLogger::ErrorPrintf ( "RemoveHandleForConnection: Serious problem here\n" );

    MapRemove ( shared.m_HandleConnectionMap, connectionHandle );
    shared.m_Mutex.Unlock();
}
Exemplo n.º 20
0
void CClientDFF::InternalRestoreModel(unsigned short usModel)
{
    // Is this a vehicle ID?
    if (CClientVehicleManager::IsValidModel(usModel))
    {
        // Stream the vehicles of that model out so we have no
        // loaded when we do the restore. The streamer will
        // eventually stream them back in with async loading.
        m_pManager->GetVehicleManager()->RestreamVehicles(usModel);
    }

    // Is this an object ID?
    else if (CClientObjectManager::IsValidModel(usModel))
    {
        if (CClientPedManager::IsValidWeaponModel(usModel))
        {
            // Stream the weapon of that model out so we have no
            // loaded when we do the restore. The streamer will
            // eventually stream them back in with async loading.
            m_pManager->GetPedManager()->RestreamWeapon(usModel);
            m_pManager->GetPickupManager()->RestreamPickups(usModel);
        }
        // Stream the objects of that model out so we have no
        // loaded when we do the restore. The streamer will
        // eventually stream them back in with async loading.
        m_pManager->GetObjectManager()->RestreamObjects(usModel);
        g_pGame->GetModelInfo(usModel)->RestreamIPL();
    }
    // Is this an ped ID?
    else if (CClientPlayerManager::IsValidModel(usModel))
    {
        // Stream the ped of that model out so we have no
        // loaded when we do the restore. The streamer will
        // eventually stream them back in with async loading.
        m_pManager->GetPedManager()->RestreamPeds(usModel);
    }
    else
        return;

    // Restore all the models we replaced.
    CModelInfo* pModelInfo = g_pGame->GetModelInfo(usModel);
    pModelInfo->RestoreOriginalModel();
    pModelInfo->ResetAlphaTransparency();

    // 'Restream' upgrades after model replacement to propagate visual changes with immediate effect
    if (CClientObjectManager::IsValidModel(usModel) && CVehicleUpgrades::IsUpgrade(usModel))
        m_pManager->GetVehicleManager()->RestreamVehicleUpgrades(usModel);

    // Force dff reload if this model id is used again
    SLoadedClumpInfo* pInfo = MapFind(m_LoadedClumpInfoMap, usModel);
    if (pInfo)
    {
        if (pInfo->pClump)
            g_pGame->GetRenderWare()->DestroyDFF(pInfo->pClump);
        MapRemove(m_LoadedClumpInfoMap, usModel);
    }
}
Exemplo n.º 21
0
////////////////////////////////////////////////////////////////
//
// CRenderWareSA::BreakAssociation
//
// Stop the texture using the shader
//
////////////////////////////////////////////////////////////////
void CRenderWareSA::BreakAssociation ( SShadInfo* pShadInfo, STexInfo* pTexInfo )
{
    assert ( pTexInfo->pAssociatedShadInfo == pShadInfo );
    assert ( MapContains ( pShadInfo->associatedTexInfoMap, pTexInfo ) );
    pTexInfo->pAssociatedShadInfo = NULL;
    MapRemove ( pShadInfo->associatedTexInfoMap, pTexInfo );
    if ( m_pfnWatchCallback )
        m_pfnWatchCallback ( pShadInfo->pShaderData, NULL, pTexInfo->pD3DData );
}
///////////////////////////////////////////////////////////////
//
// CAdditionalVertexStreamManager::OnVertexBufferDestroy
//
// Remove matching additional vertex buffer
//
///////////////////////////////////////////////////////////////
void CAdditionalVertexStreamManager::OnVertexBufferDestroy ( IDirect3DVertexBuffer9* pStreamData1  )
{
    SAdditionalStreamInfo* pAdditionalInfo = GetAdditionalStreamInfo ( pStreamData1 );
    if ( pAdditionalInfo )
    {
        pAdditionalInfo->pStreamData->Release ();
        pAdditionalInfo->pVertexDeclaration->Release ();
        MapRemove ( m_AdditionalStreamInfoMap, pStreamData1 );
    }
}
////////////////////////////////////////////////////////////////
//
// CEffectTemplateImpl::UnCloneD3DEffect
//
// Remove from list and release
//
////////////////////////////////////////////////////////////////
void CEffectTemplateImpl::UnCloneD3DEffect ( ID3DXEffect* pOldD3DEffect )
{
    assert ( MapContains ( m_CloneList, pOldD3DEffect ) );
    MapRemove ( m_CloneList, pOldD3DEffect );

    if ( m_CloneList.empty () )
        m_TickCountLastUsed = CTickCount::Now ( true );

    SAFE_RELEASE( pOldD3DEffect );
}
Exemplo n.º 24
0
// Assumes CSimControl::UpdatePuresyncSimPlayer is called soon after this function
void CPlayer::MovePlayerToFarList ( CPlayer* pOther )
{
    OutputDebugLine ( SString ( "[Sync] -- %s: Move %s to farlist", GetNick (), pOther->GetNick () ) );

    dassert ( MapContains ( m_NearPlayerList, pOther ) && !MapContains ( m_FarPlayerList, pOther ) );
    SViewerInfo* pInfo = MapFind ( m_NearPlayerList, pOther );

#ifdef MTA_DEBUG
    dassert ( MapContains ( m_PureSyncSimSendList, pOther ) == pInfo->bInPureSyncSimSendList );
#endif
    if ( pInfo->bInPureSyncSimSendList )
    {
        MapRemove ( m_PureSyncSimSendList, pOther );
        m_bPureSyncSimSendListDirty = true;
        pInfo->bInPureSyncSimSendList = false;
    }

    MapSet ( m_FarPlayerList, pOther, *pInfo );
    MapRemove ( m_NearPlayerList, pOther );
}
Exemplo n.º 25
0
// Decrement use count for an existing lua ref
void luaM_dec_use ( lua_State *luaVM, int iFunction, const void* pFuncPtr )
{
    if ( !luaVM )
        return;
    CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
    if ( !pLuaMain )
        return;

    CRefInfo* pInfo = MapFind ( pLuaMain->m_CallbackTable, pFuncPtr );
    assert ( pInfo );
    assert ( pInfo->iFunction == iFunction );

    if ( --pInfo->ulUseCount == 0 )
    {
        // Remove on last unuse
        lua_unref ( luaVM, iFunction );
        MapRemove ( pLuaMain->m_CallbackTable, pFuncPtr );
        MapRemove ( pLuaMain->m_FunctionTagMap, iFunction );
    }
}
Exemplo n.º 26
0
////////////////////////////////////////////////////////////////
//
// CEffectClonerImpl::ReleaseD3DEffect
//
// Remove all refs to the d3d effect
//
////////////////////////////////////////////////////////////////
void CEffectClonerImpl::ReleaseD3DEffect ( ID3DXEffect* pD3DEffect )
{
    // Find pEffectTemplate from which this d3d effect was cloned from
    CEffectTemplate* pEffectTemplate = MapFindRef ( m_CloneMap, pD3DEffect );
    assert ( pEffectTemplate );

    // Remove from clone map
    MapRemove ( m_CloneMap, pD3DEffect );

    // Remove from pEffectTemplate. This will alse release the d3d effect.
    pEffectTemplate->UnCloneD3DEffect ( pD3DEffect );
}
Exemplo n.º 27
0
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::NotifyDestructRenderItem
//
// Remove from managers list
//
////////////////////////////////////////////////////////////////
void CRenderItemManager::NotifyDestructRenderItem(CRenderItem* pItem)
{
    assert(MapContains(m_CreatedItemList, pItem));
    MapRemove(m_CreatedItemList, pItem);

    if (CScreenSourceItem* pScreenSourceItem = DynamicCast<CScreenSourceItem>(pItem))
        m_bBackBufferCopyMaybeNeedsResize = true;
    else if (CShaderItem* pShaderItem = DynamicCast<CShaderItem>(pItem))
        RemoveShaderItemFromWatchLists(pShaderItem);

    UpdateMemoryUsage();
}
Exemplo n.º 28
0
////////////////////////////////////////////////////////////////
//
// CEffectClonerImpl::CreateD3DEffect
//
//
//
////////////////////////////////////////////////////////////////
ID3DXEffect* CEffectClonerImpl::CreateD3DEffect ( const SString& strFilename, const SString& strRootPath, SString& strOutStatus, bool bDebug )
{
    // Do we have a match with the initial path
    CEffectTemplate* pEffectTemplate = MapFindRef ( m_ValidMap, ConformPathForSorting ( strFilename ) );
    if ( pEffectTemplate )
    {
        // Have files changed since create?
        if ( pEffectTemplate->HaveFilesChanged () )
        {
            // EffectTemplate is no good for cloning now, so move it to the old list 
            MapRemove ( m_ValidMap, ConformPathForSorting ( strFilename ) );
            m_OldList.push_back ( pEffectTemplate );
            pEffectTemplate = NULL;
        }
    }

    // Need to create new EffectTemplate?
    if ( !pEffectTemplate )
    {
        pEffectTemplate = NewEffectTemplate ( m_pManager, strFilename, strRootPath, strOutStatus, bDebug );
        if ( !pEffectTemplate->IsValid () )
        {
            SAFE_RELEASE( pEffectTemplate );
            return NULL;
        }

        OutputDebugLine ( SString ( "[Shader] CEffectClonerImpl::CreateD3DEffect - New EffectTemplate for %s", *strFilename ) );
        // Add to active map
        MapSet ( m_ValidMap, ConformPathForSorting ( strFilename ), pEffectTemplate );
    }


    //
    // Now we have a valid EffectTemplate to clone the effect from
    //

    // Clone D3DXEffect
    ID3DXEffect* pNewD3DEffect = pEffectTemplate->CloneD3DEffect ( &strOutStatus );

    if( !pNewD3DEffect )
    {
        if ( strOutStatus.empty () )
            strOutStatus = "Error: Clone failed";
        return NULL;
    }

    // Cross ref clone with original
    MapSet ( m_CloneMap, pNewD3DEffect, pEffectTemplate );

    // Return result
    return pNewD3DEffect;
}
Exemplo n.º 29
0
CPerPlayerEntity::~CPerPlayerEntity()
{
    // Unsync us from everyone
    // Sync ( false );

    // Unreference us from what we're referencing
    list<CElement*>::const_iterator iter = m_ElementReferences.begin();
    for (; iter != m_ElementReferences.end(); iter++)
    {
        (*iter)->m_ElementReferenced.remove(this);
    }
    MapRemove(ms_AllPerPlayerEntityMap, this);
}
Exemplo n.º 30
0
////////////////////////////////////////////////////////////////
//
// CRenderWareSA::OnDestroyShadInfo
//
//
//
////////////////////////////////////////////////////////////////
void CRenderWareSA::OnDestroyShadInfo ( SShadInfo* pShadInfo )
{
    // Remove from lookup maps
    assert ( MapContains ( m_ShadInfoMap, pShadInfo->pShaderData ) );
    MapRemove ( m_ShadInfoMap, pShadInfo->pShaderData );

    //  Remove from order map
    for ( std::multimap < float, SShadInfo* > ::iterator iter = m_OrderMap.begin () ; iter != m_OrderMap.end () ; )
    {
        if ( iter->second == pShadInfo )
            m_OrderMap.erase ( iter++ );
        else
            ++iter;
    }
    delete pShadInfo;
}