Permalink
Browse files

Fix for issue #746

  • Loading branch information...
ergo720
ergo720 committed Oct 11, 2017
1 parent 5d1d8f1 commit 5a13c67b54d9e640474c78537f1345c4e9b681c8
Showing with 23 additions and 4 deletions.
  1. +1 −0 CONTRIBUTORS
  2. +9 −0 src/Common/Xbe.cpp
  3. +3 −0 src/Common/Xbe.h
  4. +3 −1 src/Cxbx/WndMain.cpp
  5. +7 −3 src/CxbxKrnl/HLEIntercept.cpp
View
@@ -11,6 +11,7 @@ phire
x1mixmzeng
RadWolfie
Luca D'Amico (Luca1991/Luca91)
ergo720
Supporters:
Cisco Martinez
View
@@ -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
@@ -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
@@ -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())) {
@@ -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;

0 comments on commit 5a13c67

Please sign in to comment.