mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-12 09:48:30 +12:00
Refactor more wstring instances to utf8-encoded string
This commit is contained in:
parent
f6c3c96d94
commit
abce406ee8
26 changed files with 82 additions and 114 deletions
|
@ -54,7 +54,7 @@ void GraphicPack2::LoadGraphicPack(fs::path graphicPackPath)
|
|||
|
||||
if (versionNum > GP_LEGACY_VERSION)
|
||||
{
|
||||
GraphicPack2::LoadGraphicPack(rulesPath.generic_wstring(), iniParser);
|
||||
GraphicPack2::LoadGraphicPack(_pathToUtf8(rulesPath), iniParser);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void GraphicPack2::LoadAll()
|
|||
}
|
||||
}
|
||||
|
||||
bool GraphicPack2::LoadGraphicPack(const std::wstring& filename, IniParser& rules)
|
||||
bool GraphicPack2::LoadGraphicPack(const std::string& filename, IniParser& rules)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -216,12 +216,6 @@ void GraphicPack2::WaitUntilReady()
|
|||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
}
|
||||
|
||||
GraphicPack2::GraphicPack2(std::wstring filename)
|
||||
: m_filename(std::move(filename))
|
||||
{
|
||||
// unused for now
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, GraphicPack2::PresetVar> GraphicPack2::ParsePresetVars(IniParser& rules) const
|
||||
{
|
||||
ExpressionParser parser;
|
||||
|
@ -255,7 +249,7 @@ std::unordered_map<std::string, GraphicPack2::PresetVar> GraphicPack2::ParsePres
|
|||
return vars;
|
||||
}
|
||||
|
||||
GraphicPack2::GraphicPack2(std::wstring filename, IniParser& rules)
|
||||
GraphicPack2::GraphicPack2(std::string filename, IniParser& rules)
|
||||
: m_filename(std::move(filename))
|
||||
{
|
||||
// we're already in [Definition]
|
||||
|
@ -265,7 +259,7 @@ GraphicPack2::GraphicPack2(std::wstring filename, IniParser& rules)
|
|||
m_version = StringHelpers::ToInt(*option_version, -1);
|
||||
if (m_version < 0)
|
||||
{
|
||||
cemuLog_log(LogType::Force, L"{}: Invalid version", m_filename);
|
||||
cemuLog_log(LogType::Force, "{}: Invalid version", m_filename);
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
|
@ -839,7 +833,7 @@ void GraphicPack2::LoadReplacedFiles()
|
|||
return;
|
||||
m_patchedFilesLoaded = true;
|
||||
|
||||
fs::path gfxPackPath(m_filename.c_str());
|
||||
fs::path gfxPackPath = _utf8ToPath(m_filename);
|
||||
gfxPackPath = gfxPackPath.remove_filename();
|
||||
|
||||
// /content/
|
||||
|
@ -892,14 +886,14 @@ bool GraphicPack2::Activate()
|
|||
return false;
|
||||
}
|
||||
|
||||
FileStream* fs_rules = FileStream::openFile2({ m_filename });
|
||||
FileStream* fs_rules = FileStream::openFile2(_utf8ToPath(m_filename));
|
||||
if (!fs_rules)
|
||||
return false;
|
||||
std::vector<uint8> rulesData;
|
||||
fs_rules->extract(rulesData);
|
||||
delete fs_rules;
|
||||
|
||||
IniParser rules({ (char*)rulesData.data(), rulesData.size()}, boost::nowide::narrow(m_filename));
|
||||
IniParser rules({ (char*)rulesData.data(), rulesData.size()}, m_filename);
|
||||
|
||||
// load rules
|
||||
try
|
||||
|
@ -953,7 +947,7 @@ bool GraphicPack2::Activate()
|
|||
else if (anisotropyValue == 16)
|
||||
rule.overwrite_settings.anistropic_value = 4;
|
||||
else
|
||||
cemuLog_log(LogType::Force, fmt::format(L"Invalid value {} for overwriteAnisotropy in graphic pack {}. Only the values 1, 2, 4, 8 or 16 are allowed.", anisotropyValue, m_filename));
|
||||
cemuLog_log(LogType::Force, "Invalid value {} for overwriteAnisotropy in graphic pack {}. Only the values 1, 2, 4, 8 or 16 are allowed.", anisotropyValue, m_filename);
|
||||
}
|
||||
m_texture_rules.emplace_back(rule);
|
||||
}
|
||||
|
|
|
@ -97,13 +97,12 @@ public:
|
|||
};
|
||||
using PresetPtr = std::shared_ptr<Preset>;
|
||||
|
||||
GraphicPack2(std::wstring filename);
|
||||
GraphicPack2(std::wstring filename, IniParser& rules);
|
||||
GraphicPack2(std::string filename, IniParser& rules);
|
||||
|
||||
bool IsEnabled() const { return m_enabled; }
|
||||
bool IsActivated() const { return m_activated; }
|
||||
sint32 GetVersion() const { return m_version; }
|
||||
const std::wstring& GetFilename() const { return m_filename; }
|
||||
const std::string& GetFilename() const { return m_filename; }
|
||||
const fs::path GetFilename2() const { return fs::path(m_filename); }
|
||||
bool RequiresRestart(bool changeEnableState, bool changePreset);
|
||||
bool Reload();
|
||||
|
@ -165,7 +164,7 @@ public:
|
|||
static const std::vector<std::shared_ptr<GraphicPack2>>& GetGraphicPacks() { return s_graphic_packs; }
|
||||
static const std::vector<std::shared_ptr<GraphicPack2>>& GetActiveGraphicPacks() { return s_active_graphic_packs; }
|
||||
static void LoadGraphicPack(fs::path graphicPackPath);
|
||||
static bool LoadGraphicPack(const std::wstring& filename, class IniParser& rules);
|
||||
static bool LoadGraphicPack(const std::string& filename, class IniParser& rules);
|
||||
static bool ActivateGraphicPack(const std::shared_ptr<GraphicPack2>& graphic_pack);
|
||||
static bool DeactivateGraphicPack(const std::shared_ptr<GraphicPack2>& graphic_pack);
|
||||
static void ClearGraphicPacks();
|
||||
|
@ -209,7 +208,7 @@ private:
|
|||
parser.TryAddConstant(var.first, (TType)var.second.second);
|
||||
}
|
||||
|
||||
std::wstring m_filename;
|
||||
std::string m_filename;
|
||||
|
||||
sint32 m_version;
|
||||
std::string m_name;
|
||||
|
|
|
@ -83,7 +83,7 @@ bool GraphicPack2::LoadCemuPatches()
|
|||
};
|
||||
|
||||
bool foundPatches = false;
|
||||
fs::path path(m_filename);
|
||||
fs::path path(_utf8ToPath(m_filename));
|
||||
path.remove_filename();
|
||||
for (auto& p : fs::directory_iterator(path))
|
||||
{
|
||||
|
@ -91,10 +91,10 @@ bool GraphicPack2::LoadCemuPatches()
|
|||
if (fs::is_regular_file(p.status()) && path.has_filename())
|
||||
{
|
||||
// check if filename matches
|
||||
std::wstring filename = path.filename().generic_wstring();
|
||||
if (boost::istarts_with(filename, L"patch_") && boost::iends_with(filename, L".asm"))
|
||||
std::string filename = _pathToUtf8(path.filename());
|
||||
if (boost::istarts_with(filename, "patch_") && boost::iends_with(filename, ".asm"))
|
||||
{
|
||||
FileStream* patchFile = FileStream::openFile(path.generic_wstring().c_str());
|
||||
FileStream* patchFile = FileStream::openFile2(path);
|
||||
if (patchFile)
|
||||
{
|
||||
// read file
|
||||
|
@ -126,27 +126,20 @@ void GraphicPack2::LoadPatchFiles()
|
|||
// order of loading patches:
|
||||
// 1) Load Cemu-style patches (patch_<name>.asm), stop here if at least one patch file exists
|
||||
// 2) Load Cemuhook patches.txt
|
||||
|
||||
// update: As of 1.20.2b Cemu always takes over patching since Cemuhook patching broke due to other internal changes (memory allocation changed and some reordering on when graphic packs get loaded)
|
||||
if (LoadCemuPatches())
|
||||
return; // exit if at least one Cemu style patch file was found
|
||||
// fall back to Cemuhook patches.txt to guarantee backward compatibility
|
||||
fs::path path(m_filename);
|
||||
fs::path path(_utf8ToPath(m_filename));
|
||||
path.remove_filename();
|
||||
path.append("patches.txt");
|
||||
|
||||
FileStream* patchFile = FileStream::openFile(path.generic_wstring().c_str());
|
||||
|
||||
FileStream* patchFile = FileStream::openFile2(path);
|
||||
if (patchFile == nullptr)
|
||||
return;
|
||||
|
||||
// read file
|
||||
std::vector<uint8> fileData;
|
||||
patchFile->extract(fileData);
|
||||
delete patchFile;
|
||||
|
||||
cemu_assert_debug(list_patchGroups.empty());
|
||||
|
||||
// parse
|
||||
MemStreamReader patchesStream(fileData.data(), (sint32)fileData.size());
|
||||
ParseCemuhookPatchesTxtInternal(patchesStream);
|
||||
|
|
|
@ -25,7 +25,7 @@ sint32 GraphicPack2::GetLengthWithoutComment(const char* str, size_t length)
|
|||
|
||||
void GraphicPack2::LogPatchesSyntaxError(sint32 lineNumber, std::string_view errorMsg)
|
||||
{
|
||||
cemuLog_log(LogType::Force, fmt::format(L"Syntax error while parsing patch for graphic pack '{}':", this->GetFilename()));
|
||||
cemuLog_log(LogType::Force, "Syntax error while parsing patch for graphic pack '{}':", this->GetFilename());
|
||||
if(lineNumber >= 0)
|
||||
cemuLog_log(LogType::Force, fmt::format("Line {0}: {1}", lineNumber, errorMsg));
|
||||
else
|
||||
|
|
|
@ -511,9 +511,9 @@ void debugger_enterTW(PPCInterpreter_t* hCPU)
|
|||
{
|
||||
if (bp->bpType == DEBUGGER_BP_T_LOGGING && bp->enabled)
|
||||
{
|
||||
std::wstring logName = !bp->comment.empty() ? L"Breakpoint '"+bp->comment+L"'" : fmt::format(L"Breakpoint at 0x{:08X} (no comment)", bp->address);
|
||||
std::wstring logContext = fmt::format(L"Thread: {:08x} LR: 0x{:08x}", coreinitThread_getCurrentThreadMPTRDepr(hCPU), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? L" Stack Trace:" : L"");
|
||||
cemuLog_log(LogType::Force, L"[Debugger] {} was executed! {}", logName, logContext);
|
||||
std::string logName = !bp->comment.empty() ? "Breakpoint '"+boost::nowide::narrow(bp->comment)+"'" : fmt::format("Breakpoint at 0x{:08X} (no comment)", bp->address);
|
||||
std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", coreinitThread_getCurrentThreadMPTRDepr(hCPU), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : "");
|
||||
cemuLog_log(LogType::Force, "[Debugger] {} was executed! {}", logName, logContext);
|
||||
if (cemuLog_advancedPPCLoggingEnabled())
|
||||
DebugLogStackTrace(coreinitThread_getCurrentThreadDepr(hCPU), hCPU->gpr[1]);
|
||||
break;
|
||||
|
|
|
@ -440,7 +440,7 @@ void RendererShaderVk::ShaderCacheLoading_begin(uint64 cacheTitleId)
|
|||
}
|
||||
uint32 spirvCacheMagic = GeneratePrecompiledCacheId();
|
||||
const std::string cacheFilename = fmt::format("{:016x}_spirv.bin", cacheTitleId);
|
||||
const std::wstring cachePath = ActiveSettings::GetCachePath("shaderCache/precompiled/{}", cacheFilename).generic_wstring();
|
||||
const fs::path cachePath = ActiveSettings::GetCachePath("shaderCache/precompiled/{}", cacheFilename);
|
||||
s_spirvCache = FileCache::Open(cachePath, true, spirvCacheMagic);
|
||||
if (s_spirvCache == nullptr)
|
||||
cemuLog_log(LogType::Force, "Unable to open SPIR-V cache {}", cacheFilename);
|
||||
|
|
|
@ -59,10 +59,10 @@ uint32 VulkanPipelineStableCache::BeginLoading(uint64 cacheTitleId)
|
|||
|
||||
// open cache file or create it
|
||||
cemu_assert_debug(s_cache == nullptr);
|
||||
s_cache = FileCache::Open(pathCacheFile.generic_wstring(), true, LatteShaderCache_getPipelineCacheExtraVersion(cacheTitleId));
|
||||
s_cache = FileCache::Open(pathCacheFile, true, LatteShaderCache_getPipelineCacheExtraVersion(cacheTitleId));
|
||||
if (!s_cache)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Failed to open or create Vulkan pipeline cache file: {}", pathCacheFile.generic_string());
|
||||
cemuLog_log(LogType::Force, "Failed to open or create Vulkan pipeline cache file: {}", _pathToUtf8(pathCacheFile));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -113,7 +113,7 @@ void iosuAct_loadAccounts()
|
|||
// }
|
||||
//}
|
||||
|
||||
cemuLog_log(LogType::Force, L"IOSU_ACT: using account {} in first slot", first_acc.GetMiiName());
|
||||
cemuLog_log(LogType::Force, "IOSU_ACT: using account {} in first slot", boost::nowide::narrow(first_acc.GetMiiName()));
|
||||
|
||||
_actAccountDataInitialized = true;
|
||||
}
|
||||
|
|
|
@ -615,10 +615,10 @@ void iosuCrypto_init()
|
|||
iosuCrypto_loadSSLCertificates();
|
||||
}
|
||||
|
||||
bool iosuCrypto_checkRequirementMLCFile(std::string_view mlcSubpath, std::wstring& additionalErrorInfo_filePath)
|
||||
bool iosuCrypto_checkRequirementMLCFile(std::string_view mlcSubpath, std::string& additionalErrorInfo_filePath)
|
||||
{
|
||||
const auto path = ActiveSettings::GetMlcPath(mlcSubpath);
|
||||
additionalErrorInfo_filePath = path.generic_wstring();
|
||||
additionalErrorInfo_filePath = _pathToUtf8(path);
|
||||
sint32 fileDataSize = 0;
|
||||
auto fileData = FileStream::LoadIntoMemory(path);
|
||||
if (!fileData)
|
||||
|
@ -626,7 +626,7 @@ bool iosuCrypto_checkRequirementMLCFile(std::string_view mlcSubpath, std::wstrin
|
|||
return true;
|
||||
}
|
||||
|
||||
sint32 iosuCrypt_checkRequirementsForOnlineMode(std::wstring& additionalErrorInfo)
|
||||
sint32 iosuCrypt_checkRequirementsForOnlineMode(std::string& additionalErrorInfo)
|
||||
{
|
||||
std::error_code ec;
|
||||
// check if otp.bin is present
|
||||
|
|
|
@ -74,7 +74,7 @@ enum
|
|||
IOS_CRYPTO_ONLINE_REQ_MISSING_FILE
|
||||
};
|
||||
|
||||
sint32 iosuCrypt_checkRequirementsForOnlineMode(std::wstring& additionalErrorInfo);
|
||||
sint32 iosuCrypt_checkRequirementsForOnlineMode(std::string& additionalErrorInfo);
|
||||
void iosuCrypto_readOtpData(void* output, sint32 wordIndex, sint32 size);
|
||||
|
||||
std::vector<const wchar_t*> iosuCrypt_getCertificateKeys();
|
||||
|
|
|
@ -180,7 +180,7 @@ struct
|
|||
bool hasOpenApplicationArea; // set to true if application area was opened or created
|
||||
// currently active Amiibo
|
||||
bool hasActiveAmiibo;
|
||||
std::wstring amiiboPath;
|
||||
fs::path amiiboPath;
|
||||
bool hasInvalidHMAC;
|
||||
uint32 amiiboTouchTime;
|
||||
AmiiboRawNFCData amiiboNFCData; // raw data
|
||||
|
@ -188,7 +188,6 @@ struct
|
|||
AmiiboProcessedData amiiboProcessedData;
|
||||
}nfp_data = { 0 };
|
||||
|
||||
bool nnNfp_touchNfcTagFromFile(const wchar_t* filePath, uint32* nfcError);
|
||||
bool nnNfp_writeCurrentAmiibo();
|
||||
|
||||
#include "AmiiboCrypto.h"
|
||||
|
@ -770,7 +769,7 @@ void nnNfp_unloadAmiibo()
|
|||
nnNfpUnlock();
|
||||
}
|
||||
|
||||
bool nnNfp_touchNfcTagFromFile(const wchar_t* filePath, uint32* nfcError)
|
||||
bool nnNfp_touchNfcTagFromFile(const fs::path& filePath, uint32* nfcError)
|
||||
{
|
||||
AmiiboRawNFCData rawData = { 0 };
|
||||
auto nfcData = FileStream::LoadIntoMemory(filePath);
|
||||
|
@ -847,11 +846,11 @@ bool nnNfp_touchNfcTagFromFile(const wchar_t* filePath, uint32* nfcError)
|
|||
memcpy(&nfp_data.amiiboNFCData, &rawData, sizeof(AmiiboRawNFCData));
|
||||
// decrypt amiibo
|
||||
amiiboDecrypt();
|
||||
nfp_data.amiiboPath = std::wstring(filePath);
|
||||
nfp_data.amiiboPath = filePath;
|
||||
nfp_data.hasActiveAmiibo = true;
|
||||
if (nfp_data.activateEvent)
|
||||
{
|
||||
coreinit::OSEvent* osEvent = (coreinit::OSEvent*)memory_getPointerFromVirtualOffset(nfp_data.activateEvent);
|
||||
MEMPTR<coreinit::OSEvent> osEvent(nfp_data.activateEvent);
|
||||
coreinit::OSSignalEvent(osEvent);
|
||||
}
|
||||
nfp_data.amiiboTouchTime = GetTickCount();
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace nn::nfp
|
|||
void nnNfp_load();
|
||||
void nnNfp_update();
|
||||
|
||||
bool nnNfp_touchNfcTagFromFile(const wchar_t* filePath, uint32* nfcError);
|
||||
bool nnNfp_touchNfcTagFromFile(const fs::path& filePath, uint32* nfcError);
|
||||
|
||||
#define NFP_STATE_NONE (0)
|
||||
#define NFP_STATE_INIT (1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue