Fix for issue #746

This commit is contained in:
ergo720 2017-10-11 20:14:37 +02:00
parent 5d1d8f109c
commit 5a13c67b54
5 changed files with 23 additions and 4 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,8 +137,14 @@ 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();
setlocale(LC_ALL, "");
if (PathFileExists(filename.c_str())) {
printf("Found HLE Cache File: %08X.ini\n", uiHash);
@ -587,9 +593,7 @@ 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;