Turn loops into range-based form

and some things suggested by cppcheck and compiler warnings.
This commit is contained in:
Tillmann Karras 2014-02-12 16:00:34 +01:00
parent 2ff794d299
commit 404624bf0b
52 changed files with 199 additions and 230 deletions

View File

@ -206,23 +206,23 @@ void ARMXEmitter::ORI2R(ARMReg rd, ARMReg rs, u32 val, ARMReg scratch)
void ARMXEmitter::FlushLitPool() void ARMXEmitter::FlushLitPool()
{ {
for(std::vector<LiteralPool>::iterator it = currentLitPool.begin(); it != currentLitPool.end(); ++it) { for(LiteralPool& pool : currentLitPool) {
// Search for duplicates // Search for duplicates
for(std::vector<LiteralPool>::iterator old_it = currentLitPool.begin(); old_it != it; ++old_it) { for(LiteralPool& old_pool : currentLitPool) {
if ((*old_it).val == (*it).val) if (old_pool.val == pool.val)
(*it).loc = (*old_it).loc; pool.loc = old_pool.loc;
} }
// Write the constant to Literal Pool // Write the constant to Literal Pool
if (!(*it).loc) if (!pool.loc)
{ {
(*it).loc = (s32)code; pool.loc = (s32)code;
Write32((*it).val); Write32(pool.val);
} }
s32 offset = (*it).loc - (s32)(*it).ldr_address - 8; s32 offset = pool.loc - (s32)pool.ldr_address - 8;
// Backpatch the LDR // Backpatch the LDR
*(u32*)(*it).ldr_address |= (offset >= 0) << 23 | abs(offset); *(u32*)pool.ldr_address |= (offset >= 0) << 23 | abs(offset);
} }
// TODO: Save a copy of previous pools in case they are still in range. // TODO: Save a copy of previous pools in case they are still in range.
currentLitPool.clear(); currentLitPool.clear();

View File

@ -8,11 +8,10 @@
#include "../Core/PowerPC/JitCommon/JitBase.h" #include "../Core/PowerPC/JitCommon/JitBase.h"
#include <sstream> #include <sstream>
#include <algorithm>
bool BreakPoints::IsAddressBreakPoint(u32 _iAddress) bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
{ {
for (auto& bp : m_BreakPoints) for (const TBreakPoint& bp : m_BreakPoints)
if (bp.iAddress == _iAddress) if (bp.iAddress == _iAddress)
return true; return true;
return false; return false;
@ -20,7 +19,7 @@ bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
bool BreakPoints::IsTempBreakPoint(u32 _iAddress) bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
{ {
for (auto& bp : m_BreakPoints) for (const TBreakPoint& bp : m_BreakPoints)
if (bp.iAddress == _iAddress && bp.bTemporary) if (bp.iAddress == _iAddress && bp.bTemporary)
return true; return true;
return false; return false;
@ -29,7 +28,7 @@ bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
{ {
TBreakPointsStr bps; TBreakPointsStr bps;
for (const auto& bp : m_BreakPoints) for (const TBreakPoint& bp : m_BreakPoints)
{ {
if (!bp.bTemporary) if (!bp.bTemporary)
{ {
@ -44,7 +43,7 @@ BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
void BreakPoints::AddFromStrings(const TBreakPointsStr& bpstrs) void BreakPoints::AddFromStrings(const TBreakPointsStr& bpstrs)
{ {
for (const auto& bpstr : bpstrs) for (const std::string& bpstr : bpstrs)
{ {
TBreakPoint bp; TBreakPoint bp;
std::stringstream ss; std::stringstream ss;
@ -84,7 +83,7 @@ void BreakPoints::Add(u32 em_address, bool temp)
void BreakPoints::Remove(u32 em_address) void BreakPoints::Remove(u32 em_address)
{ {
for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i) for (auto i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
{ {
if (i->iAddress == em_address) if (i->iAddress == em_address)
{ {
@ -100,12 +99,10 @@ void BreakPoints::Clear()
{ {
if (jit) if (jit)
{ {
std::for_each(m_BreakPoints.begin(), m_BreakPoints.end(), for (const TBreakPoint& bp : m_BreakPoints)
[](const TBreakPoint& bp)
{ {
jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4); jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
} }
);
} }
m_BreakPoints.clear(); m_BreakPoints.clear();
@ -114,7 +111,7 @@ void BreakPoints::Clear()
MemChecks::TMemChecksStr MemChecks::GetStrings() const MemChecks::TMemChecksStr MemChecks::GetStrings() const
{ {
TMemChecksStr mcs; TMemChecksStr mcs;
for (const auto& bp : m_MemChecks) for (const TMemCheck& bp : m_MemChecks)
{ {
std::stringstream mc; std::stringstream mc;
mc << std::hex << bp.StartAddress; mc << std::hex << bp.StartAddress;
@ -129,7 +126,7 @@ MemChecks::TMemChecksStr MemChecks::GetStrings() const
void MemChecks::AddFromStrings(const TMemChecksStr& mcstrs) void MemChecks::AddFromStrings(const TMemChecksStr& mcstrs)
{ {
for (const auto& mcstr : mcstrs) for (const std::string& mcstr : mcstrs)
{ {
TMemCheck mc; TMemCheck mc;
std::stringstream ss; std::stringstream ss;
@ -156,7 +153,7 @@ void MemChecks::Add(const TMemCheck& _rMemoryCheck)
void MemChecks::Remove(u32 _Address) void MemChecks::Remove(u32 _Address)
{ {
for (TMemChecks::iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i) for (auto i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
{ {
if (i->StartAddress == _Address) if (i->StartAddress == _Address)
{ {
@ -168,7 +165,7 @@ void MemChecks::Remove(u32 _Address)
TMemCheck *MemChecks::GetMemCheck(u32 address) TMemCheck *MemChecks::GetMemCheck(u32 address)
{ {
for (auto& bp : m_MemChecks) for (TMemCheck& bp : m_MemChecks)
{ {
if (bp.bRange) if (bp.bRange)
{ {

View File

@ -192,7 +192,7 @@ std::vector<std::string> cdio_get_devices ()
for (unsigned int j = checklist[i].num_min; j <= checklist[i].num_max; ++j) for (unsigned int j = checklist[i].num_min; j <= checklist[i].num_max; ++j)
{ {
std::string drive = StringFromFormat(checklist[i].format, j); std::string drive = StringFromFormat(checklist[i].format, j);
if ( (is_cdrom(drive.c_str(), NULL)) > 0 ) if ( (is_cdrom(drive, NULL)) > 0 )
{ {
drives.push_back(std::move(drive)); drives.push_back(std::move(drive));
} }

View File

@ -117,9 +117,9 @@ public:
case MODE_WRITE: case MODE_WRITE:
case MODE_MEASURE: case MODE_MEASURE:
case MODE_VERIFY: case MODE_VERIFY:
for (auto itr = x.begin(); itr != x.end(); ++itr) for (V& val : x)
{ {
Do(*itr); Do(val);
} }
break; break;
} }

View File

@ -87,10 +87,9 @@ void IniFile::Section::Set(const std::string& key, const std::vector<std::string
{ {
std::string temp; std::string temp;
// Join the strings with , // Join the strings with ,
std::vector<std::string>::const_iterator it; for (const std::string& value : newValues)
for (it = newValues.begin(); it != newValues.end(); ++it)
{ {
temp = (*it) + ","; temp = value + ",";
} }
// remove last , // remove last ,
temp.resize(temp.length() - 1); temp.resize(temp.length() - 1);
@ -210,7 +209,7 @@ bool IniFile::Section::Delete(const std::string& key)
const IniFile::Section* IniFile::GetSection(const std::string& sectionName) const const IniFile::Section* IniFile::GetSection(const std::string& sectionName) const
{ {
for (const auto& sect : sections) for (const Section& sect : sections)
if (!strcasecmp(sect.name.c_str(), sectionName.c_str())) if (!strcasecmp(sect.name.c_str(), sectionName.c_str()))
return (&(sect)); return (&(sect));
return 0; return 0;
@ -218,7 +217,7 @@ const IniFile::Section* IniFile::GetSection(const std::string& sectionName) cons
IniFile::Section* IniFile::GetSection(const std::string& sectionName) IniFile::Section* IniFile::GetSection(const std::string& sectionName)
{ {
for (auto& sect : sections) for (Section& sect : sections)
if (!strcasecmp(sect.name.c_str(), sectionName.c_str())) if (!strcasecmp(sect.name.c_str(), sectionName.c_str()))
return (&(sect)); return (&(sect));
return 0; return 0;
@ -240,7 +239,7 @@ bool IniFile::DeleteSection(const std::string& sectionName)
Section* s = GetSection(sectionName); Section* s = GetSection(sectionName);
if (!s) if (!s)
return false; return false;
for (std::vector<Section>::iterator iter = sections.begin(); iter != sections.end(); ++iter) for (auto iter = sections.begin(); iter != sections.end(); ++iter)
{ {
if (&(*iter) == s) if (&(*iter) == s)
{ {
@ -399,21 +398,21 @@ bool IniFile::Save(const std::string& filename)
return false; return false;
} }
for (auto& section : sections) for (const Section& section : sections)
{ {
if (section.keys_order.size() != 0 || section.lines.size() != 0) if (section.keys_order.size() != 0 || section.lines.size() != 0)
out << "[" << section.name << "]" << std::endl; out << "[" << section.name << "]" << std::endl;
if (section.keys_order.size() == 0) if (section.keys_order.size() == 0)
{ {
for (auto s : section.lines) for (const std::string& s : section.lines)
out << s << std::endl; out << s << std::endl;
} }
else else
{ {
for (auto kvit = section.keys_order.begin(); kvit != section.keys_order.end(); ++kvit) for (const std::string& kvit : section.keys_order)
{ {
auto pair = section.values.find(*kvit); auto pair = section.values.find(kvit);
out << pair->first << " = " << pair->second << std::endl; out << pair->first << " = " << pair->second << std::endl;
} }
} }

View File

@ -81,7 +81,7 @@ LogManager::LogManager()
m_consoleLog = new ConsoleListener(); m_consoleLog = new ConsoleListener();
m_debuggerLog = new DebuggerLogListener(); m_debuggerLog = new DebuggerLogListener();
for (auto& container : m_Log) for (LogContainer* container : m_Log)
{ {
container->SetEnable(true); container->SetEnable(true);
container->AddListener(m_fileLog); container->AddListener(m_fileLog);
@ -102,7 +102,7 @@ LogManager::~LogManager()
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog); m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
} }
for (auto& container : m_Log) for (LogContainer* container : m_Log)
delete container; delete container;
delete m_fileLog; delete m_fileLog;
@ -168,10 +168,9 @@ void LogContainer::Trigger(LogTypes::LOG_LEVELS level, const char *msg)
{ {
std::lock_guard<std::mutex> lk(m_listeners_lock); std::lock_guard<std::mutex> lk(m_listeners_lock);
std::set<LogListener*>::const_iterator i; for (LogListener* listener : m_listeners)
for (i = m_listeners.begin(); i != m_listeners.end(); ++i)
{ {
(*i)->Log(level, msg); listener->Log(level, msg);
} }
} }

View File

@ -95,11 +95,6 @@ public:
const XFuncMap &Symbols() const {return functions;} const XFuncMap &Symbols() const {return functions;}
XFuncMap &AccessSymbols() {return functions;} XFuncMap &AccessSymbols() {return functions;}
// deprecated
XFuncMap::iterator GetIterator() { return functions.begin(); }
XFuncMap::const_iterator GetConstIterator() { return functions.begin(); }
XFuncMap::iterator End() { return functions.end(); }
void Clear(const char *prefix = ""); void Clear(const char *prefix = "");
void List(); void List();
void Index(); void Index();

View File

@ -25,8 +25,7 @@ SysConf::~SysConf()
void SysConf::Clear() void SysConf::Clear()
{ {
for (std::vector<SSysConfEntry>::const_iterator i = m_Entries.begin(); for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i)
i < m_Entries.end() - 1; i++)
delete [] i->data; delete [] i->data;
m_Entries.clear(); m_Entries.clear();
} }
@ -85,8 +84,7 @@ bool SysConf::LoadFromFileInternal(FILE *fh)
} }
// Last offset is an invalid entry. We ignore it throughout this class // Last offset is an invalid entry. We ignore it throughout this class
for (std::vector<SSysConfEntry>::iterator i = m_Entries.begin(); for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i)
i < m_Entries.end() - 1; i++)
{ {
SSysConfEntry& curEntry = *i; SSysConfEntry& curEntry = *i;
f.Seek(curEntry.offset, SEEK_SET); f.Seek(curEntry.offset, SEEK_SET);
@ -300,7 +298,7 @@ void SysConf::GenerateSysConf()
items[26].data[0] = 0x01; items[26].data[0] = 0x01;
for (auto& item : items) for (const SSysConfEntry& item : items)
m_Entries.push_back(item); m_Entries.push_back(item);
File::CreateFullPath(m_FilenameDefault); File::CreateFullPath(m_FilenameDefault);
@ -362,8 +360,7 @@ bool SysConf::SaveToFile(const char *filename)
{ {
File::IOFile f(filename, "r+b"); File::IOFile f(filename, "r+b");
for (std::vector<SSysConfEntry>::iterator i = m_Entries.begin(); for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i)
i < m_Entries.end() - 1; i++)
{ {
// Seek to after the name of this entry // Seek to after the name of this entry
f.Seek(i->offset + i->nameLength + 1, SEEK_SET); f.Seek(i->offset + i->nameLength + 1, SEEK_SET);

View File

@ -79,7 +79,7 @@ public:
} }
std::vector<SSysConfEntry>::iterator index = m_Entries.begin(); std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
for (; index < m_Entries.end() - 1; index++) for (; index < m_Entries.end() - 1; ++index)
{ {
if (strcmp(index->name, sectionName) == 0) if (strcmp(index->name, sectionName) == 0)
break; break;
@ -102,7 +102,7 @@ public:
} }
std::vector<SSysConfEntry>::iterator index = m_Entries.begin(); std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
for (; index < m_Entries.end() - 1; index++) for (; index < m_Entries.end() - 1; ++index)
{ {
if (strcmp(index->name, sectionName) == 0) if (strcmp(index->name, sectionName) == 0)
break; break;
@ -122,7 +122,7 @@ public:
return false; return false;
std::vector<SSysConfEntry>::iterator index = m_Entries.begin(); std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
for (; index < m_Entries.end() - 1; index++) for (; index < m_Entries.end() - 1; ++index)
{ {
if (strcmp(index->name, sectionName) == 0) if (strcmp(index->name, sectionName) == 0)
break; break;
@ -143,7 +143,7 @@ public:
return false; return false;
std::vector<SSysConfEntry>::iterator index = m_Entries.begin(); std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
for (; index < m_Entries.end() - 1; index++) for (; index < m_Entries.end() - 1; ++index)
{ {
if (strcmp(index->name, sectionName) == 0) if (strcmp(index->name, sectionName) == 0)
break; break;

View File

@ -673,9 +673,9 @@ void UpdateTitle()
if (ElapseTime == 0) if (ElapseTime == 0)
ElapseTime = 1; ElapseTime = 1;
float FPS = Common::AtomicLoad(DrawnFrame) * 1000.0 / ElapseTime; float FPS = (float) (Common::AtomicLoad(DrawnFrame) * 1000.0 / ElapseTime);
float VPS = DrawnVideo * 1000.0 / ElapseTime; float VPS = (float) (DrawnVideo * 1000.0 / ElapseTime);
float Speed = DrawnVideo * (100 * 1000.0) / (VideoInterface::TargetRefreshRate * ElapseTime); float Speed = (float) (DrawnVideo * (100 * 1000.0) / (VideoInterface::TargetRefreshRate * ElapseTime));
// Settings are shown the same for both extended and summary info // Settings are shown the same for both extended and summary info
std::string SSettings = StringFromFormat("%s %s | %s | %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC", std::string SSettings = StringFromFormat("%s %s | %s | %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC",

View File

@ -55,18 +55,17 @@ DSPDisassembler::~DSPDisassembler()
return; return;
int count = 0; int count = 0;
for (std::map<u16, int>::const_iterator iter = unk_opcodes.begin(); for (const auto& entry : unk_opcodes)
iter != unk_opcodes.end(); ++iter)
{ {
if (iter->second > 0) if (entry.second > 0)
{ {
count++; count++;
fprintf(uo.GetHandle(), "OP%04x\t%d", iter->first, iter->second); fprintf(uo.GetHandle(), "OP%04x\t%d", entry.first, entry.second);
for (int j = 15; j >= 0; j--) // print op bits for (int j = 15; j >= 0; j--) // print op bits
{ {
if ((j & 0x3) == 3) if ((j & 0x3) == 3)
fprintf(uo.GetHandle(), "\tb"); fprintf(uo.GetHandle(), "\tb");
fprintf(uo.GetHandle(), "%d", (iter->first >> j) & 0x1); fprintf(uo.GetHandle(), "%d", (entry.first >> j) & 0x1);
} }
fprintf(uo.GetHandle(), "\n"); fprintf(uo.GetHandle(), "\n");
} }

View File

@ -26,7 +26,7 @@ public:
u32 GetNextMail() u32 GetNextMail()
{ {
if (m_Mails.size()) if (!m_Mails.empty())
{ {
return m_Mails.front(); return m_Mails.front();
} }

View File

@ -77,7 +77,7 @@ bool GeckoSockServer::GetAvailableSock(sf::SocketTCP &sock_to_fill)
std::lock_guard<std::mutex> lk(connection_lock); std::lock_guard<std::mutex> lk(connection_lock);
if (waiting_socks.size()) if (!waiting_socks.empty())
{ {
sock_to_fill = waiting_socks.front(); sock_to_fill = waiting_socks.front();
if (clientThread.joinable()) if (clientThread.joinable())

View File

@ -56,7 +56,7 @@ bool GetAvailableSock(sf::SocketTCP& sock_to_fill)
std::lock_guard<std::mutex> lk(cs_gba); std::lock_guard<std::mutex> lk(cs_gba);
if (waiting_socks.size()) if (!waiting_socks.empty())
{ {
sock_to_fill = waiting_socks.front(); sock_to_fill = waiting_socks.front();
waiting_socks.pop(); waiting_socks.pop();

View File

@ -1257,7 +1257,7 @@ void Wiimote::DoState(PointerWrap& p)
if (p.mode == PointerWrap::MODE_READ) if (p.mode == PointerWrap::MODE_READ)
{ {
//clear //clear
while (m_read_requests.size()) while (!m_read_requests.empty())
m_read_requests.pop(); m_read_requests.pop();
p.Do(size); p.Do(size);

View File

@ -252,7 +252,7 @@ void Wiimote::Reset()
memset(m_shake_step, 0, sizeof(m_shake_step)); memset(m_shake_step, 0, sizeof(m_shake_step));
// clear read request queue // clear read request queue
while (m_read_requests.size()) while (!m_read_requests.empty())
{ {
delete[] m_read_requests.front().data; delete[] m_read_requests.front().data;
m_read_requests.pop(); m_read_requests.pop();
@ -351,7 +351,7 @@ bool Wiimote::Step()
} }
// check if there is a read data request // check if there is a read data request
if (m_read_requests.size()) if (!m_read_requests.empty())
{ {
ReadRequest& rr = m_read_requests.front(); ReadRequest& rr = m_read_requests.front();
// send up to 16 bytes to the wii // send up to 16 bytes to the wii

View File

@ -606,9 +606,9 @@ void Update()
void UpdateDevices() void UpdateDevices()
{ {
// Check if a hardware device must be updated // Check if a hardware device must be updated
for (TDeviceMap::const_iterator itr = g_DeviceMap.begin(); itr != g_DeviceMap.end(); ++itr) for (const auto& entry : g_DeviceMap)
{ {
if (itr->second->IsOpened() && itr->second->Update()) if (entry.second->IsOpened() && entry.second->Update())
{ {
break; break;
} }

View File

@ -59,8 +59,7 @@ bool CWII_IPC_HLE_Device_fs::Close(u32 _CommandAddress, bool _bForce)
static u64 ComputeTotalFileSize(const File::FSTEntry& parentEntry) static u64 ComputeTotalFileSize(const File::FSTEntry& parentEntry)
{ {
u64 sizeOfFiles = 0; u64 sizeOfFiles = 0;
const std::vector<File::FSTEntry>& children = parentEntry.children; for (const File::FSTEntry& entry : parentEntry.children)
for (const auto& entry : children)
{ {
if (entry.isDirectory) if (entry.isDirectory)
sizeOfFiles += ComputeTotalFileSize(entry); sizeOfFiles += ComputeTotalFileSize(entry);
@ -146,10 +145,10 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
// Decode entities of invalid file system characters so that // Decode entities of invalid file system characters so that
// games (such as HP:HBP) will be able to find what they expect. // games (such as HP:HBP) will be able to find what they expect.
for (Common::replace_v::const_iterator it = replacements.begin(); it != replacements.end(); ++it) for (const Common::replace_t& r : replacements)
{ {
for (size_t j = 0; (j = FileName.find(it->second, j)) != FileName.npos; ++j) for (size_t j = 0; (j = FileName.find(r.second, j)) != FileName.npos; ++j)
FileName.replace(j, it->second.length(), 1, it->first); FileName.replace(j, r.second.length(), 1, r.first);
} }
strcpy(pFilename, FileName.c_str()); strcpy(pFilename, FileName.c_str());

View File

@ -94,9 +94,9 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid()
deinit_libusb = true; deinit_libusb = true;
} }
for ( std::map<u32,libusb_device_handle*>::const_iterator iter = open_devices.begin(); iter != open_devices.end(); ++iter ) for (const auto& device : open_devices)
{ {
libusb_close(iter->second); libusb_close(device.second);
} }
open_devices.clear(); open_devices.clear();

View File

@ -582,9 +582,9 @@ void WiiSockMan::Update()
FD_ZERO(&read_fds); FD_ZERO(&read_fds);
FD_ZERO(&write_fds); FD_ZERO(&write_fds);
FD_ZERO(&except_fds); FD_ZERO(&except_fds);
for (auto it = WiiSockets.begin(); it != WiiSockets.end(); ++it) for (auto& entry : WiiSockets)
{ {
WiiSocket& sock = it->second; WiiSocket& sock = entry.second;
if (sock.valid()) if (sock.valid())
{ {
FD_SET(sock.fd, &read_fds); FD_SET(sock.fd, &read_fds);

View File

@ -196,14 +196,11 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket)
socket.Send(spac); socket.Send(spac);
// sync values with new client // sync values with new client
std::map<sf::SocketTCP, Client>::const_iterator for (const auto& p : m_players)
i,
e = m_players.end();
for (i = m_players.begin(); i!=e; ++i)
{ {
spac.Clear(); spac.Clear();
spac << (MessageId)NP_MSG_PLAYER_JOIN; spac << (MessageId)NP_MSG_PLAYER_JOIN;
spac << i->second.pid << i->second.name << i->second.revision; spac << p.second.pid << p.second.name << p.second.revision;
socket.Send(spac); socket.Send(spac);
} }
@ -613,7 +610,7 @@ void NetPlayServer::unmapPortThread()
// discovers the IGD // discovers the IGD
bool NetPlayServer::initUPnP() bool NetPlayServer::initUPnP()
{ {
UPNPDev *devlist, *dev; UPNPDev *devlist;
std::vector<UPNPDev *> igds; std::vector<UPNPDev *> igds;
int descXMLsize = 0, upnperror = 0; int descXMLsize = 0, upnperror = 0;
char *descXML; char *descXML;
@ -642,18 +639,14 @@ bool NetPlayServer::initUPnP()
} }
// Look for the IGD // Look for the IGD
dev = devlist; for (UPNPDev* dev = devlist; dev; dev = dev->pNext)
while (dev)
{ {
if (strstr(dev->st, "InternetGatewayDevice")) if (strstr(dev->st, "InternetGatewayDevice"))
igds.push_back(dev); igds.push_back(dev);
dev = dev->pNext;
} }
std::vector<UPNPDev *>::iterator i; for (const UPNPDev* dev : igds)
for (i = igds.begin(); i != igds.end(); i++)
{ {
dev = *i;
descXML = (char *) miniwget(dev->descURL, &descXMLsize, 0); descXML = (char *) miniwget(dev->descURL, &descXMLsize, 0);
if (descXML) if (descXML)
{ {

View File

@ -53,8 +53,8 @@ void LoadPatchSection(const char *section, std::vector<Patch> &patches,
std::string enabledSectionName = std::string(section) + "_Enabled"; std::string enabledSectionName = std::string(section) + "_Enabled";
std::vector<std::string> enabledLines; std::vector<std::string> enabledLines;
std::set<std::string> enabledNames; std::set<std::string> enabledNames;
localIni.GetLines(enabledSectionName, enabledLines); localIni.GetLines(enabledSectionName.c_str(), enabledLines);
for (auto& line : enabledLines) for (const std::string& line : enabledLines)
{ {
if (line.size() != 0 && line[0] == '$') if (line.size() != 0 && line[0] == '$')
{ {
@ -71,7 +71,7 @@ void LoadPatchSection(const char *section, std::vector<Patch> &patches,
Patch currentPatch; Patch currentPatch;
inis[i]->GetLines(section, lines); inis[i]->GetLines(section, lines);
for (auto line : lines) for (std::string& line : lines)
{ {
if (line.size() == 0) if (line.size() == 0)
continue; continue;
@ -124,10 +124,9 @@ static void LoadDiscList(const char *section, std::vector<std::string> &_discLis
if (!ini.GetLines(section, lines)) if (!ini.GetLines(section, lines))
return; return;
for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter) for (const std::string& line : lines)
{ {
std::string line = *iter; if (!line.empty())
if (line.size())
_discList.push_back(line); _discList.push_back(line);
} }
} }
@ -136,9 +135,8 @@ static void LoadSpeedhacks(const char *section, std::map<u32, int> &hacks, IniFi
{ {
std::vector<std::string> keys; std::vector<std::string> keys;
ini.GetKeys(section, keys); ini.GetKeys(section, keys);
for (std::vector<std::string>::const_iterator iter = keys.begin(); iter != keys.end(); ++iter) for (const std::string& key : keys)
{ {
std::string key = *iter;
std::string value; std::string value;
ini.Get(section, key, &value, "BOGUS"); ini.Get(section, key, &value, "BOGUS");
if (value != "BOGUS") if (value != "BOGUS")
@ -184,15 +182,15 @@ void LoadPatches()
void ApplyPatches(const std::vector<Patch> &patches) void ApplyPatches(const std::vector<Patch> &patches)
{ {
for (const auto& patch : patches) for (const Patch& patch : patches)
{ {
if (patch.active) if (patch.active)
{ {
for (std::vector<PatchEntry>::const_iterator iter2 = patch.entries.begin(); iter2 != patch.entries.end(); ++iter2) for (const PatchEntry& entry : patch.entries)
{ {
u32 addr = iter2->address; u32 addr = entry.address;
u32 value = iter2->value; u32 value = entry.value;
switch (iter2->type) switch (entry.type)
{ {
case PATCH_8BIT: case PATCH_8BIT:
Memory::Write_U8((u8)value, addr); Memory::Write_U8((u8)value, addr);

View File

@ -70,7 +70,7 @@ inline void UpdateFPSCR()
inline double ForceSingle(double _x) inline double ForceSingle(double _x)
{ {
// convert to float... // convert to float...
float x = _x; float x = (float) _x;
if (!cpu_info.bFlushToZero && FPSCR.NI) if (!cpu_info.bFlushToZero && FPSCR.NI)
{ {
x = FlushToZero(x); x = FlushToZero(x);

View File

@ -1789,7 +1789,7 @@ void Jit64::rlwimix(UGeckoInstruction inst)
} }
else if (inst.SH) else if (inst.SH)
{ {
if (mask == -(1U << inst.SH)) if (mask == 0U - (1U << inst.SH))
{ {
MOV(32, R(EAX), gpr.R(s)); MOV(32, R(EAX), gpr.R(s));
SHL(32, R(EAX), Imm8(inst.SH)); SHL(32, R(EAX), Imm8(inst.SH));

View File

@ -374,7 +374,7 @@ using namespace Gen;
JitBlock &b = blocks[it2->second]; JitBlock &b = blocks[it2->second];
*GetICachePtr(b.originalAddress) = JIT_ICACHE_INVALID_WORD; *GetICachePtr(b.originalAddress) = JIT_ICACHE_INVALID_WORD;
DestroyBlock(it2->second, true); DestroyBlock(it2->second, true);
it2++; ++it2;
} }
if (it1 != it2) if (it1 != it2)
{ {

View File

@ -196,7 +196,7 @@ void AnalyzeFunction2(Symbol *func)
u32 flags = func->flags; u32 flags = func->flags;
bool nonleafcall = false; bool nonleafcall = false;
for (auto c : func->calls) for (const SCall& c : func->calls)
{ {
Symbol *called_func = g_symbolDB.GetSymbolFromAddr(c.function); Symbol *called_func = g_symbolDB.GetSymbolFromAddr(c.function);
if (called_func && (called_func->flags & FFLAG_LEAF) == 0) if (called_func && (called_func->flags & FFLAG_LEAF) == 0)
@ -603,10 +603,10 @@ void FindFunctionsAfterBLR(PPCSymbolDB *func_db)
{ {
vector<u32> funcAddrs; vector<u32> funcAddrs;
for (PPCSymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); ++iter) for (const auto& func : func_db->Symbols())
funcAddrs.push_back(iter->second.address + iter->second.size); funcAddrs.push_back(func.second.address + func.second.size);
for (auto location : funcAddrs) for (u32& location : funcAddrs)
{ {
while (true) while (true)
{ {
@ -637,15 +637,15 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB *func_db)
int numLeafs = 0, numNice = 0, numUnNice = 0; int numLeafs = 0, numNice = 0, numUnNice = 0;
int numTimer = 0, numRFI = 0, numStraightLeaf = 0; int numTimer = 0, numRFI = 0, numStraightLeaf = 0;
int leafSize = 0, niceSize = 0, unniceSize = 0; int leafSize = 0, niceSize = 0, unniceSize = 0;
for (PPCSymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); ++iter) for (auto& func : func_db->AccessSymbols())
{ {
if (iter->second.address == 4) if (func.second.address == 4)
{ {
WARN_LOG(OSHLE, "Weird function"); WARN_LOG(OSHLE, "Weird function");
continue; continue;
} }
AnalyzeFunction2(&(iter->second)); AnalyzeFunction2(&(func.second));
Symbol &f = iter->second; Symbol &f = func.second;
if (f.name.substr(0, 3) == "zzz") if (f.name.substr(0, 3) == "zzz")
{ {
if (f.flags & FFLAG_LEAF) if (f.flags & FFLAG_LEAF)

View File

@ -119,12 +119,12 @@ void PPCSymbolDB::FillInCallers()
p.second.callers.clear(); p.second.callers.clear();
} }
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter) for (auto& entry : functions)
{ {
Symbol &f = iter->second; Symbol &f = entry.second;
for (auto& call : f.calls) for (const SCall& call : f.calls)
{ {
SCall NewCall(iter->first, call.callAddress); SCall NewCall(entry.first, call.callAddress);
u32 FunctionAddress = call.function; u32 FunctionAddress = call.function;
XFuncMap::iterator FuncIterator = functions.find(FunctionAddress); XFuncMap::iterator FuncIterator = functions.find(FunctionAddress);
@ -149,12 +149,12 @@ void PPCSymbolDB::PrintCalls(u32 funcAddr) const
{ {
const Symbol &f = iter->second; const Symbol &f = iter->second;
INFO_LOG(OSHLE, "The function %s at %08x calls:", f.name.c_str(), f.address); INFO_LOG(OSHLE, "The function %s at %08x calls:", f.name.c_str(), f.address);
for (std::vector<SCall>::const_iterator fiter = f.calls.begin(); fiter!=f.calls.end(); ++fiter) for (const SCall& call : f.calls)
{ {
XFuncMap::const_iterator n = functions.find(fiter->function); XFuncMap::const_iterator n = functions.find(call.function);
if (n != functions.end()) if (n != functions.end())
{ {
INFO_LOG(CONSOLE,"* %08x : %s", fiter->callAddress, n->second.name.c_str()); INFO_LOG(CONSOLE,"* %08x : %s", call.callAddress, n->second.name.c_str());
} }
} }
} }
@ -171,12 +171,12 @@ void PPCSymbolDB::PrintCallers(u32 funcAddr) const
{ {
const Symbol &f = iter->second; const Symbol &f = iter->second;
INFO_LOG(CONSOLE,"The function %s at %08x is called by:",f.name.c_str(),f.address); INFO_LOG(CONSOLE,"The function %s at %08x is called by:",f.name.c_str(),f.address);
for (std::vector<SCall>::const_iterator fiter = f.callers.begin(); fiter != f.callers.end(); ++fiter) for (const SCall& caller : f.callers)
{ {
XFuncMap::const_iterator n = functions.find(fiter->function); XFuncMap::const_iterator n = functions.find(caller.function);
if (n != functions.end()) if (n != functions.end())
{ {
INFO_LOG(CONSOLE,"* %08x : %s", fiter->callAddress, n->second.name.c_str()); INFO_LOG(CONSOLE,"* %08x : %s", caller.callAddress, n->second.name.c_str());
} }
} }
} }

View File

@ -56,13 +56,13 @@ bool SignatureDB::Save(const char *filename)
} }
u32 fcount = (u32)database.size(); u32 fcount = (u32)database.size();
f.WriteArray(&fcount, 1); f.WriteArray(&fcount, 1);
for (FuncDB::const_iterator iter = database.begin(); iter != database.end(); ++iter) for (const auto& entry : database)
{ {
FuncDesc temp; FuncDesc temp;
memset(&temp, 0, sizeof(temp)); memset(&temp, 0, sizeof(temp));
temp.checkSum = iter->first; temp.checkSum = entry.first;
temp.size = iter->second.size; temp.size = entry.second.size;
strncpy(temp.name, iter->second.name.c_str(), 127); strncpy(temp.name, entry.second.name.c_str(), 127);
f.WriteArray(&temp, 1); f.WriteArray(&temp, 1);
} }
@ -87,9 +87,9 @@ u32 SignatureDB::Add(u32 startAddr, u32 size, const char *name)
void SignatureDB::List() void SignatureDB::List()
{ {
for (FuncDB::iterator iter = database.begin(); iter != database.end(); ++iter) for (const auto& entry : database)
{ {
INFO_LOG(OSHLE, "%s : %i bytes, hash = %08x", iter->second.name.c_str(), iter->second.size, iter->first); INFO_LOG(OSHLE, "%s : %i bytes, hash = %08x", entry.second.name.c_str(), entry.second.size, entry.first);
} }
INFO_LOG(OSHLE, "%lu functions known in current database.", INFO_LOG(OSHLE, "%lu functions known in current database.",
(unsigned long)database.size()); (unsigned long)database.size());
@ -102,22 +102,23 @@ void SignatureDB::Clear()
void SignatureDB::Apply(PPCSymbolDB *symbol_db) void SignatureDB::Apply(PPCSymbolDB *symbol_db)
{ {
for (FuncDB::const_iterator iter = database.begin(); iter != database.end(); ++iter) for (const auto& entry : database)
{ {
u32 hash = iter->first; u32 hash = entry.first;
Symbol *function = symbol_db->GetSymbolFromHash(hash); Symbol *function = symbol_db->GetSymbolFromHash(hash);
if (function) if (function)
{ {
// Found the function. Let's rename it according to the symbol file. // Found the function. Let's rename it according to the symbol file.
if (iter->second.size == (unsigned int)function->size) if (entry.second.size == (unsigned int)function->size)
{ {
function->name = iter->second.name; function->name = entry.second.name;
INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", iter->second.name.c_str(), function->address, function->size); INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(), function->address, function->size);
} }
else else
{ {
function->name = iter->second.name; function->name = entry.second.name;
ERROR_LOG(OSHLE, "Wrong size! Found %s at %08x (size: %08x instead of %08x)!", iter->second.name.c_str(), function->address, function->size, iter->second.size); ERROR_LOG(OSHLE, "Wrong size! Found %s at %08x (size: %08x instead of %08x)!",
entry.second.name.c_str(), function->address, function->size, entry.second.size);
} }
} }
} }
@ -127,14 +128,14 @@ void SignatureDB::Apply(PPCSymbolDB *symbol_db)
void SignatureDB::Initialize(PPCSymbolDB *symbol_db, const char *prefix) void SignatureDB::Initialize(PPCSymbolDB *symbol_db, const char *prefix)
{ {
std::string prefix_str(prefix); std::string prefix_str(prefix);
for (PPCSymbolDB::XFuncMap::const_iterator iter = symbol_db->GetConstIterator(); iter != symbol_db->End(); ++iter) for (const auto& symbol : symbol_db->Symbols())
{ {
if ((iter->second.name.substr(0, prefix_str.size()) == prefix_str) || prefix_str.empty()) if ((symbol.second.name.substr(0, prefix_str.size()) == prefix_str) || prefix_str.empty())
{ {
DBFunc temp_dbfunc; DBFunc temp_dbfunc;
temp_dbfunc.name = iter->second.name; temp_dbfunc.name = symbol.second.name;
temp_dbfunc.size = iter->second.size; temp_dbfunc.size = symbol.second.size;
database[iter->second.hash] = temp_dbfunc; database[symbol.second.hash] = temp_dbfunc;
} }
} }
} }

View File

@ -21,9 +21,8 @@
namespace DiscIO namespace DiscIO
{ {
CompressedBlobReader::CompressedBlobReader(const char *filename) CompressedBlobReader::CompressedBlobReader(const char *filename) : file_name(filename)
{ {
file_name = filename;
m_file.Open(filename, "rb"); m_file.Open(filename, "rb");
file_size = File::GetSize(filename); file_size = File::GetSize(filename);
m_file.ReadArray(&header, 1); m_file.ReadArray(&header, 1);

View File

@ -267,7 +267,7 @@ bool ParsePartitionData(SPartition& _rPartition)
IVolume *OldVolume = m_Disc; IVolume *OldVolume = m_Disc;
// Ready some stuff // Ready some stuff
m_Disc = CreateVolumeFromFilename(m_Filename.c_str(), _rPartition.GroupNumber, _rPartition.Number); m_Disc = CreateVolumeFromFilename(m_Filename, _rPartition.GroupNumber, _rPartition.Number);
IFileSystem *FileSystem = CreateFileSystem(m_Disc); IFileSystem *FileSystem = CreateFileSystem(m_Disc);
if (!FileSystem) if (!FileSystem)

View File

@ -106,7 +106,7 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
WriteToBuffer(FST_ADDRESS, m_fstSize, m_FSTData, _Offset, _Length, _pBuffer); WriteToBuffer(FST_ADDRESS, m_fstSize, m_FSTData, _Offset, _Length, _pBuffer);
} }
if(m_virtualDisk.size() == 0) if(m_virtualDisk.empty())
return true; return true;
// Determine which file the offset refers to // Determine which file the offset refers to

View File

@ -127,8 +127,8 @@ namespace ButtonManager
bool pressed = false; bool pressed = false;
pressed = m_buttons[std::make_pair(padID, button)]->Pressed(); pressed = m_buttons[std::make_pair(padID, button)]->Pressed();
for (auto it = m_controllers.begin(); it != m_controllers.end(); ++it) for (const auto& ctrl : m_controllers)
pressed |= it->second->ButtonValue(padID, button); pressed |= ctrl.second->ButtonValue(padID, button);
return pressed; return pressed;
} }
@ -172,10 +172,10 @@ namespace ButtonManager
} }
void Shutdown() void Shutdown()
{ {
for(auto it = m_buttons.begin(); it != m_buttons.end(); ++it) for (const auto& button : m_buttons)
delete it->second; delete button.second;
for (auto it = m_controllers.begin(); it != m_controllers.end(); ++it) for (const auto& controller : m_controllers)
delete it->second; delete controller.second;
m_controllers.clear(); m_controllers.clear();
m_buttons.clear(); m_buttons.clear();
} }

View File

@ -108,8 +108,8 @@ namespace ButtonManager
: _dev(dev) {} : _dev(dev) {}
~InputDevice() ~InputDevice()
{ {
for (auto it = _binds.begin(); it != _binds.end(); ++it) for (const auto& bind : _binds)
delete it->second; delete bind.second;
} }
void AddBind(sBind *bind) { _binds[bind->_buttontype] = bind; _inputbinds[bind->_bind] = bind; } void AddBind(sBind *bind) { _binds[bind->_buttontype] = bind; _inputbinds[bind->_bind] = bind; }
void PressEvent(int button, int action); void PressEvent(int button, int action);

View File

@ -184,7 +184,7 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
CreateGUIControls(); CreateGUIControls();
// Update selected ISO paths // Update selected ISO paths
for(auto& folder : SConfig::GetInstance().m_ISOFolder) for(const std::string& folder : SConfig::GetInstance().m_ISOFolder)
{ {
ISOPaths->Append(StrToWxStr(folder)); ISOPaths->Append(StrToWxStr(folder));
} }
@ -250,7 +250,7 @@ void CConfigMain::InitializeGUILists()
arrayStringFor_Framelimit.Add(wxString::Format(wxT("%i"), i)); arrayStringFor_Framelimit.Add(wxString::Format(wxT("%i"), i));
// Emulator Engine // Emulator Engine
for (auto& CPUCores_a : CPUCores) for (const CPUCore& CPUCores_a : CPUCores)
arrayStringFor_CPUEngine.Add(wxGetTranslation(CPUCores_a.name)); arrayStringFor_CPUEngine.Add(wxGetTranslation(CPUCores_a.name));
// DSP Engine // DSP Engine
@ -979,12 +979,9 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event)
void CConfigMain::AddAudioBackends() void CConfigMain::AddAudioBackends()
{ {
std::vector<std::string> backends = AudioCommon::GetSoundBackends(); for (const std::string& backend : 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)
{ {
BackendSelection->Append(wxGetTranslation(StrToWxStr(*iter))); BackendSelection->Append(wxGetTranslation(StrToWxStr(backend)));
int num = BackendSelection-> int num = BackendSelection->
FindString(StrToWxStr(SConfig::GetInstance().sBackend)); FindString(StrToWxStr(SConfig::GetInstance().sBackend));
BackendSelection->SetSelection(num); BackendSelection->SetSelection(num);

View File

@ -354,10 +354,10 @@ void CCodeWindow::NotifyMapLoaded()
//symbols->Show(false); // hide it for faster filling //symbols->Show(false); // hide it for faster filling
symbols->Freeze(); // HyperIris: wx style fast filling symbols->Freeze(); // HyperIris: wx style fast filling
symbols->Clear(); 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)); int idx = symbols->Append(StrToWxStr(symbol.second.name));
symbols->SetClientData(idx, (void*)&iter->second); symbols->SetClientData(idx, (void*)&symbol.second);
} }
symbols->Thaw(); symbols->Thaw();
//symbols->Show(true); //symbols->Show(true);

View File

@ -205,11 +205,10 @@ void DSPDebuggerLLE::UpdateSymbolMap()
m_SymbolList->Freeze(); // HyperIris: wx style fast filling m_SymbolList->Freeze(); // HyperIris: wx style fast filling
m_SymbolList->Clear(); m_SymbolList->Clear();
for (SymbolDB::XFuncMap::iterator iter = DSPSymbols::g_dsp_symbol_db.GetIterator(); for (const auto& symbol : DSPSymbols::g_dsp_symbol_db.Symbols())
iter != DSPSymbols::g_dsp_symbol_db.End(); ++iter)
{ {
int idx = m_SymbolList->Append(StrToWxStr(iter->second.name)); int idx = m_SymbolList->Append(StrToWxStr(symbol.second.name));
m_SymbolList->SetClientData(idx, (void*)&iter->second); m_SymbolList->SetClientData(idx, (void*)&symbol.second);
} }
m_SymbolList->Thaw(); m_SymbolList->Thaw();
} }

View File

@ -337,7 +337,7 @@ void CMemoryWindow::onSearch(wxCommandEvent& event)
tmpstr = new char[newsize + 1]; tmpstr = new char[newsize + 1];
memset(tmpstr, 0, 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(); tmp2 = &Dest.front();
count = 0; count = 0;
for(i = 0; i < strlen(tmpstr); i++) for(i = 0; i < strlen(tmpstr); i++)

View File

@ -515,7 +515,7 @@ void FifoPlayerDlg::OnFindNextClick(wxCommandEvent& event)
return; 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) if (it->cmd_idx > cur_cmd_index)
{ {
@ -534,7 +534,7 @@ void FifoPlayerDlg::OnFindPreviousClick(wxCommandEvent& event)
return; 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) if (it->cmd_idx < cur_cmd_index)
{ {

View File

@ -1010,19 +1010,19 @@ void CISOProperties::LoadGameConfig()
// First set values from default gameini, then apply values from local gameini // First set values from default gameini, then apply values from local gameini
int iTemp; int iTemp;
GameIniDefault.Get("Video", "ProjectionHack", &iTemp); GameIniDefault.Get("Video", "ProjectionHack", &iTemp);
PHackEnable->SetValue(iTemp); PHackEnable->SetValue(!!iTemp);
if (GameIniLocal.Get("Video", "ProjectionHack", &iTemp)) if (GameIniLocal.Get("Video", "ProjectionHack", &iTemp))
PHackEnable->SetValue(iTemp); PHackEnable->SetValue(!!iTemp);
GameIniDefault.Get("Video", "PH_SZNear", &PHack_Data.PHackSZNear); GameIniDefault.Get("Video", "PH_SZNear", &PHack_Data.PHackSZNear);
if (GameIniLocal.GetIfExists("Video", "PH_SZNear", &iTemp)) if (GameIniLocal.GetIfExists("Video", "PH_SZNear", &iTemp))
PHack_Data.PHackSZNear = iTemp; PHack_Data.PHackSZNear = !!iTemp;
GameIniDefault.Get("Video", "PH_SZFar", &PHack_Data.PHackSZFar); GameIniDefault.Get("Video", "PH_SZFar", &PHack_Data.PHackSZFar);
if (GameIniLocal.GetIfExists("Video", "PH_SZFar", &iTemp)) if (GameIniLocal.GetIfExists("Video", "PH_SZFar", &iTemp))
PHack_Data.PHackSZFar = iTemp; PHack_Data.PHackSZFar = !!iTemp;
GameIniDefault.Get("Video", "PH_ExtraParam", &PHack_Data.PHackExP); GameIniDefault.Get("Video", "PH_ExtraParam", &PHack_Data.PHackExP);
if (GameIniLocal.GetIfExists("Video", "PH_ExtraParam", &iTemp)) if (GameIniLocal.GetIfExists("Video", "PH_ExtraParam", &iTemp))
PHack_Data.PHackExP = iTemp; PHack_Data.PHackExP = !!iTemp;
std::string sTemp; std::string sTemp;
GameIniDefault.Get("Video", "PH_ZNear", &PHack_Data.PHZNear); GameIniDefault.Get("Video", "PH_ZNear", &PHack_Data.PHZNear);
@ -1242,9 +1242,9 @@ void CISOProperties::PatchList_Save()
if (DefaultPatches.find(p.name) == DefaultPatches.end()) if (DefaultPatches.find(p.name) == DefaultPatches.end())
{ {
lines.push_back("$" + p.name); 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); lines.push_back(temp);
} }
} }
@ -1308,9 +1308,8 @@ void CISOProperties::ActionReplayList_Load()
ActionReplay::LoadCodes(arCodes, GameIniDefault, GameIniLocal); ActionReplay::LoadCodes(arCodes, GameIniDefault, GameIniLocal);
u32 index = 0; 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->Append(StrToWxStr(arCode.name));
Cheats->Check(index, arCode.active); Cheats->Check(index, arCode.active);
if (!arCode.user_defined) if (!arCode.user_defined)
@ -1324,7 +1323,7 @@ void CISOProperties::ActionReplayList_Save()
std::vector<std::string> lines; std::vector<std::string> lines;
std::vector<std::string> enabledLines; std::vector<std::string> enabledLines;
u32 index = 0; u32 index = 0;
for (auto code : arCodes) for (const ActionReplay::ARCode& code : arCodes)
{ {
if (Cheats->IsChecked(index)) if (Cheats->IsChecked(index))
enabledLines.push_back("$" + code.name); enabledLines.push_back("$" + code.name);
@ -1333,7 +1332,7 @@ void CISOProperties::ActionReplayList_Save()
if (DefaultCheats.find(code.name) == DefaultCheats.end()) if (DefaultCheats.find(code.name) == DefaultCheats.end())
{ {
lines.push_back("$" + code.name); 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))); lines.push_back(WxStrToStr(wxString::Format(wxT("%08X %08X"), op.cmd_addr, op.value)));
} }

View File

@ -277,7 +277,7 @@ void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
UpdateLog(); UpdateLog();
// Scroll to the last line // Scroll to the last line
if (msgQueue.size() > 0) if (!msgQueue.empty())
{ {
m_Log->ScrollLines(1); m_Log->ScrollLines(1);
m_Log->ShowPosition( m_Log->GetLastPosition() ); m_Log->ShowPosition( m_Log->GetLastPosition() );

View File

@ -47,7 +47,7 @@ void CWiiSaveCrypted::ExportAllSaves()
std::string folder = StringFromFormat("%s/%08x/", titleFolder.c_str(), pathMask | i); std::string folder = StringFromFormat("%s/%08x/", titleFolder.c_str(), pathMask | i);
File::ScanDirectoryTree(folder, FST_Temp); File::ScanDirectoryTree(folder, FST_Temp);
for (auto& entry : FST_Temp.children) for (const File::FSTEntry& entry : FST_Temp.children)
{ {
if (entry.isDirectory) if (entry.isDirectory)
{ {
@ -65,7 +65,7 @@ void CWiiSaveCrypted::ExportAllSaves()
} }
} }
SuccessAlertT("Found %x save files", (unsigned int) titles.size()); SuccessAlertT("Found %x save files", (unsigned int) titles.size());
for (auto& title : titles) for (const u64& title : titles)
{ {
CWiiSaveCrypted* exportSave = new CWiiSaveCrypted("", title); CWiiSaveCrypted* exportSave = new CWiiSaveCrypted("", title);
delete exportSave; delete exportSave;
@ -377,21 +377,21 @@ void CWiiSaveCrypted::ExportWiiSaveFiles()
__name = FilesList[i].substr(WiiTitlePath.length()+1); __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) 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; b_valid = false;
return; 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"); 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::FSTEntry FST_Temp;
File::ScanDirectoryTree(Directories[i], 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) if (strncmp(elem.virtualName.c_str(), "banner.bin", 10) != 0)
{ {

View File

@ -102,7 +102,7 @@ public:
while (it != expr.end()) while (it != expr.end())
{ {
char c = *it; char c = *it;
it++; ++it;
if (c == '`') if (c == '`')
return false; return false;
if (c > 0 && c == otherDelim) if (c > 0 && c == otherDelim)
@ -140,7 +140,7 @@ public:
if (!isalpha(c)) if (!isalpha(c))
break; break;
name += c; name += c;
it++; ++it;
} }
ControlQualifier qualifier; ControlQualifier qualifier;

View File

@ -41,8 +41,8 @@ public:
offset = 0; offset = 0;
context->Map(buf, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); context->Map(buf, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
for(std::list<bool*>::iterator it = observers.begin(); it != observers.end(); ++it) for(bool* observer : observers)
**it = true; *observer = true;
} }
else else
{ {

View File

@ -149,9 +149,9 @@ void LineGeometryShader::Shutdown()
{ {
m_ready = false; m_ready = false;
for (ComboMap::iterator it = m_shaders.begin(); it != m_shaders.end(); ++it) for (auto& it : m_shaders)
{ {
SAFE_RELEASE(it->second); SAFE_RELEASE(it.second);
} }
m_shaders.clear(); m_shaders.clear();

View File

@ -1012,10 +1012,9 @@ void PSTextureEncoder::Shutdown()
SAFE_RELEASE(m_classLinkage); SAFE_RELEASE(m_classLinkage);
SAFE_RELEASE(m_dynamicShader); SAFE_RELEASE(m_dynamicShader);
for (ComboMap::iterator it = m_staticShaders.begin(); for (auto& it : m_staticShaders)
it != m_staticShaders.end(); ++it)
{ {
SAFE_RELEASE(it->second); SAFE_RELEASE(it.second);
} }
m_staticShaders.clear(); m_staticShaders.clear();

View File

@ -410,8 +410,8 @@ void PixelShaderCache::Init()
// ONLY to be used during shutdown. // ONLY to be used during shutdown.
void PixelShaderCache::Clear() void PixelShaderCache::Clear()
{ {
for (PSCache::iterator iter = PixelShaders.begin(); iter != PixelShaders.end(); iter++) for (auto& iter : PixelShaders)
iter->second.Destroy(); iter.second.Destroy();
PixelShaders.clear(); PixelShaders.clear();
pixel_uid_checker.Invalidate(); pixel_uid_checker.Invalidate();

View File

@ -143,9 +143,9 @@ void PointGeometryShader::Shutdown()
{ {
m_ready = false; m_ready = false;
for (ComboMap::iterator it = m_shaders.begin(); it != m_shaders.end(); ++it) for (auto& it : m_shaders)
{ {
SAFE_RELEASE(it->second); SAFE_RELEASE(it.second);
} }
m_shaders.clear(); m_shaders.clear();

View File

@ -157,8 +157,8 @@ void VertexShaderCache::Init()
void VertexShaderCache::Clear() void VertexShaderCache::Clear()
{ {
for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end(); ++iter) for (auto& iter : vshaders)
iter->second.Destroy(); iter.second.Destroy();
vshaders.clear(); vshaders.clear();
vertex_uid_checker.Invalidate(); vertex_uid_checker.Invalidate();

View File

@ -710,15 +710,14 @@ void Renderer::DrawDebugInfo()
int a = 0; int a = 0;
GLfloat color[3] = {0.0f, 1.0f, 1.0f}; GLfloat color[3] = {0.0f, 1.0f, 1.0f};
for (std::vector<EFBRectangle>::const_iterator it = stats.efb_regions.begin(); for (const EFBRectangle& rect : stats.efb_regions)
it != stats.efb_regions.end(); ++it)
{ {
GLfloat halfWidth = EFB_WIDTH / 2.0f; GLfloat halfWidth = EFB_WIDTH / 2.0f;
GLfloat halfHeight = EFB_HEIGHT / 2.0f; GLfloat halfHeight = EFB_HEIGHT / 2.0f;
GLfloat x = (GLfloat) -1.0f + ((GLfloat)it->left / halfWidth); GLfloat x = (GLfloat) -1.0f + ((GLfloat)rect.left / halfWidth);
GLfloat y = (GLfloat) 1.0f - ((GLfloat)it->top / halfHeight); GLfloat y = (GLfloat) 1.0f - ((GLfloat)rect.top / halfHeight);
GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)it->right / halfWidth); GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)rect.right / halfWidth);
GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)it->bottom / halfHeight); GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)rect.bottom / halfHeight);
Vertices[a++] = x; Vertices[a++] = x;
Vertices[a++] = y; Vertices[a++] = y;
@ -1782,7 +1781,7 @@ void Renderer::FlipImageData(u8 *data, int w, int h, int pixel_width)
{ {
for(int x = 0; x < w; ++x) for(int x = 0; x < w; ++x)
{ {
for (auto delta = 0; delta < pixel_width; ++delta) for (int delta = 0; delta < pixel_width; ++delta)
std::swap(data[(y * w + x) * pixel_width + delta], data[((h - 1 - y) * w + x) * pixel_width + delta]); std::swap(data[(y * w + x) * pixel_width + delta], data[((h - 1 - y) * w + x) * pixel_width + delta]);
} }
} }

View File

@ -172,7 +172,7 @@ void TextureCache::MakeRangeDynamic(u32 start_address, u32 size)
tcend = textures.upper_bound(start_address + size); tcend = textures.upper_bound(start_address + size);
if (iter != textures.begin()) if (iter != textures.begin())
iter--; --iter;
for (; iter != tcend; ++iter) for (; iter != tcend; ++iter)
{ {

View File

@ -43,7 +43,7 @@ static VertexLoaderMap g_VertexLoaderMap;
void Init() void Init()
{ {
MarkAllDirty(); MarkAllDirty();
for (auto& vertexLoader : g_VertexLoaders) for (VertexLoader*& vertexLoader : g_VertexLoaders)
vertexLoader = NULL; vertexLoader = NULL;
RecomputeCachedArraybases(); RecomputeCachedArraybases();
} }
@ -75,19 +75,19 @@ void AppendListToString(std::string *dest)
std::vector<entry> entries; std::vector<entry> entries;
size_t total_size = 0; size_t total_size = 0;
for (VertexLoaderMap::const_iterator iter = g_VertexLoaderMap.begin(); iter != g_VertexLoaderMap.end(); ++iter) for (const auto& map_entry : g_VertexLoaderMap)
{ {
entry e; entry e;
iter->second->AppendToString(&e.text); map_entry.second->AppendToString(&e.text);
e.num_verts = iter->second->GetNumLoadedVerts(); e.num_verts = map_entry.second->GetNumLoadedVerts();
entries.push_back(e); entries.push_back(e);
total_size += e.text.size() + 1; total_size += e.text.size() + 1;
} }
sort(entries.begin(), entries.end()); sort(entries.begin(), entries.end());
dest->reserve(dest->size() + total_size); dest->reserve(dest->size() + total_size);
for (std::vector<entry>::const_iterator iter = entries.begin(); iter != entries.end(); ++iter) for (const entry& entry : entries)
{ {
dest->append(iter->text); dest->append(entry.text);
} }
} }

View File

@ -48,7 +48,7 @@ void VideoBackend::PopulateList()
#endif #endif
g_available_video_backends.push_back(backends[3] = new SW::VideoSoftware); g_available_video_backends.push_back(backends[3] = new SW::VideoSoftware);
for (auto& backend : backends) for (VideoBackend* backend : backends)
{ {
if (backend) if (backend)
{ {
@ -72,7 +72,7 @@ void VideoBackend::ActivateBackend(const std::string& name)
if (name.length() == 0) // If NULL, set it to the default backend (expected behavior) if (name.length() == 0) // If NULL, set it to the default backend (expected behavior)
g_video_backend = s_default_backend; g_video_backend = s_default_backend;
for (std::vector<VideoBackend*>::const_iterator it = g_available_video_backends.begin(); it != g_available_video_backends.end(); ++it) for (VideoBackend* backend : g_available_video_backends)
if (name == (*it)->GetName()) if (name == backend->GetName())
g_video_backend = *it; g_video_backend = backend;
} }