diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index b964b6b84a..874ef461b5 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -71,7 +71,7 @@ namespace AudioCommon { std::string audio_file_name = File::GetUserPath(D_DUMPAUDIO_IDX) + "audiodump.wav"; File::CreateFullPath(audio_file_name); - mixer->StartLogAudio(audio_file_name.c_str()); + mixer->StartLogAudio(audio_file_name); } return soundStream; diff --git a/Source/Core/AudioCommon/Mixer.h b/Source/Core/AudioCommon/Mixer.h index 2fb2d2961c..a892618cca 100644 --- a/Source/Core/AudioCommon/Mixer.h +++ b/Source/Core/AudioCommon/Mixer.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "AudioCommon/WaveFile.h" #include "Common/StdMutex.h" @@ -57,23 +59,31 @@ public: // --------------------- - virtual void StartLogAudio(const char *filename) { - if (! m_logAudio) { + virtual void StartLogAudio(const std::string& filename) + { + if (! m_logAudio) + { m_logAudio = true; g_wave_writer.Start(filename, GetSampleRate()); g_wave_writer.SetSkipSilence(false); NOTICE_LOG(DSPHLE, "Starting Audio logging"); - } else { + } + else + { WARN_LOG(DSPHLE, "Audio logging has already been started"); } } - virtual void StopLogAudio() { - if (m_logAudio) { + virtual void StopLogAudio() + { + if (m_logAudio) + { m_logAudio = false; g_wave_writer.Stop(); NOTICE_LOG(DSPHLE, "Stopping Audio logging"); - } else { + } + else + { WARN_LOG(DSPHLE, "Audio logging has already been stopped"); } } diff --git a/Source/Core/AudioCommon/WaveFile.cpp b/Source/Core/AudioCommon/WaveFile.cpp index facf59a79a..a9f1e2ca08 100644 --- a/Source/Core/AudioCommon/WaveFile.cpp +++ b/Source/Core/AudioCommon/WaveFile.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "AudioCommon/WaveFile.h" #include "Common/Common.h" #include "Core/ConfigManager.h" @@ -21,7 +23,7 @@ WaveFileWriter::~WaveFileWriter() Stop(); } -bool WaveFileWriter::Start(const char *filename, unsigned int HLESampleRate) +bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRate) { if (!conv_buffer) conv_buffer = new short[BUF_SIZE]; @@ -29,14 +31,14 @@ bool WaveFileWriter::Start(const char *filename, unsigned int HLESampleRate) // Check if the file is already open if (file) { - PanicAlertT("The file %s was already open, the file header will not be written.", filename); + PanicAlertT("The file %s was already open, the file header will not be written.", filename.c_str()); return false; } file.Open(filename, "wb"); if (!file) { - PanicAlertT("The file %s could not be opened for writing. Please check if it's already opened by another program.", filename); + PanicAlertT("The file %s could not be opened for writing. Please check if it's already opened by another program.", filename.c_str()); return false; } diff --git a/Source/Core/AudioCommon/WaveFile.h b/Source/Core/AudioCommon/WaveFile.h index baa7b0434f..a9eafd24f7 100644 --- a/Source/Core/AudioCommon/WaveFile.h +++ b/Source/Core/AudioCommon/WaveFile.h @@ -14,6 +14,7 @@ #pragma once +#include #include "Common/FileUtil.h" class WaveFileWriter @@ -31,7 +32,7 @@ public: WaveFileWriter(); ~WaveFileWriter(); - bool Start(const char *filename, unsigned int HLESampleRate); + bool Start(const std::string& filename, unsigned int HLESampleRate); void Stop(); void SetSkipSilence(bool skip) { skip_silence = skip; } diff --git a/Source/Core/Common/ChunkFile.h b/Source/Core/Common/ChunkFile.h index e89b98ad99..10eb2baa8d 100644 --- a/Source/Core/Common/ChunkFile.h +++ b/Source/Core/Common/ChunkFile.h @@ -262,7 +262,7 @@ public: } } - void DoMarker(const char* prevName, u32 arbitraryNumber = 0x42) + void DoMarker(const std::string& prevName, u32 arbitraryNumber = 0x42) { u32 cookie = arbitraryNumber; Do(cookie); @@ -270,7 +270,7 @@ public: if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber) { PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", - prevName, cookie, cookie, arbitraryNumber, arbitraryNumber); + prevName.c_str(), cookie, cookie, arbitraryNumber, arbitraryNumber); mode = PointerWrap::MODE_MEASURE; } } diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 7483ec693f..c06f4601a9 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -939,12 +939,12 @@ std::string GetThemeDir(const std::string& theme_name) return dir; } -bool WriteStringToFile(const std::string &str, const char *filename) +bool WriteStringToFile(const std::string &str, const std::string& filename) { return File::IOFile(filename, "wb").WriteBytes(str.data(), str.size()); } -bool ReadFileToString(const char *filename, std::string &str) +bool ReadFileToString(const std::string& filename, std::string &str) { File::IOFile file(filename, "rb"); auto const f = file.GetHandle(); diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index deac3814c0..b587129761 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -143,8 +143,8 @@ std::string GetBundleDirectory(); std::string &GetExeDirectory(); #endif -bool WriteStringToFile(const std::string &str, const char *filename); -bool ReadFileToString(const char *filename, std::string &str); +bool WriteStringToFile(const std::string& str, const std::string& filename); +bool ReadFileToString(const std::string& filename, std::string& str); // simple wrapper for cstdlib file functions to // hopefully will make error checking easier diff --git a/Source/Core/Common/LinearDiskCache.h b/Source/Core/Common/LinearDiskCache.h index f431479b24..418d125bc7 100644 --- a/Source/Core/Common/LinearDiskCache.h +++ b/Source/Core/Common/LinearDiskCache.h @@ -6,6 +6,7 @@ #include #include +#include #include "Common/Common.h" #include "Common/FileUtil.h" @@ -48,7 +49,7 @@ class LinearDiskCache { public: // return number of read entries - u32 OpenAndRead(const char *filename, LinearDiskCacheReader &reader) + u32 OpenAndRead(const std::string& filename, LinearDiskCacheReader &reader) { using std::ios_base; diff --git a/Source/Core/Common/SDCardUtil.cpp b/Source/Core/Common/SDCardUtil.cpp index 7f3d21a26b..7b793500d9 100644 --- a/Source/Core/Common/SDCardUtil.cpp +++ b/Source/Core/Common/SDCardUtil.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "Common/Common.h" #include "Common/FileUtil.h" @@ -188,7 +189,7 @@ static unsigned int write_empty(FILE* file, u64 count) return 0; } -bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename) +bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename) { u32 sectors_per_fat; u32 sectors_per_disk; @@ -196,7 +197,8 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename) // Convert MB to bytes disk_size *= 1024 * 1024; - if (disk_size < 0x800000 || disk_size > 0x800000000ULL) { + if (disk_size < 0x800000 || disk_size > 0x800000000ULL) + { ERROR_LOG(COMMON, "Trying to create SD Card image of size %" PRIu64 "MB is out of range (8MB-32GB)", disk_size/(1024*1024)); return false; } @@ -212,7 +214,7 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename) FILE* const f = file.GetHandle(); if (!f) { - ERROR_LOG(COMMON, "Could not create file '%s', aborting...\n", filename); + ERROR_LOG(COMMON, "Could not create file '%s', aborting...\n", filename.c_str()); return false; } @@ -229,31 +231,51 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename) * zero sectors */ - if (write_sector(f, s_boot_sector)) goto FailWrite; - if (write_sector(f, s_fsinfo_sector)) goto FailWrite; + if (write_sector(f, s_boot_sector)) + goto FailWrite; + + if (write_sector(f, s_fsinfo_sector)) + goto FailWrite; + if (BACKUP_BOOT_SECTOR > 0) { - if (write_empty(f, BACKUP_BOOT_SECTOR - 2)) goto FailWrite; - if (write_sector(f, s_boot_sector)) goto FailWrite; - if (write_sector(f, s_fsinfo_sector)) goto FailWrite; - if (write_empty(f, RESERVED_SECTORS - 2 - BACKUP_BOOT_SECTOR)) goto FailWrite; + if (write_empty(f, BACKUP_BOOT_SECTOR - 2)) + goto FailWrite; + + if (write_sector(f, s_boot_sector)) + goto FailWrite; + + if (write_sector(f, s_fsinfo_sector)) + goto FailWrite; + + if (write_empty(f, RESERVED_SECTORS - 2 - BACKUP_BOOT_SECTOR)) + goto FailWrite; } else + { if (write_empty(f, RESERVED_SECTORS - 2)) goto FailWrite; + } - if (write_sector(f, s_fat_head)) goto FailWrite; - if (write_empty(f, sectors_per_fat-1)) goto FailWrite; + if (write_sector(f, s_fat_head)) + goto FailWrite; - if (write_sector(f, s_fat_head)) goto FailWrite; - if (write_empty(f, sectors_per_fat-1)) goto FailWrite; + if (write_empty(f, sectors_per_fat - 1)) + goto FailWrite; - if (write_empty(f, sectors_per_disk - RESERVED_SECTORS - 2*sectors_per_fat)) goto FailWrite; + if (write_sector(f, s_fat_head)) + goto FailWrite; + + if (write_empty(f, sectors_per_fat - 1)) + goto FailWrite; + + if (write_empty(f, sectors_per_disk - RESERVED_SECTORS - 2*sectors_per_fat)) + goto FailWrite; return true; FailWrite: - ERROR_LOG(COMMON, "Could not write to '%s', aborting...\n", filename); - if (unlink(filename) < 0) - ERROR_LOG(COMMON, "unlink(%s) failed\n%s", filename, GetLastErrorMsg()); + ERROR_LOG(COMMON, "Could not write to '%s', aborting...\n", filename.c_str()); + if (unlink(filename.c_str()) < 0) + ERROR_LOG(COMMON, "unlink(%s) failed\n%s", filename.c_str(), GetLastErrorMsg()); return false; } diff --git a/Source/Core/Common/SDCardUtil.h b/Source/Core/Common/SDCardUtil.h index 6f95b2c96b..5cc234fddb 100644 --- a/Source/Core/Common/SDCardUtil.h +++ b/Source/Core/Common/SDCardUtil.h @@ -4,6 +4,7 @@ #pragma once +#include #include "Common/CommonTypes.h" -bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename); +bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename); diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 9a42d35fd6..16281ac91f 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -26,10 +26,10 @@ #endif // faster than sscanf -bool AsciiToHex(const char* _szValue, u32& result) +bool AsciiToHex(const std::string& _szValue, u32& result) { char *endptr = nullptr; - const u32 value = strtoul(_szValue, &endptr, 16); + const u32 value = strtoul(_szValue.c_str(), &endptr, 16); if (!endptr || *endptr) return false; diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 397a289a37..50d270e732 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -76,7 +76,7 @@ static bool TryParse(const std::string &str, N *const output) } // TODO: kill this -bool AsciiToHex(const char* _szValue, u32& result); +bool AsciiToHex(const std::string& _szValue, u32& result); std::string TabsToSpaces(int tab_size, const std::string &in); diff --git a/Source/Core/Common/SymbolDB.cpp b/Source/Core/Common/SymbolDB.cpp index c78a61ea8b..59b015a166 100644 --- a/Source/Core/Common/SymbolDB.cpp +++ b/Source/Core/Common/SymbolDB.cpp @@ -39,13 +39,14 @@ void SymbolDB::Index() } } -Symbol *SymbolDB::GetSymbolFromName(const char *name) +Symbol* SymbolDB::GetSymbolFromName(const std::string& name) { for (auto& func : functions) { - if (!strcmp(func.second.name.c_str(), name)) + if (func.second.name == name) return &func.second; } + return nullptr; } diff --git a/Source/Core/Common/SymbolDB.h b/Source/Core/Common/SymbolDB.h index 26d0d2c4be..35edd1e021 100644 --- a/Source/Core/Common/SymbolDB.h +++ b/Source/Core/Common/SymbolDB.h @@ -80,12 +80,13 @@ public: SymbolDB() {} virtual ~SymbolDB() {} virtual Symbol *GetSymbolFromAddr(u32 addr) { return nullptr; } - virtual Symbol *AddFunction(u32 startAddr) { return nullptr;} + virtual Symbol *AddFunction(u32 startAddr) { return nullptr; } void AddCompleteSymbol(const Symbol &symbol); - Symbol *GetSymbolFromName(const char *name); - Symbol *GetSymbolFromHash(u32 hash) { + Symbol* GetSymbolFromName(const std::string& name); + Symbol* GetSymbolFromHash(u32 hash) + { XFuncPtrMap::iterator iter = checksumToFunction.find(hash); if (iter != checksumToFunction.end()) return iter->second; @@ -93,8 +94,8 @@ public: return nullptr; } - const XFuncMap &Symbols() const {return functions;} - XFuncMap &AccessSymbols() {return functions;} + const XFuncMap &Symbols() const { return functions; } + XFuncMap &AccessSymbols() { return functions; } void Clear(const char *prefix = ""); void List(); diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index a352b438ac..6cd4f1bce2 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -16,7 +16,7 @@ SysConf::SysConf() : m_IsValid(false) { m_FilenameDefault = File::GetUserPath(F_WIISYSCONF_IDX); - m_IsValid = LoadFromFile(m_FilenameDefault.c_str()); + m_IsValid = LoadFromFile(m_FilenameDefault); } SysConf::~SysConf() @@ -32,10 +32,11 @@ void SysConf::Clear() { for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i) delete [] i->data; + m_Entries.clear(); } -bool SysConf::LoadFromFile(const char *filename) +bool SysConf::LoadFromFile(const std::string& filename) { // Basic check if (!File::Exists(filename)) @@ -55,7 +56,9 @@ bool SysConf::LoadFromFile(const char *filename) return true; } else + { return false; + } } File::IOFile f(filename, "rb"); @@ -361,7 +364,7 @@ void SysConf::GenerateSysConf() m_Filename = m_FilenameDefault; } -bool SysConf::SaveToFile(const char *filename) +bool SysConf::SaveToFile(const std::string& filename) { File::IOFile f(filename, "r+b"); @@ -393,7 +396,8 @@ bool SysConf::Save() { if (!m_IsValid) return false; - return SaveToFile(m_Filename.c_str()); + + return SaveToFile(m_Filename); } void SysConf::UpdateLocation() @@ -416,6 +420,6 @@ bool SysConf::Reload() std::string& filename = m_Filename.empty() ? m_FilenameDefault : m_Filename; - m_IsValid = LoadFromFile(filename.c_str()); + m_IsValid = LoadFromFile(filename); return m_IsValid; } diff --git a/Source/Core/Common/SysConf.h b/Source/Core/Common/SysConf.h index 3c2f81b8af..0edd1bbd4a 100644 --- a/Source/Core/Common/SysConf.h +++ b/Source/Core/Common/SysConf.h @@ -163,8 +163,8 @@ public: } bool Save(); - bool SaveToFile(const char* filename); - bool LoadFromFile(const char* filename); + bool SaveToFile(const std::string& filename); + bool LoadFromFile(const std::string& filename); bool Reload(); // This function is used when the NAND root is changed void UpdateLocation(); diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index fea7154759..978755e1f7 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -126,7 +126,7 @@ bool CBoot::LoadMapFromFilename() { std::string strMapFilename; bool found = FindMapFile(&strMapFilename, nullptr); - if (found && g_symbolDB.LoadMap(strMapFilename.c_str())) + if (found && g_symbolDB.LoadMap(strMapFilename)) { UpdateDebugger_MapLoaded(); return true; @@ -149,7 +149,7 @@ bool CBoot::Load_BS2(const std::string& _rBootROMFilename) // Load the whole ROM dump std::string data; - if (!File::ReadFileToString(_rBootROMFilename.c_str(), data)) + if (!File::ReadFileToString(_rBootROMFilename, data)) return false; u32 ipl_hash = HashAdler32((const u8*)data.data(), data.size()); @@ -247,7 +247,7 @@ bool CBoot::BootUp() { PPCAnalyst::FindFunctions(0x80004000, 0x811fffff, &g_symbolDB); SignatureDB db; - if (db.Load((File::GetSysDirectory() + TOTALDB).c_str())) + if (db.Load(File::GetSysDirectory() + TOTALDB)) { db.Apply(&g_symbolDB); HLE::PatchFunctions(); @@ -268,7 +268,7 @@ bool CBoot::BootUp() // DOL case SCoreStartupParameter::BOOT_DOL: { - CDolLoader dolLoader(_StartupPara.m_strFilename.c_str()); + CDolLoader dolLoader(_StartupPara.m_strFilename); // Check if we have gotten a Wii file or not bool dolWii = dolLoader.IsWii(); if (dolWii != _StartupPara.bWii) @@ -284,7 +284,7 @@ bool CBoot::BootUp() } else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty()) { - VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str()); + VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM); BS2Success = EmulatedBS2(dolWii); } @@ -320,7 +320,7 @@ bool CBoot::BootUp() } // Check if we have gotten a Wii file or not - bool elfWii = IsElfWii(_StartupPara.m_strFilename.c_str()); + bool elfWii = IsElfWii(_StartupPara.m_strFilename); if (elfWii != _StartupPara.bWii) { PanicAlertT("Warning - starting ELF in wrong console mode!"); @@ -334,7 +334,7 @@ bool CBoot::BootUp() } else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty()) { - VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str()); + VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM); BS2Success = EmulatedBS2(elfWii); } @@ -362,7 +362,7 @@ bool CBoot::BootUp() else // Poor man's bootup { Load_FST(elfWii); - Boot_ELF(_StartupPara.m_strFilename.c_str()); + Boot_ELF(_StartupPara.m_strFilename); } UpdateDebugger_MapLoaded(); Dolphin_Debugger::AddAutoBreakpoints(); @@ -371,7 +371,7 @@ bool CBoot::BootUp() // Wii WAD case SCoreStartupParameter::BOOT_WII_NAND: - Boot_WiiWAD(_StartupPara.m_strFilename.c_str()); + Boot_WiiWAD(_StartupPara.m_strFilename); if (LoadMapFromFilename()) HLE::PatchFunctions(); diff --git a/Source/Core/Core/Boot/Boot.h b/Source/Core/Core/Boot/Boot.h index e2a1be41bf..3a5efedc5e 100644 --- a/Source/Core/Core/Boot/Boot.h +++ b/Source/Core/Core/Boot/Boot.h @@ -25,7 +25,7 @@ class CBoot public: static bool BootUp(); - static bool IsElfWii(const char *filename); + static bool IsElfWii(const std::string& filename); // Tries to find a map file for the current game by looking first in the // local user directory, then in the shared user directory. @@ -46,8 +46,8 @@ private: static void UpdateDebugger_MapLoaded(const char* _gameID = nullptr); static bool LoadMapFromFilename(); - static bool Boot_ELF(const char *filename); - static bool Boot_WiiWAD(const char *filename); + static bool Boot_ELF(const std::string& filename); + static bool Boot_WiiWAD(const std::string& filename); static bool EmulatedBS2_GC(); static bool EmulatedBS2_Wii(); diff --git a/Source/Core/Core/Boot/Boot_DOL.cpp b/Source/Core/Core/Boot/Boot_DOL.cpp index 009d122f35..31050df12b 100644 --- a/Source/Core/Core/Boot/Boot_DOL.cpp +++ b/Source/Core/Core/Boot/Boot_DOL.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/CommonFuncs.h" #include "Common/FileUtil.h" @@ -14,14 +16,14 @@ CDolLoader::CDolLoader(u8* _pBuffer, u32 _Size) Initialize(_pBuffer, _Size); } -CDolLoader::CDolLoader(const char* _szFilename) +CDolLoader::CDolLoader(const std::string& filename) : m_isWii(false) { - const u64 size = File::GetSize(_szFilename); + const u64 size = File::GetSize(filename); u8* const tmpBuffer = new u8[(size_t)size]; { - File::IOFile pStream(_szFilename, "rb"); + File::IOFile pStream(filename, "rb"); pStream.ReadBytes(tmpBuffer, (size_t)size); } diff --git a/Source/Core/Core/Boot/Boot_DOL.h b/Source/Core/Core/Boot/Boot_DOL.h index e406875f8a..535c651c47 100644 --- a/Source/Core/Core/Boot/Boot_DOL.h +++ b/Source/Core/Core/Boot/Boot_DOL.h @@ -4,12 +4,14 @@ #pragma once +#include + #include "Common/CommonTypes.h" class CDolLoader { public: - CDolLoader(const char* _szFilename); + CDolLoader(const std::string& filename); CDolLoader(u8* _pBuffer, u32 _Size); ~CDolLoader(); diff --git a/Source/Core/Core/Boot/Boot_ELF.cpp b/Source/Core/Core/Boot/Boot_ELF.cpp index 5f4b41b27d..37e0d23cb9 100644 --- a/Source/Core/Core/Boot/Boot_ELF.cpp +++ b/Source/Core/Core/Boot/Boot_ELF.cpp @@ -10,7 +10,7 @@ #include "Core/HLE/HLE.h" #include "Core/PowerPC/PowerPC.h" -bool CBoot::IsElfWii(const char *filename) +bool CBoot::IsElfWii(const std::string& filename) { /* We already check if filename existed before we called this function, so there is no need for another check, just read the file right away */ @@ -55,7 +55,7 @@ bool CBoot::IsElfWii(const char *filename) } -bool CBoot::Boot_ELF(const char *filename) +bool CBoot::Boot_ELF(const std::string& filename) { const u64 filesize = File::GetSize(filename); u8 *mem = new u8[(size_t)filesize]; diff --git a/Source/Core/Core/Boot/Boot_WiiWAD.cpp b/Source/Core/Core/Boot/Boot_WiiWAD.cpp index 1cd25cf3d7..03fa4a2548 100644 --- a/Source/Core/Core/Boot/Boot_WiiWAD.cpp +++ b/Source/Core/Core/Boot/Boot_WiiWAD.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include "Common/CommonPaths.h" #include "Common/FileUtil.h" @@ -45,9 +46,8 @@ typedef struct { u32 unknown[6]; } StateFlags; -bool CBoot::Boot_WiiWAD(const char* _pFilename) +bool CBoot::Boot_WiiWAD(const std::string& _pFilename) { - std::string state_filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_STATE); if (File::Exists(state_filename)) @@ -102,7 +102,7 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename) } else { - pDolLoader.reset(new CDolLoader(pContent->m_Filename.c_str())); + pDolLoader.reset(new CDolLoader(pContent->m_Filename)); } pDolLoader->Load(); PC = pDolLoader->GetEntryPoint() | 0x80000000; diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 2c5aa48724..12c662ceda 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #ifdef _WIN32 #include #include "VideoCommon/EmuWindow.h" @@ -109,15 +111,17 @@ bool PanicAlertToVideo(const char* text, bool yes_no) return true; } -void DisplayMessage(const char *message, int time_in_ms) +void DisplayMessage(const std::string& message, int time_in_ms) { SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; // Actually displaying non-ASCII could cause things to go pear-shaped - for (const char *c = message; *c != '\0'; ++c) - if (*c < ' ') + for (const char& c : message) + { + if (!std::isprint(c)) return; + } g_video_backend->Video_AddMessage(message, time_in_ms); @@ -575,7 +579,7 @@ void SaveScreenShot() SetState(CORE_PAUSE); - g_video_backend->Video_Screenshot(GenerateScreenshotName().c_str()); + g_video_backend->Video_Screenshot(GenerateScreenshotName()); if (!bPaused) SetState(CORE_RUN); @@ -716,13 +720,11 @@ void UpdateTitle() #endif // This is our final "frame counter" string - std::string SMessage = StringFromFormat("%s | %s", - SSettings.c_str(), SFPS.c_str()); - std::string TMessage = StringFromFormat("%s | ", scm_rev_str) + - SMessage; + std::string SMessage = StringFromFormat("%s | %s", SSettings.c_str(), SFPS.c_str()); + std::string TMessage = StringFromFormat("%s | %s", scm_rev_str, SMessage.c_str()); // Show message - g_video_backend->UpdateFPSDisplay(SMessage.c_str()); + g_video_backend->UpdateFPSDisplay(SMessage); // Update the audio timestretcher with the current speed if (soundStream) @@ -734,11 +736,13 @@ void UpdateTitle() if (_CoreParameter.bRenderToMain && SConfig::GetInstance().m_InterfaceStatusbar) { - Host_UpdateStatusBar(SMessage.c_str()); + Host_UpdateStatusBar(SMessage); Host_UpdateTitle(scm_rev_str); } else - Host_UpdateTitle(TMessage.c_str()); + { + Host_UpdateTitle(TMessage); } +} } // Core diff --git a/Source/Core/Core/Core.h b/Source/Core/Core/Core.h index 4e750108dc..c841fac08e 100644 --- a/Source/Core/Core/Core.h +++ b/Source/Core/Core/Core.h @@ -59,12 +59,7 @@ void* GetWindowHandle(); void StartTrace(bool write); // This displays messages in a user-visible way. -void DisplayMessage(const char *message, int time_in_ms); - -inline void DisplayMessage(const std::string &message, int time_in_ms) -{ - DisplayMessage(message.c_str(), time_in_ms); -} +void DisplayMessage(const std::string& message, int time_in_ms); std::string GetStateFileName(); void SetStateFileName(std::string val); diff --git a/Source/Core/Core/CoreParameter.cpp b/Source/Core/Core/CoreParameter.cpp index c18d7e1f47..630ab4c5b3 100644 --- a/Source/Core/Core/CoreParameter.cpp +++ b/Source/Core/Core/CoreParameter.cpp @@ -190,14 +190,14 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) } else if (!strcasecmp(Extension.c_str(), ".elf")) { - bWii = CBoot::IsElfWii(m_strFilename.c_str()); + bWii = CBoot::IsElfWii(m_strFilename); Region = USA_DIR; m_BootType = BOOT_ELF; bNTSC = true; } else if (!strcasecmp(Extension.c_str(), ".dol")) { - CDolLoader dolfile(m_strFilename.c_str()); + CDolLoader dolfile(m_strFilename); bWii = dolfile.IsWii(); Region = USA_DIR; m_BootType = BOOT_DOL; diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index 00b1d56ef9..a520fa92f1 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include "Common/FifoQueue.h" @@ -23,7 +24,7 @@ namespace CoreTiming struct EventType { TimedCallback callback; - const char *name; + std::string name; }; std::vector event_types; @@ -79,7 +80,7 @@ void FreeEvent(Event* ev) static void EmptyTimedCallback(u64 userdata, int cyclesLate) {} -int RegisterEvent(const char *name, TimedCallback callback) +int RegisterEvent(const std::string& name, TimedCallback callback) { EventType type; type.name = name; @@ -89,9 +90,9 @@ int RegisterEvent(const char *name, TimedCallback callback) // we want event type names to remain unique so that we can use them for serialization. for (auto& event_type : event_types) { - if (!strcmp(name, event_type.name)) + if (name == event_type.name) { - WARN_LOG(POWERPC, "Discarded old event type \"%s\" because a new type with the same name was registered.", name); + WARN_LOG(POWERPC, "Discarded old event type \"%s\" because a new type with the same name was registered.", name.c_str()); // we don't know if someone might be holding on to the type index, // so we gut the old event type instead of actually removing it. event_type.name = "_discarded_event"; @@ -154,7 +155,7 @@ void EventDoState(PointerWrap &p, BaseEvent* ev) bool foundMatch = false; for (unsigned int i = 0; i < event_types.size(); ++i) { - if (!strcmp(name.c_str(), event_types[i].name)) + if (name == event_types[i].name) { ev->type = i; foundMatch = true; @@ -467,11 +468,9 @@ std::string GetScheduledEventsSummary() if (t >= event_types.size()) PanicAlertT("Invalid event type %i", t); - const char *name = event_types[ptr->type].name; - if (!name) - name = "[unknown]"; + const std::string& name = event_types[ptr->type].name; - text += StringFromFormat("%s : %" PRIi64 " %016" PRIx64 "\n", name, ptr->time, ptr->userdata); + text += StringFromFormat("%s : %" PRIi64 " %016" PRIx64 "\n", name.c_str(), ptr->time, ptr->userdata); ptr = ptr->next; } return text; diff --git a/Source/Core/Core/CoreTiming.h b/Source/Core/Core/CoreTiming.h index 29c425ac6c..f064cc10ca 100644 --- a/Source/Core/Core/CoreTiming.h +++ b/Source/Core/Core/CoreTiming.h @@ -36,7 +36,7 @@ u64 GetIdleTicks(); void DoState(PointerWrap &p); // Returns the event_type identifier. if name is not unique, an existing event_type will be discarded. -int RegisterEvent(const char *name, TimedCallback callback); +int RegisterEvent(const std::string& name, TimedCallback callback); void UnregisterAllEvents(); // userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from disk, diff --git a/Source/Core/Core/DSP/DSPAssembler.cpp b/Source/Core/Core/DSP/DSPAssembler.cpp index 4c75758886..064428a640 100644 --- a/Source/Core/Core/DSP/DSPAssembler.cpp +++ b/Source/Core/Core/DSP/DSPAssembler.cpp @@ -42,6 +42,7 @@ Initial import #include #include #include +#include #include "Common/Common.h" #include "Common/FileUtil.h" @@ -94,7 +95,7 @@ DSPAssembler::~DSPAssembler() free(gdg_buffer); } -bool DSPAssembler::Assemble(const char *text, std::vector &code, std::vector *line_numbers) +bool DSPAssembler::Assemble(const std::string& text, std::vector &code, std::vector *line_numbers) { if (line_numbers) line_numbers->clear(); diff --git a/Source/Core/Core/DSP/DSPAssembler.h b/Source/Core/Core/DSP/DSPAssembler.h index bc9e290c9d..751509271d 100644 --- a/Source/Core/Core/DSP/DSPAssembler.h +++ b/Source/Core/Core/DSP/DSPAssembler.h @@ -73,7 +73,7 @@ public: // one for each word of code, indicating the source assembler code line number it came from. // If returns false, call GetErrorString to get some text to present to the user. - bool Assemble(const char *text, std::vector &code, std::vector *line_numbers = nullptr); + bool Assemble(const std::string& text, std::vector &code, std::vector *line_numbers = nullptr); std::string GetErrorString() const { return last_error_str; } err_t GetError() const { return last_error; } diff --git a/Source/Core/Core/DSP/DSPCodeUtil.cpp b/Source/Core/Core/DSP/DSPCodeUtil.cpp index 560fce53de..3d4050dbe8 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.cpp +++ b/Source/Core/Core/DSP/DSPCodeUtil.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include "Common/Common.h" @@ -13,7 +14,7 @@ #include "Core/DSP/DSPCodeUtil.h" #include "Core/DSP/DSPDisassembler.h" -bool Assemble(const char *text, std::vector &code, bool force) +bool Assemble(const std::string& text, std::vector &code, bool force) { AssemblerSettings settings; // settings.pc = 0; @@ -194,7 +195,7 @@ void BinaryStringBEToCode(const std::string &str, std::vector &code) } } -bool LoadBinary(const char *filename, std::vector &code) +bool LoadBinary(const std::string& filename, std::vector &code) { std::string buffer; if (!File::ReadFileToString(filename, buffer)) @@ -204,7 +205,7 @@ bool LoadBinary(const char *filename, std::vector &code) return true; } -bool SaveBinary(const std::vector &code, const char *filename) +bool SaveBinary(const std::vector &code, const std::string& filename) { std::string buffer; CodeToBinaryStringBE(code, buffer); diff --git a/Source/Core/Core/DSP/DSPCodeUtil.h b/Source/Core/Core/DSP/DSPCodeUtil.h index ccfa9c97ce..5813b011e5 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.h +++ b/Source/Core/Core/DSP/DSPCodeUtil.h @@ -9,7 +9,7 @@ #include "Common/Common.h" -bool Assemble(const char *text, std::vector &code, bool force = false); +bool Assemble(const std::string& text, std::vector &code, bool force = false); bool Disassemble(const std::vector &code, bool line_numbers, std::string &text); bool Compare(const std::vector &code1, const std::vector &code2); void GenRandomCode(u32 size, std::vector &code); @@ -23,5 +23,5 @@ void CodeToBinaryStringBE(const std::vector &code, std::string &str); void BinaryStringBEToCode(const std::string &str, std::vector &code); // Load code (big endian binary). -bool LoadBinary(const char *filename, std::vector &code); -bool SaveBinary(const std::vector &code, const char *filename); +bool LoadBinary(const std::string& filename, std::vector &code); +bool SaveBinary(const std::vector &code, const std::string& filename); diff --git a/Source/Core/Core/DSP/DSPCore.cpp b/Source/Core/Core/DSP/DSPCore.cpp index 2be2f8e907..520db9ac49 100644 --- a/Source/Core/Core/DSP/DSPCore.cpp +++ b/Source/Core/Core/DSP/DSPCore.cpp @@ -44,7 +44,7 @@ bool init_hax = false; DSPEmitter *dspjit = nullptr; Common::Event step_event; -static bool LoadRom(const char *fname, int size_in_words, u16 *rom) +static bool LoadRom(const std::string& fname, int size_in_words, u16 *rom) { File::IOFile pFile(fname, "rb"); const size_t size_in_bytes = size_in_words * sizeof(u16); @@ -70,12 +70,12 @@ static bool LoadRom(const char *fname, int size_in_words, u16 *rom) "Use DSPSpy to dump the file from your physical console.\n" "\n" "You may use the DSP HLE engine which does not require ROM dumps.\n" - "(Choose it from the \"Audio\" tab of the configuration dialog.)", fname); + "(Choose it from the \"Audio\" tab of the configuration dialog.)", fname.c_str()); return false; } // Returns false iff the hash fails and the user hits "Yes" -static bool VerifyRoms(const char *irom_filename, const char *coef_filename) +static bool VerifyRoms(const std::string& irom_filename, const std::string& coef_filename) { struct DspRomHashes { @@ -136,8 +136,7 @@ static void DSPCore_FreeMemoryPages() g_dsp.irom = g_dsp.iram = g_dsp.dram = g_dsp.coef = nullptr; } -bool DSPCore_Init(const char *irom_filename, const char *coef_filename, - bool bUsingJIT) +bool DSPCore_Init(const std::string& irom_filename, const std::string& coef_filename, bool bUsingJIT) { g_dsp.step_counter = 0; cyclesLeft = 0; @@ -155,8 +154,8 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename, // Try to load real ROM contents. if (!LoadRom(irom_filename, DSP_IROM_SIZE, g_dsp.irom) || - !LoadRom(coef_filename, DSP_COEF_SIZE, g_dsp.coef) || - !VerifyRoms(irom_filename, coef_filename)) + !LoadRom(coef_filename, DSP_COEF_SIZE, g_dsp.coef) || + !VerifyRoms(irom_filename, coef_filename)) { DSPCore_FreeMemoryPages(); return false; diff --git a/Source/Core/Core/DSP/DSPCore.h b/Source/Core/Core/DSP/DSPCore.h index 88c8308961..31b8830c2d 100644 --- a/Source/Core/Core/DSP/DSPCore.h +++ b/Source/Core/Core/DSP/DSPCore.h @@ -25,6 +25,8 @@ #pragma once +#include + #include "Common/Thread.h" #include "Core/DSP/DSPBreakpoints.h" @@ -268,8 +270,7 @@ extern DSPEmitter *dspjit; extern u16 cyclesLeft; extern bool init_hax; -bool DSPCore_Init(const char *irom_filename, const char *coef_filename, - bool bUsingJIT); +bool DSPCore_Init(const std::string& irom_filename, const std::string& coef_filename, bool bUsingJIT); void DSPCore_Reset(); void DSPCore_Shutdown(); // Frees all allocated memory. diff --git a/Source/Core/Core/DSP/DSPDisassembler.cpp b/Source/Core/Core/DSP/DSPDisassembler.cpp index 74195e5df8..fa0bf1cb21 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.cpp +++ b/Source/Core/Core/DSP/DSPDisassembler.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "Common/Common.h" #include "Common/FileUtil.h" @@ -333,7 +334,7 @@ bool DSPDisassembler::DisOpcode(const u16 *binbuf, int base_addr, int pass, u16 return true; } -bool DSPDisassembler::DisFile(const char* name, int base_addr, int pass, std::string &output) +bool DSPDisassembler::DisFile(const std::string& name, int base_addr, int pass, std::string &output) { File::IOFile in(name, "rb"); if (!in) diff --git a/Source/Core/Core/DSP/DSPDisassembler.h b/Source/Core/Core/DSP/DSPDisassembler.h index 855ee9af35..d5c15221c6 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.h +++ b/Source/Core/Core/DSP/DSPDisassembler.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include #include "Common/Common.h" @@ -73,7 +74,7 @@ public: private: // Moves PC forward and writes the result to dest. - bool DisFile(const char* name, int base_addr, int pass, std::string &output); + bool DisFile(const std::string& name, int base_addr, int pass, std::string &output); char* DisParams(const DSPOPCTemplate& opc, u16 op1, u16 op2, char* strbuf); std::map unk_opcodes; diff --git a/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp b/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp index 59fae90e70..112c4c310b 100644 --- a/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp +++ b/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include "Common/Common.h" #include "Common/StringUtil.h" @@ -139,9 +140,9 @@ void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) }); } -void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const char* _title) +void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const std::string& _title) { - GENERIC_LOG(type, LogTypes::LDEBUG, "%s", _title); + GENERIC_LOG(type, LogTypes::LDEBUG, "%s", _title.c_str()); for (u32 j = 0; j < _Size;) { std::string hex_line = ""; diff --git a/Source/Core/Core/Debugger/Debugger_SymbolMap.h b/Source/Core/Core/Debugger/Debugger_SymbolMap.h index 0388024de9..e2fc5fbeb2 100644 --- a/Source/Core/Core/Debugger/Debugger_SymbolMap.h +++ b/Source/Core/Core/Debugger/Debugger_SymbolMap.h @@ -21,7 +21,7 @@ struct CallstackEntry bool GetCallstack(std::vector &output); void PrintCallstack(); void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level); -void PrintDataBuffer(LogTypes::LOG_TYPE _Log, u8* _pData, size_t _Size, const char* _title); +void PrintDataBuffer(LogTypes::LOG_TYPE _Log, u8* _pData, size_t _Size, const std::string& _title); void AddAutoBreakpoints(); diff --git a/Source/Core/Core/Debugger/Dump.cpp b/Source/Core/Core/Debugger/Dump.cpp index c55f61cf12..e6c54435e0 100644 --- a/Source/Core/Core/Debugger/Dump.cpp +++ b/Source/Core/Core/Debugger/Dump.cpp @@ -3,16 +3,17 @@ // Refer to the license.txt file included. #include +#include #include "Common/Common.h" #include "Common/FileUtil.h" #include "Core/Debugger/Dump.h" -CDump::CDump(const char* _szFilename) : +CDump::CDump(const std::string& filename) : m_pData(nullptr) { - File::IOFile pStream(_szFilename, "rb"); + File::IOFile pStream(filename, "rb"); if (pStream) { m_size = (size_t)pStream.GetSize(); diff --git a/Source/Core/Core/Debugger/Dump.h b/Source/Core/Core/Debugger/Dump.h index 71c987f5e3..051241c180 100644 --- a/Source/Core/Core/Debugger/Dump.h +++ b/Source/Core/Core/Debugger/Dump.h @@ -8,13 +8,14 @@ // #pragma once +#include #include "Common/Common.h" class CDump { public: - CDump(const char* _szFilename); + CDump(const std::string& filename); ~CDump(); int GetNumberOfSteps(); diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp index c6fecdac1b..480b784165 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/FileUtil.h" #include "Core/FifoPlayer/FifoDataFile.h" @@ -41,7 +43,7 @@ void FifoDataFile::AddFrame(const FifoFrameInfo &frameInfo) m_Frames.push_back(frameInfo); } -bool FifoDataFile::Save(const char *filename) +bool FifoDataFile::Save(const std::string& filename) { File::IOFile file; if (!file.Open(filename, "wb")) diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.h b/Source/Core/Core/FifoPlayer/FifoDataFile.h index f1d4ace8c3..9be14296b4 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.h +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include "Common/Common.h" @@ -68,7 +69,7 @@ public: const FifoFrameInfo &GetFrame(size_t frame) const { return m_Frames[frame]; } size_t GetFrameCount() { return m_Frames.size(); } - bool Save(const char *filename); + bool Save(const std::string& filename); static FifoDataFile *Load(const std::string &filename, bool flagsOnly); diff --git a/Source/Core/Core/GeckoCode.cpp b/Source/Core/Core/GeckoCode.cpp index 310704a79a..df01a15b4f 100644 --- a/Source/Core/Core/GeckoCode.cpp +++ b/Source/Core/Core/GeckoCode.cpp @@ -73,7 +73,7 @@ bool InstallCodeHandler() u32 codelist_location = 0x800028B8; // Debugger on location (0x800022A8 = Debugger off, using codehandleronly.bin) std::string data; std::string _rCodeHandlerFilename = File::GetSysDirectory() + GECKO_CODE_HANDLER; - if (!File::ReadFileToString(_rCodeHandlerFilename.c_str(), data)) + if (!File::ReadFileToString(_rCodeHandlerFilename, data)) { NOTICE_LOG(ACTIONREPLAY, "Could not enable cheats because codehandler.bin was missing."); return false; diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index 56f8e3e457..807eea9018 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -156,9 +156,10 @@ bool IsEnabled(int flags) return true; } -u32 UnPatch(std::string patchName) +u32 UnPatch(const std::string& patchName) { - Symbol *symbol = g_symbolDB.GetSymbolFromName(patchName.c_str()); + Symbol* symbol = g_symbolDB.GetSymbolFromName(patchName); + if (symbol) { for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4) @@ -168,6 +169,7 @@ u32 UnPatch(std::string patchName) } return symbol->address; } + return 0; } diff --git a/Source/Core/Core/HLE/HLE.h b/Source/Core/Core/HLE/HLE.h index f320ff3023..5b687c3764 100644 --- a/Source/Core/Core/HLE/HLE.h +++ b/Source/Core/Core/HLE/HLE.h @@ -29,7 +29,7 @@ namespace HLE void PatchFunctions(); void Patch(u32 pc, const char *func_name); - u32 UnPatch(std::string patchName); + u32 UnPatch(const std::string& patchName); void Execute(u32 _CurrentPC, u32 _Instruction); u32 GetFunctionIndex(u32 em_address); diff --git a/Source/Core/Core/HLE/HLE_Misc.cpp b/Source/Core/Core/HLE/HLE_Misc.cpp index aeb7b480ea..887762c0f0 100644 --- a/Source/Core/Core/HLE/HLE_Misc.cpp +++ b/Source/Core/Core/HLE/HLE_Misc.cpp @@ -71,7 +71,7 @@ void ExecuteDOL(u8* dolFile, u32 fileSize) g_symbolDB.Clear(); PPCAnalyst::FindFunctions(0x80004000, 0x811fffff, &g_symbolDB); SignatureDB db; - if (db.Load((File::GetSysDirectory() + TOTALDB).c_str())) + if (db.Load(File::GetSysDirectory() + TOTALDB)) { db.Apply(&g_symbolDB); HLE::PatchFunctions(); @@ -127,17 +127,17 @@ void ExecuteDOL(u8* dolFile, u32 fileSize) void LoadDOLFromDisc(std::string dol) { - DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename.c_str()); + DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename); DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume); if (dol.length() > 1 && dol.compare(0, 1, "/") == 0) dol = dol.substr(1); - u32 fileSize = (u32) pFileSystem->GetFileSize(dol.c_str()); + u32 fileSize = (u32) pFileSystem->GetFileSize(dol); u8* dolFile = new u8[fileSize]; if (fileSize > 0) { - pFileSystem->ReadFile(dol.c_str(), dolFile, fileSize); + pFileSystem->ReadFile(dol, dolFile, fileSize); ExecuteDOL(dolFile, fileSize); } delete[] dolFile; @@ -145,7 +145,7 @@ void LoadDOLFromDisc(std::string dol) void LoadBootDOLFromDisc() { - DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename.c_str()); + DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename); DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume); u32 fileSize = pFileSystem->GetBootDOLSize(); u8* dolFile = new u8[fileSize]; @@ -159,7 +159,7 @@ void LoadBootDOLFromDisc() u32 GetDolFileSize(std::string dol) { - DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename.c_str()); + DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename); DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume); std::string dolFile; @@ -169,7 +169,7 @@ u32 GetDolFileSize(std::string dol) else dolFile = dol; - return (u32)pFileSystem->GetFileSize(dolFile.c_str()); + return (u32)pFileSystem->GetFileSize(dolFile); } u16 GetIOSVersion() diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp index 5209f32616..420d5dc84d 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp @@ -143,7 +143,7 @@ bool DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread) irom_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_IROM; if (!File::Exists(coef_file)) coef_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_COEF; - if (!DSPCore_Init(irom_file.c_str(), coef_file.c_str(), AudioCommon::UseJIT())) + if (!DSPCore_Init(irom_file, coef_file, AudioCommon::UseJIT())) return false; g_dsp.cpu_ram = Memory::GetPointer(0); diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLETools.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLETools.cpp index 3bf4a7e091..4c0aad73d6 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLETools.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLETools.cpp @@ -8,9 +8,11 @@ #include #include +#include #include "Common/Common.h" #include "Common/FileUtil.h" +#include "Common/StringUtil.h" #include "Core/DSP/DSPCodeUtil.h" #include "Core/DSP/DSPCore.h" @@ -21,10 +23,8 @@ bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc) { - char binFile[MAX_PATH]; - char txtFile[MAX_PATH]; - sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc); - sprintf(txtFile, "%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc); + const std::string binFile = StringFromFormat("%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc); + const std::string txtFile = StringFromFormat("%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc); File::IOFile pFile(binFile, "wb"); if (pFile) @@ -34,7 +34,7 @@ bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc) } else { - PanicAlert("Can't open file (%s) to dump UCode!!", binFile); + PanicAlert("Can't open file (%s) to dump UCode!!", binFile.c_str()); return false; } diff --git a/Source/Core/Core/HW/DSPLLE/DSPSymbols.cpp b/Source/Core/Core/HW/DSPLLE/DSPSymbols.cpp index 09609b6304..912c93d96f 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPSymbols.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPSymbols.cpp @@ -111,12 +111,12 @@ void DisasssembleRange(u16 start, u16 end) } -bool ReadAnnotatedAssembly(const char *filename) +bool ReadAnnotatedAssembly(const std::string& filename) { File::IOFile f(filename, "r"); if (!f) { - ERROR_LOG(DSPLLE, "Bah! ReadAnnotatedAssembly couldn't find the file %s", filename); + ERROR_LOG(DSPLLE, "Bah! ReadAnnotatedAssembly couldn't find the file %s", filename.c_str()); return false; } char line[512]; diff --git a/Source/Core/Core/HW/DSPLLE/DSPSymbols.h b/Source/Core/Core/HW/DSPLLE/DSPSymbols.h index acf646b9f4..e48927da7d 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPSymbols.h +++ b/Source/Core/Core/HW/DSPLLE/DSPSymbols.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "Common/Common.h" #include "Common/SymbolDB.h" @@ -22,7 +24,7 @@ public: extern DSPSymbolDB g_dsp_symbol_db; -bool ReadAnnotatedAssembly(const char *filename); +bool ReadAnnotatedAssembly(const std::string& filename); void AutoDisassembly(u16 start_addr, u16 end_addr); void Clear(); diff --git a/Source/Core/Core/HW/DVDInterface.cpp b/Source/Core/Core/HW/DVDInterface.cpp index e4c9c3a019..7ad7fb9a21 100644 --- a/Source/Core/Core/HW/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVDInterface.cpp @@ -317,15 +317,15 @@ void InsertDiscCallback(u64 userdata, int cyclesLate) delete _FileName; } -void ChangeDisc(const char* _newFileName) +void ChangeDisc(const std::string& newFileName) { - std::string* _FileName = new std::string(_newFileName); + std::string* _FileName = new std::string(newFileName); CoreTiming::ScheduleEvent_Threadsafe(0, ejectDisc); CoreTiming::ScheduleEvent_Threadsafe(500000000, insertDisc, (u64)_FileName); if (Movie::IsRecordingInput()) { Movie::g_bDiscChange = true; - std::string fileName = _newFileName; + std::string fileName = newFileName; auto sizeofpath = fileName.find_last_of("/\\") + 1; if (fileName.substr(sizeofpath).length() > 40) { diff --git a/Source/Core/Core/HW/DVDInterface.h b/Source/Core/Core/HW/DVDInterface.h index 2eaf3b2ffc..6b03c7f123 100644 --- a/Source/Core/Core/HW/DVDInterface.h +++ b/Source/Core/Core/HW/DVDInterface.h @@ -4,6 +4,7 @@ #pragma once +#include #include "Common/CommonTypes.h" class PointerWrap; @@ -21,7 +22,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base); // Disc detection and swapping void SetDiscInside(bool _DiscInside); bool IsDiscInside(); -void ChangeDisc(const char* _FileName); +void ChangeDisc(const std::string& fileName); // Lid Functions void SetLidOpen(bool _bOpen = true); diff --git a/Source/Core/Core/HW/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard.cpp index 07a66288c1..6d91d53527 100644 --- a/Source/Core/Core/HW/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include "Common/ColorUtil.h" #include "Core/HW/GCMemcard.h" @@ -14,7 +15,7 @@ static void ByteSwap(u8 *valueA, u8 *valueB) *valueB = tmp; } -GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis) +GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool sjis) : m_valid(false) , m_fileName(filename) { @@ -23,7 +24,7 @@ GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis) File::IOFile mcdFile(m_fileName, "rb"); if (!mcdFile.IsOpen()) { - if (!forceCreation && !AskYesNoT("\"%s\" does not exist.\n Create a new 16MB Memcard?", filename)) + if (!forceCreation && !AskYesNoT("\"%s\" does not exist.\n Create a new 16MB Memcard?", filename.c_str())) { return; } @@ -43,12 +44,12 @@ GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis) auto size = mcdFile.GetSize(); if (size < MC_FST_BLOCKS*BLOCK_SIZE) { - PanicAlertT("%s failed to load as a memorycard \nfile is not large enough to be a valid memory card file (0x%x bytes)", filename, (unsigned) size); + PanicAlertT("%s failed to load as a memorycard \nfile is not large enough to be a valid memory card file (0x%x bytes)", filename.c_str(), (unsigned) size); return; } if (size % BLOCK_SIZE) { - PanicAlertT("%s failed to load as a memorycard \n Card file size is invalid (0x%x bytes)", filename, (unsigned) size); + PanicAlertT("%s failed to load as a memorycard \n Card file size is invalid (0x%x bytes)", filename.c_str(), (unsigned) size); return; } @@ -63,7 +64,7 @@ GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis) case MemCard2043Mb: break; default: - PanicAlertT("%s failed to load as a memorycard \n Card size is invalid (0x%x bytes)", filename, (unsigned) size); + PanicAlertT("%s failed to load as a memorycard \n Card size is invalid (0x%x bytes)", filename.c_str(), (unsigned) size); return; } } @@ -795,7 +796,7 @@ u32 GCMemcard::CopyFrom(const GCMemcard& source, u8 index) } } -u32 GCMemcard::ImportGci(const char *inputFile, const std::string &outputFile) +u32 GCMemcard::ImportGci(const std::string& inputFile, const std::string &outputFile) { if (outputFile.empty() && !m_valid) return OPENFAIL; @@ -809,7 +810,7 @@ u32 GCMemcard::ImportGci(const char *inputFile, const std::string &outputFile) return result; } -u32 GCMemcard::ImportGciInternal(FILE* gcih, const char *inputFile, const std::string &outputFile) +u32 GCMemcard::ImportGciInternal(FILE* gcih, const std::string& inputFile, const std::string &outputFile) { File::IOFile gci(gcih); unsigned int offset; @@ -898,30 +899,22 @@ u32 GCMemcard::ImportGciInternal(FILE* gcih, const char *inputFile, const std::s return ret; } -u32 GCMemcard::ExportGci(u8 index, const char *fileName, const std::string &directory) const +u32 GCMemcard::ExportGci(u8 index, const std::string& fileName, const std::string &directory) const { File::IOFile gci; int offset = GCI; - if (!fileName) - { - std::string gciFilename; - if (!GCI_FileName(index, gciFilename)) return SUCCESS; - gci.Open(directory + DIR_SEP + gciFilename, "wb"); - } - else - { - gci.Open(fileName, "wb"); - std::string fileType; - SplitPath(fileName, nullptr, nullptr, &fileType); - if (!strcasecmp(fileType.c_str(), ".gcs")) - { - offset = GCS; - } - else if (!strcasecmp(fileType.c_str(), ".sav")) - { - offset = SAV; - } + gci.Open(fileName, "wb"); + + std::string fileType; + SplitPath(fileName, nullptr, nullptr, &fileType); + if (!strcasecmp(fileType.c_str(), ".gcs")) + { + offset = GCS; + } + else if (!strcasecmp(fileType.c_str(), ".sav")) + { + offset = SAV; } if (!gci) diff --git a/Source/Core/Core/HW/GCMemcard.h b/Source/Core/Core/HW/GCMemcard.h index 37a601daa2..584db1856e 100644 --- a/Source/Core/Core/HW/GCMemcard.h +++ b/Source/Core/Core/HW/GCMemcard.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "Common/Common.h" #include "Common/CommonPaths.h" #include "Common/StringUtil.h" @@ -169,12 +171,12 @@ private: }; #pragma pack(pop) - u32 ImportGciInternal(FILE* gcih, const char *inputFile, const std::string &outputFile); + u32 ImportGciInternal(FILE* gcih, const std::string& inputFile, const std::string &outputFile); static void FormatInternal(GCMC_Header &GCP); void initDirBatPointers() ; public: - GCMemcard(const char* fileName, bool forceCreation=false, bool sjis=false); + GCMemcard(const std::string& fileName, bool forceCreation=false, bool sjis=false); bool IsValid() const { return m_valid; } bool IsAsciiEncoding() const; bool Save(); @@ -233,10 +235,10 @@ public: u32 CopyFrom(const GCMemcard& source, u8 index); // reads a .gci/.gcs/.sav file and calls ImportFile or saves out a gci file - u32 ImportGci(const char* inputFile,const std::string &outputFile); + u32 ImportGci(const std::string& inputFile,const std::string &outputFile); // writes a .gci file to disk containing index - u32 ExportGci(u8 index, const char* fileName, const std::string &directory) const; + u32 ExportGci(u8 index, const std::string& fileName, const std::string &directory) const; // GCI files are untouched, SAV files are byteswapped // GCS files have the block count set, default is 1 (For export as GCS) diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index 94d4b42261..ffb638be5d 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -4,6 +4,7 @@ #pragma once +#include // Host - defines an interface for the emulator core to communicate back to the // OS-specific layer @@ -38,8 +39,8 @@ void Host_UpdateBreakPointView(); void Host_UpdateDisasmDialog(); void Host_UpdateLogDisplay(); void Host_UpdateMainFrame(); -void Host_UpdateStatusBar(const char* _pText, int Filed = 0); -void Host_UpdateTitle(const char* title); +void Host_UpdateStatusBar(const std::string& text, int Filed = 0); +void Host_UpdateTitle(const std::string& title); // TODO (neobrain): Remove these from host! void* Host_GetInstance(); diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp index e0726ae44a..8cf9b6fb55 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp @@ -100,35 +100,35 @@ void Init() u32 i = 0; // Build hardware devices - g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_oh1_57e_305(i, std::string("/dev/usb/oh1/57e/305")); i++; - g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_immediate(i, std::string("/dev/stm/immediate")); i++; - g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_eventhook(i, std::string("/dev/stm/eventhook")); i++; - g_DeviceMap[i] = new CWII_IPC_HLE_Device_fs(i, std::string("/dev/fs")); i++; + g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_oh1_57e_305(i, "/dev/usb/oh1/57e/305"); i++; + g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_immediate(i, "/dev/stm/immediate"); i++; + g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_eventhook(i, "/dev/stm/eventhook"); i++; + g_DeviceMap[i] = new CWII_IPC_HLE_Device_fs(i, "/dev/fs"); i++; // IOS allows two ES devices at a time for (u32 j=0; jGetDeviceName().find(std::string("/dev/es")) == 0) + if (entry.second && entry.second->GetDeviceName().find("/dev/es") == 0) { ((CWII_IPC_HLE_Device_es*)entry.second)->LoadWAD(_rFilename); } @@ -205,7 +205,7 @@ void ES_DIVerify(u8 *_pTMD, u32 _sz) void SDIO_EventNotify() { CWII_IPC_HLE_Device_sdio_slot0 *pDevice = - (CWII_IPC_HLE_Device_sdio_slot0*)GetDeviceByName(std::string("/dev/sdio/slot0")); + (CWII_IPC_HLE_Device_sdio_slot0*)GetDeviceByName("/dev/sdio/slot0"); if (pDevice) pDevice->EventNotify(); } diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp index 1c16e496d2..35aad66889 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -922,7 +922,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) } else { - pDolLoader.reset(new CDolLoader(pContent->m_Filename.c_str())); + pDolLoader.reset(new CDolLoader(pContent->m_Filename)); } pDolLoader->Load(); // TODO: Check why sysmenu does not load the DOL correctly PC = pDolLoader->GetEntryPoint() | 0x80000000; @@ -1111,7 +1111,7 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz) if (Movie::IsRecordingInput()) { // TODO: Check for the actual save data - if (File::Exists((savePath + "banner.bin").c_str())) + if (File::Exists(savePath + "banner.bin")) Movie::g_bClearSave = false; else Movie::g_bClearSave = true; @@ -1120,34 +1120,34 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz) // TODO: Force the game to save to another location, instead of moving the user's save. if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsStartingFromClearSave()) { - if (File::Exists((savePath + "banner.bin").c_str())) + if (File::Exists(savePath + "banner.bin")) { - if (File::Exists((savePath + "../backup/").c_str())) + if (File::Exists(savePath + "../backup/")) { // The last run of this game must have been to play back a movie, so their save is already backed up. - File::DeleteDirRecursively(savePath.c_str()); + File::DeleteDirRecursively(savePath); } else { #ifdef _WIN32 MoveFile(UTF8ToTStr(savePath).c_str(), UTF8ToTStr(savePath + "../backup/").c_str()); #else - File::CopyDir(savePath.c_str(),(savePath + "../backup/").c_str()); - File::DeleteDirRecursively(savePath.c_str()); + File::CopyDir(savePath, savePath + "../backup/"); + File::DeleteDirRecursively(savePath); #endif } } } - else if (File::Exists((savePath + "../backup/").c_str())) + else if (File::Exists(savePath + "../backup/")) { // Delete the save made by a previous movie, and copy back the user's save. - if (File::Exists((savePath + "banner.bin").c_str())) + if (File::Exists(savePath + "banner.bin")) File::DeleteDirRecursively(savePath); #ifdef _WIN32 MoveFile(UTF8ToTStr(savePath + "../backup/").c_str(), UTF8ToTStr(savePath).c_str()); #else - File::CopyDir((savePath + "../backup/").c_str(), savePath.c_str()); - File::DeleteDirRecursively((savePath + "../backup/").c_str()); + File::CopyDir(savePath + "../backup/", savePath); + File::DeleteDirRecursively(savePath + "../backup/"); #endif } diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp index 17735bad8c..748beffa33 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp @@ -35,7 +35,7 @@ bool CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode) { std::string Path = File::GetUserPath(D_WIIUSER_IDX) + "tmp"; File::DeleteDirRecursively(Path); - File::CreateDir(Path.c_str()); + File::CreateDir(Path); } Memory::Write_U32(GetDeviceID(), _CommandAddress+4); @@ -505,10 +505,11 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) if (p.GetMode() == PointerWrap::MODE_READ) { File::DeleteDirRecursively(Path); - File::CreateDir(Path.c_str()); + File::CreateDir(Path); //now restore from the stream - while (1) { + while (1) + { char type = 0; p.Do(type); if (!type) @@ -520,7 +521,7 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) { case 'd': { - File::CreateDir(name.c_str()); + File::CreateDir(name); break; } case 'f': @@ -531,7 +532,8 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) File::IOFile handle(name, "wb"); char buf[65536]; u32 count = size; - while (count > 65536) { + while (count > 65536) + { p.DoArray(&buf[0], 65536); handle.WriteArray(&buf[0], 65536); count -= 65536; diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp index f681a40a96..89d4af0f41 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp @@ -53,7 +53,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::OpenInternal() if (!m_Card) { WARN_LOG(WII_IPC_SD, "Failed to open SD Card image, trying to create a new 128MB image..."); - if (SDCardCreate(128, filename.c_str())) + if (SDCardCreate(128, filename)) { WARN_LOG(WII_IPC_SD, "Successfully created %s", filename.c_str()); m_Card.Open(filename, "r+b"); diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 6f0f3f9af5..bc13a76be6 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -435,14 +435,14 @@ bool BeginRecordingInput(int controllers) if (File::Exists(tmpStateFilename)) File::Delete(tmpStateFilename); - State::SaveAs(tmpStateFilename.c_str()); + State::SaveAs(tmpStateFilename); g_bRecordingFromSaveState = true; // This is only done here if starting from save state because otherwise we won't have the titleid. Otherwise it's set in WII_IPC_HLE_Device_es.cpp. // TODO: find a way to GetTitleDataPath() from Movie::Init() if (Core::g_CoreStartupParameter.bWii) { - if (File::Exists((Common::GetTitleDataPath(g_titleID) + "banner.bin").c_str())) + if (File::Exists(Common::GetTitleDataPath(g_titleID) + "banner.bin")) Movie::g_bClearSave = false; else Movie::g_bClearSave = true; @@ -711,9 +711,9 @@ void ReadHeader() memcpy(MD5, tmpHeader.md5, 16); } -bool PlayInput(const char *filename) +bool PlayInput(const std::string& filename) { - if (!filename || g_playMode != MODE_NONE) + if (g_playMode != MODE_NONE) return false; if (!File::Exists(filename)) @@ -753,7 +753,7 @@ bool PlayInput(const char *filename) // Load savestate (and skip to frame data) if (tmpHeader.bFromSaveState) { - const std::string stateFilename = std::string(filename) + ".sav"; + const std::string stateFilename = filename + ".sav"; if (File::Exists(stateFilename)) Core::SetStateFileName(stateFilename); g_bRecordingFromSaveState = true; @@ -782,12 +782,12 @@ void DoState(PointerWrap &p) // other variables (such as g_totalBytes and g_totalFrames) are set in LoadInput } -void LoadInput(const char *filename) +void LoadInput(const std::string& filename) { File::IOFile t_record; if (!t_record.Open(filename, "r+b")) { - PanicAlertT("Failed to read %s", filename); + PanicAlertT("Failed to read %s", filename.c_str()); EndPlayInput(false); return; } @@ -796,7 +796,7 @@ void LoadInput(const char *filename) if (tmpHeader.filetype[0] != 'D' || tmpHeader.filetype[1] != 'T' || tmpHeader.filetype[2] != 'M' || tmpHeader.filetype[3] != 0x1A) { - PanicAlertT("Savestate movie %s is corrupted, movie recording stopping...", filename); + PanicAlertT("Savestate movie %s is corrupted, movie recording stopping...", filename.c_str()); EndPlayInput(false); return; } @@ -1002,7 +1002,7 @@ void PlayController(SPADStatus *PadStatus, int controllerID) for (int i = 0; i < numPaths; i++) { path = SConfig::GetInstance().m_ISOFolder[i]; - if (File::Exists((path + '/' + g_discChange.c_str()).c_str())) + if (File::Exists(path + '/' + g_discChange)) { found = true; break; @@ -1010,7 +1010,7 @@ void PlayController(SPADStatus *PadStatus, int controllerID) } if (found) { - DVDInterface::ChangeDisc((path + '/' + g_discChange.c_str()).c_str()); + DVDInterface::ChangeDisc(path + '/' + g_discChange); Core::SetState(Core::CORE_RUN); } else @@ -1091,7 +1091,7 @@ void EndPlayInput(bool cont) } } -void SaveRecording(const char *filename) +void SaveRecording(const std::string& filename) { File::IOFile save_record(filename, "wb"); // Create the real header now and write it @@ -1145,15 +1145,14 @@ void SaveRecording(const char *filename) if (success && g_bRecordingFromSaveState) { - std::string stateFilename = filename; - stateFilename.append(".sav"); + std::string stateFilename = filename + ".sav"; success = File::Copy(tmpStateFilename, stateFilename); } if (success) - Core::DisplayMessage(StringFromFormat("DTM %s saved", filename).c_str(), 2000); + Core::DisplayMessage(StringFromFormat("DTM %s saved", filename.c_str()), 2000); else - Core::DisplayMessage(StringFromFormat("Failed to save %s", filename).c_str(), 2000); + Core::DisplayMessage(StringFromFormat("Failed to save %s", filename.c_str()), 2000); } void SetInputManip(ManipFunction func) diff --git a/Source/Core/Core/Movie.h b/Source/Core/Core/Movie.h index 391449ddfd..a317b0b01b 100644 --- a/Source/Core/Core/Movie.h +++ b/Source/Core/Core/Movie.h @@ -18,10 +18,12 @@ struct ReportFeatures; // Per-(video )Movie actions -namespace Movie { +namespace Movie +{ // Enumerations and structs -enum PlayMode { +enum PlayMode +{ MODE_NONE = 0, MODE_RECORDING, MODE_PLAYING @@ -29,7 +31,8 @@ enum PlayMode { // Gamecube Controller State #pragma pack(push,1) -struct ControllerState { +struct ControllerState +{ bool Start:1, A:1, B:1, X:1, Y:1, Z:1; // Binary buttons, 6 bits bool DPadUp:1, DPadDown:1, // Binary D-Pad buttons, 4 bits DPadLeft:1, DPadRight:1; @@ -66,7 +69,8 @@ extern std::string g_discChange; extern u32 g_rerecords; #pragma pack(push,1) -struct DTMHeader { +struct DTMHeader +{ u8 filetype[4]; // Unique Identifier (always "DTM"0x1A) u8 gameID[6]; // The Game ID @@ -161,13 +165,13 @@ bool BeginRecordingInput(int controllers); void RecordInput(SPADStatus *PadStatus, int controllerID); void RecordWiimote(int wiimote, u8 *data, u8 size); -bool PlayInput(const char *filename); -void LoadInput(const char *filename); +bool PlayInput(const std::string& filename); +void LoadInput(const std::string& filename); void ReadHeader(); void PlayController(SPADStatus *PadStatus, int controllerID); bool PlayWiimote(int wiimote, u8* data, const struct WiimoteEmu::ReportFeatures& rptf, int irMode); void EndPlayInput(bool cont); -void SaveRecording(const char *filename); +void SaveRecording(const std::string& filename); void DoState(PointerWrap &p); void CheckMD5(); void GetMD5(); diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index 5882fef75f..bc00053963 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -47,14 +47,13 @@ std::vector onFrame; std::map speedHacks; std::vector discList; -void LoadPatchSection(const char *section, std::vector& patches, - IniFile& globalIni, IniFile& localIni) +void LoadPatchSection(const std::string& section, std::vector& patches, IniFile& globalIni, IniFile& localIni) { // Load the name of all enabled patches - std::string enabledSectionName = std::string(section) + "_Enabled"; + std::string enabledSectionName = section + "_Enabled"; std::vector enabledLines; std::set enabledNames; - localIni.GetLines(enabledSectionName.c_str(), enabledLines); + localIni.GetLines(enabledSectionName, enabledLines); for (const std::string& line : enabledLines) { if (line.size() != 0 && line[0] == '$') diff --git a/Source/Core/Core/PatchEngine.h b/Source/Core/Core/PatchEngine.h index b601e41d39..2eb08fcc31 100644 --- a/Source/Core/Core/PatchEngine.h +++ b/Source/Core/Core/PatchEngine.h @@ -4,6 +4,7 @@ #pragma once +#include #include "Common/IniFile.h" namespace PatchEngine @@ -36,7 +37,7 @@ struct Patch }; int GetSpeedhackCycles(const u32 addr); -void LoadPatchSection(const char *section, std::vector &patches, +void LoadPatchSection(const std::string& section, std::vector &patches, IniFile &globalIni, IniFile &localIni); void LoadPatches(); void ApplyFramePatches(); diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp index 2b6ea69b7c..281f853911 100644 --- a/Source/Core/Core/PowerPC/JitInterface.cpp +++ b/Source/Core/Core/PowerPC/JitInterface.cpp @@ -4,6 +4,7 @@ #include #include +#include #ifdef _WIN32 #include @@ -123,7 +124,7 @@ namespace JitInterface return jit; } - void WriteProfileResults(const char *filename) + void WriteProfileResults(const std::string& filename) { // Can't really do this with no jit core available #if _M_X86 @@ -157,7 +158,7 @@ namespace JitInterface File::IOFile f(filename, "w"); if (!f) { - PanicAlert("Failed to open %s", filename); + PanicAlert("Failed to open %s", filename.c_str()); return; } fprintf(f.GetHandle(), "origAddr\tblkName\tcost\ttimeCost\tpercent\ttimePercent\tOvAllinBlkTime(ms)\tblkCodeSize\n"); diff --git a/Source/Core/Core/PowerPC/JitInterface.h b/Source/Core/Core/PowerPC/JitInterface.h index 51fa746fa2..3843f4e7c4 100644 --- a/Source/Core/Core/PowerPC/JitInterface.h +++ b/Source/Core/Core/PowerPC/JitInterface.h @@ -4,6 +4,7 @@ #pragma once +#include #include "Common/ChunkFile.h" #include "Core/PowerPC/CPUCoreBase.h" @@ -16,7 +17,7 @@ namespace JitInterface CPUCoreBase *GetCore(); // Debugging - void WriteProfileResults(const char *filename); + void WriteProfileResults(const std::string& filename); // Memory Utilities bool IsInCodeSpace(u8 *ptr); diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index da15e21b25..982b246f83 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -55,7 +55,7 @@ Symbol *PPCSymbolDB::AddFunction(u32 startAddr) } } -void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const char *name, int type) +void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name, int type) { XFuncMap::iterator iter = functions.find(startAddr); if (iter != functions.end()) @@ -196,7 +196,7 @@ void PPCSymbolDB::LogFunctionCall(u32 addr) // This one can load both leftover map files on game discs (like Zelda), and mapfiles // produced by SaveSymbolMap below. -bool PPCSymbolDB::LoadMap(const char *filename) +bool PPCSymbolDB::LoadMap(const std::string& filename) { File::IOFile f(filename, "r"); if (!f) @@ -263,11 +263,12 @@ bool PPCSymbolDB::LoadMap(const char *filename) // =================================================== /* Save the map file and save a code file */ // ---------------- -bool PPCSymbolDB::SaveMap(const char *filename, bool WithCodes) const +bool PPCSymbolDB::SaveMap(const std::string& filename, bool WithCodes) const { // Format the name for the codes version std::string mapFile = filename; - if (WithCodes) mapFile = mapFile.substr(0, mapFile.find_last_of(".")) + "_code.map"; + if (WithCodes) + mapFile = mapFile.substr(0, mapFile.find_last_of(".")) + "_code.map"; // Check size const int wxYES_NO = 0x00000002 | 0x00000008; @@ -277,7 +278,9 @@ bool PPCSymbolDB::SaveMap(const char *filename, bool WithCodes) const "No symbol names are generated. Do you want to replace '%s' with a blank file?", mapFile.c_str()).c_str(), "Confirm", wxYES_NO)) return false; } - if (WithCodes) Host_UpdateStatusBar("Saving code, please stand by ..."); + + if (WithCodes) + Host_UpdateStatusBar("Saving code, please stand by ..."); // Make a file File::IOFile f(mapFile, "w"); diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.h b/Source/Core/Core/PowerPC/PPCSymbolDB.h index 842bae0cb7..09e01d13ed 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.h +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.h @@ -26,7 +26,7 @@ public: ~PPCSymbolDB(); Symbol *AddFunction(u32 startAddr) override; - void AddKnownSymbol(u32 startAddr, u32 size, const char *name, int type = Symbol::SYMBOL_FUNCTION); + void AddKnownSymbol(u32 startAddr, u32 size, const std::string& name, int type = Symbol::SYMBOL_FUNCTION); Symbol *GetSymbolFromAddr(u32 addr) override; @@ -34,8 +34,8 @@ public: void FillInCallers(); - bool LoadMap(const char *filename); - bool SaveMap(const char *filename, bool WithCodes = false) const; + bool LoadMap(const std::string& filename); + bool SaveMap(const std::string& filename, bool WithCodes = false) const; void PrintCalls(u32 funcAddr) const; void PrintCallers(u32 funcAddr) const; diff --git a/Source/Core/Core/PowerPC/Profiler.cpp b/Source/Core/Core/PowerPC/Profiler.cpp index 59a7535d3a..3ab1fde237 100644 --- a/Source/Core/Core/PowerPC/Profiler.cpp +++ b/Source/Core/Core/PowerPC/Profiler.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include "Core/PowerPC/JitInterface.h" namespace Profiler @@ -10,7 +11,7 @@ namespace Profiler bool g_ProfileBlocks; bool g_ProfileInstructions; -void WriteProfileResults(const char *filename) +void WriteProfileResults(const std::string& filename) { JitInterface::WriteProfileResults(filename); } diff --git a/Source/Core/Core/PowerPC/Profiler.h b/Source/Core/Core/PowerPC/Profiler.h index 24da8b8e9f..1f766718ba 100644 --- a/Source/Core/Core/PowerPC/Profiler.h +++ b/Source/Core/Core/PowerPC/Profiler.h @@ -5,6 +5,8 @@ #pragma once +#include + #ifdef _WIN32 #if _M_X86_32 @@ -58,5 +60,5 @@ namespace Profiler extern bool g_ProfileBlocks; extern bool g_ProfileInstructions; -void WriteProfileResults(const char *filename); +void WriteProfileResults(const std::string& filename); } diff --git a/Source/Core/Core/PowerPC/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB.cpp index 1d21ddc538..5eb7e409da 100644 --- a/Source/Core/Core/PowerPC/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/Common.h" #include "Common/FileUtil.h" @@ -11,7 +13,8 @@ #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/SignatureDB.h" -namespace { +namespace +{ // On-disk format for SignatureDB entries. struct FuncDesc @@ -23,7 +26,7 @@ struct FuncDesc } // namespace -bool SignatureDB::Load(const char *filename) +bool SignatureDB::Load(const std::string& filename) { File::IOFile f(filename, "rb"); if (!f) @@ -47,7 +50,7 @@ bool SignatureDB::Load(const char *filename) return true; } -bool SignatureDB::Save(const char *filename) +bool SignatureDB::Save(const std::string& filename) { File::IOFile f(filename, "wb"); if (!f) @@ -72,7 +75,7 @@ bool SignatureDB::Save(const char *filename) } //Adds a known function to the hash database -u32 SignatureDB::Add(u32 startAddr, u32 size, const char *name) +u32 SignatureDB::Add(u32 startAddr, u32 size, const std::string& name) { u32 hash = ComputeCodeChecksum(startAddr, startAddr + size); @@ -83,6 +86,7 @@ u32 SignatureDB::Add(u32 startAddr, u32 size, const char *name) FuncDB::iterator iter = database.find(hash); if (iter == database.end()) database[hash] = temp_dbfunc; + return hash; } @@ -126,12 +130,11 @@ void SignatureDB::Apply(PPCSymbolDB *symbol_db) symbol_db->Index(); } -void SignatureDB::Initialize(PPCSymbolDB *symbol_db, const char *prefix) +void SignatureDB::Initialize(PPCSymbolDB *symbol_db, const std::string& prefix) { - std::string prefix_str(prefix); for (const auto& symbol : symbol_db->Symbols()) { - if ((symbol.second.name.substr(0, prefix_str.size()) == prefix_str) || prefix_str.empty()) + if ((symbol.second.name.substr(0, prefix.size()) == prefix) || prefix.empty()) { DBFunc temp_dbfunc; temp_dbfunc.name = symbol.second.name; diff --git a/Source/Core/Core/PowerPC/SignatureDB.h b/Source/Core/Core/PowerPC/SignatureDB.h index 9d1029b61b..7df44a069e 100644 --- a/Source/Core/Core/PowerPC/SignatureDB.h +++ b/Source/Core/Core/PowerPC/SignatureDB.h @@ -31,15 +31,15 @@ class SignatureDB public: // Returns the hash. - u32 Add(u32 startAddr, u32 size, const char *name); + u32 Add(u32 startAddr, u32 size, const std::string& name); - bool Load(const char *filename); // Does not clear. Remember to clear first if that's what you want. - bool Save(const char *filename); + bool Load(const std::string& filename); // Does not clear. Remember to clear first if that's what you want. + bool Save(const std::string& filename); void Clean(const char *prefix); void Clear(); void List(); - void Initialize(PPCSymbolDB *func_db, const char *prefix = ""); + void Initialize(PPCSymbolDB *func_db, const std::string& prefix = ""); void Apply(PPCSymbolDB *func_db); static u32 ComputeCodeChecksum(u32 offsetStart, u32 offsetEnd); diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index ca35619847..6d16cef7c5 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -235,7 +235,7 @@ void CompressAndDumpState(CompressAndDumpState_args save_args) } if ((Movie::IsRecordingInput() || Movie::IsPlayingInput()) && !Movie::IsJustStartingRecordingInputFromSaveState()) - Movie::SaveRecording((filename + ".dtm").c_str()); + Movie::SaveRecording(filename + ".dtm"); else if (!Movie::IsRecordingInput() && !Movie::IsPlayingInput()) File::Delete(filename + ".dtm"); @@ -290,8 +290,7 @@ void CompressAndDumpState(CompressAndDumpState_args save_args) f.WriteBytes(buffer_data, buffer_size); } - Core::DisplayMessage(StringFromFormat("Saved State to %s", - filename.c_str()).c_str(), 2000); + Core::DisplayMessage(StringFromFormat("Saved State to %s", filename.c_str()), 2000); g_compressAndDumpStateSyncEvent.Set(); } @@ -444,7 +443,7 @@ void LoadAs(const std::string& filename) std::lock_guard lk(g_cs_undo_load_buffer); SaveToBuffer(g_undo_load_buffer); if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) - Movie::SaveRecording((File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm").c_str()); + Movie::SaveRecording(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm"); else if (File::Exists(File::GetUserPath(D_STATESAVES_IDX) +"undo.dtm")) File::Delete(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm"); } @@ -471,9 +470,9 @@ void LoadAs(const std::string& filename) { if (loadedSuccessfully) { - Core::DisplayMessage(StringFromFormat("Loaded state from %s", filename.c_str()).c_str(), 2000); + Core::DisplayMessage(StringFromFormat("Loaded state from %s", filename.c_str()), 2000); if (File::Exists(filename + ".dtm")) - Movie::LoadInput((filename + ".dtm").c_str()); + Movie::LoadInput(filename + ".dtm"); else if (!Movie::IsJustStartingRecordingInputFromSaveState() && !Movie::IsJustStartingPlayingInputFromSaveState()) Movie::EndPlayInput(false); } @@ -522,7 +521,7 @@ void VerifyAt(const std::string& filename) DoState(p); if (p.GetMode() == PointerWrap::MODE_VERIFY) - Core::DisplayMessage(StringFromFormat("Verified state at %s", filename.c_str()).c_str(), 2000); + Core::DisplayMessage(StringFromFormat("Verified state at %s", filename.c_str()), 2000); else Core::DisplayMessage("Unable to Verify : Can't verify state from other revisions !", 4000); } @@ -623,7 +622,7 @@ void UndoLoadState() { LoadFromBuffer(g_undo_load_buffer); if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) - Movie::LoadInput((File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm").c_str()); + Movie::LoadInput(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm"); } else { @@ -639,7 +638,7 @@ void UndoLoadState() // Load the state that the last save state overwritten on void UndoSaveState() { - LoadAs((File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav").c_str()); + LoadAs(File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav"); } } // namespace State diff --git a/Source/Core/DiscIO/Blob.cpp b/Source/Core/DiscIO/Blob.cpp index c912dad3c5..7a4c5a8469 100644 --- a/Source/Core/DiscIO/Blob.cpp +++ b/Source/Core/DiscIO/Blob.cpp @@ -33,7 +33,8 @@ void SectorReader::SetSectorSize(int blocksize) m_blocksize = blocksize; } -SectorReader::~SectorReader() { +SectorReader::~SectorReader() +{ for (u8*& block : cache) { delete [] block; @@ -100,6 +101,7 @@ bool SectorReader::Read(u64 offset, u64 size, u8* out_ptr) block++; } } + return true; } @@ -112,12 +114,13 @@ bool SectorReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 * return false; memcpy(out_ptr + i * m_blocksize, data, m_blocksize); } + return true; } -IBlobReader* CreateBlobReader(const char* filename) +IBlobReader* CreateBlobReader(const std::string& filename) { - if (cdio_is_cdrom(std::string(filename))) + if (cdio_is_cdrom(filename)) return DriveReader::Create(filename); if (!File::Exists(filename)) diff --git a/Source/Core/DiscIO/Blob.h b/Source/Core/DiscIO/Blob.h index 5ceb4c3bcf..e674a4e44e 100644 --- a/Source/Core/DiscIO/Blob.h +++ b/Source/Core/DiscIO/Blob.h @@ -14,6 +14,7 @@ // detect whether the file is a compressed blob, or just a big hunk of data, or a drive, and // automatically do the right thing. +#include #include "Common/CommonTypes.h" namespace DiscIO @@ -63,13 +64,13 @@ public: }; // Factory function - examines the path to choose the right type of IBlobReader, and returns one. -IBlobReader* CreateBlobReader(const char *filename); +IBlobReader* CreateBlobReader(const std::string& filename); typedef void (*CompressCB)(const char *text, float percent, void* arg); -bool CompressFileToBlob(const char *infile, const char *outfile, u32 sub_type = 0, int sector_size = 16384, +bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u32 sub_type = 0, int sector_size = 16384, CompressCB callback = nullptr, void *arg = nullptr); -bool DecompressBlobToFile(const char *infile, const char *outfile, +bool DecompressBlobToFile(const std::string& infile, const std::string& outfile, CompressCB callback = nullptr, void *arg = nullptr); } // namespace diff --git a/Source/Core/DiscIO/CISOBlob.cpp b/Source/Core/DiscIO/CISOBlob.cpp index ea0a01eafd..23e1bb797a 100644 --- a/Source/Core/DiscIO/CISOBlob.cpp +++ b/Source/Core/DiscIO/CISOBlob.cpp @@ -29,7 +29,7 @@ CISOFileReader::CISOFileReader(std::FILE* file) m_ciso_map[idx] = (1 == header.map[idx]) ? count++ : UNUSED_BLOCK_ID; } -CISOFileReader* CISOFileReader::Create(const char* filename) +CISOFileReader* CISOFileReader::Create(const std::string& filename) { if (IsCISOBlob(filename)) { @@ -37,7 +37,9 @@ CISOFileReader* CISOFileReader::Create(const char* filename) return new CISOFileReader(f.ReleaseHandle()); } else + { return nullptr; + } } u64 CISOFileReader::GetDataSize() const @@ -79,7 +81,7 @@ bool CISOFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) return true; } -bool IsCISOBlob(const char* filename) +bool IsCISOBlob(const std::string& filename) { File::IOFile f(filename, "rb"); diff --git a/Source/Core/DiscIO/CISOBlob.h b/Source/Core/DiscIO/CISOBlob.h index a947f357ab..ed0dbfb753 100644 --- a/Source/Core/DiscIO/CISOBlob.h +++ b/Source/Core/DiscIO/CISOBlob.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include "Common/CommonTypes.h" #include "Common/FileUtil.h" @@ -13,7 +14,7 @@ namespace DiscIO { -bool IsCISOBlob(const char* filename); +bool IsCISOBlob(const std::string& filename); static const u32 CISO_HEADER_SIZE = 0x8000; static const u32 CISO_MAP_SIZE = CISO_HEADER_SIZE - sizeof(u32) - sizeof(char) * 4; @@ -33,7 +34,7 @@ struct CISOHeader class CISOFileReader : public IBlobReader { public: - static CISOFileReader* Create(const char* filename); + static CISOFileReader* Create(const std::string& filename); u64 GetDataSize() const override; u64 GetRawSize() const override; diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp index 0d7ba59310..98b19f328d 100644 --- a/Source/Core/DiscIO/CompressedBlob.cpp +++ b/Source/Core/DiscIO/CompressedBlob.cpp @@ -25,7 +25,7 @@ namespace DiscIO { -CompressedBlobReader::CompressedBlobReader(const char *filename) : file_name(filename) +CompressedBlobReader::CompressedBlobReader(const std::string& filename) : file_name(filename) { m_file.Open(filename, "rb"); file_size = File::GetSize(filename); @@ -50,7 +50,7 @@ CompressedBlobReader::CompressedBlobReader(const char *filename) : file_name(fil memset(zlib_buffer, 0, zlib_buffer_size); } -CompressedBlobReader* CompressedBlobReader::Create(const char* filename) +CompressedBlobReader* CompressedBlobReader::Create(const std::string& filename) { if (IsCompressedBlob(filename)) return new CompressedBlobReader(filename); @@ -107,7 +107,7 @@ void CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr) PanicAlert("Hash of block %" PRIu64 " is %08x instead of %08x.\n" "Your ISO, %s, is corrupt.", block_num, block_hash, hashes[block_num], - file_name.c_str()); + file_name.c_str()); if (uncompressed) { @@ -140,14 +140,14 @@ void CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr) } } -bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type, +bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u32 sub_type, int block_size, CompressCB callback, void* arg) { bool scrubbing = false; if (IsCompressedBlob(infile)) { - PanicAlertT("%s is already compressed! Cannot compress it further.", infile); + PanicAlertT("%s is already compressed! Cannot compress it further.", infile.c_str()); return false; } @@ -155,7 +155,7 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type, { if (!DiscScrubber::SetupScrub(infile, block_size)) { - PanicAlertT("%s failed to be scrubbed. Probably the image is corrupt.", infile); + PanicAlertT("%s failed to be scrubbed. Probably the image is corrupt.", infile.c_str()); return false; } @@ -278,7 +278,7 @@ cleanup: return true; } -bool DecompressBlobToFile(const char* infile, const char* outfile, CompressCB callback, void* arg) +bool DecompressBlobToFile(const std::string& infile, const std::string& outfile, CompressCB callback, void* arg) { if (!IsCompressedBlob(infile)) { @@ -320,7 +320,7 @@ bool DecompressBlobToFile(const char* infile, const char* outfile, CompressCB ca return true; } -bool IsCompressedBlob(const char* filename) +bool IsCompressedBlob(const std::string& filename) { File::IOFile f(filename, "rb"); diff --git a/Source/Core/DiscIO/CompressedBlob.h b/Source/Core/DiscIO/CompressedBlob.h index 09590848cf..caf886bad5 100644 --- a/Source/Core/DiscIO/CompressedBlob.h +++ b/Source/Core/DiscIO/CompressedBlob.h @@ -23,7 +23,7 @@ namespace DiscIO { -bool IsCompressedBlob(const char* filename); +bool IsCompressedBlob(const std::string& filename); const u32 kBlobCookie = 0xB10BC001; @@ -46,23 +46,23 @@ struct CompressedBlobHeader // 32 bytes class CompressedBlobReader : public SectorReader { public: - static CompressedBlobReader* Create(const char *filename); + static CompressedBlobReader* Create(const std::string& filename); ~CompressedBlobReader(); const CompressedBlobHeader &GetHeader() const { return header; } u64 GetDataSize() const override { return header.data_size; } u64 GetRawSize() const override { return file_size; } u64 GetBlockCompressedSize(u64 block_num) const; - void GetBlock(u64 block_num, u8 *out_ptr) override; + void GetBlock(u64 block_num, u8* out_ptr) override; private: - CompressedBlobReader(const char *filename); + CompressedBlobReader(const std::string& filename); CompressedBlobHeader header; - u64 *block_pointers; - u32 *hashes; + u64* block_pointers; + u32* hashes; int data_offset; File::IOFile m_file; u64 file_size; - u8 *zlib_buffer; + u8* zlib_buffer; int zlib_buffer_size; std::string file_name; }; diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index 68a3e9f36f..b48967d31b 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -81,10 +81,10 @@ bool ParsePartitionData(SPartition& _rPartition); u32 GetDOLSize(u64 _DOLOffset); -bool SetupScrub(const char* filename, int block_size) +bool SetupScrub(const std::string& filename, int block_size) { bool success = true; - m_Filename = std::string(filename); + m_Filename = filename; m_BlockSize = block_size; if (CLUSTER_SIZE % m_BlockSize != 0) @@ -102,7 +102,7 @@ bool SetupScrub(const char* filename, int block_size) // Warn if not DVD5 or DVD9 size if (numClusters != 0x23048 && numClusters != 0x46090) - WARN_LOG(DISCIO, "%s is not a standard sized Wii disc! (%x blocks)", filename, numClusters); + WARN_LOG(DISCIO, "%s is not a standard sized Wii disc! (%x blocks)", filename.c_str(), numClusters); // Table of free blocks m_FreeTable = new u8[numClusters]; diff --git a/Source/Core/DiscIO/DiscScrubber.h b/Source/Core/DiscIO/DiscScrubber.h index 4a759113aa..360c684dc3 100644 --- a/Source/Core/DiscIO/DiscScrubber.h +++ b/Source/Core/DiscIO/DiscScrubber.h @@ -13,6 +13,7 @@ #pragma once +#include #include "Common/CommonTypes.h" namespace File { class IOFile; } @@ -23,7 +24,7 @@ namespace DiscIO namespace DiscScrubber { -bool SetupScrub(const char* filename, int block_size); +bool SetupScrub(const std::string& filename, int block_size); void GetNextBlock(File::IOFile& in, u8* buffer); void Cleanup(); diff --git a/Source/Core/DiscIO/DriveBlob.cpp b/Source/Core/DiscIO/DriveBlob.cpp index 361a74abdd..eb72a143d3 100644 --- a/Source/Core/DiscIO/DriveBlob.cpp +++ b/Source/Core/DiscIO/DriveBlob.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "Common/Common.h" #include "Common/FileUtil.h" @@ -17,7 +18,7 @@ namespace DiscIO { -DriveReader::DriveReader(const char *drive) +DriveReader::DriveReader(const std::string& drive) { #ifdef _WIN32 SectorReader::SetSectorSize(2048); @@ -56,8 +57,10 @@ DriveReader::DriveReader(const char *drive) #endif } else - NOTICE_LOG(DISCIO, "Load from DVD backup failed or no disc in drive %s", drive); -} // DriveReader::DriveReader + { + NOTICE_LOG(DISCIO, "Load from DVD backup failed or no disc in drive %s", drive.c_str()); + } +} DriveReader::~DriveReader() { @@ -79,18 +82,20 @@ DriveReader::~DriveReader() #endif } -DriveReader *DriveReader::Create(const char *drive) +DriveReader* DriveReader::Create(const std::string& drive) { - DriveReader *reader = new DriveReader(drive); + DriveReader* reader = new DriveReader(drive); + if (!reader->IsOK()) { delete reader; return nullptr; } + return reader; } -void DriveReader::GetBlock(u64 block_num, u8 *out_ptr) +void DriveReader::GetBlock(u64 block_num, u8* out_ptr) { u8* const lpSector = new u8[m_blocksize]; #ifdef _WIN32 @@ -109,7 +114,7 @@ void DriveReader::GetBlock(u64 block_num, u8 *out_ptr) delete[] lpSector; } -bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *out_ptr) +bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8* out_ptr) { #ifdef _WIN32 u32 NotUsed; diff --git a/Source/Core/DiscIO/DriveBlob.h b/Source/Core/DiscIO/DriveBlob.h index ae2b6875f6..8f49700c6c 100644 --- a/Source/Core/DiscIO/DriveBlob.h +++ b/Source/Core/DiscIO/DriveBlob.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "DiscIO/Blob.h" @@ -19,7 +21,7 @@ namespace DiscIO class DriveReader : public SectorReader { private: - DriveReader(const char *drive); + DriveReader(const std::string& drive); void GetBlock(u64 block_num, u8 *out_ptr) override; #ifdef _WIN32 @@ -33,7 +35,7 @@ private: s64 size; public: - static DriveReader *Create(const char *drive); + static DriveReader* Create(const std::string& drive); ~DriveReader(); u64 GetDataSize() const override { return size; } u64 GetRawSize() const override { return size; } diff --git a/Source/Core/DiscIO/FileBlob.cpp b/Source/Core/DiscIO/FileBlob.cpp index bb4d28680d..d7c4467738 100644 --- a/Source/Core/DiscIO/FileBlob.cpp +++ b/Source/Core/DiscIO/FileBlob.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include "DiscIO/FileBlob.h" namespace DiscIO @@ -13,7 +14,7 @@ PlainFileReader::PlainFileReader(std::FILE* file) m_size = m_file.GetSize(); } -PlainFileReader* PlainFileReader::Create(const char* filename) +PlainFileReader* PlainFileReader::Create(const std::string& filename) { File::IOFile f(filename, "rb"); if (f) diff --git a/Source/Core/DiscIO/FileBlob.h b/Source/Core/DiscIO/FileBlob.h index 68eb122eb2..3334328d70 100644 --- a/Source/Core/DiscIO/FileBlob.h +++ b/Source/Core/DiscIO/FileBlob.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include "Common/CommonTypes.h" #include "Common/FileUtil.h" @@ -21,7 +22,7 @@ class PlainFileReader : public IBlobReader s64 m_size; public: - static PlainFileReader* Create(const char* filename); + static PlainFileReader* Create(const std::string& filename); u64 GetDataSize() const override { return m_size; } u64 GetRawSize() const override { return m_size; } diff --git a/Source/Core/DiscIO/FileSystemGCWii.cpp b/Source/Core/DiscIO/FileSystemGCWii.cpp index 5b7f53af2b..1ecf71d4b5 100644 --- a/Source/Core/DiscIO/FileSystemGCWii.cpp +++ b/Source/Core/DiscIO/FileSystemGCWii.cpp @@ -33,7 +33,7 @@ CFileSystemGCWii::~CFileSystemGCWii() m_FileInfoVector.clear(); } -u64 CFileSystemGCWii::GetFileSize(const char* _rFullPath) +u64 CFileSystemGCWii::GetFileSize(const std::string& _rFullPath) { if (!m_Initialized) InitFileSystem(); @@ -63,7 +63,7 @@ const char* CFileSystemGCWii::GetFileName(u64 _Address) return nullptr; } -u64 CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) +u64 CFileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) { if (!m_Initialized) InitFileSystem(); @@ -75,14 +75,14 @@ u64 CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _Max if (pFileInfo->m_FileSize > _MaxBufferSize) return 0; - DEBUG_LOG(DISCIO, "Filename: %s. Offset: %" PRIx64 ". Size: %" PRIx64, _rFullPath, + DEBUG_LOG(DISCIO, "Filename: %s. Offset: %" PRIx64 ". Size: %" PRIx64, _rFullPath.c_str(), pFileInfo->m_Offset, pFileInfo->m_FileSize); m_rVolume->Read(pFileInfo->m_Offset, pFileInfo->m_FileSize, _pBuffer); return pFileInfo->m_FileSize; } -bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilename) +bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename) { if (!m_Initialized) InitFileSystem(); @@ -122,7 +122,7 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi return result; } -bool CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const +bool CFileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const { u32 AppSize = Read32(0x2440 + 0x14);// apploader size AppSize += Read32(0x2440 + 0x18); // + trailer size @@ -177,7 +177,7 @@ bool CFileSystemGCWii::GetBootDOL(u8* &buffer, u32 DolSize) const return m_rVolume->Read(DolOffset, DolSize, buffer); } -bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const +bool CFileSystemGCWii::ExportDOL(const std::string& _rExportFolder) const { u32 DolOffset = Read32(0x420) << m_OffsetShift; u32 DolSize = GetBootDOLSize(); @@ -232,14 +232,14 @@ size_t CFileSystemGCWii::GetFileList(std::vector &_rFilenames return m_FileInfoVector.size(); } -const SFileInfo* CFileSystemGCWii::FindFileInfo(const char* _rFullPath) +const SFileInfo* CFileSystemGCWii::FindFileInfo(const std::string& _rFullPath) { if (!m_Initialized) InitFileSystem(); for (auto& fileInfo : m_FileInfoVector) { - if (!strcasecmp(fileInfo.m_FullPath, _rFullPath)) + if (!strcasecmp(fileInfo.m_FullPath, _rFullPath.c_str())) return &fileInfo; } diff --git a/Source/Core/DiscIO/FileSystemGCWii.h b/Source/Core/DiscIO/FileSystemGCWii.h index e882b7a2a5..4ce1e09cbf 100644 --- a/Source/Core/DiscIO/FileSystemGCWii.h +++ b/Source/Core/DiscIO/FileSystemGCWii.h @@ -22,13 +22,13 @@ public: CFileSystemGCWii(const IVolume* _rVolume); virtual ~CFileSystemGCWii(); virtual bool IsValid() const override { return m_Valid; } - virtual u64 GetFileSize(const char* _rFullPath) override; + virtual u64 GetFileSize(const std::string& _rFullPath) override; virtual size_t GetFileList(std::vector &_rFilenames) override; virtual const char* GetFileName(u64 _Address) override; - virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) override; - virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) override; - virtual bool ExportApploader(const char* _rExportFolder) const override; - virtual bool ExportDOL(const char* _rExportFolder) const override; + virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) override; + virtual bool ExportFile(const std::string& _rFullPath, const std::string&_rExportFilename) override; + virtual bool ExportApploader(const std::string& _rExportFolder) const override; + virtual bool ExportDOL(const std::string& _rExportFolder) const override; virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const override; virtual u32 GetBootDOLSize() const override; @@ -40,7 +40,7 @@ private: std::vector m_FileInfoVector; u32 Read32(u64 _Offset) const; std::string GetStringFromOffset(u64 _Offset) const; - const SFileInfo* FindFileInfo(const char* _rFullPath); + const SFileInfo* FindFileInfo(const std::string& _rFullPath); bool DetectFileSystem(); void InitFileSystem(); size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset); diff --git a/Source/Core/DiscIO/Filesystem.h b/Source/Core/DiscIO/Filesystem.h index af51c4cdaa..44fa88391b 100644 --- a/Source/Core/DiscIO/Filesystem.h +++ b/Source/Core/DiscIO/Filesystem.h @@ -6,6 +6,7 @@ #include #include +#include #include #include "Common/CommonTypes.h" @@ -43,11 +44,11 @@ public: virtual ~IFileSystem(); virtual bool IsValid() const = 0; virtual size_t GetFileList(std::vector &_rFilenames) = 0; - virtual u64 GetFileSize(const char* _rFullPath) = 0; - virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) = 0; - virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) = 0; - virtual bool ExportApploader(const char* _rExportFolder) const = 0; - virtual bool ExportDOL(const char* _rExportFolder) const = 0; + virtual u64 GetFileSize(const std::string& _rFullPath) = 0; + virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) = 0; + virtual bool ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename) = 0; + virtual bool ExportApploader(const std::string& _rExportFolder) const = 0; + virtual bool ExportDOL(const std::string& _rExportFolder) const = 0; virtual const char* GetFileName(u64 _Address) = 0; virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const = 0; virtual u32 GetBootDOLSize() const = 0; diff --git a/Source/Core/DiscIO/VolumeCreator.cpp b/Source/Core/DiscIO/VolumeCreator.cpp index a223c263ea..bb5aeb31a1 100644 --- a/Source/Core/DiscIO/VolumeCreator.cpp +++ b/Source/Core/DiscIO/VolumeCreator.cpp @@ -74,7 +74,7 @@ EDiscType GetDiscType(IBlobReader& _rReader); IVolume* CreateVolumeFromFilename(const std::string& _rFilename, u32 _PartitionGroup, u32 _VolumeNum) { - IBlobReader* pReader = CreateBlobReader(_rFilename.c_str()); + IBlobReader* pReader = CreateBlobReader(_rFilename); if (pReader == nullptr) return nullptr; diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp index 53dd7380cc..c60c38f387 100644 --- a/Source/Core/DiscIO/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/VolumeDirectory.cpp @@ -133,7 +133,7 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const _dbg_assert_(DVDINTERFACE, fileIter->first <= _Offset); u64 fileOffset = _Offset - fileIter->first; - PlainFileReader* reader = PlainFileReader::Create(fileIter->second.c_str()); + PlainFileReader* reader = PlainFileReader::Create(fileIter->second); if (reader == nullptr) return false; @@ -326,12 +326,12 @@ bool CVolumeDirectory::SetApploader(const std::string& _rApploader) } } -void CVolumeDirectory::SetDOL(const std::string& _rDOL) +void CVolumeDirectory::SetDOL(const std::string& rDOL) { - if (!_rDOL.empty()) + if (!rDOL.empty()) { std::string data; - File::ReadFileToString(_rDOL.c_str(), data); + File::ReadFileToString(rDOL, data); m_DOLSize = data.size(); m_DOL = new u8[m_DOLSize]; copy(data.begin(), data.end(), m_DOL); diff --git a/Source/Core/DiscIO/WbfsBlob.cpp b/Source/Core/DiscIO/WbfsBlob.cpp index 4b93244f83..61733fa7cb 100644 --- a/Source/Core/DiscIO/WbfsBlob.cpp +++ b/Source/Core/DiscIO/WbfsBlob.cpp @@ -23,10 +23,10 @@ static inline u64 align(u64 value, u64 bounds) return (value + (bounds - 1)) & (~(bounds - 1)); } -WbfsFileReader::WbfsFileReader(const char* filename) +WbfsFileReader::WbfsFileReader(const std::string& filename) : m_total_files(0), m_size(0), m_wlba_table(nullptr), m_good(true) { - if (!filename || (strlen(filename) < 4) || !OpenFiles(filename) || !ReadHeader()) + if (filename.length() < 4 || !OpenFiles(filename) || !ReadHeader()) { m_good = false; return; @@ -48,7 +48,7 @@ WbfsFileReader::~WbfsFileReader() delete[] m_wlba_table; } -bool WbfsFileReader::OpenFiles(const char* filename) +bool WbfsFileReader::OpenFiles(const std::string& filename) { m_total_files = 0; @@ -171,7 +171,7 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available) return m_files[0]->file; } -WbfsFileReader* WbfsFileReader::Create(const char* filename) +WbfsFileReader* WbfsFileReader::Create(const std::string& filename) { WbfsFileReader* reader = new WbfsFileReader(filename); @@ -186,7 +186,7 @@ WbfsFileReader* WbfsFileReader::Create(const char* filename) } } -bool IsWbfsBlob(const char* filename) +bool IsWbfsBlob(const std::string& filename) { File::IOFile f(filename, "rb"); diff --git a/Source/Core/DiscIO/WbfsBlob.h b/Source/Core/DiscIO/WbfsBlob.h index dea62819b6..dc75869b82 100644 --- a/Source/Core/DiscIO/WbfsBlob.h +++ b/Source/Core/DiscIO/WbfsBlob.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include "Common/CommonTypes.h" @@ -15,10 +16,10 @@ namespace DiscIO class WbfsFileReader : public IBlobReader { - WbfsFileReader(const char* filename); + WbfsFileReader(const std::string& filename); ~WbfsFileReader(); - bool OpenFiles(const char* filename); + bool OpenFiles(const std::string& filename); bool ReadHeader(); File::IOFile& SeekToCluster(u64 offset, u64* available); @@ -54,14 +55,14 @@ class WbfsFileReader : public IBlobReader bool m_good; public: - static WbfsFileReader* Create(const char* filename); + static WbfsFileReader* Create(const std::string& filename); u64 GetDataSize() const override { return m_size; } u64 GetRawSize() const override { return m_size; } bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; }; -bool IsWbfsBlob(const char* filename); +bool IsWbfsBlob(const std::string& filename); } // namespace diff --git a/Source/Core/DiscIO/WiiWad.cpp b/Source/Core/DiscIO/WiiWad.cpp index 48e40a4b68..4223a899b0 100644 --- a/Source/Core/DiscIO/WiiWad.cpp +++ b/Source/Core/DiscIO/WiiWad.cpp @@ -34,7 +34,7 @@ private: WiiWAD::WiiWAD(const std::string& _rName) { - DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName.c_str()); + DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName); if (pReader == nullptr || File::IsDirectory(_rName)) { m_Valid = false; @@ -120,7 +120,7 @@ bool WiiWAD::ParseWAD(DiscIO::IBlobReader& _rReader) bool WiiWAD::IsWiiWAD(const std::string& _rName) { - DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName.c_str()); + DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName); if (pReader == nullptr) return false; diff --git a/Source/Core/DolphinWX/ARCodeAddEdit.cpp b/Source/Core/DolphinWX/ARCodeAddEdit.cpp index ec8934d5c9..60a3215f45 100644 --- a/Source/Core/DolphinWX/ARCodeAddEdit.cpp +++ b/Source/Core/DolphinWX/ARCodeAddEdit.cpp @@ -112,8 +112,8 @@ void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event)) if (pieces.size() == 2 && pieces[0].size() == 8 && pieces[1].size() == 8) { // Decrypted code line. - u32 addr = strtoul(pieces[0].c_str(), nullptr, 16); - u32 value = strtoul(pieces[1].c_str(), nullptr, 16); + u32 addr = std::stoul(pieces[0], nullptr, 16); + u32 value = std::stoul(pieces[1], nullptr, 16); decryptedLines.push_back(ActionReplay::AREntry(addr, value)); continue; diff --git a/Source/Core/DolphinWX/ConfigMain.cpp b/Source/Core/DolphinWX/ConfigMain.cpp index a504ced08c..3f1812420f 100644 --- a/Source/Core/DolphinWX/ConfigMain.cpp +++ b/Source/Core/DolphinWX/ConfigMain.cpp @@ -1062,7 +1062,7 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA) { if (File::Exists(filename)) { - GCMemcard memorycard(filename.c_str()); + GCMemcard memorycard(filename); if (!memorycard.IsValid()) { PanicAlertT("Cannot use that file as a memory card.\n%s\n" \ diff --git a/Source/Core/DolphinWX/Debugger/BreakpointDlg.cpp b/Source/Core/DolphinWX/Debugger/BreakpointDlg.cpp index 87a2a3a32a..f19510b9f1 100644 --- a/Source/Core/DolphinWX/Debugger/BreakpointDlg.cpp +++ b/Source/Core/DolphinWX/Debugger/BreakpointDlg.cpp @@ -42,7 +42,7 @@ void BreakPointDlg::OnOK(wxCommandEvent& event) { wxString AddressString = m_pEditAddress->GetLineText(0); u32 Address = 0; - if (AsciiToHex(WxStrToStr(AddressString).c_str(), Address)) + if (AsciiToHex(WxStrToStr(AddressString), Address)) { PowerPC::breakpoints.Add(Address); Parent->NotifyUpdate(); diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index ef76d59424..698265613d 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -195,7 +195,7 @@ void CCodeWindow::OnProfilerMenu(wxCommandEvent& event) { std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt"; File::CreateFullPath(filename); - Profiler::WriteProfileResults(filename.c_str()); + Profiler::WriteProfileResults(filename); wxFileType* filetype = nullptr; if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("txt")))) @@ -235,7 +235,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) { PPCAnalyst::FindFunctions(0x80000000, 0x81800000, &g_symbolDB); SignatureDB db; - if (db.Load((File::GetSysDirectory() + TOTALDB).c_str())) + if (db.Load(File::GetSysDirectory() + TOTALDB)) { db.Apply(&g_symbolDB); Parent->StatusBarMessage("Generated symbol names from '%s'", TOTALDB); @@ -255,23 +255,23 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) g_symbolDB.Clear(); PPCAnalyst::FindFunctions(0x81300000, 0x81800000, &g_symbolDB); SignatureDB db; - if (db.Load((File::GetSysDirectory() + TOTALDB).c_str())) + if (db.Load(File::GetSysDirectory() + TOTALDB)) db.Apply(&g_symbolDB); Parent->StatusBarMessage("'%s' not found, scanning for common functions instead", writable_map_file.c_str()); } else { - g_symbolDB.LoadMap(existing_map_file.c_str()); + g_symbolDB.LoadMap(existing_map_file); Parent->StatusBarMessage("Loaded symbols from '%s'", existing_map_file.c_str()); } HLE::PatchFunctions(); NotifyMapLoaded(); break; case IDM_SAVEMAPFILE: - g_symbolDB.SaveMap(writable_map_file.c_str()); + g_symbolDB.SaveMap(writable_map_file); break; case IDM_SAVEMAPFILEWITHCODES: - g_symbolDB.SaveMap(writable_map_file.c_str(), true); + g_symbolDB.SaveMap(writable_map_file, true); break; case IDM_RENAME_SYMBOLS: @@ -328,8 +328,8 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) if (!path.IsEmpty()) { SignatureDB db; - db.Initialize(&g_symbolDB, prefix.c_str()); - db.Save(WxStrToStr(path).c_str()); + db.Initialize(&g_symbolDB, prefix); + db.Save(WxStrToStr(path)); } } } @@ -343,7 +343,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) if (!path.IsEmpty()) { SignatureDB db; - db.Load(WxStrToStr(path).c_str()); + db.Load(WxStrToStr(path)); db.Apply(&g_symbolDB); } } diff --git a/Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp b/Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp index 333438773d..4ab8b93026 100644 --- a/Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp +++ b/Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp @@ -278,50 +278,50 @@ void GFXDebuggerPanel::OnDumpButton(wxCommandEvent& event) switch (m_pDumpList->GetSelection()) { case 0: // Pixel Shader - DumpPixelShader(dump_path.c_str()); + DumpPixelShader(dump_path); break; case 1: // Vertex Shader - DumpVertexShader(dump_path.c_str()); + DumpVertexShader(dump_path); break; case 2: // Pixel Shader Constants - DumpPixelShaderConstants(dump_path.c_str()); + DumpPixelShaderConstants(dump_path); wxMessageBox(_("Not implemented"), _("Error"), wxOK); break; case 3: // Vertex Shader Constants - DumpVertexShaderConstants(dump_path.c_str()); + DumpVertexShaderConstants(dump_path); wxMessageBox(_("Not implemented"), _("Error"), wxOK); break; case 4: // Textures - DumpTextures(dump_path.c_str()); + DumpTextures(dump_path); wxMessageBox(_("Not implemented"), _("Error"), wxOK); break; case 5: // Frame Buffer - DumpFrameBuffer(dump_path.c_str()); + DumpFrameBuffer(dump_path); wxMessageBox(_("Not implemented"), _("Error"), wxOK); break; case 6: // Geometry - DumpGeometry(dump_path.c_str()); + DumpGeometry(dump_path); wxMessageBox(_("Not implemented"), _("Error"), wxOK); break; case 7: // Vertex Description - DumpVertexDecl(dump_path.c_str()); + DumpVertexDecl(dump_path); wxMessageBox(_("Not implemented"), _("Error"), wxOK); break; case 8: // Vertex Matrices - DumpMatrices(dump_path.c_str()); + DumpMatrices(dump_path); wxMessageBox(_("Not implemented"), _("Error"), wxOK); break; case 9: // Statistics - DumpStats(dump_path.c_str()); + DumpStats(dump_path); wxMessageBox(_("Not implemented"), _("Error"), wxOK); break; } diff --git a/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp b/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp index 8c5deb93ac..569cd8ad0a 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp @@ -81,9 +81,9 @@ void MemoryCheckDlg::OnOK(wxCommandEvent& event) u32 StartAddress, EndAddress; bool EndAddressOK = EndAddressString.Len() && - AsciiToHex(WxStrToStr(EndAddressString).c_str(), EndAddress); + AsciiToHex(WxStrToStr(EndAddressString), EndAddress); - if (AsciiToHex(WxStrToStr(StartAddressString).c_str(), StartAddress) && + if (AsciiToHex(WxStrToStr(StartAddressString), StartAddress) && (OnRead || OnWrite) && (Log || Break)) { TMemCheck MemCheck; diff --git a/Source/Core/DolphinWX/FifoPlayerDlg.cpp b/Source/Core/DolphinWX/FifoPlayerDlg.cpp index baa5aace96..8262af96dd 100644 --- a/Source/Core/DolphinWX/FifoPlayerDlg.cpp +++ b/Source/Core/DolphinWX/FifoPlayerDlg.cpp @@ -413,7 +413,7 @@ void FifoPlayerDlg::OnSaveFile(wxCommandEvent& WXUNUSED(event)) { // Attempt to save the file to the path the user chose wxBeginBusyCursor(); - bool result = file->Save(WxStrToStr(path).c_str()); + bool result = file->Save(WxStrToStr(path)); wxEndBusyCursor(); // Wasn't able to save the file, shit's whack, yo. diff --git a/Source/Core/DolphinWX/FrameAui.cpp b/Source/Core/DolphinWX/FrameAui.cpp index ba7ae55186..10aa258fe6 100644 --- a/Source/Core/DolphinWX/FrameAui.cpp +++ b/Source/Core/DolphinWX/FrameAui.cpp @@ -579,7 +579,7 @@ void CFrame::OnToolBar(wxCommandEvent& event) } SaveIniPerspectives(); GetStatusBar()->SetStatusText(StrToWxStr(std::string - ("Saved " + Perspectives[ActivePerspective].Name).c_str()), 0); + ("Saved " + Perspectives[ActivePerspective].Name)), 0); break; case IDM_PERSPECTIVES_ADD_PANE: AddPane(); @@ -869,12 +869,14 @@ void CFrame::LoadIniPerspectives() for (auto& Width : _SWidth) { int _Tmp; - if (TryParse(Width.c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp); + if (TryParse(Width, &_Tmp)) + Tmp.Width.push_back(_Tmp); } for (auto& Height : _SHeight) { int _Tmp; - if (TryParse(Height.c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp); + if (TryParse(Height, &_Tmp)) + Tmp.Height.push_back(_Tmp); } Perspectives.push_back(Tmp); } diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 7b55249af6..1fa071645f 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -674,7 +674,7 @@ void CFrame::DoOpen(bool Boot) } else { - DVDInterface::ChangeDisc(WxStrToStr(path).c_str()); + DVDInterface::ChangeDisc(WxStrToStr(path)); } } @@ -771,7 +771,7 @@ void CFrame::OnPlayRecording(wxCommandEvent& WXUNUSED (event)) GetMenuBar()->FindItem(IDM_RECORDREADONLY)->Check(true); } - if (Movie::PlayInput(WxStrToStr(path).c_str())) + if (Movie::PlayInput(WxStrToStr(path))) BootGame(std::string("")); } @@ -1183,7 +1183,7 @@ void CFrame::DoRecordingSave() if (path.IsEmpty()) return; - Movie::SaveRecording(WxStrToStr(path).c_str()); + Movie::SaveRecording(WxStrToStr(path)); if (!paused) DoPause(); @@ -1822,7 +1822,7 @@ void CFrame::GameListChanged(wxCommandEvent& event) break; case IDM_PURGECACHE: CFileSearch::XStringVector Directories; - Directories.push_back(File::GetUserPath(D_CACHE_IDX).c_str()); + Directories.push_back(File::GetUserPath(D_CACHE_IDX)); CFileSearch::XStringVector Extensions; Extensions.push_back("*.cache"); diff --git a/Source/Core/DolphinWX/GLInterface/EGL.cpp b/Source/Core/DolphinWX/GLInterface/EGL.cpp index 4ad45005a1..440e4bab03 100644 --- a/Source/Core/DolphinWX/GLInterface/EGL.cpp +++ b/Source/Core/DolphinWX/GLInterface/EGL.cpp @@ -7,7 +7,7 @@ #include "VideoCommon/RenderBase.h" // Show the current FPS -void cInterfaceEGL::UpdateFPSDisplay(const char *text) +void cInterfaceEGL::UpdateFPSDisplay(const std::string& text) { Platform.UpdateFPSDisplay(text); } @@ -20,7 +20,7 @@ void cInterfaceEGL::SwapInterval(int Interval) eglSwapInterval(GLWin.egl_dpy, Interval); } -void* cInterfaceEGL::GetFuncAddress(std::string name) +void* cInterfaceEGL::GetFuncAddress(const std::string& name) { return (void*)eglGetProcAddress(name.c_str()); } diff --git a/Source/Core/DolphinWX/GLInterface/EGL.h b/Source/Core/DolphinWX/GLInterface/EGL.h index 54a977aa1b..d482ae8c90 100644 --- a/Source/Core/DolphinWX/GLInterface/EGL.h +++ b/Source/Core/DolphinWX/GLInterface/EGL.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include "Core/ConfigManager.h" #include "DolphinWX/GLInterface/InterfaceBase.h" @@ -26,7 +27,7 @@ public: EGLDisplay EGLGetDisplay(void); EGLNativeWindowType CreateWindow(void); void DestroyWindow(void); - void UpdateFPSDisplay(const char *text); + void UpdateFPSDisplay(const std::string& text); void ToggleFullscreen(bool fullscreen); void SwapBuffers(); }; @@ -41,8 +42,8 @@ public: void SwapInterval(int Interval); void Swap(); void SetMode(u32 mode) { s_opengl_mode = mode; } - void UpdateFPSDisplay(const char *Text); - void* GetFuncAddress(std::string name); + void UpdateFPSDisplay(const std::string& text); + void* GetFuncAddress(const std::string& name); bool Create(void *&window_handle); bool MakeCurrent(); void Shutdown(); diff --git a/Source/Core/DolphinWX/GLInterface/GLX.cpp b/Source/Core/DolphinWX/GLInterface/GLX.cpp index 2735eb2b6e..d48ff9086e 100644 --- a/Source/Core/DolphinWX/GLInterface/GLX.cpp +++ b/Source/Core/DolphinWX/GLInterface/GLX.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Core/Host.h" #include "DolphinWX/GLInterface/GLInterface.h" @@ -13,9 +15,9 @@ typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr; // Show the current FPS -void cInterfaceGLX::UpdateFPSDisplay(const char *text) +void cInterfaceGLX::UpdateFPSDisplay(const std::string& text) { - XStoreName(GLWin.evdpy, GLWin.win, text); + XStoreName(GLWin.evdpy, GLWin.win, text.c_str()); } void cInterfaceGLX::SwapInterval(int Interval) diff --git a/Source/Core/DolphinWX/GLInterface/GLX.h b/Source/Core/DolphinWX/GLInterface/GLX.h index 264d3e37e7..b8ab9687b4 100644 --- a/Source/Core/DolphinWX/GLInterface/GLX.h +++ b/Source/Core/DolphinWX/GLInterface/GLX.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "DolphinWX/GLInterface/InterfaceBase.h" #include "DolphinWX/GLInterface/X11_Util.h" @@ -15,7 +17,7 @@ public: friend class cX11Window; void SwapInterval(int Interval) override; void Swap() override; - void UpdateFPSDisplay(const char *Text) override; + void UpdateFPSDisplay(const std::string& text) override; void* GetFuncAddress(std::string name) override; bool Create(void *&window_handle) override; bool MakeCurrent() override; diff --git a/Source/Core/DolphinWX/GLInterface/InterfaceBase.h b/Source/Core/DolphinWX/GLInterface/InterfaceBase.h index f6091d5221..cdb51eeed4 100644 --- a/Source/Core/DolphinWX/GLInterface/InterfaceBase.h +++ b/Source/Core/DolphinWX/GLInterface/InterfaceBase.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "Common/Common.h" enum GLInterfaceMode { @@ -23,7 +25,7 @@ protected: u32 s_opengl_mode; public: virtual void Swap() {} - virtual void UpdateFPSDisplay(const char *Text) {} + virtual void UpdateFPSDisplay(const std::string& text) {} virtual void SetMode(u32 mode) { s_opengl_mode = GLInterfaceMode::MODE_OPENGL; } virtual u32 GetMode() { return s_opengl_mode; } virtual void* GetFuncAddress(std::string name) { return nullptr; } diff --git a/Source/Core/DolphinWX/GLInterface/Platform.cpp b/Source/Core/DolphinWX/GLInterface/Platform.cpp index 66f7d3ce61..6dc8826c46 100644 --- a/Source/Core/DolphinWX/GLInterface/Platform.cpp +++ b/Source/Core/DolphinWX/GLInterface/Platform.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include "Core/Host.h" #include "DolphinWX/GLInterface/GLInterface.h" @@ -185,7 +186,7 @@ void cPlatform::DestroyWindow(void) #endif } -void cPlatform::UpdateFPSDisplay(const char *text) +void cPlatform::UpdateFPSDisplay(const std::string& text) { #if HAVE_WAYLAND if (cPlatform::platform == EGL_PLATFORM_WAYLAND) diff --git a/Source/Core/DolphinWX/GLInterface/WGL.cpp b/Source/Core/DolphinWX/GLInterface/WGL.cpp index 69a8e44924..5d5aba260b 100644 --- a/Source/Core/DolphinWX/GLInterface/WGL.cpp +++ b/Source/Core/DolphinWX/GLInterface/WGL.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Core/Host.h" #include "DolphinWX/GLInterface/GLInterface.h" @@ -55,11 +57,9 @@ bool cInterfaceWGL::PeekMessages() } // Show the current FPS -void cInterfaceWGL::UpdateFPSDisplay(const char *text) +void cInterfaceWGL::UpdateFPSDisplay(const std::string& text) { - TCHAR temp[512]; - swprintf_s(temp, sizeof(temp)/sizeof(TCHAR), _T("%hs"), text); - EmuWindow::SetWindowText(temp); + EmuWindow::SetWindowText(text); } // Create rendering window. diff --git a/Source/Core/DolphinWX/GLInterface/WGL.h b/Source/Core/DolphinWX/GLInterface/WGL.h index fa8846cfbe..f0cd27ccf5 100644 --- a/Source/Core/DolphinWX/GLInterface/WGL.h +++ b/Source/Core/DolphinWX/GLInterface/WGL.h @@ -4,6 +4,7 @@ #pragma once +#include #include "DolphinWX/GLInterface/InterfaceBase.h" class cInterfaceWGL : public cInterfaceBase @@ -11,7 +12,7 @@ class cInterfaceWGL : public cInterfaceBase public: void SwapInterval(int Interval); void Swap(); - void UpdateFPSDisplay(const char *Text); + void UpdateFPSDisplay(const std::string& text); void* GetFuncAddress(std::string name); bool Create(void *&window_handle); bool MakeCurrent(); diff --git a/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp b/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp index ccd9ed7101..577d8a5a13 100644 --- a/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp +++ b/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp @@ -379,9 +379,9 @@ void cWaylandInterface::DestroyWindow(void) wl_surface_destroy(GLWin.wl_surface); } -void cWaylandInterface::UpdateFPSDisplay(const char *text) +void cWaylandInterface::UpdateFPSDisplay(const std::string& text) { - wl_shell_surface_set_title(GLWin.wl_shell_surface, text); + wl_shell_surface_set_title(GLWin.wl_shell_surface, text.c_str()); } void cWaylandInterface::ToggleFullscreen(bool fullscreen) diff --git a/Source/Core/DolphinWX/GLInterface/Wayland_Util.h b/Source/Core/DolphinWX/GLInterface/Wayland_Util.h index 9025e00505..1f5ac5e4ed 100644 --- a/Source/Core/DolphinWX/GLInterface/Wayland_Util.h +++ b/Source/Core/DolphinWX/GLInterface/Wayland_Util.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include @@ -22,7 +23,7 @@ public: void *EGLGetDisplay(void); void *CreateWindow(void); void DestroyWindow(void); - void UpdateFPSDisplay(const char *text); + void UpdateFPSDisplay(const std::string& text); void ToggleFullscreen(bool fullscreen); void SwapBuffers(); }; diff --git a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp index 24534787f5..06bf09fe80 100644 --- a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp +++ b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp @@ -106,9 +106,9 @@ void cXInterface::DestroyWindow(void) XFreeColormap(GLWin.evdpy, GLWin.attr.colormap); } -void cXInterface::UpdateFPSDisplay(const char *text) +void cXInterface::UpdateFPSDisplay(const std::string& text) { - XStoreName(GLWin.evdpy, GLWin.win, text); + XStoreName(GLWin.evdpy, GLWin.win, text.c_str()); } void cXInterface::SwapBuffers() diff --git a/Source/Core/DolphinWX/GLInterface/X11_Util.h b/Source/Core/DolphinWX/GLInterface/X11_Util.h index 6294df5f9e..be187906bb 100644 --- a/Source/Core/DolphinWX/GLInterface/X11_Util.h +++ b/Source/Core/DolphinWX/GLInterface/X11_Util.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include @@ -19,7 +20,7 @@ public: void *EGLGetDisplay(void); void *CreateWindow(void); void DestroyWindow(void); - void UpdateFPSDisplay(const char *text); + void UpdateFPSDisplay(const std::string& text); void SwapBuffers(); }; #else diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index 3ff0055948..a193e19447 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -500,16 +500,14 @@ void CGameListCtrl::ScanForISOs() bool duplicate = false; for (auto& Directory : Directories) { - if (strcmp(Directory.c_str(), - Entry.physicalName.c_str()) == 0) + if (Directory == Entry.physicalName) { duplicate = true; break; } } if (!duplicate) - Directories.push_back( - Entry.physicalName.c_str()); + Directories.push_back(Entry.physicalName); } } } @@ -949,7 +947,7 @@ void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) wxFileName path = wxFileName::FileName(StrToWxStr(iso->GetFileName())); path.MakeAbsolute(); - WxUtils::Explore(path.GetPath().char_str()); + WxUtils::Explore(WxStrToStr(path.GetPath())); } void CGameListCtrl::OnOpenSaveFolder(wxCommandEvent& WXUNUSED (event)) @@ -959,7 +957,7 @@ void CGameListCtrl::OnOpenSaveFolder(wxCommandEvent& WXUNUSED (event)) return; std::string path = iso->GetWiiFSPath(); if (!path.empty()) - WxUtils::Explore(path.c_str()); + WxUtils::Explore(path); } void CGameListCtrl::OnExportSave(wxCommandEvent& WXUNUSED (event)) @@ -1056,7 +1054,7 @@ void CGameListCtrl::OnWiki(wxCommandEvent& WXUNUSED (event)) else wikiUrl = ReplaceAll(wikiUrl, "[GAME_NAME]", ""); - WxUtils::Launch(wikiUrl.c_str()); + WxUtils::Launch(wikiUrl); } void CGameListCtrl::MultiCompressCB(const char* text, float percent, void* arg) @@ -1128,8 +1126,8 @@ void CGameListCtrl::CompressSelection(bool _compress) wxYES_NO) == wxNO) continue; - all_good &= DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), - OutputFileName.c_str(), + all_good &= DiscIO::CompressFileToBlob(iso->GetFileName(), + OutputFileName, (iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0, 16384, &MultiCompressCB, &progressDialog); } @@ -1240,11 +1238,11 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) if (iso->IsCompressed()) - all_good = DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), - path.char_str(), &CompressCB, &dialog); + all_good = DiscIO::DecompressBlobToFile(iso->GetFileName(), + WxStrToStr(path), &CompressCB, &dialog); else - all_good = DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), - path.char_str(), + all_good = DiscIO::CompressFileToBlob(iso->GetFileName(), + WxStrToStr(path), (iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0, 16384, &CompressCB, &dialog); } @@ -1326,7 +1324,7 @@ void CGameListCtrl::OnDropFiles(wxDropFilesEvent& event) main_frame->GetMenuBar()->FindItem(IDM_RECORDREADONLY)->Check(true); } - if (Movie::PlayInput(file.GetFullPath().c_str())) + if (Movie::PlayInput(WxStrToStr(file.GetFullPath()))) main_frame->BootGame(std::string("")); } else if (!Core::IsRunning()) @@ -1335,6 +1333,6 @@ void CGameListCtrl::OnDropFiles(wxDropFilesEvent& event) } else { - DVDInterface::ChangeDisc(WxStrToStr(file.GetFullPath()).c_str()); + DVDInterface::ChangeDisc(WxStrToStr(file.GetFullPath())); } } diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 81a2f49593..63c30f10bb 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -73,7 +73,7 @@ GameListItem::GameListItem(const std::string& _rFileName) m_VolumeSize = pVolume->GetSize(); m_UniqueID = pVolume->GetUniqueID(); - m_BlobCompressed = DiscIO::IsCompressedBlob(_rFileName.c_str()); + m_BlobCompressed = DiscIO::IsCompressedBlob(_rFileName); m_IsDiscTwo = pVolume->IsDiscTwo(); m_Revision = pVolume->GetRevision(); @@ -278,32 +278,31 @@ std::string GameListItem::GetName(int _index) const const std::string GameListItem::GetWiiFSPath() const { - DiscIO::IVolume *Iso = DiscIO::CreateVolumeFromFilename(m_FileName); + DiscIO::IVolume *iso = DiscIO::CreateVolumeFromFilename(m_FileName); std::string ret; - if (Iso == nullptr) + if (iso == nullptr) return ret; - if (DiscIO::IsVolumeWiiDisc(Iso) || DiscIO::IsVolumeWadFile(Iso)) + if (DiscIO::IsVolumeWiiDisc(iso) || DiscIO::IsVolumeWadFile(iso)) { - char Path[250]; - u64 Title; + u64 title; - Iso->GetTitleID((u8*)&Title); - Title = Common::swap64(Title); + iso->GetTitleID((u8*)&title); + title = Common::swap64(title); - sprintf(Path, "%stitle/%08x/%08x/data/", - File::GetUserPath(D_WIIUSER_IDX).c_str(), (u32)(Title>>32), (u32)Title); + const std::string path = StringFromFormat("%stitle/%08x/%08x/data/", + File::GetUserPath(D_WIIUSER_IDX).c_str(), (u32)(title>>32), (u32)title); - if (!File::Exists(Path)) - File::CreateFullPath(Path); + if (!File::Exists(path)) + File::CreateFullPath(path); - if (Path[0] == '.') - ret = WxStrToStr(wxGetCwd()) + std::string(Path).substr(strlen(ROOT_DIR)); + if (path[0] == '.') + ret = WxStrToStr(wxGetCwd()) + path.substr(strlen(ROOT_DIR)); else - ret = std::string(Path); + ret = path; } - delete Iso; + delete iso; return ret; } diff --git a/Source/Core/DolphinWX/ISOProperties.cpp b/Source/Core/DolphinWX/ISOProperties.cpp index a461389cd1..8f821e5058 100644 --- a/Source/Core/DolphinWX/ISOProperties.cpp +++ b/Source/Core/DolphinWX/ISOProperties.cpp @@ -735,11 +735,11 @@ void CISOProperties::OnExtractFile(wxCommandEvent& WXUNUSED (event)) { int partitionNum = wxAtoi(File.Mid(File.find_first_of("/"), 1)); File.Remove(0, File.find_first_of("/") +1); // Remove "Partition x/" - WiiDisc.at(partitionNum).FileSystem->ExportFile(WxStrToStr(File).c_str(), WxStrToStr(Path).c_str()); + WiiDisc.at(partitionNum).FileSystem->ExportFile(WxStrToStr(File), WxStrToStr(Path)); } else { - pFileSystem->ExportFile(WxStrToStr(File).c_str(), WxStrToStr(Path).c_str()); + pFileSystem->ExportFile(WxStrToStr(File), WxStrToStr(Path)); } } @@ -915,11 +915,11 @@ void CISOProperties::OnExtractDataFromHeader(wxCommandEvent& event) bool ret = false; if (event.GetId() == IDM_EXTRACTAPPLOADER) { - ret = FS->ExportApploader(WxStrToStr(Path).c_str()); + ret = FS->ExportApploader(WxStrToStr(Path)); } else if (event.GetId() == IDM_EXTRACTDOL) { - ret = FS->ExportDOL(WxStrToStr(Path).c_str()); + ret = FS->ExportDOL(WxStrToStr(Path)); } if (!ret) @@ -1135,7 +1135,7 @@ bool CISOProperties::SaveGameConfig() ActionReplayList_Save(); Gecko::SaveCodes(GameIniLocal, m_geckocode_panel->GetCodes()); - bool success = GameIniLocal.Save(GameIniFileLocal.c_str()); + bool success = GameIniLocal.Save(GameIniFileLocal); // If the resulting file is empty, delete it. Kind of a hack, but meh. if (success && File::GetSize(GameIniFileLocal) == 0) diff --git a/Source/Core/DolphinWX/InputConfigDiag.cpp b/Source/Core/DolphinWX/InputConfigDiag.cpp index 6cac0e4d25..ef38ca53cb 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/InputConfigDiag.cpp @@ -113,7 +113,7 @@ void PadSettingExtension::UpdateValue() extension->switch_extension = ((wxChoice*)wxcontrol)->GetSelection(); } -PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label) +PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const std::string& label) : PadSetting(new wxCheckBox(parent, -1, wxGetTranslation(StrToWxStr(label)))) , value(_value) { diff --git a/Source/Core/DolphinWX/InputConfigDiag.h b/Source/Core/DolphinWX/InputConfigDiag.h index 6a1bb60f5c..64a3ceabe6 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.h +++ b/Source/Core/DolphinWX/InputConfigDiag.h @@ -84,7 +84,7 @@ public: class PadSettingCheckBox : public PadSetting { public: - PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label); + PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const std::string& label); void UpdateGUI() override; void UpdateValue() override; diff --git a/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp b/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp index 5ade4c711b..e1bc6bd3f2 100644 --- a/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp +++ b/Source/Core/DolphinWX/InputConfigDiagBitmaps.cpp @@ -128,12 +128,12 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event)) , d_of = box / 256.0 , x_of = box / 2.0; - if (strcmp(g->control_group->name, "Main Stick") == 0) + if (g->control_group->name == "Main Stick") { max = (87.0f / 127.0f) * 100; diagonal = (55.0f / 127.0f) * 100.0; } - else if (strcmp(g->control_group->name,"C-Stick") == 0) + else if (g->control_group->name == "C-Stick") { max = (74.0f / 127.0f) * 100; diagonal = (46.0f / 127.0f) * 100; @@ -278,7 +278,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event)) dc.DrawRectangle(n * 12, 0, 14, 12); // text - const char* const name = g->control_group->controls[n]->name; + const std::string name = g->control_group->controls[n]->name; // bit of hax so ZL, ZR show up as L, R dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1); } diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 454512cefe..60574d9820 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -386,7 +386,7 @@ void DolphinApp::AfterInit(wxTimerEvent& WXUNUSED(event)) if (playMovie && movieFile != wxEmptyString) { - if (Movie::PlayInput(movieFile.char_str())) + if (Movie::PlayInput(WxStrToStr(movieFile))) { if (LoadFile && FileToLoad != wxEmptyString) { @@ -602,7 +602,7 @@ void Host_UpdateMainFrame() } } -void Host_UpdateTitle(const char* title) +void Host_UpdateTitle(const std::string& title) { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATETITLE); event.SetString(StrToWxStr(title)); @@ -668,11 +668,11 @@ void Host_SetStartupDebuggingParameters() StartUp.bEnableDebugging = main_frame->g_pCodeWindow ? true : false; // RUNNING_DEBUG } -void Host_UpdateStatusBar(const char* _pText, int Field) +void Host_UpdateStatusBar(const std::string& text, int Field) { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR); // Set the event string - event.SetString(StrToWxStr(_pText)); + event.SetString(StrToWxStr(text)); // Update statusbar field event.SetInt(Field); // Post message diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index d50438f083..5d6366cdba 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -70,9 +70,9 @@ void* Host_GetRenderHandle() void* Host_GetInstance() { return nullptr; } -void Host_UpdateTitle(const char* title) +void Host_UpdateTitle(const std::string& title) { - LOGI(title); + LOGI(title.c_str()); }; void Host_UpdateLogDisplay(){} @@ -112,7 +112,7 @@ void Host_ConnectWiimote(int wm_idx, bool connect) {} void Host_SetWaitCursor(bool enable){} -void Host_UpdateStatusBar(const char* _pText, int Filed){} +void Host_UpdateStatusBar(const std::string& text, int filed){} void Host_SysMessage(const char *fmt, ...) { diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index 04406f32f3..f7f56b2ec5 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "Common/Common.h" #include "Common/LogManager.h" @@ -65,7 +66,7 @@ void* Host_GetRenderHandle() void* Host_GetInstance() { return nullptr; } -void Host_UpdateTitle(const char* title){}; +void Host_UpdateTitle(const std::string& title){}; void Host_UpdateLogDisplay(){} @@ -108,7 +109,7 @@ void Host_ConnectWiimote(int wm_idx, bool connect) {} void Host_SetWaitCursor(bool enable){} -void Host_UpdateStatusBar(const char* _pText, int Filed){} +void Host_UpdateStatusBar(const std::string& text, int filed){} void Host_SysMessage(const char *fmt, ...) { diff --git a/Source/Core/DolphinWX/MemcardManager.cpp b/Source/Core/DolphinWX/MemcardManager.cpp index 1aecc2d9e1..37bd50340a 100644 --- a/Source/Core/DolphinWX/MemcardManager.cpp +++ b/Source/Core/DolphinWX/MemcardManager.cpp @@ -305,7 +305,7 @@ void CMemcardManager::ChangePath(int slot) } else { - if (m_MemcardPath[slot]->GetPath().length() && ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()).c_str(), slot)) + if (m_MemcardPath[slot]->GetPath().length() && ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()), slot)) { if (memoryCard[slot2]) { @@ -360,7 +360,7 @@ void CMemcardManager::OnPageChange(wxCommandEvent& event) m_NextPage[slot]->Disable(); m_MemcardList[slot]->nextPage = false; } - ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()).c_str(), slot); + ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()), slot); break; case ID_PREVPAGE_A: slot = SLOT_A; @@ -376,7 +376,7 @@ void CMemcardManager::OnPageChange(wxCommandEvent& event) m_PrevPage[slot]->Disable(); m_MemcardList[slot]->prevPage = false; } - ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()).c_str(), slot); + ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()), slot); break; } } @@ -415,8 +415,8 @@ void CMemcardManager::OnMenuChange(wxCommandEvent& event) break; } - if (memoryCard[SLOT_A]) ReloadMemcard(WxStrToStr(m_MemcardPath[SLOT_A]->GetPath()).c_str(), SLOT_A); - if (memoryCard[SLOT_B]) ReloadMemcard(WxStrToStr(m_MemcardPath[SLOT_B]->GetPath()).c_str(), SLOT_B); + if (memoryCard[SLOT_A]) ReloadMemcard(WxStrToStr(m_MemcardPath[SLOT_A]->GetPath()), SLOT_A); + if (memoryCard[SLOT_B]) ReloadMemcard(WxStrToStr(m_MemcardPath[SLOT_B]->GetPath()), SLOT_B); } bool CMemcardManager::CopyDeleteSwitch(u32 error, int slot) { @@ -431,7 +431,7 @@ bool CMemcardManager::CopyDeleteSwitch(u32 error, int slot) memoryCard[slot]->FixChecksums(); if (!memoryCard[slot]->Save()) PanicAlert(E_SAVEFAILED); page[slot] = FIRSTPAGE; - ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()).c_str(), slot); + ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()), slot); } break; case NOMEMCARD: @@ -557,7 +557,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) } if (fileName.length() > 0) { - CopyDeleteSwitch(memoryCard[slot]->ImportGci(WxStrToStr(fileName).c_str(), fileName2), slot); + CopyDeleteSwitch(memoryCard[slot]->ImportGci(WxStrToStr(fileName), fileName2), slot); } } break; @@ -585,7 +585,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) if (fileName.length() > 0) { - if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, WxStrToStr(fileName).c_str(), ""), -1)) + if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, WxStrToStr(fileName), ""), -1)) { File::Delete(WxStrToStr(fileName)); } @@ -622,7 +622,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) } } -bool CMemcardManager::ReloadMemcard(const char *fileName, int card) +bool CMemcardManager::ReloadMemcard(const std::string& fileName, int card) { if (memoryCard[card]) delete memoryCard[card]; diff --git a/Source/Core/DolphinWX/MemcardManager.h b/Source/Core/DolphinWX/MemcardManager.h index c2857368f5..625a14fb6d 100644 --- a/Source/Core/DolphinWX/MemcardManager.h +++ b/Source/Core/DolphinWX/MemcardManager.h @@ -116,7 +116,7 @@ class CMemcardManager : public wxDialog void CreateGUIControls(); void CopyDeleteClick(wxCommandEvent& event); - bool ReloadMemcard(const char *fileName, int card); + bool ReloadMemcard(const std::string& fileName, int card); void OnMenuChange(wxCommandEvent& event); void OnPageChange(wxCommandEvent& event); void OnPathChange(wxFileDirPickerEvent& event); diff --git a/Source/Core/DolphinWX/MemoryCards/WiiSaveCrypted.cpp b/Source/Core/DolphinWX/MemoryCards/WiiSaveCrypted.cpp index 7928ae33f0..1f1091328d 100644 --- a/Source/Core/DolphinWX/MemoryCards/WiiSaveCrypted.cpp +++ b/Source/Core/DolphinWX/MemoryCards/WiiSaveCrypted.cpp @@ -65,7 +65,7 @@ void CWiiSaveCrypted::ExportAllSaves() if (entry.isDirectory) { u32 gameid; - if (AsciiToHex(entry.virtualName.c_str(), gameid)) + if (AsciiToHex(entry.virtualName, gameid)) { std::string bannerPath = StringFromFormat("%s%08x/data/banner.bin", folder.c_str(), gameid); if (File::Exists(bannerPath)) diff --git a/Source/Core/DolphinWX/PHackSettings.cpp b/Source/Core/DolphinWX/PHackSettings.cpp index c3cbc77e3f..c43f49b999 100644 --- a/Source/Core/DolphinWX/PHackSettings.cpp +++ b/Source/Core/DolphinWX/PHackSettings.cpp @@ -37,9 +37,8 @@ CPHackSettings::CPHackSettings(wxWindow* parent, wxWindowID id, const wxString& : wxDialog(parent, id, title, position, size, style) { CreateGUIControls(); - std::string _iniFilename; - _iniFilename = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP "PH_PRESETS.ini"; - PHPresetsIni.Load(_iniFilename.c_str()); + std::string _iniFilename = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP "PH_PRESETS.ini"; + PHPresetsIni.Load(_iniFilename); PHPresetsIni.SortSections(); LoadPHackData(); diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index ff61792243..a77e8afe20 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -87,7 +87,7 @@ void VideoConfigDiag::Event_ClickClose(wxCommandEvent&) void VideoConfigDiag::Event_Close(wxCloseEvent& ev) { - g_Config.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); + g_Config.Save(File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini"); EndModal(wxID_OK); } @@ -213,7 +213,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con , vconfig(g_Config) , ininame(_ininame) { - vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); + vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini"); Bind(wxEVT_UPDATE_UI, &VideoConfigDiag::OnUpdateUI, this); diff --git a/Source/Core/DolphinWX/WxUtils.cpp b/Source/Core/DolphinWX/WxUtils.cpp index 11eafa91e9..e4ead447ee 100644 --- a/Source/Core/DolphinWX/WxUtils.cpp +++ b/Source/Core/DolphinWX/WxUtils.cpp @@ -17,10 +17,11 @@ #import #endif -namespace WxUtils { +namespace WxUtils +{ // Launch a file according to its mime type -void Launch(const char *filename) +void Launch(const std::string& filename) { if (! ::wxLaunchDefaultBrowser(StrToWxStr(filename))) { @@ -29,7 +30,7 @@ void Launch(const char *filename) } // Launch an file explorer window on a certain path -void Explore(const char *path) +void Explore(const std::string& path) { wxString wxPath = StrToWxStr(path); #ifndef _WIN32 diff --git a/Source/Core/DolphinWX/WxUtils.h b/Source/Core/DolphinWX/WxUtils.h index f4a77e9f21..e626432cdd 100644 --- a/Source/Core/DolphinWX/WxUtils.h +++ b/Source/Core/DolphinWX/WxUtils.h @@ -16,10 +16,10 @@ namespace WxUtils { // Launch a file according to its mime type -void Launch(const char *filename); +void Launch(const std::string& filename); // Launch an file explorer window on a certain path -void Explore(const char *path); +void Explore(const std::string& path); double GetCurrentBitmapLogicalScale(); diff --git a/Source/Core/InputCommon/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu.cpp index 34b8695ebd..dae3d32e56 100644 --- a/Source/Core/InputCommon/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu.cpp @@ -148,22 +148,22 @@ ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup( } -ControllerEmu::Buttons::Buttons(const char* const _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS) +ControllerEmu::Buttons::Buttons(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS) { settings.emplace_back(new Setting(_trans("Threshold"), 0.5f)); } -ControllerEmu::MixedTriggers::MixedTriggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS) +ControllerEmu::MixedTriggers::MixedTriggers(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS) { settings.emplace_back(new Setting(_trans("Threshold"), 0.9f)); } -ControllerEmu::Triggers::Triggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS) +ControllerEmu::Triggers::Triggers(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS) { settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); } -ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GROUP_TYPE_SLIDER) +ControllerEmu::Slider::Slider(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_SLIDER) { controls.emplace_back(new Input("Left")); controls.emplace_back(new Input("Right")); @@ -171,7 +171,7 @@ ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GRO settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); } -ControllerEmu::Force::Force(const char* const _name) : ControlGroup(_name, GROUP_TYPE_FORCE) +ControllerEmu::Force::Force(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_FORCE) { memset(m_swing, 0, sizeof(m_swing)); @@ -185,7 +185,7 @@ ControllerEmu::Force::Force(const char* const _name) : ControlGroup(_name, GROUP settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); } -ControllerEmu::Tilt::Tilt(const char* const _name) +ControllerEmu::Tilt::Tilt(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_TILT) { memset(m_tilt, 0, sizeof(m_tilt)); @@ -202,7 +202,7 @@ ControllerEmu::Tilt::Tilt(const char* const _name) settings.emplace_back(new Setting(_trans("Angle"), 0.9f, 0, 180)); } -ControllerEmu::Cursor::Cursor(const char* const _name) +ControllerEmu::Cursor::Cursor(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_CURSOR) , m_z(0) { diff --git a/Source/Core/InputCommon/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu.h index 9f8f2db497..eec79ab4e2 100644 --- a/Source/Core/InputCommon/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu.h @@ -60,13 +60,13 @@ public: class Control { protected: - Control(ControllerInterface::ControlReference* const _ref, const char* const _name) + Control(ControllerInterface::ControlReference* const _ref, const std::string& _name) : control_ref(_ref), name(_name) {} public: virtual ~Control() {} std::unique_ptr const control_ref; - const char* const name; + const std::string name; }; @@ -74,7 +74,7 @@ public: { public: - Input(const char* const _name) + Input(const std::string& _name) : Control(new ControllerInterface::InputReference, _name) {} }; @@ -82,7 +82,7 @@ public: { public: - Output(const char* const _name) + Output(const std::string& _name) : Control(new ControllerInterface::OutputReference, _name) {} }; @@ -90,7 +90,7 @@ public: { public: - Setting(const char* const _name, const ControlState def_value + Setting(const std::string& _name, const ControlState def_value , const unsigned int _low = 0, const unsigned int _high = 100) : name(_name) , value(def_value) @@ -98,19 +98,19 @@ public: , low(_low) , high(_high){} - const char* const name; + const std::string name; ControlState value; const ControlState default_value; const unsigned int low, high; }; - ControlGroup(const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {} + ControlGroup(const std::string& _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {} virtual ~ControlGroup() {} virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" ); virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" ); - const char* const name; + const std::string name; const unsigned int type; std::vector> controls; @@ -186,7 +186,7 @@ public: class Buttons : public ControlGroup { public: - Buttons(const char* const _name); + Buttons(const std::string& _name); template void GetState(C* const buttons, const C* bitmasks) @@ -224,7 +224,7 @@ public: } } - MixedTriggers(const char* const _name); + MixedTriggers(const std::string& _name); }; @@ -241,7 +241,7 @@ public: *analog = S(std::max(controls[i]->control_ref->State() - deadzone, 0.0f) / (1 - deadzone) * range); } - Triggers(const char* const _name); + Triggers(const std::string& _name); }; @@ -261,14 +261,14 @@ public: *slider = 0; } - Slider(const char* const _name); + Slider(const std::string& _name); }; class Force : public ControlGroup { public: - Force(const char* const _name); + Force(const std::string& _name); template void GetState(C* axis, const u8 base, const R range) @@ -294,7 +294,7 @@ public: class Tilt : public ControlGroup { public: - Tilt(const char* const _name); + Tilt(const std::string& _name); template void GetState(C* const x, C* const y, const unsigned int base, const R range, const bool step = true) @@ -374,7 +374,7 @@ public: class Cursor : public ControlGroup { public: - Cursor(const char* const _name); + Cursor(const std::string& _name); template void GetState(C* const x, C* const y, C* const z, const bool adjusted = false) @@ -418,7 +418,7 @@ public: class Extension : public ControlGroup { public: - Extension(const char* const _name) + Extension(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_EXTENSION) , switch_extension(0) , active_extension(0) {} diff --git a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp index 036b3fda05..1117ed9856 100644 --- a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include "InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h" namespace ciface @@ -17,7 +18,7 @@ template class ForceFeedbackDevice::Force; typedef struct { GUID guid; - const char* name; + const std::string name; } ForceType; static const ForceType force_type_names[] = @@ -216,7 +217,7 @@ void ForceFeedbackDevice::ForcePeriodic::SetState(const ControlState state) } template -ForceFeedbackDevice::Force

