-fixed scummvm covers (untested)

This commit is contained in:
fix94.1 2012-05-28 12:57:52 +00:00
parent 1a713f7b3e
commit 9f0a4d5a66
2 changed files with 20 additions and 3 deletions

View File

@ -2551,7 +2551,15 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq)
SmartBuf zBuffer = m_compressCache ? smartMem2Alloc(zBufferSize) : tex.data; SmartBuf zBuffer = m_compressCache ? smartMem2Alloc(zBufferSize) : tex.data;
if (!!zBuffer && (!m_compressCache || compress(zBuffer.get(), &zBufferSize, tex.data.get(), bufSize) == Z_OK)) if (!!zBuffer && (!m_compressCache || compress(zBuffer.get(), &zBufferSize, tex.data.get(), bufSize) == Z_OK))
{ {
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == EMU_MAGIC ? &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "wb"); char gamePath[256];
if(m_items[i].hdr->hdr.gc_magic == EMU_MAGIC)
{
if(string(m_items[i].hdr->path).find_last_of("/") != string::npos)
strncpy(gamePath, &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")], sizeof(gamePath));
else
strncpy(gamePath, m_items[i].hdr->path, sizeof(gamePath));
}
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == EMU_MAGIC ? gamePath : (char*)m_items[i].hdr->hdr.id)), "wb");
if (file != 0) if (file != 0)
{ {
SWFCHeader header(tex, box, m_compressCache); SWFCHeader header(tex, box, m_compressCache);
@ -2618,7 +2626,15 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq)
// Try to find the texture in the cache // Try to find the texture in the cache
if (!m_cachePath.empty()) if (!m_cachePath.empty())
{ {
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == EMU_MAGIC ? &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "rb"); char gamePath[256];
if(m_items[i].hdr->hdr.gc_magic == EMU_MAGIC)
{
if(string(m_items[i].hdr->path).find_last_of("/") != string::npos)
strncpy(gamePath, &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")], sizeof(gamePath));
else
strncpy(gamePath, m_items[i].hdr->path, sizeof(gamePath));
}
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == EMU_MAGIC ? gamePath : (char*)m_items[i].hdr->hdr.id)), "rb");
if (file != 0) if (file != 0)
{ {
bool success = false; bool success = false;

View File

@ -1648,7 +1648,8 @@ void CMenu::_initCF(void)
if (m_current_view == COVERFLOW_EMU) if (m_current_view == COVERFLOW_EMU)
{ {
string tempname(m_gameList[i].path); string tempname(m_gameList[i].path);
tempname.assign(&tempname[tempname.find_last_of('/') + 1]); if(tempname.find_last_of("/") != string::npos)
tempname.assign(&tempname[tempname.find_last_of("/") + 1]);
string coverFolder(m_plugin.GetCoverFolderName(m_gameList[i].hdr.magic)); string coverFolder(m_plugin.GetCoverFolderName(m_gameList[i].hdr.magic));
//if(tempname.find_last_of('.') != string::npos) //if(tempname.find_last_of('.') != string::npos)
// tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.')); // tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.'));