Permalink
Browse files

Update UI and internal task to clear cache

  • Loading branch information...
RadWolfie committed Sep 4, 2018
1 parent 8ff36ff commit 1e555bec3f059441e42319c1920fc743fe7db308
Showing with 11 additions and 11 deletions.
  1. +3 −3 resource/Cxbx.rc
  2. +8 −8 src/Cxbx/WndMain.cpp
View
@@ -579,10 +579,10 @@ BEGIN
MENUITEM "Store with Executable", ID_SETTINGS_CONFIG_DLOCCURDIR,MFT_STRING,MFS_ENABLED
MENUITEM "Custom", ID_SETTINGS_CONFIG_DLOCCUSTOM,MFT_STRING,MFS_ENABLED
END
POPUP "&HLE Cache", 65535,MFT_STRING,MFS_ENABLED
POPUP "&Symbol Cache", 65535,MFT_STRING,MFS_ENABLED
BEGIN
MENUITEM "&Clear entire HLE Cache", ID_CACHE_CLEARHLECACHE_ALL,MFT_STRING,MFS_ENABLED
MENUITEM "&Rescan title HLE Cache", ID_CACHE_CLEARHLECACHE_CURRENT,MFT_STRING,MFS_ENABLED
MENUITEM "&Clear entire Symbol Cache", ID_CACHE_CLEARHLECACHE_ALL,MFT_STRING,MFS_ENABLED
MENUITEM "&Rescan title Symbol Cache", ID_CACHE_CLEARHLECACHE_CURRENT,MFT_STRING,MFS_ENABLED
END
MENUITEM MFT_SEPARATOR
POPUP "&LLE (Experimental)", 65535,MFT_STRING,MFS_ENABLED
View
@@ -76,9 +76,9 @@ static int splashLogoWidth, splashLogoHeight;
bool g_SaveOnExit = true;
void ClearHLECache(const char sStorageLocation[MAX_PATH])
void ClearSymbolCache(const char sStorageLocation[MAX_PATH])
{
std::string cacheDir = std::string(sStorageLocation) + "\\HLECache\\";
std::string cacheDir = std::string(sStorageLocation) + "\\SymbolCache\\";
std::string fullpath = cacheDir + "*.ini";
WIN32_FIND_DATA data;
@@ -90,7 +90,7 @@ void ClearHLECache(const char sStorageLocation[MAX_PATH])
if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
fullpath = cacheDir + data.cFileName;
if (!DeleteFile(fullpath.c_str())) {
if (!std::experimental::filesystem::remove(fullpath)) {
break;
}
}
@@ -1049,14 +1049,14 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
case ID_CACHE_CLEARHLECACHE_ALL:

This comment has been minimized.

Show comment
Hide comment
@PatrickvL

PatrickvL Sep 4, 2018

Member

It's by no means important or a requirement if you ask me, but the constants still read HLE instead of SYMBOL

@PatrickvL

PatrickvL Sep 4, 2018

Member

It's by no means important or a requirement if you ask me, but the constants still read HLE instead of SYMBOL

This comment has been minimized.

Show comment
Hide comment
@RadWolfie

RadWolfie Sep 4, 2018

Member

I'm too lazy to fix it at the moment. 😉 Currently, I am doing the next "final" task. (prepare multi-plugin support) Maybe I will have the time not to be lazy and put the correct constant names.

@RadWolfie

RadWolfie Sep 4, 2018

Member

I'm too lazy to fix it at the moment. 😉 Currently, I am doing the next "final" task. (prepare multi-plugin support) Maybe I will have the time not to be lazy and put the correct constant names.

{
ClearHLECache(g_Settings->GetDataLocation().c_str());
MessageBox(m_hwnd, "The entire HLE Cache has been cleared.", "Cxbx-Reloaded", MB_OK);
ClearSymbolCache(g_Settings->GetDataLocation().c_str());
MessageBox(m_hwnd, "The entire Symbol Cache has been cleared.", "Cxbx-Reloaded", MB_OK);
}
break;
case ID_CACHE_CLEARHLECACHE_CURRENT:
{
std::string cacheDir = g_Settings->GetDataLocation() + "\\HLECache\\";
std::string cacheDir = g_Settings->GetDataLocation() + "\\SymbolCache\\";
// 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);
@@ -1066,8 +1066,8 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
sstream << cacheDir << szTitleName << "-" << std::hex << uiHash << ".ini";
std::string fullpath = sstream.str();
if (DeleteFile(fullpath.c_str())) {
MessageBox(m_hwnd, "This title's HLE Cache entry has been cleared.", "Cxbx-Reloaded", MB_OK);
if (std::experimental::filesystem::remove(fullpath)) {
MessageBox(m_hwnd, "This title's Symbol Cache entry has been cleared.", "Cxbx-Reloaded", MB_OK);
}
}
break;

0 comments on commit 1e555be

Please sign in to comment.