예제 #1
0
void CMapManager::BroadcastResourceElements ( CElement* pResourceElement, CElementGroup* pElementGroup )
{
    CEntityAddPacket Packet;
    Packet.Add ( pResourceElement );

    std::set < CElement* > doneElements;                // Lookup map of elements already processed
    std::vector < CPerPlayerEntity* > pPerPlayerList;   // A list of per player elements we will process the last

    if ( pResourceElement->CountChildren() > 0 )
        BroadcastElementChildren ( pResourceElement, Packet, pPerPlayerList, doneElements );

    // Also send elements that are in the element group but have not been processed yet (i.e. are not parented by the resource)
    for ( CFastList < CElement* > ::const_iterator iter = pElementGroup->IterBegin() ; iter != pElementGroup->IterEnd() ; iter++ )
        if ( !MapContains( doneElements, *iter ) )
            BroadcastElement( *iter, Packet, pPerPlayerList );

    //send to all players
    g_pGame->GetPlayerManager()->BroadcastOnlyJoined ( Packet );

    std::vector < CPerPlayerEntity* > ::const_iterator iter = pPerPlayerList.begin();
    for ( ; iter != pPerPlayerList.end(); iter++ )
    {
        (*iter)->Sync ( true );
    }
}
예제 #2
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 ) );
    }
}
예제 #3
0
///////////////////////////////////////////////////////////////
//
// CCompressorJobQueueImpl::RemoveUnwantedResults
//
// Check result queue items for match with ignore list items.
// * Must be called from inside a locked section *
//
///////////////////////////////////////////////////////////////
void CCompressorJobQueueImpl::RemoveUnwantedResults()
{
    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;
    }
}
예제 #4
0
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::NotifyContructRenderItem
//
// Add to managers list
//
////////////////////////////////////////////////////////////////
void CRenderItemManager::NotifyContructRenderItem ( CRenderItem* pItem )
{
    assert ( !MapContains ( m_CreatedItemList, pItem ) );
    MapInsert ( m_CreatedItemList, pItem );

    if ( CScreenSourceItem* pScreenSourceItem = DynamicCast < CScreenSourceItem > ( pItem ) )
        m_bBackBufferCopyMaybeNeedsResize = true;
}
예제 #5
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 );
}
예제 #6
0
///////////////////////////////////////////////////////////////
//
// CDatabaseJobQueueImpl::GetNextJobHandle
//
// Return a new job data object
//
///////////////////////////////////////////////////////////////
CDbJobData* CDatabaseJobQueueImpl::GetNewJobData ( void )
{
    g_pStats->iDbJobDataCount++;
    CDbJobData* pJobData = new CDbJobData ();
    assert ( !MapContains ( m_ActiveJobHandles, pJobData->GetId () ) );
    MapSet ( m_ActiveJobHandles, pJobData->GetId (), pJobData );
    return pJobData;
}
예제 #7
0
///////////////////////////////////////////////////////////////
//
// CModelCacheManagerImpl::AddModelToPersistentCache
//
// Keep this model around 4 evar now
//
///////////////////////////////////////////////////////////////
void CModelCacheManagerImpl::AddModelToPersistentCache ( ushort usModelId )
{
    if ( !MapContains ( m_PermoLoadedModels, usModelId ) )
    {
        AddModelRefCount ( usModelId );
        MapInsert ( m_PermoLoadedModels, usModelId );
    }
}
예제 #8
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();
}
예제 #9
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 );
}
////////////////////////////////////////////////////////////////
//
// 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 );
}
예제 #11
0
////////////////////////////////////////////////////////////////
//
// CRenderWareSA::MakeAssociation
//
// Make the texture use the shader
//
////////////////////////////////////////////////////////////////
void CRenderWareSA::MakeAssociation ( SShadInfo* pShadInfo, STexInfo* pTexInfo )
{
    assert ( !pTexInfo->pAssociatedShadInfo );
    assert ( !MapContains ( pShadInfo->associatedTexInfoMap, pTexInfo ) );
    pTexInfo->pAssociatedShadInfo = pShadInfo;
    pShadInfo->associatedTexInfoMap.insert ( pTexInfo );

    if ( m_pfnWatchCallback )
        m_pfnWatchCallback ( pShadInfo->pShaderData, pTexInfo->pD3DData, NULL );
}
예제 #12
0
//
// Check is a debug tag is hidden
//
bool SharedUtil::IsDebugTagHidden ( const SString& strTag )
{
    static bool bDoneInitTags = false;
    if ( !bDoneInitTags )
    {
        bDoneInitTags = true;
        InitDebugTags ();
    }
    return MapContains ( ms_debugTagInvisibleMap, strTag.ToLower () );
}
예제 #13
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 );
}
예제 #14
0
///////////////////////////////////////////////////////////////
//
// CCompressorJobQueueImpl::DoPulse
//
// Check if any callback functions are due
//
///////////////////////////////////////////////////////////////
void CCompressorJobQueueImpl::DoPulse ( void )
{
    shared.m_Mutex.Lock ();

again:
    // Delete finished
    for ( std::set < CCompressJobData* >::iterator iter = m_FinishedList.begin () ; iter != m_FinishedList.end () ; )
    {
        CCompressJobData* pJobData = *iter;
        m_FinishedList.erase ( iter++ );
        // Check not refed
        assert ( !ListContains ( shared.m_CommandQueue, pJobData ) );
        assert ( !ListContains ( shared.m_ResultQueue, pJobData ) );
        assert ( !MapContains ( m_IgnoreResultList, pJobData ) );
        assert ( !MapContains ( m_FinishedList, pJobData ) );

        assert ( !pJobData->HasCallback () );
        SAFE_DELETE( pJobData );
    }

    // Remove ignored
    RemoveUnwantedResults ();

    // Do pending callbacks
    for ( std::list < CCompressJobData* >::iterator iter = shared.m_ResultQueue.begin () ; iter != shared.m_ResultQueue.end () ; ++iter )
    {
        CCompressJobData* pJobData = *iter;

        if ( pJobData->HasCallback () )
        {
            shared.m_Mutex.Unlock ();
            pJobData->ProcessCallback ();
            shared.m_Mutex.Lock ();

            // Redo from the top to ensure everything is consistent
            goto again;
        }
    }

    shared.m_Mutex.Unlock ();
}
예제 #15
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();
}
예제 #16
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 );
}
예제 #17
0
///////////////////////////////////////////////////////////////
//
// CPerfStatDebugInfoImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatDebugInfoImpl::GetStats ( CPerfStatResult* pResult, const std::map < SString, int >& strOptionMap, const SString& strFilter )
{
    m_bActive = true;
    m_LastGetStatsTime = CTickCount::Now ();


    //
    // Set option flags
    //
    bool bHelp = MapContains ( strOptionMap, "h" );

    m_LastFilter = strFilter;

    //
    // Process help
    //
    if ( bHelp || strFilter.empty () )
    {
        pResult->AddColumn ( "Debug info help" );

        std::set < SString > sectionNames;
        for ( std::list < SLineInfo >::iterator iter = m_LineList.begin () ; iter != m_LineList.end () ; ++iter )
            MapInsert ( sectionNames, (*iter).strSection );

        pResult->AddRow ()[0] = "Option h - This help";
        pResult->AddRow ()[0] = "Filter all - View all data";
        for ( std::set < SString >::iterator iter = sectionNames.begin () ; iter != sectionNames.end () ; ++iter )
        {
            pResult->AddRow ()[0] = SString ( "Filter %s - View only this data set", **iter );
        }
        return;
    }

    // Add columns
    pResult->AddColumn ( "" );
    pResult->AddColumn ( "" );

    for ( std::list < SLineInfo >::iterator iter = m_LineList.begin () ; iter != m_LineList.end () ; ++iter )
    {
        const SLineInfo& info = *iter;

        if ( m_LastFilter.ContainsI ( "all" ) || m_LastFilter.ContainsI ( info.strSection ) )
        {
            SString* row = pResult->AddRow ();
            int c = 0;

            row[c++] = info.strHead;
            row[c++] = info.strData;
        }
    }
}
///////////////////////////////////////////////////////////////
//
// CPerfStatEventPacketUsageImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatEventPacketUsageImpl::GetStats ( CPerfStatResult* pResult, const std::map < SString, int >& strOptionMap, const SString& strFilter )
{
    m_TimeSinceGetStats.Reset ();
    m_bEnabled = true;
    MaybeRecordStats();

    //
    // Set option flags
    //
    bool bHelp = MapContains ( strOptionMap, "h" );

    //
    // Process help
    //
    if ( bHelp )
    {
        pResult->AddColumn ( "Event Packet usage help" );
        pResult->AddRow ()[0] ="Option h - This help";
        return;
    }

    // Add columns
    pResult->AddColumn ( "Type" );
    pResult->AddColumn ( "Name" );
    pResult->AddColumn ( "msgs/sec" );
    pResult->AddColumn ( "5 sec.msgs" );

    // Fill rows
    for ( uint i = 0 ; i < m_EventUsageSortedList.size() && i < 30 ; i++ )
    {
        const SEventUsage& usage = m_EventUsageSortedList[i];

        // Add row
        SString* row = pResult->AddRow ();

        SString strType;
        if ( usage.iEventOut )
            strType += "Event ";
        if ( usage.iElementDataOut )
            strType += "ElementData ";
        if ( usage.iElementDataRelay )
            strType += "ElementData(Relay) ";

        int c = 0;
        row[c++] = strType;
        row[c++] = usage.strName;
        row[c++] = SString ( "%d", ( usage.iTotal + 4 ) / 5 );
        row[c++] = SString ( "%d", usage.iTotal );
    }
}
예제 #19
0
void CModelInfoSA::StaticFlushPendingRestreamIPL ( void )
{
    if ( ms_RestreamTxdIDMap.empty () )
        return;
    // This function restreams all instances of the model *that are from the default SA world (ipl)*.
    // In other words, it does not affect elements created by MTA.
    // It's mostly a reimplementation of SA's DeleteAllRwObjects, except that it filters by model ID.

    ( (void (*)())FUNC_FlushRequestList )();

    std::set < unsigned short > removedModels;
    
    for ( int i = 0; i < 2*NUM_StreamSectorRows*NUM_StreamSectorCols; i++ )
    {
        DWORD* pSectorEntry = ((DWORD **)ARRAY_StreamSectors) [ i ];
        while ( pSectorEntry )
        {
            CEntitySAInterface* pEntity = (CEntitySAInterface *)pSectorEntry [ 0 ];

            // Possible bug - pEntity seems to be invalid here occasionally
            if ( pEntity->vtbl->DeleteRwObject != 0x00534030 )
            {
                // Log info
                OutputDebugString ( SString ( "Entity 0x%08x (with model %d) at ARRAY_StreamSectors[%d,%d] is invalid\n", pEntity, pEntity->m_nModelIndex, i / 2 % NUM_StreamSectorRows, i / 2 / NUM_StreamSectorCols ) );
                // Assert in debug
                #if _DEBUG
                    assert ( pEntity->vtbl->DeleteRwObject == 0x00534030 );
                #endif
                pSectorEntry = (DWORD *)pSectorEntry [ 1 ];
                continue;
            }

            if ( MapContains ( ms_RestreamTxdIDMap, pGame->GetModelInfo ( pEntity->m_nModelIndex )->GetTextureDictionaryID () ) )
            {
                if ( !pEntity->bStreamingDontDelete && !pEntity->bImBeingRendered )
                {
                    __asm
                    {
                        mov ecx, pEntity
                        mov eax, [ecx]
                        call dword ptr [eax+20h]
                    }
                    removedModels.insert ( pEntity->m_nModelIndex );
                }
            }
            
            pSectorEntry = (DWORD *)pSectorEntry [ 1 ];
        }
    }
예제 #20
0
///////////////////////////////////////////////////////////////
//
// CCompressorJobQueueImpl::FreeCommand
//
// Throw away result when this job is done
// Returns false if jobHandle not correct
//
///////////////////////////////////////////////////////////////
bool CCompressorJobQueueImpl::FreeCommand ( CCompressJobData* pJobData )
{
    if ( MapContains ( m_IgnoreResultList, pJobData ) )
        return false;       // Already ignoring query handle

    // if in command or result queue, then put in ignore result list
    bool bFound;
    shared.m_Mutex.Lock ();

    bFound = ListContains ( shared.m_CommandQueue, pJobData ) || ListContains ( shared.m_ResultQueue, pJobData );

    shared.m_Mutex.Unlock ();

    if ( !bFound )
    {
        // Must be in finished list
        if ( !MapContains ( m_FinishedList, pJobData ) )
            OutputDebugLine ( "FreeCommand: Serious problem #2 here\n" );
        return false; 
    }

    IgnoreJobResults ( pJobData );
    return true;
}
예제 #21
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;
}
예제 #22
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);
    }
}
////////////////////////////////////////////////////////////////
//
// CEffectTemplateImpl::CloneD3DEffect
//
// Clone the d3d effect
//
////////////////////////////////////////////////////////////////
ID3DXEffect* CEffectTemplateImpl::CloneD3DEffect ( SString& strOutStatus, bool& bOutUsesVertexShader, bool& bOutUsesDepthBuffer )
{
    // Clone D3DXEffect
    ID3DXEffect* pNewD3DEffect = NULL;
    LPDIRECT3DDEVICE9 pDevice = NULL;
    m_pD3DEffect->GetDevice ( &pDevice );
    m_pD3DEffect->CloneEffect ( pDevice, &pNewD3DEffect );

    if ( !pNewD3DEffect )
        return NULL;

    // Set the same technique
    {
        D3DXHANDLE hTechnique = m_pD3DEffect->GetCurrentTechnique ();
        D3DXTECHNIQUE_DESC TechniqueDesc;
        m_pD3DEffect->GetTechniqueDesc( hTechnique, &TechniqueDesc );
        pNewD3DEffect->SetTechnique ( pNewD3DEffect->GetTechniqueByName ( TechniqueDesc.Name ) );

        // Output technique name
        strOutStatus = TechniqueDesc.Name;
    }

    // Check if any technique uses a vertex shader
    bOutUsesVertexShader = false;
    D3DXEFFECT_DESC EffectDesc;
    m_pD3DEffect->GetDesc ( &EffectDesc );
    for ( uint i = 0 ; i < EffectDesc.Techniques ; i++ )
    {
        D3DXHANDLE hTechnique = m_pD3DEffect->GetTechnique ( i );
        D3DXTECHNIQUE_DESC TechniqueDesc;
        m_pD3DEffect->GetTechniqueDesc( hTechnique, &TechniqueDesc );
        for ( uint i = 0 ; i < TechniqueDesc.Passes ; i++ )
        {
            D3DXPASS_DESC PassDesc;
            m_pD3DEffect->GetPassDesc ( m_pD3DEffect->GetPass ( hTechnique, i ), &PassDesc );
            if ( PassDesc.pVertexShaderFunction )
                bOutUsesVertexShader = true;
        }
    }

    bOutUsesDepthBuffer = m_bUsesDepthBuffer;

    // Add to list of clones
    assert ( !MapContains ( m_CloneList, pNewD3DEffect ) );
    MapInsert ( m_CloneList, pNewD3DEffect );
    return pNewD3DEffect;
}
예제 #24
0
///////////////////////////////////////////////////////////////
//
// CDatabaseManagerImpl::QueryStart
//
// Start a query
//
///////////////////////////////////////////////////////////////
CDbJobData* CDatabaseManagerImpl::QueryStart ( SConnectionHandle hConnection, const SString& strQuery, CLuaArguments* pArgs )
{
    ClearLastErrorMessage ();

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

    // Insert arguments with correct escapement
    SString strEscapedQuery = InsertQueryArguments ( hConnection, strQuery, pArgs );

    // Start query
    return m_JobQueue->AddCommand ( EJobCommand::QUERY, hConnection, strEscapedQuery );
}
예제 #25
0
////////////////////////////////////////////////////////////////
//
// CRenderWareSA::CreateTexInfo
//
//
//
////////////////////////////////////////////////////////////////
STexInfo* CRenderWareSA::CreateTexInfo ( ushort usTxdId, const SString& strTextureName, CD3DDUMMY* pD3DData )
{
    // Create texinfo
    m_TexInfoList.push_back ( STexInfo ( usTxdId, strTextureName, pD3DData ) );
    STexInfo* pTexInfo = &m_TexInfoList.back ();

    // Add to lookup maps
    SString strUniqueKey ( "%d_%s", pTexInfo->usTxdId, *pTexInfo->strTextureName );
    if ( MapContains ( m_UniqueTexInfoMap, strUniqueKey ) )
        AddReportLog ( 5132, SString ( "CreateTexInfo duplicate %s", *strUniqueKey ) );
    MapSet ( m_UniqueTexInfoMap, strUniqueKey, pTexInfo );

	// This assert fails when using engine txd replace functions - TODO find out why
    //assert ( !MapContains ( m_D3DDataTexInfoMap, pTexInfo->pD3DData ) );
    MapSet ( m_D3DDataTexInfoMap, pTexInfo->pD3DData, pTexInfo );
    return pTexInfo;
}
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::GetVisibleTextureNames
//
// Get the names of all streamed in world textures, filtered by name and/or model
//
////////////////////////////////////////////////////////////////
void CRenderItemManager::GetVisibleTextureNames ( std::vector < SString >& outNameList, const SString& strTextureNameMatch, ushort usModelID )
{
    // If modelid supplied, get the model texture names into a map
    std::set < SString > modelTextureNameMap;
    if ( usModelID )
    {
        std::vector < SString > modelTextureNameList;
        m_pRenderWare->GetModelTextureNames ( modelTextureNameList, usModelID );
        for ( std::vector < SString >::const_iterator iter = modelTextureNameList.begin () ; iter != modelTextureNameList.end () ; ++iter )
            modelTextureNameMap.insert ( (*iter).ToLower () );
    }

    SString strTextureNameMatchLower = strTextureNameMatch.ToLower ();

    std::set < SString > resultMap;

    // For each texture that was used in the previous frame
    for ( std::set < CD3DDUMMY* >::const_iterator iter = m_PrevFrameTextureUsage.begin () ; iter != m_PrevFrameTextureUsage.end () ; ++iter )
    {
        // Get the texture name
        SString strTextureName = m_pRenderWare->GetTextureName ( *iter );
        SString strTextureNameLower = strTextureName.ToLower ();

        if ( strTextureName.empty () )
            continue;

        // Filter by wildcard match
        if ( !WildcardMatch ( strTextureNameMatchLower, strTextureNameLower ) )
            continue;

        // Filter by model
        if ( usModelID )
            if ( !MapContains ( modelTextureNameMap, strTextureNameLower ) )
                continue;

        resultMap.insert ( strTextureName );
    }

    for ( std::set < SString >::const_iterator iter = resultMap.begin () ; iter != resultMap.end () ; ++iter )
    {
        outNameList.push_back ( *iter );
    }
}
예제 #27
0
///////////////////////////////////////////////////////////////
//
// CDatabaseManagerImpl::QueryStartf
//
//
//
///////////////////////////////////////////////////////////////
CDbJobData* CDatabaseManagerImpl::QueryStartf ( SConnectionHandle hConnection, const char* szQuery, ... )
{
    va_list vl;
    va_start ( vl, szQuery );

    ClearLastErrorMessage ();

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

    // Insert arguments with correct escapement
    SString strEscapedQuery = InsertQueryArguments ( hConnection, szQuery, vl );

    // Start query
    return m_JobQueue->AddCommand ( EJobCommand::QUERY, hConnection, strEscapedQuery );
}
예제 #28
0
///////////////////////////////////////////////////////////////
//
// CPerfStatDebugTableImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatDebugTableImpl::GetStats ( CPerfStatResult* pResult, const std::map < SString, int >& strOptionMap, const SString& strFilter )
{
    LOCK_SCOPE ( m_CS );

    //
    // Set option flags
    //
    bool bHelp = MapContains ( strOptionMap, "h" );

    //
    // Process help
    //
    if ( bHelp )
    {
        pResult->AddColumn ( "Debug table help" );
        pResult->AddRow ()[0] = "Option h - This help";
        return;
    }

    // Add columns
    const int iNumColumns = 4;
    for ( int i = 0 ; i < iNumColumns ; i++ )
        pResult->AddColumn ( "" );

    for ( std::map < SString, SLineInfo >::iterator iter = m_LineMap.begin () ; iter != m_LineMap.end () ; ++iter )
    {
        const SLineInfo& info = iter->second;

        // Apply filter
        if ( !strFilter.empty () && !info.strCellList[0].ContainsI ( strFilter ) )
            continue;

        SString* row = pResult->AddRow ();
        int c = 0;

        // Add cells
        for ( uint i = 0 ; i < info.strCellList.size () && c < iNumColumns ; i++ )
            row[c++] = info.strCellList[i];
    }
}
예제 #29
0
void CModelInfoSA::SetLODDistance ( float fDistance )
{
#if 0
    // fLodDistanceUnscaled values:
    //
    // With the draw distance setting in GTA SP options menu set to maximum:
    //      0 - 170     roughly correlates to a LOD distance of 0 - 300 game units
    //      170 - 480   sets the LOD distance to 300 game units and has a negative effect on the alpha fade-in
    //      490 - 1e7   sets the LOD distance to 300 game units and removes the alpha fade-in completely
    //
    // With the draw distance setting in GTA SP options menu set to minimum:
    //      0 - 325     roughly correlates to a LOD distance of 0 - 300 game units
    //      340 - 960   sets the LOD distance to 300 game units and has a negative effect on the alpha fade-in
    //      1000 - 1e7  sets the LOD distance to 300 game units and removes the alpha fade-in completely
    //
    // So, to ensure the maximum draw distance with a working alpha fade-in, fLodDistanceUnscaled has to be
    // no more than: 325 - (325-170) * draw_distance_setting
    //

    // Change GTA draw distance value from 0.925 to 1.8 into 0 to 1
    float fDrawDistanceSetting = UnlerpClamped ( 0.925f, CSettingsSA ().GetDrawDistance (), 1.8f );

    // Calc max setting allowed for fLodDistanceUnscaled to preserve alpha fade-in
    float fMaximumValue = Lerp ( 325.f, fDrawDistanceSetting, 170.f );

    // Ensure fDistance is in range
    fDistance = Min ( fDistance, fMaximumValue );
#endif
    // Limit to 325.f as it goes horrible after that
    fDistance = Min ( fDistance, 325.f );
    m_pInterface = ppModelInfo [ m_dwModelID ];
    if ( m_pInterface )
    {
        // Save default value if not done yet
        if ( !MapContains ( ms_ModelDefaultLodDistanceMap, m_dwModelID ) )
            MapSet ( ms_ModelDefaultLodDistanceMap, m_dwModelID, m_pInterface->fLodDistanceUnscaled );
        m_pInterface->fLodDistanceUnscaled = fDistance;
    }
}
예제 #30
0
///////////////////////////////////////////////////////////////
//
// CDatabaseManagerImpl::QueryWithResultf
//
// Start a query and wait for the result
//
///////////////////////////////////////////////////////////////
bool CDatabaseManagerImpl::QueryWithResultf ( SConnectionHandle hConnection, CRegistryResult* pResult, const char* szQuery, ... )
{
    va_list vl;
    va_start ( vl, szQuery );

    ClearLastErrorMessage ();

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

    // Insert arguments with correct escapement
    SString strEscapedQuery = InsertQueryArguments ( hConnection, szQuery, vl );

    // Start query
    CDbJobData* pJobData = m_JobQueue->AddCommand ( EJobCommand::QUERY, hConnection, strEscapedQuery );

    // Wait for result
    QueryPoll ( pJobData, -1 );

    // Process result
    if ( pJobData->result.status == EJobResult::FAIL )
    {
        if ( pResult )
            *pResult = CRegistryResult ();
        return false;
    }
    else
    {
        if ( pResult )
            *pResult = pJobData->result.registryResult;
        return true;
    }
}