mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 10:09:36 -06:00
Turn loops into range-based form
and some things suggested by cppcheck and compiler warnings.
This commit is contained in:
@ -127,8 +127,8 @@ namespace ButtonManager
|
||||
bool pressed = false;
|
||||
pressed = m_buttons[std::make_pair(padID, button)]->Pressed();
|
||||
|
||||
for (auto it = m_controllers.begin(); it != m_controllers.end(); ++it)
|
||||
pressed |= it->second->ButtonValue(padID, button);
|
||||
for (const auto& ctrl : m_controllers)
|
||||
pressed |= ctrl.second->ButtonValue(padID, button);
|
||||
|
||||
return pressed;
|
||||
}
|
||||
@ -172,10 +172,10 @@ namespace ButtonManager
|
||||
}
|
||||
void Shutdown()
|
||||
{
|
||||
for(auto it = m_buttons.begin(); it != m_buttons.end(); ++it)
|
||||
delete it->second;
|
||||
for (auto it = m_controllers.begin(); it != m_controllers.end(); ++it)
|
||||
delete it->second;
|
||||
for (const auto& button : m_buttons)
|
||||
delete button.second;
|
||||
for (const auto& controller : m_controllers)
|
||||
delete controller.second;
|
||||
m_controllers.clear();
|
||||
m_buttons.clear();
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ namespace ButtonManager
|
||||
: _dev(dev) {}
|
||||
~InputDevice()
|
||||
{
|
||||
for (auto it = _binds.begin(); it != _binds.end(); ++it)
|
||||
delete it->second;
|
||||
for (const auto& bind : _binds)
|
||||
delete bind.second;
|
||||
}
|
||||
void AddBind(sBind *bind) { _binds[bind->_buttontype] = bind; _inputbinds[bind->_bind] = bind; }
|
||||
void PressEvent(int button, int action);
|
||||
|
@ -184,7 +184,7 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
|
||||
CreateGUIControls();
|
||||
|
||||
// Update selected ISO paths
|
||||
for(auto& folder : SConfig::GetInstance().m_ISOFolder)
|
||||
for(const std::string& folder : SConfig::GetInstance().m_ISOFolder)
|
||||
{
|
||||
ISOPaths->Append(StrToWxStr(folder));
|
||||
}
|
||||
@ -250,7 +250,7 @@ void CConfigMain::InitializeGUILists()
|
||||
arrayStringFor_Framelimit.Add(wxString::Format(wxT("%i"), i));
|
||||
|
||||
// Emulator Engine
|
||||
for (auto& CPUCores_a : CPUCores)
|
||||
for (const CPUCore& CPUCores_a : CPUCores)
|
||||
arrayStringFor_CPUEngine.Add(wxGetTranslation(CPUCores_a.name));
|
||||
|
||||
// DSP Engine
|
||||
@ -979,12 +979,9 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event)
|
||||
|
||||
void CConfigMain::AddAudioBackends()
|
||||
{
|
||||
std::vector<std::string> backends = AudioCommon::GetSoundBackends();
|
||||
// I'm sure Billiard will change this into an auto sometimes soon :P
|
||||
for (std::vector<std::string>::const_iterator iter = backends.begin();
|
||||
iter != backends.end(); ++iter)
|
||||
for (const std::string& backend : AudioCommon::GetSoundBackends())
|
||||
{
|
||||
BackendSelection->Append(wxGetTranslation(StrToWxStr(*iter)));
|
||||
BackendSelection->Append(wxGetTranslation(StrToWxStr(backend)));
|
||||
int num = BackendSelection->
|
||||
FindString(StrToWxStr(SConfig::GetInstance().sBackend));
|
||||
BackendSelection->SetSelection(num);
|
||||
|
@ -354,10 +354,10 @@ void CCodeWindow::NotifyMapLoaded()
|
||||
//symbols->Show(false); // hide it for faster filling
|
||||
symbols->Freeze(); // HyperIris: wx style fast filling
|
||||
symbols->Clear();
|
||||
for (PPCSymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); ++iter)
|
||||
for (const auto& symbol : g_symbolDB.Symbols())
|
||||
{
|
||||
int idx = symbols->Append(StrToWxStr(iter->second.name));
|
||||
symbols->SetClientData(idx, (void*)&iter->second);
|
||||
int idx = symbols->Append(StrToWxStr(symbol.second.name));
|
||||
symbols->SetClientData(idx, (void*)&symbol.second);
|
||||
}
|
||||
symbols->Thaw();
|
||||
//symbols->Show(true);
|
||||
|
@ -205,11 +205,10 @@ void DSPDebuggerLLE::UpdateSymbolMap()
|
||||
|
||||
m_SymbolList->Freeze(); // HyperIris: wx style fast filling
|
||||
m_SymbolList->Clear();
|
||||
for (SymbolDB::XFuncMap::iterator iter = DSPSymbols::g_dsp_symbol_db.GetIterator();
|
||||
iter != DSPSymbols::g_dsp_symbol_db.End(); ++iter)
|
||||
for (const auto& symbol : DSPSymbols::g_dsp_symbol_db.Symbols())
|
||||
{
|
||||
int idx = m_SymbolList->Append(StrToWxStr(iter->second.name));
|
||||
m_SymbolList->SetClientData(idx, (void*)&iter->second);
|
||||
int idx = m_SymbolList->Append(StrToWxStr(symbol.second.name));
|
||||
m_SymbolList->SetClientData(idx, (void*)&symbol.second);
|
||||
}
|
||||
m_SymbolList->Thaw();
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ void CMemoryWindow::onSearch(wxCommandEvent& event)
|
||||
tmpstr = new char[newsize + 1];
|
||||
memset(tmpstr, 0, newsize + 1);
|
||||
}
|
||||
sprintf(tmpstr, "%s%s", tmpstr, WxStrToStr(rawData).c_str());
|
||||
strcat(tmpstr, WxStrToStr(rawData).c_str());
|
||||
tmp2 = &Dest.front();
|
||||
count = 0;
|
||||
for(i = 0; i < strlen(tmpstr); i++)
|
||||
|
@ -515,7 +515,7 @@ void FifoPlayerDlg::OnFindNextClick(wxCommandEvent& event)
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::vector<SearchResult>::iterator it = search_results.begin(); it != search_results.end(); ++it)
|
||||
for (auto it = search_results.begin(); it != search_results.end(); ++it)
|
||||
{
|
||||
if (it->cmd_idx > cur_cmd_index)
|
||||
{
|
||||
@ -534,7 +534,7 @@ void FifoPlayerDlg::OnFindPreviousClick(wxCommandEvent& event)
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::vector<SearchResult>::reverse_iterator it = search_results.rbegin(); it != search_results.rend(); ++it)
|
||||
for (auto it = search_results.rbegin(); it != search_results.rend(); ++it)
|
||||
{
|
||||
if (it->cmd_idx < cur_cmd_index)
|
||||
{
|
||||
|
@ -1010,19 +1010,19 @@ void CISOProperties::LoadGameConfig()
|
||||
// First set values from default gameini, then apply values from local gameini
|
||||
int iTemp;
|
||||
GameIniDefault.Get("Video", "ProjectionHack", &iTemp);
|
||||
PHackEnable->SetValue(iTemp);
|
||||
PHackEnable->SetValue(!!iTemp);
|
||||
if (GameIniLocal.Get("Video", "ProjectionHack", &iTemp))
|
||||
PHackEnable->SetValue(iTemp);
|
||||
PHackEnable->SetValue(!!iTemp);
|
||||
|
||||
GameIniDefault.Get("Video", "PH_SZNear", &PHack_Data.PHackSZNear);
|
||||
if (GameIniLocal.GetIfExists("Video", "PH_SZNear", &iTemp))
|
||||
PHack_Data.PHackSZNear = iTemp;
|
||||
PHack_Data.PHackSZNear = !!iTemp;
|
||||
GameIniDefault.Get("Video", "PH_SZFar", &PHack_Data.PHackSZFar);
|
||||
if (GameIniLocal.GetIfExists("Video", "PH_SZFar", &iTemp))
|
||||
PHack_Data.PHackSZFar = iTemp;
|
||||
PHack_Data.PHackSZFar = !!iTemp;
|
||||
GameIniDefault.Get("Video", "PH_ExtraParam", &PHack_Data.PHackExP);
|
||||
if (GameIniLocal.GetIfExists("Video", "PH_ExtraParam", &iTemp))
|
||||
PHack_Data.PHackExP = iTemp;
|
||||
PHack_Data.PHackExP = !!iTemp;
|
||||
|
||||
std::string sTemp;
|
||||
GameIniDefault.Get("Video", "PH_ZNear", &PHack_Data.PHZNear);
|
||||
@ -1242,9 +1242,9 @@ void CISOProperties::PatchList_Save()
|
||||
if (DefaultPatches.find(p.name) == DefaultPatches.end())
|
||||
{
|
||||
lines.push_back("$" + p.name);
|
||||
for (auto iter2 = p.entries.begin(); iter2 != p.entries.end(); ++iter2)
|
||||
for (const PatchEngine::PatchEntry& entry : p.entries)
|
||||
{
|
||||
std::string temp = StringFromFormat("0x%08X:%s:0x%08X", iter2->address, PatchEngine::PatchTypeStrings[iter2->type], iter2->value);
|
||||
std::string temp = StringFromFormat("0x%08X:%s:0x%08X", entry.address, PatchEngine::PatchTypeStrings[entry.type], entry.value);
|
||||
lines.push_back(temp);
|
||||
}
|
||||
}
|
||||
@ -1308,9 +1308,8 @@ void CISOProperties::ActionReplayList_Load()
|
||||
ActionReplay::LoadCodes(arCodes, GameIniDefault, GameIniLocal);
|
||||
|
||||
u32 index = 0;
|
||||
for (std::vector<ActionReplay::ARCode>::const_iterator it = arCodes.begin(); it != arCodes.end(); ++it)
|
||||
for (const ActionReplay::ARCode& arCode : arCodes)
|
||||
{
|
||||
ActionReplay::ARCode arCode = *it;
|
||||
Cheats->Append(StrToWxStr(arCode.name));
|
||||
Cheats->Check(index, arCode.active);
|
||||
if (!arCode.user_defined)
|
||||
@ -1324,7 +1323,7 @@ void CISOProperties::ActionReplayList_Save()
|
||||
std::vector<std::string> lines;
|
||||
std::vector<std::string> enabledLines;
|
||||
u32 index = 0;
|
||||
for (auto code : arCodes)
|
||||
for (const ActionReplay::ARCode& code : arCodes)
|
||||
{
|
||||
if (Cheats->IsChecked(index))
|
||||
enabledLines.push_back("$" + code.name);
|
||||
@ -1333,7 +1332,7 @@ void CISOProperties::ActionReplayList_Save()
|
||||
if (DefaultCheats.find(code.name) == DefaultCheats.end())
|
||||
{
|
||||
lines.push_back("$" + code.name);
|
||||
for (auto& op : code.ops)
|
||||
for (const ActionReplay::AREntry& op : code.ops)
|
||||
{
|
||||
lines.push_back(WxStrToStr(wxString::Format(wxT("%08X %08X"), op.cmd_addr, op.value)));
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
|
||||
|
||||
UpdateLog();
|
||||
// Scroll to the last line
|
||||
if (msgQueue.size() > 0)
|
||||
if (!msgQueue.empty())
|
||||
{
|
||||
m_Log->ScrollLines(1);
|
||||
m_Log->ShowPosition( m_Log->GetLastPosition() );
|
||||
|
@ -47,7 +47,7 @@ void CWiiSaveCrypted::ExportAllSaves()
|
||||
std::string folder = StringFromFormat("%s/%08x/", titleFolder.c_str(), pathMask | i);
|
||||
File::ScanDirectoryTree(folder, FST_Temp);
|
||||
|
||||
for (auto& entry : FST_Temp.children)
|
||||
for (const File::FSTEntry& entry : FST_Temp.children)
|
||||
{
|
||||
if (entry.isDirectory)
|
||||
{
|
||||
@ -65,7 +65,7 @@ void CWiiSaveCrypted::ExportAllSaves()
|
||||
}
|
||||
}
|
||||
SuccessAlertT("Found %x save files", (unsigned int) titles.size());
|
||||
for (auto& title : titles)
|
||||
for (const u64& title : titles)
|
||||
{
|
||||
CWiiSaveCrypted* exportSave = new CWiiSaveCrypted("", title);
|
||||
delete exportSave;
|
||||
@ -377,21 +377,21 @@ void CWiiSaveCrypted::ExportWiiSaveFiles()
|
||||
__name = FilesList[i].substr(WiiTitlePath.length()+1);
|
||||
|
||||
|
||||
for (Common::replace_v::const_iterator iter = replacements.begin(); iter != replacements.end(); ++iter)
|
||||
for (const Common::replace_t& repl : replacements)
|
||||
{
|
||||
for (size_t j = 0; (j = __name.find(iter->second, j)) != __name.npos; ++j)
|
||||
for (size_t j = 0; (j = __name.find(repl.second, j)) != __name.npos; ++j)
|
||||
{
|
||||
__name.replace(j, iter->second.length(), 1, iter->first);
|
||||
__name.replace(j, repl.second.length(), 1, repl.first);
|
||||
}
|
||||
}
|
||||
|
||||
if (__name.length() > 0x44)
|
||||
{
|
||||
PanicAlertT("%s is too long for the filename, max chars is 45", __name.c_str());
|
||||
PanicAlertT("\"%s\" is too long for the filename, max length is 0x44 + \\0", __name.c_str());
|
||||
b_valid = false;
|
||||
return;
|
||||
}
|
||||
strncpy((char *)tmpFileHDR.name, __name.c_str(), __name.length());
|
||||
strncpy((char *)tmpFileHDR.name, __name.c_str(), sizeof(tmpFileHDR.name));
|
||||
|
||||
{
|
||||
File::IOFile fpData_bin(encryptedSavePath, "ab");
|
||||
@ -583,7 +583,7 @@ void CWiiSaveCrypted::ScanForFiles(std::string savDir, std::vector<std::string>&
|
||||
|
||||
File::FSTEntry FST_Temp;
|
||||
File::ScanDirectoryTree(Directories[i], FST_Temp);
|
||||
for (auto& elem : FST_Temp.children)
|
||||
for (const File::FSTEntry& elem : FST_Temp.children)
|
||||
{
|
||||
if (strncmp(elem.virtualName.c_str(), "banner.bin", 10) != 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user