::Force(const char* name, EffectState& state) +ForceFeedbackDevice::Force

::Force(const std::string& name, EffectState& state) : m_name(name), m_state(state) { memset(¶ms, 0, sizeof(params)); diff --git a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h index 643ca2434b..54a465d83e 100644 --- a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h +++ b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include "InputCommon/ControllerInterface/Device.h" @@ -41,10 +42,10 @@ private: { public: std::string GetName() const; - Force(const char* name, EffectState& state); + Force(const std::string& name, EffectState& state); void SetState(ControlState state); private: - const char* m_name; + const std::string m_name; EffectState& m_state; P params; }; diff --git a/Source/Core/InputCommon/UDPWiimote.cpp b/Source/Core/InputCommon/UDPWiimote.cpp index 1519de350a..b4bccdb9f4 100644 --- a/Source/Core/InputCommon/UDPWiimote.cpp +++ b/Source/Core/InputCommon/UDPWiimote.cpp @@ -4,10 +4,11 @@ #include #include +#include #include #include #include -#include +#include #include "Common/Thread.h" #include "Common/Timer.h" @@ -63,10 +64,10 @@ struct UDPWiimote::_d int UDPWiimote::noinst = 0; -UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) : +UDPWiimote::UDPWiimote(const std::string& _port, const std::string& name, int _index) : port(_port), displayName(name), - d(new _d) ,x(0),y(0),z(1.0f),naX(0),naY(0),naZ(-1.0f),nunX(0),nunY(0), - pointerX(1001.0f/2),pointerY(0),nunMask(0),mask(0),index(_index), int_port(atoi(_port)) + d(new _d) ,x(0), y(0), z(1.0f), naX(0), naY(0), naZ(-1.0f), nunX(0), nunY(0), + pointerX(1001.0f / 2), pointerY(0), nunMask(0), mask(0), index(_index), int_port(atoi(_port.c_str())) { static bool sranded=false; @@ -107,7 +108,7 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) : return; } - if ((rv = getaddrinfo(nullptr, _port, &hints, &servinfo)) != 0) + if ((rv = getaddrinfo(nullptr, _port.c_str(), &hints, &servinfo)) != 0) { cleanup; err=-1; @@ -403,7 +404,7 @@ u32 UDPWiimote::getButtons() return msk; } -void UDPWiimote::getIR(float &_x, float &_y) +void UDPWiimote::getIR(float& _x, float& _y) { std::lock_guard lk(d->mutex); _x=(float)pointerX; @@ -418,21 +419,21 @@ void UDPWiimote::getNunchuck(float &_x, float &_y, u8 &_mask) _mask=nunMask; } -void UDPWiimote::getNunchuckAccel(float &_x, float &_y, float &_z) +void UDPWiimote::getNunchuckAccel(float& _x, float& _y, float& _z) { std::lock_guard lk(d->mutex); - _x=(float)naX; - _y=(float)naY; - _z=(float)naZ; + _x = (float)naX; + _y = (float)naY; + _z = (float)naZ; } -const char * UDPWiimote::getPort() +const std::string& UDPWiimote::getPort() { - return port.c_str(); + return port; } -void UDPWiimote::changeName(const char * name) +void UDPWiimote::changeName(const std::string& name) { std::lock_guard lk(d->nameMutex); - displayName=name; + displayName = name; } diff --git a/Source/Core/InputCommon/UDPWiimote.h b/Source/Core/InputCommon/UDPWiimote.h index 82f9635aea..806aa610e2 100644 --- a/Source/Core/InputCommon/UDPWiimote.h +++ b/Source/Core/InputCommon/UDPWiimote.h @@ -25,23 +25,23 @@ class UDPWiimote { public: - UDPWiimote(const char * port, const char * name, int index); + UDPWiimote(const std::string& port, const std::string& name, int index); virtual ~UDPWiimote(); - void getAccel(float &x, float &y, float &z); + void getAccel(float& x, float& y, float& z); u32 getButtons(); - void getNunchuck(float &x, float &y, u8 &mask); - void getIR(float &x, float &y); - void getNunchuckAccel(float &x, float &y, float &z); - int getErrNo() {return err;}; - const char * getPort(); - void changeName(const char * name); + void getNunchuck(float& x, float& y, u8& mask); + void getIR(float& x, float& y); + void getNunchuckAccel(float& x, float& y, float& z); + int getErrNo() { return err; } + const std::string& getPort(); + void changeName(const std::string& name); void mainThread(); private: std::string port,displayName; - int pharsePacket(u8 * data, size_t size); + int pharsePacket(u8* data, size_t size); struct _d; //using pimpl because Winsock2.h doesn't have include guards -_- - _d *d; + _d* d; double x,y,z; double naX,naY,naZ; double nunX,nunY; @@ -54,8 +54,8 @@ private: int int_port; static int noinst; void broadcastPresence(); - void broadcastIPv4(const void * data, size_t size); - void broadcastIPv6(const void * data, size_t size); + void broadcastIPv4(const void* data, size_t size); + void broadcastIPv6(const void* data, size_t size); void initBroadcastIPv4(); void initBroadcastIPv6(); }; diff --git a/Source/Core/InputCommon/UDPWrapper.cpp b/Source/Core/InputCommon/UDPWrapper.cpp index a205fb0280..eeba3bbafd 100644 --- a/Source/Core/InputCommon/UDPWrapper.cpp +++ b/Source/Core/InputCommon/UDPWrapper.cpp @@ -69,12 +69,12 @@ void UDPWrapper::SaveConfig(IniFile::Section *sec, const std::string& defdev, co void UDPWrapper::Refresh() { bool udpAEn=(inst!=nullptr); - if (udpEn&&udpAEn) + if (udpEn && udpAEn) { - if (strcmp(inst->getPort(),port.c_str())) + if (inst->getPort() == port) { delete inst; - inst = new UDPWiimote(port.c_str(),"Dolphin-Emu",index); //TODO: Changeable display name + inst = new UDPWiimote(port, "Dolphin-Emu", index); //TODO: Changeable display name } return; } @@ -86,7 +86,7 @@ void UDPWrapper::Refresh() return; } //else - inst = new UDPWiimote(port.c_str(),"Dolphin-Emu",index); + inst = new UDPWiimote(port, "Dolphin-Emu", index); } UDPWrapper::~UDPWrapper() diff --git a/Source/Core/VideoBackends/D3D/D3DUtil.cpp b/Source/Core/VideoBackends/D3D/D3DUtil.cpp index aeca510f28..a89898de3a 100644 --- a/Source/Core/VideoBackends/D3D/D3DUtil.cpp +++ b/Source/Core/VideoBackends/D3D/D3DUtil.cpp @@ -2,7 +2,9 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include +#include #include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3D/D3DShader.h" @@ -316,7 +318,7 @@ int CD3DFont::Shutdown() return S_OK; } -int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dwColor, const char* strText) +int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dwColor, const std::string& text) { if (!m_pVB) return 0; @@ -331,7 +333,6 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw // translate starting positions float sx = x * scalex - 1.f; float sy = 1.f - y * scaley; - char c; // Fill vertex buffer FONT2DVERTEX* pVertices; @@ -355,14 +356,14 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw D3D::context->PSSetShaderResources(0, 1, &m_pTexture); float fStartX = sx; - while (c = *strText++) + for (char c : text) { - if (c == ('\n')) + if (c == '\n') { sx = fStartX; sy -= scaley * size; } - if (c < (' ')) + if (!std::isprint(c)) continue; c -= 32; diff --git a/Source/Core/VideoBackends/D3D/D3DUtil.h b/Source/Core/VideoBackends/D3D/D3DUtil.h index c3569fded9..bd47d9ff0e 100644 --- a/Source/Core/VideoBackends/D3D/D3DUtil.h +++ b/Source/Core/VideoBackends/D3D/D3DUtil.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include "Common/MathUtil.h" @@ -41,9 +42,9 @@ namespace D3D int Init(); int Shutdown(); int DrawTextScaled(float x, float y, - float size, - float spacing, u32 dwColor, - const char* strText); + float size, + float spacing, u32 dwColor, + const std::string& text); }; extern CD3DFont font; diff --git a/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp b/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp index 466326f64f..d4d3e392b4 100644 --- a/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp @@ -391,7 +391,7 @@ void PixelShaderCache::Init() Clear(); if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX))) - File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX).c_str()); + File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX)); SETSTAT(stats.numPixelShadersCreated, 0); SETSTAT(stats.numPixelShadersAlive, 0); diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 885471aca6..6ed8ae82bc 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -255,7 +255,7 @@ Renderer::~Renderer() D3D::Close(); } -void Renderer::RenderText(const char *text, int left, int top, u32 color) +void Renderer::RenderText(const std::string& text, int left, int top, u32 color) { D3D::font.DrawTextScaled((float)left, (float)top, 20.f, 0.0f, color, text); } diff --git a/Source/Core/VideoBackends/D3D/Render.h b/Source/Core/VideoBackends/D3D/Render.h index b5948164d4..69ce9f3e78 100644 --- a/Source/Core/VideoBackends/D3D/Render.h +++ b/Source/Core/VideoBackends/D3D/Render.h @@ -1,5 +1,6 @@ #pragma once +#include #include "VideoCommon/RenderBase.h" namespace DX11 @@ -30,7 +31,7 @@ public: void ApplyCullDisable(); void RestoreCull(); - void RenderText(const char* pstr, int left, int top, u32 color); + void RenderText(const std::string& text, int left, int top, u32 color); u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data); diff --git a/Source/Core/VideoBackends/D3D/VertexShaderCache.cpp b/Source/Core/VideoBackends/D3D/VertexShaderCache.cpp index d51ce98b30..e58526504c 100644 --- a/Source/Core/VideoBackends/D3D/VertexShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D/VertexShaderCache.cpp @@ -138,7 +138,7 @@ void VertexShaderCache::Init() Clear(); if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX))) - File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX).c_str()); + File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX)); SETSTAT(stats.numVertexShadersCreated, 0); SETSTAT(stats.numVertexShadersAlive, 0); diff --git a/Source/Core/VideoBackends/D3D/VideoBackend.h b/Source/Core/VideoBackends/D3D/VideoBackend.h index a158aced0b..696913cdc4 100644 --- a/Source/Core/VideoBackends/D3D/VideoBackend.h +++ b/Source/Core/VideoBackends/D3D/VideoBackend.h @@ -1,5 +1,6 @@ #pragma once +#include #include "VideoCommon/VideoBackendBase.h" namespace DX11 @@ -18,7 +19,7 @@ class VideoBackend : public VideoBackendHardware void ShowConfig(void* parent); - void UpdateFPSDisplay(const char*); + void UpdateFPSDisplay(const std::string&); unsigned int PeekMessages(); }; diff --git a/Source/Core/VideoBackends/D3D/main.cpp b/Source/Core/VideoBackends/D3D/main.cpp index ae509cbfde..99def4998e 100644 --- a/Source/Core/VideoBackends/D3D/main.cpp +++ b/Source/Core/VideoBackends/D3D/main.cpp @@ -2,11 +2,13 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/LogManager.h" +#include "Common/StringUtil.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -54,11 +56,9 @@ unsigned int VideoBackend::PeekMessages() return TRUE; } -void VideoBackend::UpdateFPSDisplay(const char *text) +void VideoBackend::UpdateFPSDisplay(const std::string& text) { - TCHAR temp[512]; - swprintf_s(temp, sizeof(temp)/sizeof(TCHAR), _T("%hs | D3D | %hs"), scm_rev_str, text); - EmuWindow::SetWindowText(temp); + EmuWindow::SetWindowText(StringFromFormat("%s | D3D | %s", scm_rev_str, text.c_str())); } std::string VideoBackend::GetName() @@ -154,7 +154,7 @@ bool VideoBackend::Initialize(void *&window_handle) frameCount = 0; - g_Config.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_dx11.ini").c_str()); + g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_dx11.ini"); g_Config.GameIniLoad(); g_Config.UpdateProjectionHack(); g_Config.VerifyValidity(); diff --git a/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.cpp b/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.cpp index 99f5004bda..6b6456435e 100644 --- a/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.cpp +++ b/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.cpp @@ -1755,7 +1755,7 @@ namespace GLExtensions // Public members u32 Version() { return _GLVersion; } - bool Supports(std::string name) + bool Supports(const std::string& name) { return m_extension_list[name]; } diff --git a/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h b/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h index 442fda9e78..5bd938f846 100644 --- a/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h +++ b/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h @@ -40,7 +40,7 @@ namespace GLExtensions // Function for checking if the hardware supports an extension // example: if (GLExtensions::Supports("GL_ARB_multi_map")) - bool Supports(std::string name); + bool Supports(const std::string& name); // Returns OpenGL version in format 430 u32 Version(); diff --git a/Source/Core/VideoBackends/OGL/GLUtil.cpp b/Source/Core/VideoBackends/OGL/GLUtil.cpp index 9c5226309d..cafc157145 100644 --- a/Source/Core/VideoBackends/OGL/GLUtil.cpp +++ b/Source/Core/VideoBackends/OGL/GLUtil.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "Common/IniFile.h" +#include "Common/StringUtil.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -27,11 +28,9 @@ unsigned int VideoBackend::PeekMessages() } // Show the current FPS -void VideoBackend::UpdateFPSDisplay(const char *text) +void VideoBackend::UpdateFPSDisplay(const std::string& text) { - char temp[100]; - snprintf(temp, sizeof temp, "%s | %s | %s", scm_rev_str, GetDisplayName().c_str(), text); - return GLInterface->UpdateFPSDisplay(temp); + return GLInterface->UpdateFPSDisplay(StringFromFormat("%s | %s | %s", scm_rev_str, GetDisplayName().c_str(), text.c_str())); } } @@ -48,7 +47,7 @@ void InitInterface() #endif } -GLuint OpenGL_CompileProgram ( const char* vertexShader, const char* fragmentShader ) +GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShader) { // generate objects GLuint vertexShaderID = glCreateShader(GL_VERTEX_SHADER); diff --git a/Source/Core/VideoBackends/OGL/PostProcessing.cpp b/Source/Core/VideoBackends/OGL/PostProcessing.cpp index a4a4c0bbf3..e885d63a56 100644 --- a/Source/Core/VideoBackends/OGL/PostProcessing.cpp +++ b/Source/Core/VideoBackends/OGL/PostProcessing.cpp @@ -133,7 +133,7 @@ void ApplyShader() // Fallback to shared user dir path = File::GetSysDirectory() + SHADERS_DIR DIR_SEP + g_ActiveConfig.sPostProcessingShader + ".glsl"; } - if (!File::ReadFileToString(path.c_str(), code)) { + if (!File::ReadFileToString(path, code)) { ERROR_LOG(VIDEO, "Post-processing shader not found: %s", path.c_str()); return; } diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index 8751ec35c4..5558b13a40 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -381,7 +381,7 @@ void ProgramShaderCache::Init(void) else { if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX))) - File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX).c_str()); + File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX)); char cache_filename[MAX_PATH]; sprintf(cache_filename, "%sogl-%s-shaders.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(), diff --git a/Source/Core/VideoBackends/OGL/RasterFont.cpp b/Source/Core/VideoBackends/OGL/RasterFont.cpp index 55b6f280b3..eb288d9414 100644 --- a/Source/Core/VideoBackends/OGL/RasterFont.cpp +++ b/Source/Core/VideoBackends/OGL/RasterFont.cpp @@ -141,9 +141,12 @@ RasterFont::RasterFont() glActiveTexture(GL_TEXTURE0+8); glBindTexture(GL_TEXTURE_2D, texture); u32* texture_data = new u32[char_width*char_count*char_height]; - for (u32 y=0; y= char_count+char_offset) continue; + if (c < char_offset || c >= char_count+char_offset) + continue; vertices[usage++] = x; vertices[usage++] = y; @@ -245,7 +249,8 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta x += delta_x + border_x; } - if (!usage) { + if (!usage) + { delete [] vertices; return; } @@ -258,7 +263,8 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta s_shader.Bind(); - if (color != cached_color) { + if (color != cached_color) + { glUniform4f(uniform_color_id, GLfloat((color>>16)&0xff)/255.f,GLfloat((color>>8)&0xff)/255.f,GLfloat((color>>0)&0xff)/255.f,GLfloat((color>>24)&0xff)/255.f); cached_color = color; } diff --git a/Source/Core/VideoBackends/OGL/RasterFont.h b/Source/Core/VideoBackends/OGL/RasterFont.h index 9a7732d353..1f760868e6 100644 --- a/Source/Core/VideoBackends/OGL/RasterFont.h +++ b/Source/Core/VideoBackends/OGL/RasterFont.h @@ -4,6 +4,8 @@ #pragma once +#include + namespace OGL { @@ -14,7 +16,7 @@ public: ~RasterFont(void); static int debug; - void printMultilineText(const char *text, double x, double y, double z, int bbWidth, int bbHeight, u32 color); + void printMultilineText(const std::string& text, double x, double y, double z, int bbWidth, int bbHeight, u32 color); private: u32 VBO; diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index cd682137b6..1d83f79d72 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "Common/Atomic.h" @@ -829,7 +830,7 @@ void Renderer::DrawDebugInfo() } } -void Renderer::RenderText(const char *text, int left, int top, u32 color) +void Renderer::RenderText(const std::string& text, int left, int top, u32 color) { const int nBackbufferWidth = (int)GLInterface->GetBackBufferWidth(); const int nBackbufferHeight = (int)GLInterface->GetBackBufferHeight(); @@ -1436,7 +1437,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl { OSD::AddMessage(StringFromFormat( "Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)", - File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), w, h).c_str(), 2000); + File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), w, h), 2000); } } if (bAVIDumping) @@ -1485,7 +1486,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl OSD::AddMessage("Error opening framedump.raw for writing.", 2000); else { - OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h).c_str(), 2000); + OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h), 2000); } } if (pFrameDump) diff --git a/Source/Core/VideoBackends/OGL/Render.h b/Source/Core/VideoBackends/OGL/Render.h index c14faf4ce9..fb822aa352 100644 --- a/Source/Core/VideoBackends/OGL/Render.h +++ b/Source/Core/VideoBackends/OGL/Render.h @@ -1,5 +1,6 @@ #pragma once +#include #include "VideoCommon/RenderBase.h" namespace OGL @@ -27,8 +28,8 @@ extern struct VideoConfig { bool bSupportOGL31; bool bSupportViewportFloat; - const char *gl_vendor; - const char *gl_renderer; + const char* gl_vendor; + const char* gl_renderer; const char* gl_version; const char* glsl_version; @@ -60,7 +61,7 @@ public: void ApplyState(bool bUseDstAlpha) override {} void RestoreState() override {} - void RenderText(const char* pstr, int left, int top, u32 color) override; + void RenderText(const std::string& text, int left, int top, u32 color) override; void DrawDebugInfo(); void FlipImageData(u8 *data, int w, int h, int pixel_width = 3); diff --git a/Source/Core/VideoBackends/OGL/VideoBackend.h b/Source/Core/VideoBackends/OGL/VideoBackend.h index 8b41b006fe..c356feb734 100644 --- a/Source/Core/VideoBackends/OGL/VideoBackend.h +++ b/Source/Core/VideoBackends/OGL/VideoBackend.h @@ -1,5 +1,6 @@ #pragma once +#include #include "VideoCommon/VideoBackendBase.h" namespace OGL @@ -18,7 +19,7 @@ class VideoBackend : public VideoBackendHardware void ShowConfig(void* parent) override; - void UpdateFPSDisplay(const char*) override; + void UpdateFPSDisplay(const std::string&) override; unsigned int PeekMessages() override; }; diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp index d902485bb8..3821225031 100644 --- a/Source/Core/VideoBackends/OGL/main.cpp +++ b/Source/Core/VideoBackends/OGL/main.cpp @@ -123,7 +123,7 @@ void GetShaders(std::vector &shaders) File::ScanDirectoryTree(directory, entry); for (auto& file : entry.children) { - std::string name = file.virtualName.c_str(); + std::string name = file.virtualName; if (name.size() < 5) continue; if (strcasecmp(name.substr(name.size() - 5).c_str(), ".glsl")) @@ -176,7 +176,7 @@ bool VideoBackend::Initialize(void *&window_handle) frameCount = 0; - g_Config.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_opengl.ini").c_str()); + g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_opengl.ini"); g_Config.GameIniLoad(); g_Config.UpdateProjectionHack(); g_Config.VerifyValidity(); diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 60ab61300e..c0736c883a 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -2,10 +2,13 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/Atomic.h" #include "Common/Common.h" #include "Common/FileUtil.h" #include "Common/LogManager.h" +#include "Common/StringUtil.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -284,9 +287,9 @@ u32 VideoSoftware::Video_GetQueryResult(PerfQueryType type) return 0; } -bool VideoSoftware::Video_Screenshot(const char *_szFilename) +bool VideoSoftware::Video_Screenshot(const std::string& filename) { - SWRenderer::SetScreenshot(_szFilename); + SWRenderer::SetScreenshot(filename.c_str()); return true; } @@ -336,7 +339,7 @@ void VideoSoftware::Video_ExitLoop() // TODO : could use the OSD class in video common, we would need to implement the Renderer class // however most of it is useless for the SW backend so we could as well move it to its own class -void VideoSoftware::Video_AddMessage(const char* pstr, u32 milliseconds) +void VideoSoftware::Video_AddMessage(const std::string& msg, u32 milliseconds) { } void VideoSoftware::Video_ClearMessages() @@ -385,11 +388,9 @@ unsigned int VideoSoftware::PeekMessages() } // Show the current FPS -void VideoSoftware::UpdateFPSDisplay(const char *text) +void VideoSoftware::UpdateFPSDisplay(const std::string& text) { - char temp[100]; - snprintf(temp, sizeof temp, "%s | Software | %s", scm_rev_str, text); - GLInterface->UpdateFPSDisplay(temp); + GLInterface->UpdateFPSDisplay(StringFromFormat("%s | Software | %s", scm_rev_str, text.c_str())); } } diff --git a/Source/Core/VideoBackends/Software/VideoBackend.h b/Source/Core/VideoBackends/Software/VideoBackend.h index 1559427599..a9de97d816 100644 --- a/Source/Core/VideoBackends/Software/VideoBackend.h +++ b/Source/Core/VideoBackends/Software/VideoBackend.h @@ -1,5 +1,6 @@ #pragma once +#include #include "VideoCommon/VideoBackendBase.h" namespace MMIO { class Mapping; } @@ -31,9 +32,9 @@ class VideoSoftware : public VideoBackend u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) override; u32 Video_GetQueryResult(PerfQueryType type) override; - void Video_AddMessage(const char* pstr, unsigned int milliseconds) override; + void Video_AddMessage(const std::string& msg, unsigned int milliseconds) override; void Video_ClearMessages() override; - bool Video_Screenshot(const char* filename) override; + bool Video_Screenshot(const std::string& filename) override; int Video_LoadTexture(char *imagedata, u32 width, u32 height); void Video_DeleteTexture(int texID); @@ -49,7 +50,7 @@ class VideoSoftware : public VideoBackend void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) override; void RegisterPEMMIO(MMIO::Mapping* mmio, u32 base) override; - void UpdateFPSDisplay(const char*) override; + void UpdateFPSDisplay(const std::string&) override; unsigned int PeekMessages() override; void PauseAndLock(bool doLock, bool unpauseOnUnlock=true) override; diff --git a/Source/Core/VideoCommon/Debugger.cpp b/Source/Core/VideoCommon/Debugger.cpp index 98db44bd05..3197c5dd85 100644 --- a/Source/Core/VideoCommon/Debugger.cpp +++ b/Source/Core/VideoCommon/Debugger.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/FileUtil.h" #include "Common/IniFile.h" @@ -79,10 +81,9 @@ void ContinueGFXDebugger() } -void GFXDebuggerBase::DumpPixelShader(const char* path) +void GFXDebuggerBase::DumpPixelShader(const std::string& path) { - char filename[MAX_PATH]; - sprintf(filename, "%sdump_ps.txt", path); + const std::string filename = StringFromFormat("%sdump_ps.txt", path.c_str()); std::string output; bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; @@ -111,51 +112,50 @@ void GFXDebuggerBase::DumpPixelShader(const char* path) File::WriteStringToFile(output, filename); } -void GFXDebuggerBase::DumpVertexShader(const char* path) +void GFXDebuggerBase::DumpVertexShader(const std::string& path) { - char filename[MAX_PATH]; - sprintf(filename, "%sdump_vs.txt", path); + const std::string filename = StringFromFormat("%sdump_vs.txt", path.c_str()); File::CreateEmptyFile(filename); /// File::WriteStringToFile(GenerateVertexShaderCode(g_nativeVertexFmt->m_components, g_ActiveConfig.backend_info.APIType), filename); } -void GFXDebuggerBase::DumpPixelShaderConstants(const char* path) +void GFXDebuggerBase::DumpPixelShaderConstants(const std::string& path) { // TODO } -void GFXDebuggerBase::DumpVertexShaderConstants(const char* path) +void GFXDebuggerBase::DumpVertexShaderConstants(const std::string& path) { // TODO } -void GFXDebuggerBase::DumpTextures(const char* path) +void GFXDebuggerBase::DumpTextures(const std::string& path) { // TODO } -void GFXDebuggerBase::DumpFrameBuffer(const char* path) +void GFXDebuggerBase::DumpFrameBuffer(const std::string& path) { // TODO } -void GFXDebuggerBase::DumpGeometry(const char* path) +void GFXDebuggerBase::DumpGeometry(const std::string& path) { // TODO } -void GFXDebuggerBase::DumpVertexDecl(const char* path) +void GFXDebuggerBase::DumpVertexDecl(const std::string& path) { // TODO } -void GFXDebuggerBase::DumpMatrices(const char* path) +void GFXDebuggerBase::DumpMatrices(const std::string& path) { // TODO } -void GFXDebuggerBase::DumpStats(const char* path) +void GFXDebuggerBase::DumpStats(const std::string& path) { // TODO } diff --git a/Source/Core/VideoCommon/Debugger.h b/Source/Core/VideoCommon/Debugger.h index 3c918f61c5..894921c744 100644 --- a/Source/Core/VideoCommon/Debugger.h +++ b/Source/Core/VideoCommon/Debugger.h @@ -4,6 +4,8 @@ #pragma once +#include + class GFXDebuggerBase { public: @@ -13,19 +15,20 @@ public: virtual void OnPause() {}; virtual void OnContinue() {}; - void DumpPixelShader(const char* path); - void DumpVertexShader(const char* path); - void DumpPixelShaderConstants(const char* path); - void DumpVertexShaderConstants(const char* path); - void DumpTextures(const char* path); - void DumpFrameBuffer(const char* path); - void DumpGeometry(const char* path); - void DumpVertexDecl(const char* path); - void DumpMatrices(const char* path); - void DumpStats(const char* path); + void DumpPixelShader(const std::string& path); + void DumpVertexShader(const std::string& path); + void DumpPixelShaderConstants(const std::string& path); + void DumpVertexShaderConstants(const std::string& path); + void DumpTextures(const std::string& path); + void DumpFrameBuffer(const std::string& path); + void DumpGeometry(const std::string& path); + void DumpVertexDecl(const std::string& path); + void DumpMatrices(const std::string& path); + void DumpStats(const std::string& path); }; -enum PauseEvent { +enum PauseEvent +{ NOT_PAUSE = 0, NEXT_FRAME = 1<<0, NEXT_FLUSH = 1<<1, diff --git a/Source/Core/VideoCommon/EmuWindow.cpp b/Source/Core/VideoCommon/EmuWindow.cpp index 8030316d31..7983b5d7a6 100644 --- a/Source/Core/VideoCommon/EmuWindow.cpp +++ b/Source/Core/VideoCommon/EmuWindow.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include #include "Core/ConfigManager.h" @@ -22,8 +23,6 @@ WNDCLASSEX wndClass; const TCHAR m_szClassName[] = _T("DolphinEmuWnd"); int g_winstyle; static volatile bool s_sizing; -static const int TITLE_TEXT_BUF_SIZE = 1024; -TCHAR m_titleTextBuffer[TITLE_TEXT_BUF_SIZE]; static const int WM_SETTEXT_CUSTOM = WM_USER + WM_SETTEXT; bool IsSizing() @@ -193,27 +192,11 @@ void SetSize(int width, int height) MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); } -void SetWindowText(const TCHAR* text) +void SetWindowText(const std::string& text) { - // the simple way. - // we don't do this because it's a blocking call and the GUI thread might be waiting for us. - //::SetWindowText(m_hWnd, text); - - // copy to m_titleTextBuffer in such a way that - // it remains null-terminated and without garbage data at every point in time, - // in case another thread reads it while we're doing this. - for (int i = 0; i < TITLE_TEXT_BUF_SIZE-1; ++i) - { - m_titleTextBuffer[i+1] = 0; - TCHAR c = text[i]; - m_titleTextBuffer[i] = c; - if (!c) - break; - } - // the OS doesn't allow posting WM_SETTEXT, // so we post our own message and convert it to that in WndProc - PostMessage(m_hWnd, WM_SETTEXT_CUSTOM, 0, (LPARAM)m_titleTextBuffer); + PostMessage(m_hWnd, WM_SETTEXT_CUSTOM, 0, (LPARAM)text.c_str()); } } diff --git a/Source/Core/VideoCommon/EmuWindow.h b/Source/Core/VideoCommon/EmuWindow.h index 25fd8ca568..676ac43ad4 100644 --- a/Source/Core/VideoCommon/EmuWindow.h +++ b/Source/Core/VideoCommon/EmuWindow.h @@ -1,5 +1,6 @@ #pragma once +#include #include namespace EmuWindow @@ -13,6 +14,6 @@ void Close(); void SetSize(int displayWidth, int displayHeight); bool IsSizing(); void OSDMenu(WPARAM wParam); -void SetWindowText(const TCHAR* text); +void SetWindowText(const std::string& text); } diff --git a/Source/Core/VideoCommon/HiresTextures.cpp b/Source/Core/VideoCommon/HiresTextures.cpp index 151173f637..938e8cc5aa 100644 --- a/Source/Core/VideoCommon/HiresTextures.cpp +++ b/Source/Core/VideoCommon/HiresTextures.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -19,16 +20,14 @@ namespace HiresTextures std::map textureMap; -void Init(const char *gameCode) +void Init(const std::string& gameCode) { textureMap.clear(); CFileSearch::XStringVector Directories; - //Directories.push_back(File::GetUserPath(D_HIRESTEXTURES_IDX)); - char szDir[MAX_PATH]; - sprintf(szDir, "%s%s", File::GetUserPath(D_HIRESTEXTURES_IDX).c_str(), gameCode); - Directories.push_back(std::string(szDir)); + std::string szDir = StringFromFormat("%s%s", File::GetUserPath(D_HIRESTEXTURES_IDX).c_str(), gameCode.c_str()); + Directories.push_back(szDir); for (u32 i = 0; i < Directories.size(); i++) { @@ -39,31 +38,34 @@ void Init(const char *gameCode) if (entry.isDirectory) { bool duplicate = false; + for (auto& Directory : Directories) { - if (strcmp(Directory.c_str(), entry.physicalName.c_str()) == 0) + if (Directory == entry.physicalName) { duplicate = true; break; } } + if (!duplicate) - Directories.push_back(entry.physicalName.c_str()); + Directories.push_back(entry.physicalName); } } } - CFileSearch::XStringVector Extensions; - Extensions.push_back("*.png"); - Extensions.push_back("*.bmp"); - Extensions.push_back("*.tga"); - Extensions.push_back("*.dds"); - Extensions.push_back("*.jpg"); // Why not? Could be useful for large photo-like textures + CFileSearch::XStringVector Extensions = { + "*.png", + "*.bmp", + "*.tga", + "*.dds", + "*.jpg" // Why not? Could be useful for large photo-like textures + }; CFileSearch FileSearch(Extensions, Directories); const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames(); - char code[MAX_PATH]; - sprintf(code, "%s_", gameCode); + + const std::string code = StringFromFormat("%s_", gameCode.c_str()); if (rFilenames.size() > 0) { @@ -72,32 +74,30 @@ void Init(const char *gameCode) std::string FileName; SplitPath(rFilename, nullptr, &FileName, nullptr); - if (FileName.substr(0, strlen(code)).compare(code) == 0 && textureMap.find(FileName) == textureMap.end()) + if (FileName.substr(0, code.length()).compare(code) == 0 && textureMap.find(FileName) == textureMap.end()) textureMap.insert(std::map::value_type(FileName, rFilename)); } } } -bool HiresTexExists(const char* filename) +bool HiresTexExists(const std::string& filename) { - std::string key(filename); - return textureMap.find(key) != textureMap.end(); + return textureMap.find(filename) != textureMap.end(); } -PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned int *pHeight, unsigned int *required_size, int texformat, unsigned int data_size, u8 *data) +PC_TexFormat GetHiresTex(const std::string& filename, unsigned int* pWidth, unsigned int* pHeight, unsigned int* required_size, int texformat, unsigned int data_size, u8* data) { - std::string key(fileName); - if (textureMap.find(key) == textureMap.end()) + if (textureMap.find(filename) == textureMap.end()) return PC_TEX_FMT_NONE; int width; int height; int channels; - u8 *temp = SOIL_load_image(textureMap[key].c_str(), &width, &height, &channels, SOIL_LOAD_RGBA); + u8 *temp = SOIL_load_image(textureMap[filename].c_str(), &width, &height, &channels, SOIL_LOAD_RGBA); if (temp == nullptr) { - ERROR_LOG(VIDEO, "Custom texture %s failed to load", textureMap[key].c_str()); + ERROR_LOG(VIDEO, "Custom texture %s failed to load", textureMap[filename].c_str()); return PC_TEX_FMT_NONE; } @@ -136,7 +136,7 @@ PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned in break; } - INFO_LOG(VIDEO, "Loading custom texture from %s", textureMap[key].c_str()); + INFO_LOG(VIDEO, "Loading custom texture from %s", textureMap[filename].c_str()); cleanup: SOIL_free_image_data(temp); return returnTex; diff --git a/Source/Core/VideoCommon/HiresTextures.h b/Source/Core/VideoCommon/HiresTextures.h index c51d0b8b6d..78b9b14e74 100644 --- a/Source/Core/VideoCommon/HiresTextures.h +++ b/Source/Core/VideoCommon/HiresTextures.h @@ -5,13 +5,14 @@ #pragma once #include +#include #include "VideoCommon/TextureDecoder.h" #include "VideoCommon/VideoCommon.h" namespace HiresTextures { -void Init(const char *gameCode); -bool HiresTexExists(const char *filename); -PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned int *pHeight, unsigned int *required_size, int texformat, unsigned int data_size, u8 *data); +void Init(const std::string& gameCode); +bool HiresTexExists(const std::string& filename); +PC_TexFormat GetHiresTex(const std::string& fileName, unsigned int* pWidth, unsigned int* pHeight, unsigned int* required_size, int texformat, unsigned int data_size, u8* data); }; diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp index f491d06f97..f5d313045d 100644 --- a/Source/Core/VideoCommon/MainBase.cpp +++ b/Source/Core/VideoCommon/MainBase.cpp @@ -119,9 +119,9 @@ void VideoBackendHardware::Video_EndField() } } -void VideoBackendHardware::Video_AddMessage(const char* pstr, u32 milliseconds) +void VideoBackendHardware::Video_AddMessage(const std::string& msg, u32 milliseconds) { - OSD::AddMessage(pstr, milliseconds); + OSD::AddMessage(msg, milliseconds); } void VideoBackendHardware::Video_ClearMessages() @@ -130,9 +130,9 @@ void VideoBackendHardware::Video_ClearMessages() } // Screenshot -bool VideoBackendHardware::Video_Screenshot(const char *_szFilename) +bool VideoBackendHardware::Video_Screenshot(const std::string& filename) { - Renderer::SetScreenshot(_szFilename); + Renderer::SetScreenshot(filename.c_str()); return true; } diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 1e4a8b41ec..30f6725ed6 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -56,8 +56,8 @@ void DrawMessages() alpha <<= 24; - g_renderer->RenderText(it->str.c_str(), left + 1, top + 1, 0x000000 | alpha); - g_renderer->RenderText(it->str.c_str(), left, top, 0xffff30 | alpha); + g_renderer->RenderText(it->str, left + 1, top + 1, 0x000000 | alpha); + g_renderer->RenderText(it->str, left, top, 0xffff30 | alpha); top += 15; if (time_left <= 0) diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index ec15fe131b..0b5d890aa6 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -238,7 +238,7 @@ bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int return false; } -void Renderer::SetScreenshot(const char *filename) +void Renderer::SetScreenshot(const std::string& filename) { std::lock_guard lk(s_criticalScreenshot); s_sScreenshotName = filename; @@ -343,11 +343,11 @@ void Renderer::DrawDebugText() } // Render a shadow - g_renderer->RenderText(final_cyan.c_str(), 21, 21, 0xDD000000); - g_renderer->RenderText(final_yellow.c_str(), 21, 21, 0xDD000000); + g_renderer->RenderText(final_cyan, 21, 21, 0xDD000000); + g_renderer->RenderText(final_yellow, 21, 21, 0xDD000000); //and then the text - g_renderer->RenderText(final_cyan.c_str(), 20, 20, 0xFF00FFFF); - g_renderer->RenderText(final_yellow.c_str(), 20, 20, 0xFFFFFF00); + g_renderer->RenderText(final_cyan, 20, 20, 0xFF00FFFF); + g_renderer->RenderText(final_yellow, 20, 20, 0xFFFFFF00); } // TODO: remove diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 96bf4312d7..e16ee8fd40 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -90,10 +90,10 @@ public: static float EFBToScaledYf(float y) { return y * ((float)GetTargetHeight() / (float)EFB_HEIGHT); } // Random utilities - static void SetScreenshot(const char *filename); + static void SetScreenshot(const std::string& filename); static void DrawDebugText(); - virtual void RenderText(const char* pstr, int left, int top, u32 color) = 0; + virtual void RenderText(const std::string& text, int left, int top, u32 color) = 0; virtual void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) = 0; virtual void ReinterpretPixelData(unsigned int convtype) = 0; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 7bbbc4aff6..6c9ef30e28 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -47,7 +47,7 @@ TextureCache::TextureCache() TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter); if (g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures) - HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); + HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID); SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); @@ -89,7 +89,7 @@ void TextureCache::OnConfigChanged(VideoConfig& config) g_texture_cache->Invalidate(); if (g_ActiveConfig.bHiresTextures) - HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); + HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID); SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter); @@ -290,8 +290,8 @@ void TextureCache::DumpTexture(TCacheEntryBase* entry, unsigned int level) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID; // make sure that the directory exists - if (false == File::Exists(szDir) || false == File::IsDirectory(szDir)) - File::CreateDir(szDir.c_str()); + if (!File::Exists(szDir) || !File::IsDirectory(szDir)) + File::CreateDir(szDir); // For compatibility with old texture packs, don't print the LOD index for level 0. // TODO: TLUT format should actually be stored in filename? :/ @@ -421,8 +421,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage, // TODO: Don't we need to force texture decoding to RGBA8 for dynamic EFB copies? // TODO: Actually, it should be enough if the internal texture format matches... if ((entry->type == TCET_NORMAL && - width == entry->virtual_width && - height == entry->virtual_height && + width == entry->virtual_width && + height == entry->virtual_height && full_format == entry->format && entry->num_mipmaps > maxlevel) || (entry->type == TCET_EC_DYNAMIC && diff --git a/Source/Core/VideoCommon/VideoBackendBase.h b/Source/Core/VideoCommon/VideoBackendBase.h index 704afb8adb..fcbe66bcce 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.h +++ b/Source/Core/VideoCommon/VideoBackendBase.h @@ -72,7 +72,7 @@ public: virtual void EmuStateChange(EMUSTATE_CHANGE) = 0; - virtual void UpdateFPSDisplay(const char*) = 0; + virtual void UpdateFPSDisplay(const std::string&) = 0; virtual unsigned int PeekMessages() = 0; @@ -96,9 +96,9 @@ public: virtual u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) = 0; virtual u32 Video_GetQueryResult(PerfQueryType type) = 0; - virtual void Video_AddMessage(const char* pstr, unsigned int milliseconds) = 0; + virtual void Video_AddMessage(const std::string& msg, unsigned int milliseconds) = 0; virtual void Video_ClearMessages() = 0; - virtual bool Video_Screenshot(const char* filename) = 0; + virtual bool Video_Screenshot(const std::string& filename) = 0; virtual void Video_SetRendering(bool bEnabled) = 0; @@ -146,9 +146,9 @@ class VideoBackendHardware : public VideoBackend u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) override; u32 Video_GetQueryResult(PerfQueryType type) override; - void Video_AddMessage(const char* pstr, unsigned int milliseconds) override; + void Video_AddMessage(const std::string& pstr, unsigned int milliseconds) override; void Video_ClearMessages() override; - bool Video_Screenshot(const char* filename) override; + bool Video_Screenshot(const std::string& filename) override; void Video_SetRendering(bool bEnabled) override; diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index c6e37b96fc..23a078e244 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -39,7 +39,7 @@ VideoConfig::VideoConfig() backend_info.bSupports3DVision = false; } -void VideoConfig::Load(const char *ini_file) +void VideoConfig::Load(const std::string& ini_file) { IniFile iniFile; iniFile.Load(ini_file); @@ -217,7 +217,7 @@ void VideoConfig::VerifyValidity() if (!backend_info.bSupportsPixelLighting) bEnablePixelLighting = false; } -void VideoConfig::Save(const char *ini_file) +void VideoConfig::Save(const std::string& ini_file) { IniFile iniFile; iniFile.Load(ini_file); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 4c30305440..09cfa79a2c 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -50,10 +50,10 @@ class IniFile; struct VideoConfig { VideoConfig(); - void Load(const char *ini_file); + void Load(const std::string& ini_file); void GameIniLoad(); void VerifyValidity(); - void Save(const char *ini_file); + void Save(const std::string& ini_file); void UpdateProjectionHack(); bool IsVSync();