Merge pull request #764 from ergo720/hlecache

Fix #746 issue
This commit is contained in:
RadWolfie 2017-10-11 14:43:07 -05:00 committed by GitHub
commit 853eea7bdb
5 changed files with 22 additions and 5 deletions

View File

@ -11,6 +11,7 @@ phire
x1mixmzeng
RadWolfie
Luca D'Amico (Luca1991/Luca91)
ergo720
Supporters:
Cisco Martinez

View File

@ -1004,3 +1004,12 @@ void *Xbe::FindSection(char *zsSectionName)
return NULL;
}
void Xbe::PurgeBadChar(std::string &s, const std::string &illegalChars)
{
for (auto it = s.begin(); it < s.end(); ++it)
{
bool found = illegalChars.find(*it) != std::string::npos;
if (found) { *it = '_'; }
}
}

View File

@ -71,6 +71,9 @@ class Xbe : public Error
// export logo bitmap to raw monochrome data
void ExportLogoBitmap(uint08 x_Gray[100*17]);
// purge illegal characters in Windows filenames or other OS's
void PurgeBadChar(std::string &s, const std::string &illegalChars = "\\/:?\"<>|");
// Xbe header
#include "AlignPrefix1.h"
struct Header

View File

@ -1010,7 +1010,9 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
// Hash the loaded XBE's header, use it as a filename
uint32_t uiHash = XXHash32::hash((void*)&m_Xbe->m_Header, sizeof(Xbe::Header), 0);
std::stringstream sstream;
sstream << cacheDir << std::hex << uiHash << ".ini";
std::string szTitleName(m_Xbe->m_szAsciiTitle);
m_Xbe->PurgeBadChar(szTitleName);
sstream << cacheDir << szTitleName << "-" << std::hex << uiHash << ".ini";
std::string fullpath = sstream.str();
if (DeleteFile(fullpath.c_str())) {

View File

@ -137,7 +137,12 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
// Hash the loaded XBE's header, use it as a filename
uint32_t uiHash = XXHash32::hash((void*)&CxbxKrnl_Xbe->m_Header, sizeof(Xbe::Header), 0);
std::stringstream sstream;
sstream << cachePath << std::hex << uiHash << ".ini";
char tAsciiTitle[40] = "Unknown";
setlocale(LC_ALL, "English");
wcstombs(tAsciiTitle, g_pCertificate->wszTitleName, sizeof(tAsciiTitle));
std::string szTitleName(tAsciiTitle);
CxbxKrnl_Xbe->PurgeBadChar(szTitleName);
sstream << cachePath << szTitleName << "-" << std::hex << uiHash << ".ini";
std::string filename = sstream.str();
if (PathFileExists(filename.c_str())) {
@ -587,9 +592,6 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
WritePrivateProfileString("Info", "HLEDatabaseVersion", szHLELastCompileTime, filename.c_str());
// Write the Certificate Details to the cache file
char tAsciiTitle[40] = "Unknown";
setlocale(LC_ALL, "English");
wcstombs(tAsciiTitle, g_pCertificate->wszTitleName, sizeof(tAsciiTitle));
WritePrivateProfileString("Certificate", "Name", tAsciiTitle, filename.c_str());
std::stringstream titleId;