Example #1
0
void AppState::OpenScript(WORD w)
{
    TCHAR szGameIni[MAX_PATH];
    HRESULT hr = _GetGameIni(szGameIni, ARRAYSIZE(szGameIni));
    if (SUCCEEDED(hr))
    {
        std::string keyName = default_reskey(w, NoBase36);
        TCHAR szScriptName[100];
        if (GetPrivateProfileString(GetResourceInfo(ResourceType::Script).pszTitleDefault, keyName.c_str(), keyName.c_str(), szScriptName, ARRAYSIZE(szScriptName), szGameIni))
        {
            OpenScript(szScriptName, nullptr, w);
        }
    }
}
VFS::UInt32
CResArchive::GetFileSize( const VFS::CString& filePath ) const
{GUCEF_TRACE;

    // First perform a sanity check on the resource type
    CORE::Int32 fileType = CORE::StringToInt32( filePath.SubstrToChar( '.', false ) );
    if ( fileType != m_index.recordType )
        return 0;

    CORE::Int32 offset = 0;
    CORE::Int32 size = 0;
    CORE::Int32 resourceId = CORE::StringToInt32( filePath.SubstrToChar( '.', true ) );
    if ( GetResourceInfo( resourceId ,
                          offset     ,
                          size       ) )
    {
        return size;
    }
    return 0;
}
CORE::CIOAccess*
CResArchive::LoadFile( const VFS::CString& file      ,
                       const VFS::UInt32 memLoadSize ) const
{GUCEF_TRACE;

    // First perform a sanity check on the resource type
    CORE::Int32 fileType = CORE::StringToInt32( file.SubstrToChar( '.', false ) );
    if ( fileType != m_index.recordType )
        return NULL;
    
    CORE::Int32 offset = 0;
    CORE::Int32 size = 0;
    CORE::Int32 resourceId = CORE::StringToInt32( file.SubstrToChar( '.', true ) );
    if ( !GetResourceInfo( resourceId ,
                           offset     ,
                           size       ) )
    {
        return NULL;
    }
        
    if ( (CORE::UInt32) size <= memLoadSize )
    {
        CORE::CDynamicBufferAccess* memBuffer = new CORE::CDynamicBufferAccess();
        if ( memBuffer->LoadContentFromFile( m_resPath, offset, size ) )
        {
            return memBuffer;
        } 
    }
    else
    {
        CORE::CSubFileAccess* subFile = new CORE::CSubFileAccess();
        if ( subFile->Load( m_resPath, offset, size ) )
        {
            return subFile;
        }
    }

    return NULL;
}