From 9f0a4d5a664904c033e2aa98f96dd3e57131c35a Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Mon, 28 May 2012 12:57:52 +0000 Subject: [PATCH] -fixed scummvm covers (untested) --- source/gui/coverflow.cpp | 20 ++++++++++++++++++-- source/menu/menu.cpp | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/source/gui/coverflow.cpp b/source/gui/coverflow.cpp index 221a01b5..1734ca09 100644 --- a/source/gui/coverflow.cpp +++ b/source/gui/coverflow.cpp @@ -2551,7 +2551,15 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq) SmartBuf zBuffer = m_compressCache ? smartMem2Alloc(zBufferSize) : tex.data; 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) { 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 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) { bool success = false; diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index d2522a22..c3a5dbfd 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1648,7 +1648,8 @@ void CMenu::_initCF(void) if (m_current_view == COVERFLOW_EMU) { 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)); //if(tempname.find_last_of('.') != string::npos) // tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.'));