Ejemplo n.º 1
0
///////////////////////////////////////////////////////////////
//
// CResourceChecker::CheckVersionRequirements
//
// Update m_strReqClientVersion or m_strReqServerVersion with the version requirement for the
// supplied identifier
//
///////////////////////////////////////////////////////////////
void CResourceChecker::CheckVersionRequirements ( const string& strIdentifierName, bool bClientScript )
{
//    if ( MTASA_VERSION_TYPE < VERSION_TYPE_RELEASE )
//        return;

    static CHashMap < SString, SString > clientFunctionMap;
    static CHashMap < SString, SString > serverFunctionMap;

    // Check if lookup maps need initializing
    if ( clientFunctionMap.empty () )
    {
        for ( uint i = 0 ; i < NUMELMS( clientFunctionInitList ) ; i++ )
            MapSet ( clientFunctionMap, clientFunctionInitList[i].functionName, clientFunctionInitList[i].minMtaVersion );

        for ( uint i = 0 ; i < NUMELMS( serverFunctionInitList ) ; i++ )
            MapSet ( serverFunctionMap, serverFunctionInitList[i].functionName, serverFunctionInitList[i].minMtaVersion );
    }

    // Select client or server check
    const CHashMap < SString, SString >& functionMap = bClientScript ? clientFunctionMap : serverFunctionMap;
    SString& strReqMtaVersion                        = bClientScript ? m_strReqClientVersion : m_strReqServerVersion;
    SString& strReqMtaReason                         = bClientScript ? m_strReqClientReason : m_strReqServerReason;

    const SString* pResult = MapFind ( functionMap, strIdentifierName );
    if ( pResult )
    {
        // This identifier has a version requirement
        const SString& strResult = *pResult;

        // Is the new requirement relevant for this MTA generation
        if ( strResult > CStaticFunctionDefinitions::GetVersionSortable ().Left ( 3 ) )
        {
            // Is the new requirement higher than the current?
            if ( strResult > strReqMtaVersion )
            {
                strReqMtaVersion = strResult;
                strReqMtaReason = strIdentifierName;
            }
        }
    }
}