Run code through clang-modernize -loop-convert to create range-based for loops, and manually fix some stuff up.

This commit is contained in:
comex 2013-10-29 01:09:01 -04:00
parent 00fe5057f1
commit 965b32be9c
90 changed files with 688 additions and 739 deletions

View File

@ -144,10 +144,10 @@ ALDeviceList::ALDeviceList()
*/
ALDeviceList::~ALDeviceList()
{
for (u32 i = 0; i < vDeviceInfo.size(); i++) {
if (vDeviceInfo[i].pvstrExtensions) {
vDeviceInfo[i].pvstrExtensions->clear();
delete vDeviceInfo[i].pvstrExtensions;
for (auto& di : vDeviceInfo) {
if (di.pvstrExtensions) {
di.pvstrExtensions->clear();
delete di.pvstrExtensions;
}
}
@ -206,8 +206,8 @@ bool ALDeviceList::IsExtensionSupported(s32 index, char *szExtName)
bool bReturn = false;
if (index < GetNumDevices()) {
for (u32 i = 0; i < vDeviceInfo[index].pvstrExtensions->size(); i++) {
if (!strcasecmp(vDeviceInfo[index].pvstrExtensions->at(i).c_str(), szExtName)) {
for (auto& ext : *vDeviceInfo[index].pvstrExtensions) {
if (!strcasecmp(ext.c_str(), szExtName)) {
bReturn = true;
break;
}
@ -260,16 +260,16 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName)
{
bool bFound;
for (u32 i = 0; i < vDeviceInfo.size(); i++) {
for (auto& di : vDeviceInfo) {
bFound = false;
for (u32 j = 0; j < vDeviceInfo[i].pvstrExtensions->size(); j++) {
if (!strcasecmp(vDeviceInfo[i].pvstrExtensions->at(j).c_str(), szExtName)) {
for (auto& ext : *di.pvstrExtensions) {
if (!strcasecmp(ext.c_str(), szExtName)) {
bFound = true;
break;
}
}
if (!bFound)
vDeviceInfo[i].bSelected = false;
di.bSelected = false;
}
}
@ -339,9 +339,9 @@ u32 ALDeviceList::GetMaxNumSources()
alDeleteSources(iSourceCount, uiSources);
if (alGetError() != AL_NO_ERROR)
{
for (u32 i = 0; i < 256; i++)
for (auto& uiSource : uiSources)
{
alDeleteSources(1, &uiSources[i]);
alDeleteSources(1, &uiSource);
}
}

View File

@ -12,16 +12,16 @@
bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
{
for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
if (i->iAddress == _iAddress)
for (auto& bp : m_BreakPoints)
if (bp.iAddress == _iAddress)
return true;
return false;
}
bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
{
for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
if (i->iAddress == _iAddress && i->bTemporary)
for (auto& bp : m_BreakPoints)
if (bp.iAddress == _iAddress && bp.bTemporary)
return true;
return false;
}
@ -29,29 +29,28 @@ bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
{
TBreakPointsStr bps;
for (TBreakPoints::const_iterator i = m_BreakPoints.begin();
i != m_BreakPoints.end(); ++i)
for (const auto& bp : m_BreakPoints)
{
if (!i->bTemporary)
if (!bp.bTemporary)
{
std::stringstream bp;
bp << std::hex << i->iAddress << " " << (i->bOn ? "n" : "");
bps.push_back(bp.str());
std::stringstream ss;
ss << std::hex << bp.iAddress << " " << (bp.bOn ? "n" : "");
bps.push_back(ss.str());
}
}
return bps;
}
void BreakPoints::AddFromStrings(const TBreakPointsStr& bps)
void BreakPoints::AddFromStrings(const TBreakPointsStr& bpstrs)
{
for (TBreakPointsStr::const_iterator i = bps.begin(); i != bps.end(); ++i)
for (const auto& bpstr : bpstrs)
{
TBreakPoint bp;
std::stringstream bpstr;
bpstr << std::hex << *i;
bpstr >> bp.iAddress;
bp.bOn = i->find("n") != i->npos;
std::stringstream ss;
ss << std::hex << bpstr;
ss >> bp.iAddress;
bp.bOn = bpstr.find("n") != bpstr.npos;
bp.bTemporary = false;
Add(bp);
}
@ -115,35 +114,34 @@ void BreakPoints::Clear()
MemChecks::TMemChecksStr MemChecks::GetStrings() const
{
TMemChecksStr mcs;
for (TMemChecks::const_iterator i = m_MemChecks.begin();
i != m_MemChecks.end(); ++i)
for (const auto& bp : m_MemChecks)
{
std::stringstream mc;
mc << std::hex << i->StartAddress;
mc << " " << (i->bRange ? i->EndAddress : i->StartAddress) << " " <<
(i->bRange ? "n" : "") << (i->OnRead ? "r" : "") <<
(i->OnWrite ? "w" : "") << (i->Log ? "l" : "") << (i->Break ? "p" : "");
mc << std::hex << bp.StartAddress;
mc << " " << (bp.bRange ? bp.EndAddress : bp.StartAddress) << " " <<
(bp.bRange ? "n" : "") << (bp.OnRead ? "r" : "") <<
(bp.OnWrite ? "w" : "") << (bp.Log ? "l" : "") << (bp.Break ? "p" : "");
mcs.push_back(mc.str());
}
return mcs;
}
void MemChecks::AddFromStrings(const TMemChecksStr& mcs)
void MemChecks::AddFromStrings(const TMemChecksStr& mcstrs)
{
for (TMemChecksStr::const_iterator i = mcs.begin(); i != mcs.end(); ++i)
for (const auto& mcstr : mcstrs)
{
TMemCheck mc;
std::stringstream mcstr;
mcstr << std::hex << *i;
mcstr >> mc.StartAddress;
mc.bRange = i->find("n") != i->npos;
mc.OnRead = i->find("r") != i->npos;
mc.OnWrite = i->find("w") != i->npos;
mc.Log = i->find("l") != i->npos;
mc.Break = i->find("p") != i->npos;
std::stringstream ss;
ss << std::hex << mcstr;
ss >> mc.StartAddress;
mc.bRange = mcstr.find("n") != mcstr.npos;
mc.OnRead = mcstr.find("r") != mcstr.npos;
mc.OnWrite = mcstr.find("w") != mcstr.npos;
mc.Log = mcstr.find("l") != mcstr.npos;
mc.Break = mcstr.find("p") != mcstr.npos;
if (mc.bRange)
mcstr >> mc.EndAddress;
ss >> mc.EndAddress;
else
mc.EndAddress = mc.StartAddress;
Add(mc);
@ -170,15 +168,15 @@ void MemChecks::Remove(u32 _Address)
TMemCheck *MemChecks::GetMemCheck(u32 address)
{
for (TMemChecks::iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
for (auto& bp : m_MemChecks)
{
if (i->bRange)
if (bp.bRange)
{
if (address >= i->StartAddress && address <= i->EndAddress)
return &(*i);
if (address >= bp.StartAddress && address <= bp.EndAddress)
return &(bp);
}
else if (i->StartAddress == address)
return &(*i);
else if (bp.StartAddress == address)
return &(bp);
}
// none found

View File

@ -211,24 +211,21 @@ std::vector<std::string> cdio_get_devices ()
// Returns true if device is a cdrom/dvd drive
bool cdio_is_cdrom(std::string device)
{
#ifdef __linux__
#ifndef _WIN32
// Resolve symbolic links. This allows symbolic links to valid
// drives to be passed from the command line with the -e flag.
char resolved_path[MAX_PATH];
char *devname = realpath(device.c_str(), resolved_path);
if (!devname)
return false;
device = devname;
#endif
std::vector<std::string> devices = cdio_get_devices();
bool res = false;
for (unsigned int i = 0; i < devices.size(); i++)
for (auto& odevice : devices)
{
#ifdef __linux__
if (strncmp(devices[i].c_str(), devname, MAX_PATH) == 0)
#else
if (strncmp(devices[i].c_str(), device.c_str(), MAX_PATH) == 0)
#endif
if (strncmp(odevice.c_str(), device.c_str(), MAX_PATH) == 0)
{
res = true;
break;

View File

@ -90,10 +90,10 @@ public:
case MODE_WRITE:
case MODE_MEASURE:
case MODE_VERIFY:
for (auto itr = x.begin(); itr != x.end(); ++itr)
for (auto& elem : x)
{
Do(itr->first);
Do(itr->second);
Do(elem.first);
Do(elem.second);
}
break;
}
@ -134,8 +134,8 @@ public:
Do(size);
x.resize(size);
for (auto itr = x.begin(); itr != x.end(); ++itr)
Do(*itr);
for (auto& elem : x)
Do(elem);
}
template <typename T>

View File

@ -21,11 +21,11 @@
CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, const CFileSearch::XStringVector& _rDirectories)
{
// Reverse the loop order for speed?
for (size_t j = 0; j < _rSearchStrings.size(); j++)
for (auto& _rSearchString : _rSearchStrings)
{
for (size_t i = 0; i < _rDirectories.size(); i++)
for (auto& _rDirectory : _rDirectories)
{
FindFiles(_rSearchStrings[j], _rDirectories[i]);
FindFiles(_rSearchString, _rDirectory);
}
}
}

View File

@ -125,18 +125,16 @@ bool IniFile::Section::Get(const char* key, std::vector<std::string>& out)
size_t subEnd;
// split by ,
while (subStart != std::string::npos) {
while (subStart != std::string::npos)
{
// Find next ,
subEnd = temp.find_first_of(",", subStart);
if (subStart != subEnd)
// take from first char until next ,
out.push_back(StripSpaces(temp.substr(subStart, subEnd - subStart)));
// Find the next non , char
subStart = temp.find_first_not_of(",", subEnd);
}
return true;
}
@ -210,17 +208,17 @@ bool IniFile::Section::Delete(const char *key)
const IniFile::Section* IniFile::GetSection(const char* sectionName) const
{
for (std::vector<Section>::const_iterator iter = sections.begin(); iter != sections.end(); ++iter)
if (!strcasecmp(iter->name.c_str(), sectionName))
return (&(*iter));
for (const auto& sect : sections)
if (!strcasecmp(sect.name.c_str(), sectionName))
return (&(sect));
return 0;
}
IniFile::Section* IniFile::GetSection(const char* sectionName)
{
for (std::vector<Section>::iterator iter = sections.begin(); iter != sections.end(); ++iter)
if (!strcasecmp(iter->name.c_str(), sectionName))
return (&(*iter));
for (auto& sect : sections)
if (!strcasecmp(sect.name.c_str(), sectionName))
return (&(sect));
return 0;
}
@ -291,9 +289,9 @@ bool IniFile::GetLines(const char* sectionName, std::vector<std::string>& lines,
return false;
lines.clear();
for (std::vector<std::string>::const_iterator iter = section->lines.begin(); iter != section->lines.end(); ++iter)
for (std::string line : section->lines)
{
std::string line = StripSpaces(*iter);
line = StripSpaces(line);
if (remove_comments)
{
@ -399,21 +397,16 @@ bool IniFile::Save(const char* filename)
return false;
}
for (auto iter = sections.begin(); iter != sections.end(); ++iter)
for (auto& section : sections)
{
const Section& section = *iter;
if (section.keys_order.size() != 0 || section.lines.size() != 0)
out << "[" << section.name << "]" << std::endl;
if (section.keys_order.size() == 0)
{
for (auto liter = section.lines.begin(); liter != section.lines.end(); ++liter)
{
std::string s = *liter;
for (auto s : section.lines)
out << s << std::endl;
}
}
else
{
for (auto kvit = section.keys_order.begin(); kvit != section.keys_order.end(); ++kvit)

View File

@ -81,14 +81,14 @@ LogManager::LogManager()
m_consoleLog = new ConsoleListener();
m_debuggerLog = new DebuggerLogListener();
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
for (auto& container : m_Log)
{
m_Log[i]->SetEnable(true);
m_Log[i]->AddListener(m_fileLog);
m_Log[i]->AddListener(m_consoleLog);
container->SetEnable(true);
container->AddListener(m_fileLog);
container->AddListener(m_consoleLog);
#ifdef _MSC_VER
if (IsDebuggerPresent())
m_Log[i]->AddListener(m_debuggerLog);
container->AddListener(m_debuggerLog);
#endif
}
}
@ -102,8 +102,8 @@ LogManager::~LogManager()
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
}
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
delete m_Log[i];
for (auto& container : m_Log)
delete container;
delete m_fileLog;
delete m_consoleLog;

View File

@ -263,7 +263,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
base_attempts = 0;
break;
}
}
#else
// Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors.
@ -289,9 +288,8 @@ void MemoryMap_Shutdown(const MemoryView *views, int num_views, u32 flags, MemAr
{
const MemoryView* view = &views[i];
u8** outptrs[2] = {view->out_ptr_low, view->out_ptr};
for (int j = 0; j < 2; j++)
for (auto outptr : outptrs)
{
u8** outptr = outptrs[j];
if (outptr && *outptr && !freeset.count(*outptr))
{
arena->ReleaseView(*outptr, view->size);

View File

@ -28,18 +28,18 @@ void SymbolDB::Clear(const char *prefix)
void SymbolDB::Index()
{
int i = 0;
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter)
for (auto& func : functions)
{
iter->second.index = i++;
func.second.index = i++;
}
}
Symbol *SymbolDB::GetSymbolFromName(const char *name)
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter)
for (auto& func : functions)
{
if (!strcmp(iter->second.name.c_str(), name))
return &iter->second;
if (!strcmp(func.second.name.c_str(), name))
return &func.second;
}
return 0;
}

View File

@ -298,8 +298,8 @@ void SysConf::GenerateSysConf()
items[26].data[0] = 0x01;
for (int i = 0; i < 27; i++)
m_Entries.push_back(items[i]);
for (auto& item : items)
m_Entries.push_back(item);
File::CreateFullPath(m_FilenameDefault);
File::IOFile g(m_FilenameDefault, "wb");

View File

@ -123,9 +123,8 @@ void LoadCodes(IniFile &globalIni, IniFile &localIni, bool forceLoad)
std::vector<std::string> enabledLines;
std::set<std::string> enabledNames;
localIni.GetLines("ActionReplay_Enabled", enabledLines);
for (auto iter = enabledLines.begin(); iter != enabledLines.end(); ++iter)
for (auto& line : enabledLines)
{
const std::string& line = *iter;
if (line.size() != 0 && line[0] == '$')
{
std::string name = line.substr(1, line.size() - 1);
@ -258,11 +257,11 @@ void RunAllActive()
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats)
{
for (std::vector<ARCode>::iterator i = activeCodes.begin(); i != activeCodes.end(); ++i)
for (auto& activeCode : activeCodes)
{
if (i->active)
if (activeCode.active)
{
i->active = RunCode(*i);
activeCode.active = RunCode(activeCode);
LogInfo("\n");
}
}
@ -467,10 +466,10 @@ void UpdateActiveList()
SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats = false;
b_RanOnce = false;
activeCodes.clear();
for (size_t i = 0; i < arCodes.size(); i++)
for (auto& arCode : arCodes)
{
if (arCodes[i].active)
activeCodes.push_back(arCodes[i]);
if (arCode.active)
activeCodes.push_back(arCode);
}
SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats = old_value;
}

View File

@ -30,16 +30,16 @@ CDolLoader::CDolLoader(const char* _szFilename)
CDolLoader::~CDolLoader()
{
for (int i = 0; i < DOL_NUM_TEXT; i++)
for (auto& sect : text_section)
{
delete [] text_section[i];
text_section[i] = NULL;
delete [] sect;
sect = NULL;
}
for (int i = 0; i < DOL_NUM_DATA; i++)
for (auto& sect : data_section)
{
delete [] data_section[i];
data_section[i] = NULL;
delete [] sect;
sect = NULL;
}
}
@ -52,10 +52,10 @@ void CDolLoader::Initialize(u8* _pBuffer, u32 _Size)
for (size_t i = 0; i < (sizeof(SDolHeader)/sizeof(u32)); i++)
p[i] = Common::swap32(p[i]);
for (int i = 0; i < DOL_NUM_TEXT; i++)
text_section[i] = NULL;
for (int i = 0; i < DOL_NUM_DATA; i++)
data_section[i] = NULL;
for (auto& sect : text_section)
sect = NULL;
for (auto& sect : data_section)
sect = NULL;
u32 HID4_pattern = 0x7c13fba6;
u32 HID4_mask = 0xfc1fffff;

View File

@ -84,15 +84,15 @@ int RegisterEvent(const char *name, TimedCallback callback)
// check for existing type with same name.
// we want event type names to remain unique so that we can use them for serialization.
for (unsigned int i = 0; i < event_types.size(); ++i)
for (auto& event_type : event_types)
{
if (!strcmp(name, event_types[i].name))
if (!strcmp(name, event_type.name))
{
WARN_LOG(POWERPC, "Discarded old event type \"%s\" because a new type with the same name was registered.", name);
// 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_types[i].name = "_discarded_event";
event_types[i].callback = &EmptyTimedCallback;
event_type.name = "_discarded_event";
event_type.callback = &EmptyTimedCallback;
}
}

View File

@ -49,8 +49,7 @@ public:
void Clear()
{
for (int i = 0; i < 65536; i++)
b[i] = 0;
memset(b, 0, sizeof(b));
}
void DeleteByAddress(u32 addr)

View File

@ -489,10 +489,10 @@ const char* pdname(u16 val)
{
static char tmpstr[12]; // nasty
for (int i = 0; i < (int)(sizeof(pdlabels) / sizeof(pdlabel_t)); i++)
for (auto& pdlabel : pdlabels)
{
if (pdlabels[i].addr == val)
return pdlabels[i].name;
if (pdlabel.addr == val)
return pdlabel.name;
}
sprintf(tmpstr, "0x%04x", val);
@ -521,23 +521,22 @@ void InitInstructionTable()
{
// ext op table
for (int i = 0; i < EXT_OPTABLE_SIZE; i++)
{
extOpTable[i] = &cw;
for (int i = 0; i < EXT_OPTABLE_SIZE; i++)
for (auto& ext : opcodes_ext)
{
for (int j = 0; j < opcodes_ext_size; j++)
{
u16 mask = opcodes_ext[j].opcode_mask;
if ((mask & i) == opcodes_ext[j].opcode)
u16 mask = ext.opcode_mask;
if ((mask & i) == ext.opcode)
{
if (extOpTable[i] == &cw)
extOpTable[i] = &opcodes_ext[j];
extOpTable[i] = &ext;
else
{
//if the entry already in the table
//is a strict subset, allow it
if ((extOpTable[i]->opcode_mask | opcodes_ext[j].opcode_mask) != extOpTable[i]->opcode_mask)
ERROR_LOG(DSPLLE, "opcode ext table place %d already in use by %s when inserting %s", i, extOpTable[i]->name, opcodes_ext[j].name);
if ((extOpTable[i]->opcode_mask | ext.opcode_mask) != extOpTable[i]->opcode_mask)
ERROR_LOG(DSPLLE, "opcode ext table place %d already in use by %s when inserting %s", i, extOpTable[i]->name, ext.name);
}
}
}
@ -549,15 +548,15 @@ void InitInstructionTable()
for (int i = 0; i < OPTABLE_SIZE; i++)
{
for (int j = 0; j < opcodes_size; j++)
for (auto& opcode : opcodes)
{
u16 mask = opcodes[j].opcode_mask;
if ((mask & i) == opcodes[j].opcode)
u16 mask = opcode.opcode_mask;
if ((mask & i) == opcode.opcode)
{
if (opTable[i] == &cw)
opTable[i] = &opcodes[j];
opTable[i] = &opcode;
else
ERROR_LOG(DSPLLE, "opcode table place %d already in use for %s", i, opcodes[j].name);
ERROR_LOG(DSPLLE, "opcode table place %d already in use for %s", i, opcode.name);
}
}
}

View File

@ -75,10 +75,10 @@ static void *reg_ptr(int reg)
DSPJitRegCache::DSPJitRegCache(DSPEmitter &_emitter)
: emitter(_emitter), temporary(false), merged(false)
{
for(unsigned int i = 0; i < NUMXREGS; i++)
for(auto& xreg : xregs)
{
xregs[i].guest_reg = DSP_REG_STATIC;
xregs[i].pushed = false;
xreg.guest_reg = DSP_REG_STATIC;
xreg.pushed = false;
}
xregs[RAX].guest_reg = DSP_REG_STATIC;// reserved for MUL/DIV
@ -449,9 +449,9 @@ void DSPJitRegCache::pushRegs()
}
int push_count = 0;
for(unsigned int i = 0; i < NUMXREGS; i++)
for(auto& xreg : xregs)
{
if (xregs[i].guest_reg == DSP_REG_USED)
if (xreg.guest_reg == DSP_REG_USED)
push_count++;
}
@ -503,9 +503,9 @@ void DSPJitRegCache::popRegs() {
emitter.MOV(32, M(&ebp_store), R(EBP));
#endif
int push_count = 0;
for(unsigned int i = 0; i < NUMXREGS; i++)
for(auto& xreg : xregs)
{
if (xregs[i].pushed)
if (xreg.pushed)
push_count++;
}
@ -1037,11 +1037,11 @@ void DSPJitRegCache::spillXReg(X64Reg reg)
X64Reg DSPJitRegCache::findFreeXReg()
{
for(unsigned int i = 0; i < sizeof(alloc_order)/sizeof(alloc_order[0]); i++)
for(auto& x : alloc_order)
{
if (xregs[alloc_order[i]].guest_reg == DSP_REG_NONE)
if (xregs[x].guest_reg == DSP_REG_NONE)
{
return alloc_order[i];
return x;
}
}
return INVALID_REG;

View File

@ -49,20 +49,20 @@ void LabelMap::DeleteLabel(const std::string &label)
}
}
bool LabelMap::GetLabelValue(const std::string &label, u16 *value, LabelType type) const
bool LabelMap::GetLabelValue(const std::string &name, u16 *value, LabelType type) const
{
for (u32 i = 0; i < labels.size(); i++)
for (auto& label : labels)
{
if (!label.compare(labels[i].name))
if (!name.compare(label.name))
{
if (type & labels[i].type)
if (type & label.type)
{
*value = labels[i].addr;
*value = label.addr;
return true;
}
else
{
printf("WARNING: Wrong label type requested. %s\n", label.c_str());
printf("WARNING: Wrong label type requested. %s\n", name.c_str());
}
}
}

View File

@ -128,8 +128,8 @@ u32 CalculateVertexSize(int vatIndex, const CPMemory &cpMem)
int sizes[21];
CalculateVertexElementSizes(sizes, vatIndex, cpMem);
for (int i = 0; i < 21; ++i)
vertexSize += sizes[i];
for (auto& size : sizes)
vertexSize += size;
return vertexSize;
}

View File

@ -17,12 +17,10 @@ FifoDataFile::FifoDataFile() :
FifoDataFile::~FifoDataFile()
{
for (unsigned int frameIdx = 0; frameIdx < m_Frames.size(); ++frameIdx)
for (auto& frame : m_Frames)
{
FifoFrameInfo &frame = m_Frames[frameIdx];
for (unsigned int i = 0; i < frame.memoryUpdates.size(); ++i)
delete []frame.memoryUpdates[i].data;
for (auto& update : frame.memoryUpdates)
delete []update.data;
delete []frame.fifoData;
}
@ -54,7 +52,7 @@ bool FifoDataFile::Save(const char *filename)
// Add space for frame list
u64 frameListOffset = file.Tell();
for (unsigned int i = 0; i < m_Frames.size(); ++i)
for (size_t i = 0; i < m_Frames.size(); i++)
PadFile(sizeof(FileFrameInfo), file);
u64 bpMemOffset = file.Tell();
@ -221,7 +219,7 @@ u64 FifoDataFile::WriteMemoryUpdates(const std::vector<MemoryUpdate> &memUpdates
{
// Add space for memory update list
u64 updateListOffset = file.Tell();
for (unsigned int i = 0; i < memUpdates.size(); ++i)
for (size_t i = 0; i < memUpdates.size(); i++)
PadFile(sizeof(FileMemoryUpdate), file);
for (unsigned int i = 0; i < memUpdates.size(); ++i)

View File

@ -115,10 +115,8 @@ void FifoPlaybackAnalyzer::AddMemoryUpdate(MemoryUpdate memUpdate, AnalyzedFrame
u32 end = memUpdate.address + memUpdate.size;
// Remove portions of memUpdate that overlap with memory ranges that have been written by the GP
for (unsigned int i = 0; i < m_WrittenMemory.size(); ++i)
for (const auto& range : m_WrittenMemory)
{
const MemoryRange &range = m_WrittenMemory[i];
if (range.begin < end &&
range.end > begin)
{

View File

@ -259,9 +259,9 @@ void FifoPlayer::WriteAllMemoryUpdates()
for (int frameNum = 0; frameNum < m_File->GetFrameCount(); ++frameNum)
{
const FifoFrameInfo &frame = m_File->GetFrame(frameNum);
for (unsigned int i = 0; i < frame.memoryUpdates.size(); ++i)
for (auto& update : frame.memoryUpdates)
{
WriteMemory(frame.memoryUpdates[i]);
WriteMemory(update);
}
}
}

View File

@ -23,14 +23,14 @@ void LoadCodes(const IniFile& globalIni, const IniFile& localIni, std::vector<Ge
GeckoCode gcode;
for (auto lines_iter = lines.begin(); lines_iter!=lines.end(); ++lines_iter)
for (auto& line : lines)
{
if (lines_iter->empty())
if (line.empty())
continue;
std::istringstream ss(*lines_iter);
std::istringstream ss(line);
switch ((*lines_iter)[0])
switch ((line)[0])
{
// enabled or disabled code
@ -52,7 +52,7 @@ void LoadCodes(const IniFile& globalIni, const IniFile& localIni, std::vector<Ge
// notes
case '*':
gcode.notes.push_back(std::string(++lines_iter->begin(), lines_iter->end()));
gcode.notes.push_back(std::string(++line.begin(), line.end()));
break;
// either part of the code, or an option choice
@ -60,7 +60,7 @@ void LoadCodes(const IniFile& globalIni, const IniFile& localIni, std::vector<Ge
{
GeckoCode::Code new_code;
// TODO: support options
new_code.original_line = *lines_iter;
new_code.original_line = line;
ss >> std::hex >> new_code.address >> new_code.data;
gcode.codes.push_back(new_code);
}
@ -75,16 +75,15 @@ void LoadCodes(const IniFile& globalIni, const IniFile& localIni, std::vector<Ge
inis[i]->GetLines("Gecko_Enabled", lines, false);
for (auto lines_iter = lines.begin(); lines_iter!=lines.end(); ++lines_iter)
for (auto line : lines)
{
auto line = *lines_iter;
if (line.size() == 0 || line[0] != '$')
continue;
std::string name = line.substr(1);
for (auto gcodes_iter = gcodes.begin(); gcodes_iter != gcodes.end(); ++gcodes_iter)
for (auto& ogcode : gcodes)
{
if ((*gcodes_iter).name == name)
(*gcodes_iter).enabled = true;
if (ogcode.name == name)
ogcode.enabled = true;
}
}
}

View File

@ -72,8 +72,8 @@ void CUCode_AX::LoadResamplingCoefficients()
File::IOFile fp(filename, "rb");
fp.ReadBytes(m_coeffs, 0x1000);
for (u32 i = 0; i < 0x800; ++i)
m_coeffs[i] = Common::swap16(m_coeffs[i]);
for (auto& coef : m_coeffs)
coef = Common::swap16(coef);
m_coeffs_available = true;
}
@ -386,7 +386,7 @@ void CUCode_AX::SetupProcessing(u32 init_addr)
};
u32 init_idx = 0;
for (u32 i = 0; i < sizeof (buffers) / sizeof (buffers[0]); ++i)
for (auto& buffer : buffers)
{
s32 init_val = (s32)((init_data[init_idx] << 16) | init_data[init_idx + 1]);
s16 delta = (s16)init_data[init_idx + 2];
@ -395,13 +395,13 @@ void CUCode_AX::SetupProcessing(u32 init_addr)
if (!init_val)
{
memset(buffers[i], 0, 5 * 32 * sizeof (int));
memset(buffer, 0, 5 * 32 * sizeof (int));
}
else
{
for (u32 j = 0; j < 32 * 5; ++j)
{
buffers[i][j] = init_val;
buffer[j] = init_val;
init_val += delta;
}
}
@ -501,20 +501,20 @@ void CUCode_AX::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr)
if (write_addr)
{
int* ptr = (int*)HLEMemory_Get_Pointer(write_addr);
for (u32 i = 0; i < 3; ++i)
for (auto& buffer : buffers)
for (u32 j = 0; j < 5 * 32; ++j)
*ptr++ = Common::swap32(buffers[i][j]);
*ptr++ = Common::swap32(buffer[j]);
}
// Then, we read the new temp from the CPU and add to our current
// temp.
int* ptr = (int*)HLEMemory_Get_Pointer(read_addr);
for (u32 i = 0; i < 5 * 32; ++i)
m_samples_left[i] += (int)Common::swap32(*ptr++);
for (u32 i = 0; i < 5 * 32; ++i)
m_samples_right[i] += (int)Common::swap32(*ptr++);
for (u32 i = 0; i < 5 * 32; ++i)
m_samples_surround[i] += (int)Common::swap32(*ptr++);
for (auto& sample : m_samples_left)
sample += (int)Common::swap32(*ptr++);
for (auto& sample : m_samples_right)
sample += (int)Common::swap32(*ptr++);
for (auto& sample : m_samples_surround)
sample += (int)Common::swap32(*ptr++);
}
void CUCode_AX::UploadLRS(u32 dst_addr)
@ -575,10 +575,10 @@ void CUCode_AX::MixAUXBLR(u32 ul_addr, u32 dl_addr)
{
// Upload AUXB L/R
int* ptr = (int*)HLEMemory_Get_Pointer(ul_addr);
for (u32 i = 0; i < 5 * 32; ++i)
*ptr++ = Common::swap32(m_samples_auxB_left[i]);
for (u32 i = 0; i < 5 * 32; ++i)
*ptr++ = Common::swap32(m_samples_auxB_right[i]);
for (auto& sample : m_samples_auxB_left)
*ptr++ = Common::swap32(sample);
for (auto& sample : m_samples_auxB_right)
*ptr++ = Common::swap32(sample);
// Mix AUXB L/R to MAIN L/R, and replace AUXB L/R
ptr = (int*)HLEMemory_Get_Pointer(dl_addr);
@ -620,14 +620,14 @@ void CUCode_AX::SendAUXAndMix(u32 main_auxa_up, u32 auxb_s_up, u32 main_l_dl,
// Upload AUXA LRS
int* ptr = (int*)HLEMemory_Get_Pointer(main_auxa_up);
for (u32 i = 0; i < sizeof (up_buffers) / sizeof (up_buffers[0]); ++i)
for (auto& up_buffer : up_buffers)
for (u32 j = 0; j < 32 * 5; ++j)
*ptr++ = Common::swap32(up_buffers[i][j]);
*ptr++ = Common::swap32(up_buffer[j]);
// Upload AUXB S
ptr = (int*)HLEMemory_Get_Pointer(auxb_s_up);
for (u32 i = 0; i < 32 * 5; ++i)
*ptr++ = Common::swap32(m_samples_auxB_surround[i]);
for (auto& sample : m_samples_auxB_surround)
*ptr++ = Common::swap32(sample);
// Download buffers and addresses
int* dl_buffers[] = {

View File

@ -21,6 +21,7 @@ CUCode_AXWii::CUCode_AXWii(DSPHLE *dsp_hle, u32 l_CRC)
{
for (int i = 0; i < 3; ++i)
m_last_aux_volumes[i] = 0x8000;
WARN_LOG(DSPHLE, "Instantiating CUCode_AXWii");
m_old_axwii = (l_CRC == 0xfa450138);
@ -279,7 +280,7 @@ void CUCode_AXWii::SetupProcessing(u32 init_addr)
};
u32 init_idx = 0;
for (u32 i = 0; i < sizeof (buffers) / sizeof (buffers[0]); ++i)
for (auto& buffer : buffers)
{
s32 init_val = (s32)((init_data[init_idx] << 16) | init_data[init_idx + 1]);
s16 delta = (s16)init_data[init_idx + 2];
@ -288,13 +289,13 @@ void CUCode_AXWii::SetupProcessing(u32 init_addr)
if (!init_val)
{
memset(buffers[i].ptr, 0, 3 * buffers[i].samples * sizeof (int));
memset(buffer.ptr, 0, 3 * buffer.samples * sizeof (int));
}
else
{
for (u32 j = 0; j < 3 * buffers[i].samples; ++j)
for (u32 j = 0; j < 3 * buffer.samples; ++j)
{
buffers[i].ptr[j] = init_val;
buffer.ptr[j] = init_val;
init_val += delta;
}
}
@ -523,19 +524,19 @@ void CUCode_AXWii::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16
if (write_addr)
{
int* ptr = (int*)HLEMemory_Get_Pointer(write_addr);
for (u32 i = 0; i < 3; ++i)
for (auto& buffer : buffers)
for (u32 j = 0; j < 3 * 32; ++j)
*ptr++ = Common::swap32(buffers[i][j]);
*ptr++ = Common::swap32(buffer[j]);
}
// Then read the buffers from the CPU and add to our main buffers.
int* ptr = (int*)HLEMemory_Get_Pointer(read_addr);
for (u32 i = 0; i < 3; ++i)
for (auto& main_buffer : main_buffers)
for (u32 j = 0; j < 3 * 32; ++j)
{
s64 sample = (s64)(s32)Common::swap32(*ptr++);
sample *= volume_ramp[j];
main_buffers[i][j] += (s32)(sample >> 15);
main_buffer[j] += (s32)(sample >> 15);
}
}

View File

@ -21,10 +21,10 @@ void CUCode_Zelda::AFCdecodebuffer(const s16 *coef, const char *src, signed shor
nibbles[i + 1] = *src & 15;
src++;
}
for (int i = 0; i < 16; i++) {
if (nibbles[i] >= 8)
nibbles[i] = nibbles[i] - 16;
nibbles[i] <<= 11;
for (auto& nibble : nibbles) {
if (nibble >= 8)
nibble = nibble - 16;
nibble <<= 11;
}
}
else
@ -41,11 +41,11 @@ void CUCode_Zelda::AFCdecodebuffer(const s16 *coef, const char *src, signed shor
src++;
}
for (int i = 0; i < 16; i++)
for (auto& nibble : nibbles)
{
if (nibbles[i] >= 2)
nibbles[i] = nibbles[i] - 4;
nibbles[i] <<= 13;
if (nibble >= 2)
nibble = nibble - 4;
nibble <<= 13;
}
}

View File

@ -64,10 +64,10 @@ Symbol *DSPSymbolDB::GetSymbolFromAddr(u32 addr)
}
else
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter)
for (auto& func : functions)
{
if (addr >= iter->second.address && addr < iter->second.address + iter->second.size)
return &iter->second;
if (addr >= func.second.address && addr < func.second.address + func.second.size)
return &func.second;
}
}
return 0;

View File

@ -48,23 +48,23 @@ void Init()
void Shutdown()
{
for (u32 i = 0; i < NUM_CHANNELS; i++)
for (auto& channel : g_Channels)
{
delete g_Channels[i];
g_Channels[i] = NULL;
delete channel;
channel = NULL;
}
}
void DoState(PointerWrap &p)
{
for (int c = 0; c < NUM_CHANNELS; ++c)
g_Channels[c]->DoState(p);
for (auto& channel : g_Channels)
channel->DoState(p);
}
void PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
for (int c = 0; c < NUM_CHANNELS; ++c)
g_Channels[c]->PauseAndLock(doLock, unpauseOnUnlock);
for (auto& channel : g_Channels)
channel->PauseAndLock(doLock, unpauseOnUnlock);
}
@ -87,9 +87,9 @@ void ChangeDevice(const u8 channel, const TEXIDevices device_type, const u8 devi
IEXIDevice* FindDevice(TEXIDevices device_type, int customIndex)
{
for (int i = 0; i < NUM_CHANNELS; ++i)
for (auto& channel : g_Channels)
{
IEXIDevice* device = g_Channels[i]->FindDevice(device_type, customIndex);
IEXIDevice* device = channel->FindDevice(device_type, customIndex);
if (device)
return device;
}
@ -145,8 +145,8 @@ void UpdateInterrupts()
g_Channels[2]->SetEXIINT(g_Channels[0]->GetDevice(4)->IsInterruptSet());
bool causeInt = false;
for (int i = 0; i < NUM_CHANNELS; i++)
causeInt |= g_Channels[i]->IsCausingInterrupt();
for (auto& channel : g_Channels)
causeInt |= channel->IsCausingInterrupt();
ProcessorInterface::SetInterrupt(ProcessorInterface::INT_CAUSE_EXI, causeInt);
}

View File

@ -30,8 +30,8 @@ CEXIChannel::CEXIChannel(u32 ChannelId) :
if (m_ChannelId == 1)
m_Status.CHIP_SELECT = 1;
for (int i = 0; i < NUM_DEVICES; i++)
m_pDevices[i] = EXIDevice_Create(EXIDEVICE_NONE, m_ChannelId);
for (auto& device : m_pDevices)
device.reset(EXIDevice_Create(EXIDEVICE_NONE, m_ChannelId));
updateInterrupts = CoreTiming::RegisterEvent("EXIInterrupt", UpdateInterrupts);
}
@ -43,11 +43,8 @@ CEXIChannel::~CEXIChannel()
void CEXIChannel::RemoveDevices()
{
for (int i = 0; i < NUM_DEVICES; i++)
{
delete m_pDevices[i];
m_pDevices[i] = NULL;
}
for (auto& device : m_pDevices)
device.reset();
}
void CEXIChannel::AddDevice(const TEXIDevices device_type, const int device_num)
@ -60,15 +57,8 @@ void CEXIChannel::AddDevice(IEXIDevice* pDevice, const int device_num, bool noti
{
_dbg_assert_(EXPANSIONINTERFACE, device_num < NUM_DEVICES);
// delete the old device
if (m_pDevices[device_num] != NULL)
{
delete m_pDevices[device_num];
m_pDevices[device_num] = NULL;
}
// replace it with the new one
m_pDevices[device_num] = pDevice;
m_pDevices[device_num].reset(pDevice);
if(notifyPresenceChanged)
{
@ -111,9 +101,9 @@ IEXIDevice* CEXIChannel::GetDevice(const u8 chip_select)
{
switch (chip_select)
{
case 1: return m_pDevices[0];
case 2: return m_pDevices[1];
case 4: return m_pDevices[2];
case 1: return m_pDevices[0].get();
case 2: return m_pDevices[1].get();
case 4: return m_pDevices[2].get();
}
return NULL;
}
@ -121,10 +111,8 @@ IEXIDevice* CEXIChannel::GetDevice(const u8 chip_select)
void CEXIChannel::Update()
{
// start the transfer
for (int i = 0; i < NUM_DEVICES; i++)
{
m_pDevices[i]->Update();
}
for (auto& device : m_pDevices)
device->Update();
}
void CEXIChannel::Read32(u32& _uReturnValue, const u32 _iRegister)
@ -283,7 +271,7 @@ void CEXIChannel::DoState(PointerWrap &p)
for (int d = 0; d < NUM_DEVICES; ++d)
{
IEXIDevice* pDevice = m_pDevices[d];
IEXIDevice* pDevice = m_pDevices[d].get();
TEXIDevices type = pDevice->m_deviceType;
p.Do(type);
IEXIDevice* pSaveDevice = (type == pDevice->m_deviceType) ? pDevice : EXIDevice_Create(type, m_ChannelId);
@ -308,15 +296,15 @@ void CEXIChannel::DoState(PointerWrap &p)
void CEXIChannel::PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
for (int d = 0; d < NUM_DEVICES; ++d)
m_pDevices[d]->PauseAndLock(doLock, unpauseOnUnlock);
for (auto& device : m_pDevices)
device->PauseAndLock(doLock, unpauseOnUnlock);
}
IEXIDevice* CEXIChannel::FindDevice(TEXIDevices device_type, int customIndex)
{
for (int d = 0; d < NUM_DEVICES; ++d)
for (auto& sup : m_pDevices)
{
IEXIDevice* device = m_pDevices[d]->FindDevice(device_type, customIndex);
IEXIDevice* device = sup->FindDevice(device_type, customIndex);
if (device)
return device;
}

View File

@ -8,6 +8,7 @@
#include "CommonTypes.h"
#include "EXI_Device.h"
#include <memory>
#ifdef _WIN32
#pragma warning(disable:4201)
@ -92,7 +93,7 @@ private:
NUM_DEVICES = 3
};
IEXIDevice* m_pDevices[NUM_DEVICES];
std::unique_ptr<IEXIDevice> m_pDevices[NUM_DEVICES];
// Since channels operate a bit differently from each other
u32 m_ChannelId;

View File

@ -65,8 +65,8 @@ GCPad::GCPad(const unsigned int index) : m_index(index)
// triggers
groups.push_back(m_triggers = new MixedTriggers(_trans("Triggers")));
for (unsigned int i=0; i < sizeof(named_triggers)/sizeof(*named_triggers); ++i)
m_triggers->controls.push_back(new ControlGroup::Input(named_triggers[i]));
for (auto& named_trigger : named_triggers)
m_triggers->controls.push_back(new ControlGroup::Input(named_trigger));
// rumble
groups.push_back(m_rumble = new ControlGroup(_trans("Rumble")));
@ -74,8 +74,8 @@ GCPad::GCPad(const unsigned int index) : m_index(index)
// dpad
groups.push_back(m_dpad = new Buttons(_trans("D-Pad")));
for (unsigned int i=0; i < 4; ++i)
m_dpad->controls.push_back(new ControlGroup::Input(named_directions[i]));
for (auto& named_direction : named_directions)
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
// options
groups.push_back(m_options = new ControlGroup(_trans("Options")));

View File

@ -57,8 +57,8 @@ Classic::Classic(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Classic"),
{
// buttons
groups.push_back(m_buttons = new Buttons("Buttons"));
for (unsigned int i = 0; i < sizeof(classic_button_names)/sizeof(*classic_button_names); ++i)
m_buttons->controls.push_back(new ControlGroup::Input(classic_button_names[i]));
for (auto& classic_button_name : classic_button_names)
m_buttons->controls.push_back(new ControlGroup::Input(classic_button_name));
// sticks
groups.push_back(m_left_stick = new AnalogStick(_trans("Left Stick")));
@ -66,13 +66,13 @@ Classic::Classic(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Classic"),
// triggers
groups.push_back(m_triggers = new MixedTriggers("Triggers"));
for (unsigned int i=0; i < sizeof(classic_trigger_names)/sizeof(*classic_trigger_names); ++i)
m_triggers->controls.push_back(new ControlGroup::Input(classic_trigger_names[i]));
for (auto& classic_trigger_name : classic_trigger_names)
m_triggers->controls.push_back(new ControlGroup::Input(classic_trigger_name));
// dpad
groups.push_back(m_dpad = new Buttons("D-Pad"));
for (unsigned int i=0; i < 4; ++i)
m_dpad->controls.push_back(new ControlGroup::Input(named_directions[i]));
for (auto& named_direction : named_directions)
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
// set up register
// calibration

View File

@ -36,8 +36,8 @@ Drums::Drums(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Drums"), _reg)
{
// pads
groups.push_back(m_pads = new Buttons(_trans("Pads")));
for (unsigned int i = 0; i < sizeof(drum_pad_names)/sizeof(*drum_pad_names); ++i)
m_pads->controls.push_back(new ControlGroup::Input(drum_pad_names[i]));
for (auto& drum_pad_name : drum_pad_names)
m_pads->controls.push_back(new ControlGroup::Input(drum_pad_name));
// stick
groups.push_back(m_stick = new AnalogStick("Stick"));

View File

@ -40,8 +40,8 @@ Guitar::Guitar(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Guitar"), _r
{
// frets
groups.push_back(m_frets = new Buttons(_trans("Frets")));
for (unsigned int i = 0; i < sizeof(guitar_fret_names)/sizeof(*guitar_fret_names); ++i)
m_frets->controls.push_back(new ControlGroup::Input(guitar_fret_names[i]));
for (auto& guitar_fret_name : guitar_fret_names)
m_frets->controls.push_back(new ControlGroup::Input(guitar_fret_name));
// strum
groups.push_back(m_strum = new Buttons(_trans("Strum")));

View File

@ -34,8 +34,8 @@ Turntable::Turntable(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Turnta
{
// buttons
groups.push_back(m_buttons = new Buttons("Buttons"));
for (unsigned int i = 0; i < sizeof(turntable_button_names)/sizeof(*turntable_button_names); ++i)
m_buttons->controls.push_back(new ControlGroup::Input(turntable_button_names[i]));
for (auto& turntable_button_name : turntable_button_names)
m_buttons->controls.push_back(new ControlGroup::Input(turntable_button_name));
// turntables
groups.push_back(m_left_table = new Slider(_trans("Table Left")));

View File

@ -264,8 +264,8 @@ Wiimote::Wiimote( const unsigned int index )
// buttons
groups.push_back(m_buttons = new Buttons("Buttons"));
for (unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons); ++i)
m_buttons->controls.push_back(new ControlGroup::Input( named_buttons[i]));
for (auto& named_button : named_buttons)
m_buttons->controls.push_back(new ControlGroup::Input( named_button));
// udp
groups.push_back(m_udp = new UDPWrapper(m_index, _trans("UDP Wiimote")));
@ -302,8 +302,8 @@ Wiimote::Wiimote( const unsigned int index )
// dpad
groups.push_back(m_dpad = new Buttons("D-Pad"));
for (unsigned int i=0; i < 4; ++i)
m_dpad->controls.push_back(new ControlGroup::Input(named_directions[i]));
for (auto& named_direction : named_directions)
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
// options
groups.push_back( m_options = new ControlGroup(_trans("Options")));
@ -503,12 +503,12 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
static const double dist1=100.f/camWidth; //this seems the optimal distance for zelda
static const double dist2=1.2f*dist1;
for (int i=0; i<4; i++)
for (auto& vtx : v)
{
v[i].x=xx*(bndright-bndleft)/2+(bndleft+bndright)/2;
if (m_sensor_bar_on_top) v[i].y=yy*(bndup-bnddown)/2+(bndup+bnddown)/2;
else v[i].y=yy*(bndup-bnddown)/2-(bndup+bnddown)/2;
v[i].z=0;
vtx.x=xx*(bndright-bndleft)/2+(bndleft+bndright)/2;
if (m_sensor_bar_on_top) vtx.y=yy*(bndup-bnddown)/2+(bndup+bnddown)/2;
else vtx.y=yy*(bndup-bnddown)/2-(bndup+bnddown)/2;
vtx.z=0;
}
v[0].x-=(zz*0.5+1)*dist1;

View File

@ -612,9 +612,9 @@ void Initialize(bool wait)
// called on emulation shutdown
void Stop(void)
{
for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
if (g_wiimotes[i] && g_wiimotes[i]->IsConnected())
g_wiimotes[i]->EmuStop();
for (auto& wiimote : g_wiimotes)
if (wiimote && wiimote->IsConnected())
wiimote->EmuStop();
}
// called when the dolphin app exits
@ -637,16 +637,16 @@ void Shutdown(void)
void Resume()
{
for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
if (g_wiimotes[i] && g_wiimotes[i]->IsConnected())
g_wiimotes[i]->EmuResume();
for (auto& wiimote : g_wiimotes)
if (wiimote && wiimote->IsConnected())
wiimote->EmuResume();
}
void Pause()
{
for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
if (g_wiimotes[i] && g_wiimotes[i]->IsConnected())
g_wiimotes[i]->EmuPause();
for (auto& wiimote : g_wiimotes)
if (wiimote && wiimote->IsConnected())
wiimote->EmuPause();
}
void ChangeWiimoteSource(unsigned int index, int source)

View File

@ -21,10 +21,10 @@ std::string HLE_IPC_BuildFilename(std::string path_wii, int _size)
std::string path_full = File::GetUserPath(D_WIIROOT_IDX);
// Replaces chars that FAT32 can't support with strings defined in /sys/replace
for (auto i = replacements.begin(); i != replacements.end(); ++i)
for (auto& replacement : replacements)
{
for (size_t j = 0; (j = path_wii.find(i->first, j)) != path_wii.npos; ++j)
path_wii.replace(j, 1, i->second);
for (size_t j = 0; (j = path_wii.find(replacement.first, j)) != path_wii.npos; ++j)
path_wii.replace(j, 1, replacement.second);
}
path_full += path_wii;

View File

@ -152,10 +152,10 @@ void CWII_IPC_HLE_Device_es::DoState(PointerWrap& p)
}
else
{
for (auto itr = m_ContentAccessMap.begin(); itr != m_ContentAccessMap.end(); ++itr)
for (auto& pair : m_ContentAccessMap)
{
CFD = itr->first;
SContentAccess& Access = itr->second;
CFD = pair.first;
SContentAccess& Access = pair.second;
Position = Access.m_Position;
TitleID = Access.m_TitleID;
Index = Access.m_pContent->m_Index;
@ -182,9 +182,9 @@ bool CWII_IPC_HLE_Device_es::Close(u32 _CommandAddress, bool _bForce)
{
// Leave deletion of the INANDContentLoader objects to CNANDContentManager, don't do it here!
m_NANDContent.clear();
for (auto itr = m_ContentAccessMap.begin(); itr != m_ContentAccessMap.end(); ++itr)
for (auto& pair : m_ContentAccessMap)
{
delete itr->second.m_pFile;
delete pair.second.m_pFile;
}
m_ContentAccessMap.clear();
m_pContentLoader = NULL;

View File

@ -60,9 +60,8 @@ static u64 ComputeTotalFileSize(const File::FSTEntry& parentEntry)
{
u64 sizeOfFiles = 0;
const std::vector<File::FSTEntry>& children = parentEntry.children;
for (std::vector<File::FSTEntry>::const_iterator it = children.begin(); it != children.end(); ++it)
for (const auto& entry : children)
{
const File::FSTEntry& entry = *it;
if (entry.isDirectory)
sizeOfFiles += ComputeTotalFileSize(entry);
else

View File

@ -734,13 +734,13 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
// Do the level/optname translation
int nat_level = -1, nat_optname = -1;
for (unsigned int i = 0; i < sizeof (opt_level_mapping) / sizeof (opt_level_mapping[0]); ++i)
if (level == opt_level_mapping[i][1])
nat_level = opt_level_mapping[i][0];
for (auto& map : opt_level_mapping)
if (level == map[1])
nat_level = map[0];
for (unsigned int i = 0; i < sizeof (opt_name_mapping) / sizeof (opt_name_mapping[0]); ++i)
if (optname == opt_name_mapping[i][1])
nat_optname = opt_name_mapping[i][0];
for (auto& map : opt_name_mapping)
if (optname == map[1])
nat_optname = map[0];
u8 optval[20];
u32 optlen = 4;
@ -785,13 +785,13 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
// Do the level/optname translation
int nat_level = -1, nat_optname = -1;
for (unsigned int i = 0; i < sizeof (opt_level_mapping) / sizeof (opt_level_mapping[0]); ++i)
if (level == opt_level_mapping[i][1])
nat_level = opt_level_mapping[i][0];
for (auto& map : opt_level_mapping)
if (level == map[1])
nat_level = map[0];
for (unsigned int i = 0; i < sizeof (opt_name_mapping) / sizeof (opt_name_mapping[0]); ++i)
if (optname == opt_name_mapping[i][1])
nat_optname = opt_name_mapping[i][0];
for (auto& map : opt_name_mapping)
if (optname == map[1])
nat_optname = map[0];
if (nat_level == -1 || nat_optname == -1)
{
@ -924,11 +924,11 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
// Translate Wii to native events
int unhandled_events = events;
ufds[i].events = 0;
for (unsigned int j = 0; j < sizeof (mapping) / sizeof (mapping[0]); ++j)
for (auto& map : mapping)
{
if (events & mapping[j][1])
ufds[i].events |= mapping[j][0];
unhandled_events &= ~mapping[j][1];
if (events & map[1])
ufds[i].events |= map[0];
unhandled_events &= ~map[1];
}
DEBUG_LOG(WII_IPC_NET, "IOCTL_SO_POLL(%d) "
@ -949,10 +949,10 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
// Translate native to Wii events
int revents = 0;
for (unsigned int j = 0; j < sizeof (mapping) / sizeof (mapping[0]); ++j)
for (auto& map : mapping)
{
if (ufds[i].revents & mapping[j][0])
revents |= mapping[j][1];
if (ufds[i].revents & map[0])
revents |= map[1];
}
// No need to change fd or events as they are input only.

View File

@ -436,12 +436,12 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
// Create ACL connection
if (m_HCIEndpoint.IsValid() && (m_ScanEnable & HCI_PAGE_SCAN_ENABLE))
{
for (unsigned int i = 0; i < m_WiiMotes.size(); i++)
for (auto& wiimote : m_WiiMotes)
{
if (m_WiiMotes[i].EventPagingChanged(m_ScanEnable))
if (wiimote.EventPagingChanged(m_ScanEnable))
{
Host_SetWiiMoteConnectionState(1);
SendEventRequestConnection(m_WiiMotes[i]);
SendEventRequestConnection(wiimote);
}
}
}
@ -449,9 +449,9 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
// Link channels when connected
if (m_ACLEndpoint.IsValid())
{
for (unsigned int i = 0; i < m_WiiMotes.size(); i++)
for (auto& wiimote : m_WiiMotes)
{
if (m_WiiMotes[i].LinkChannel())
if (wiimote.LinkChannel())
break;
}
}
@ -1818,16 +1818,16 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandVendorSpecific_FC4C(u8* _Input,
//
CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305::AccessWiiMote(const bdaddr_t& _rAddr)
{
for (size_t i=0; i<m_WiiMotes.size(); i++)
for (auto& wiimote : m_WiiMotes)
{
const bdaddr_t& BD = m_WiiMotes[i].GetBD();
const bdaddr_t& BD = wiimote.GetBD();
if ((_rAddr.b[0] == BD.b[0]) &&
(_rAddr.b[1] == BD.b[1]) &&
(_rAddr.b[2] == BD.b[2]) &&
(_rAddr.b[3] == BD.b[3]) &&
(_rAddr.b[4] == BD.b[4]) &&
(_rAddr.b[5] == BD.b[5]))
return &m_WiiMotes[i];
return &wiimote;
}
ERROR_LOG(WII_IPC_WIIMOTE,"Can't find WiiMote by bd: %02x:%02x:%02x:%02x:%02x:%02x",
@ -1837,10 +1837,10 @@ CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305::AccessWiiMote(const b
CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305::AccessWiiMote(u16 _ConnectionHandle)
{
for (size_t i=0; i<m_WiiMotes.size(); i++)
for (auto& wiimote : m_WiiMotes)
{
if (m_WiiMotes[i].GetConnectionHandle() == _ConnectionHandle)
return &m_WiiMotes[i];
if (wiimote.GetConnectionHandle() == _ConnectionHandle)
return &wiimote;
}
ERROR_LOG(WII_IPC_WIIMOTE, "Can't find WiiMote by connection handle %02x", _ConnectionHandle);

View File

@ -28,6 +28,7 @@ bool CWII_IPC_HLE_Device_usb_kbd::Open(u32 _CommandAddress, u32 _Mode)
for(int i = 0; i < 256; i++)
m_OldKeyBuffer[i] = false;
m_OldModifiers = 0x00;
//m_MessageQueue.push(SMessageData(MSG_KBD_CONNECT, 0, NULL));

View File

@ -602,9 +602,9 @@ void WiiSockMan::Update()
if (ret >= 0)
{
for (auto it = WiiSockets.begin(); it != WiiSockets.end(); ++it)
for (auto& pair : WiiSockets)
{
WiiSocket& sock = it->second;
WiiSocket& sock = pair.second;
sock.update(
FD_ISSET(sock.fd, &read_fds) != 0,
FD_ISSET(sock.fd, &write_fds) != 0,
@ -614,9 +614,9 @@ void WiiSockMan::Update()
}
else
{
for (auto it = WiiSockets.begin(); it != WiiSockets.end(); ++it)
for (auto& elem : WiiSockets)
{
it->second.update(false, false, false);
elem.second.update(false, false, false);
}
}
}

View File

@ -176,8 +176,8 @@ void Init()
if (!tmpHeader.bFromSaveState || !IsPlayingInput())
Core::SetStateFileName("");
for (int i = 0; i < 8; ++i)
g_InputDisplay[i].clear();
for (auto& disp : g_InputDisplay)
disp.clear();
if (!IsPlayingInput() && !IsRecordingInput())
{

View File

@ -54,9 +54,8 @@ void LoadPatchSection(const char *section, std::vector<Patch> &patches,
std::vector<std::string> enabledLines;
std::set<std::string> enabledNames;
localIni.GetLines(enabledSectionName.c_str(), enabledLines);
for (auto iter = enabledLines.begin(); iter != enabledLines.end(); ++iter)
for (auto& line : enabledLines)
{
const std::string& line = *iter;
if (line.size() != 0 && line[0] == '$')
{
std::string name = line.substr(1, line.size() - 1);
@ -72,10 +71,8 @@ void LoadPatchSection(const char *section, std::vector<Patch> &patches,
Patch currentPatch;
inis[i]->GetLines(section, lines);
for (auto iter = lines.begin(); iter != lines.end(); ++iter)
for (auto line : lines)
{
std::string line = *iter;
if (line.size() == 0)
continue;
@ -187,11 +184,11 @@ void LoadPatches()
void ApplyPatches(const std::vector<Patch> &patches)
{
for (std::vector<Patch>::const_iterator iter = patches.begin(); iter != patches.end(); ++iter)
for (const auto& patch : patches)
{
if (iter->active)
if (patch.active)
{
for (std::vector<PatchEntry>::const_iterator iter2 = iter->entries.begin(); iter2 != iter->entries.end(); ++iter2)
for (std::vector<PatchEntry>::const_iterator iter2 = patch.entries.begin(); iter2 != patch.entries.end(); ++iter2)
{
u32 addr = iter2->address;
u32 value = iter2->value;

View File

@ -382,112 +382,112 @@ void InitTables()
m_infoTable63[i] = 0;
}
for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : primarytable)
{
Interpreter::m_opTable[primarytable[i].opcode] = primarytable[i].Inst;
m_infoTable[primarytable[i].opcode] = &primarytable[i].opinfo;
Interpreter::m_opTable[tpl.opcode] = tpl.Inst;
m_infoTable[tpl.opcode] = &tpl.opinfo;
}
for (int i = 0; i < 32; i++)
{
int fill = i << 5;
for (int j = 0; j < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table4_2)
{
int op = fill+table4_2[j].opcode;
Interpreter::m_opTable4[op] = table4_2[j].Inst;
m_infoTable4[op] = &table4_2[j].opinfo;
int op = fill+tpl.opcode;
Interpreter::m_opTable4[op] = tpl.Inst;
m_infoTable4[op] = &tpl.opinfo;
}
}
for (int i = 0; i < 16; i++)
{
int fill = i << 6;
for (int j = 0; j < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table4_3)
{
int op = fill+table4_3[j].opcode;
Interpreter::m_opTable4[op] = table4_3[j].Inst;
m_infoTable4[op] = &table4_3[j].opinfo;
int op = fill+tpl.opcode;
Interpreter::m_opTable4[op] = tpl.Inst;
m_infoTable4[op] = &tpl.opinfo;
}
}
for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table4)
{
int op = table4[i].opcode;
Interpreter::m_opTable4[op] = table4[i].Inst;
m_infoTable4[op] = &table4[i].opinfo;
int op = tpl.opcode;
Interpreter::m_opTable4[op] = tpl.Inst;
m_infoTable4[op] = &tpl.opinfo;
}
for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table31)
{
int op = table31[i].opcode;
Interpreter::m_opTable31[op] = table31[i].Inst;
m_infoTable31[op] = &table31[i].opinfo;
int op = tpl.opcode;
Interpreter::m_opTable31[op] = tpl.Inst;
m_infoTable31[op] = &tpl.opinfo;
}
for (int i = 0; i < 1; i++)
{
int fill = i << 9;
for (int j = 0; j < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table31_2)
{
int op = fill + table31_2[j].opcode;
Interpreter::m_opTable31[op] = table31_2[j].Inst;
m_infoTable31[op] = &table31_2[j].opinfo;
int op = fill + tpl.opcode;
Interpreter::m_opTable31[op] = tpl.Inst;
m_infoTable31[op] = &tpl.opinfo;
}
}
for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table19)
{
int op = table19[i].opcode;
Interpreter::m_opTable19[op] = table19[i].Inst;
m_infoTable19[op] = &table19[i].opinfo;
int op = tpl.opcode;
Interpreter::m_opTable19[op] = tpl.Inst;
m_infoTable19[op] = &tpl.opinfo;
}
for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table59)
{
int op = table59[i].opcode;
Interpreter::m_opTable59[op] = table59[i].Inst;
m_infoTable59[op] = &table59[i].opinfo;
int op = tpl.opcode;
Interpreter::m_opTable59[op] = tpl.Inst;
m_infoTable59[op] = &tpl.opinfo;
}
for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table63)
{
int op = table63[i].opcode;
Interpreter::m_opTable63[op] = table63[i].Inst;
m_infoTable63[op] = &table63[i].opinfo;
int op = tpl.opcode;
Interpreter::m_opTable63[op] = tpl.Inst;
m_infoTable63[op] = &tpl.opinfo;
}
for (int i = 0; i < 32; i++)
{
int fill = i << 5;
for (int j = 0; j < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table63_2)
{
int op = fill + table63_2[j].opcode;
Interpreter::m_opTable63[op] = table63_2[j].Inst;
m_infoTable63[op] = &table63_2[j].opinfo;
int op = fill + tpl.opcode;
Interpreter::m_opTable63[op] = tpl.Inst;
m_infoTable63[op] = &tpl.opinfo;
}
}
m_numInstructions = 0;
for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &primarytable[i].opinfo;
for (int i = 0; i < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table4_2[i].opinfo;
for (int i = 0; i < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table4_3[i].opinfo;
for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table4[i].opinfo;
for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table31[i].opinfo;
for (int i = 0; i < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table31_2[i].opinfo;
for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table19[i].opinfo;
for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table59[i].opinfo;
for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table63[i].opinfo;
for (int i = 0; i < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table63_2[i].opinfo;
for (auto& tpl : primarytable)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table4_2)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table4_3)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table4)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table31)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table31_2)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table19)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table59)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table63)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
for (auto& tpl : table63_2)
m_allInstructions[m_numInstructions++] = &tpl.opinfo;
if (m_numInstructions >= 512) {
PanicAlert("m_allInstructions underdimensioned");
}

View File

@ -394,9 +394,9 @@ void InitTables()
return;
//clear
for (int i = 0; i < 32; i++)
for (auto& tpl : dynaOpTable59)
{
dynaOpTable59[i] = &Jit64::unknown_instruction;
tpl = &Jit64::unknown_instruction;
}
for (int i = 0; i < 1024; i++)
@ -407,78 +407,78 @@ void InitTables()
dynaOpTable63[i] = &Jit64::unknown_instruction;
}
for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : primarytable)
{
dynaOpTable[primarytable[i].opcode] = primarytable[i].Inst;
dynaOpTable[tpl.opcode] = tpl.Inst;
}
for (int i = 0; i < 32; i++)
{
int fill = i << 5;
for (int j = 0; j < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table4_2)
{
int op = fill+table4_2[j].opcode;
dynaOpTable4[op] = table4_2[j].Inst;
int op = fill+tpl.opcode;
dynaOpTable4[op] = tpl.Inst;
}
}
for (int i = 0; i < 16; i++)
{
int fill = i << 6;
for (int j = 0; j < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table4_3)
{
int op = fill+table4_3[j].opcode;
dynaOpTable4[op] = table4_3[j].Inst;
int op = fill+tpl.opcode;
dynaOpTable4[op] = tpl.Inst;
}
}
for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table4)
{
int op = table4[i].opcode;
dynaOpTable4[op] = table4[i].Inst;
int op = tpl.opcode;
dynaOpTable4[op] = tpl.Inst;
}
for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table31)
{
int op = table31[i].opcode;
dynaOpTable31[op] = table31[i].Inst;
int op = tpl.opcode;
dynaOpTable31[op] = tpl.Inst;
}
for (int i = 0; i < 1; i++)
{
int fill = i << 9;
for (int j = 0; j < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table31_2)
{
int op = fill + table31_2[j].opcode;
dynaOpTable31[op] = table31_2[j].Inst;
int op = fill + tpl.opcode;
dynaOpTable31[op] = tpl.Inst;
}
}
for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table19)
{
int op = table19[i].opcode;
dynaOpTable19[op] = table19[i].Inst;
int op = tpl.opcode;
dynaOpTable19[op] = tpl.Inst;
}
for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table59)
{
int op = table59[i].opcode;
dynaOpTable59[op] = table59[i].Inst;
int op = tpl.opcode;
dynaOpTable59[op] = tpl.Inst;
}
for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table63)
{
int op = table63[i].opcode;
dynaOpTable63[op] = table63[i].Inst;
int op = tpl.opcode;
dynaOpTable63[op] = tpl.Inst;
}
for (int i = 0; i < 32; i++)
{
int fill = i << 5;
for (int j = 0; j < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table63_2)
{
int op = fill + table63_2[j].opcode;
dynaOpTable63[op] = table63_2[j].Inst;
int op = fill + tpl.opcode;
dynaOpTable63[op] = tpl.Inst;
}
}

View File

@ -75,14 +75,14 @@ void RegCache::LockX(int x1, int x2, int x3, int x4)
void RegCache::UnlockAll()
{
for (int i = 0; i < 32; i++)
locks[i] = false;
for (auto& lock : locks)
lock = false;
}
void RegCache::UnlockAllX()
{
for (int i = 0; i < NUMXREGS; i++)
xlocks[i] = false;
for (auto& xlock : xlocks)
xlock = false;
}
X64Reg RegCache::GetFreeXReg()

View File

@ -163,9 +163,9 @@ static const int FRegAllocSize = sizeof(FRegAllocOrder) / sizeof(X64Reg);
#endif
static X64Reg regFindFreeReg(RegInfo& RI) {
for (int i = 0; i < RegAllocSize; i++)
if (RI.regs[RegAllocOrder[i]] == 0)
return RegAllocOrder[i];
for (auto& reg : RegAllocOrder)
if (RI.regs[reg] == 0)
return reg;
int bestIndex = -1;
InstLoc bestEnd = 0;
@ -184,9 +184,9 @@ static X64Reg regFindFreeReg(RegInfo& RI) {
}
static X64Reg fregFindFreeReg(RegInfo& RI) {
for (int i = 0; i < FRegAllocSize; i++)
if (RI.fregs[FRegAllocOrder[i]] == 0)
return FRegAllocOrder[i];
for (auto& reg : FRegAllocOrder)
if (RI.fregs[reg] == 0)
return reg;
int bestIndex = -1;
InstLoc bestEnd = 0;
@ -205,9 +205,9 @@ static X64Reg fregFindFreeReg(RegInfo& RI) {
}
static OpArg regLocForInst(RegInfo& RI, InstLoc I) {
for (int i = 0; i < RegAllocSize; i++)
if (RI.regs[RegAllocOrder[i]] == I)
return R(RegAllocOrder[i]);
for (auto& reg : RegAllocOrder)
if (RI.regs[reg] == I)
return R(reg);
if (regGetSpill(RI, I) == 0)
PanicAlert("Retrieving unknown spill slot?!");
@ -215,9 +215,9 @@ static OpArg regLocForInst(RegInfo& RI, InstLoc I) {
}
static OpArg fregLocForInst(RegInfo& RI, InstLoc I) {
for (int i = 0; i < FRegAllocSize; i++)
if (RI.fregs[FRegAllocOrder[i]] == I)
return R(FRegAllocOrder[i]);
for (auto& reg : FRegAllocOrder)
if (RI.fregs[reg] == I)
return R(reg);
if (fregGetSpill(RI, I) == 0)
PanicAlert("Retrieving unknown spill slot?!");
@ -225,15 +225,15 @@ static OpArg fregLocForInst(RegInfo& RI, InstLoc I) {
}
static void regClearInst(RegInfo& RI, InstLoc I) {
for (int i = 0; i < RegAllocSize; i++)
if (RI.regs[RegAllocOrder[i]] == I)
RI.regs[RegAllocOrder[i]] = 0;
for (auto& reg : RegAllocOrder)
if (RI.regs[reg] == I)
RI.regs[reg] = 0;
}
static void fregClearInst(RegInfo& RI, InstLoc I) {
for (int i = 0; i < FRegAllocSize; i++)
if (RI.fregs[FRegAllocOrder[i]] == I)
RI.fregs[FRegAllocOrder[i]] = 0;
for (auto& reg : FRegAllocOrder)
if (RI.fregs[reg] == I)
RI.fregs[reg] = 0;
}
static X64Reg regEnsureInReg(RegInfo& RI, InstLoc I) {

View File

@ -211,11 +211,11 @@ namespace JitILProfiler
File::IOFile file(buffer, "w");
setvbuf(file.GetHandle(), NULL, _IOFBF, 1024 * 1024);
fprintf(file.GetHandle(), "code hash,total elapsed,number of calls,elapsed per call\n");
for (std::vector<Block>::iterator it = blocks.begin(), itEnd = blocks.end(); it != itEnd; ++it)
for (auto& block : blocks)
{
const u64 codeHash = it->codeHash;
const u64 totalElapsed = it->totalElapsed;
const u64 numberOfCalls = it->numberOfCalls;
const u64 codeHash = block.codeHash;
const u64 totalElapsed = block.totalElapsed;
const u64 numberOfCalls = block.numberOfCalls;
const double elapsedPerCall = totalElapsed / (double)numberOfCalls;
fprintf(file.GetHandle(), "%016llx,%lld,%lld,%f\n", codeHash, totalElapsed, numberOfCalls, elapsedPerCall);
}

View File

@ -397,9 +397,9 @@ void InitTables()
return;
//clear
for (int i = 0; i < 32; i++)
for (auto& tpl : dynaOpTable59)
{
dynaOpTable59[i] = &JitIL::unknown_instruction;
tpl = &JitIL::unknown_instruction;
}
for (int i = 0; i < 1024; i++)
@ -410,78 +410,78 @@ void InitTables()
dynaOpTable63[i] = &JitIL::unknown_instruction;
}
for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : primarytable)
{
dynaOpTable[primarytable[i].opcode] = primarytable[i].Inst;
dynaOpTable[tpl.opcode] = tpl.Inst;
}
for (int i = 0; i < 32; i++)
{
int fill = i << 5;
for (int j = 0; j < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table4_2)
{
int op = fill+table4_2[j].opcode;
dynaOpTable4[op] = table4_2[j].Inst;
int op = fill+tpl.opcode;
dynaOpTable4[op] = tpl.Inst;
}
}
for (int i = 0; i < 16; i++)
{
int fill = i << 6;
for (int j = 0; j < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table4_3)
{
int op = fill+table4_3[j].opcode;
dynaOpTable4[op] = table4_3[j].Inst;
int op = fill+tpl.opcode;
dynaOpTable4[op] = tpl.Inst;
}
}
for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table4)
{
int op = table4[i].opcode;
dynaOpTable4[op] = table4[i].Inst;
int op = tpl.opcode;
dynaOpTable4[op] = tpl.Inst;
}
for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table31)
{
int op = table31[i].opcode;
dynaOpTable31[op] = table31[i].Inst;
int op = tpl.opcode;
dynaOpTable31[op] = tpl.Inst;
}
for (int i = 0; i < 1; i++)
{
int fill = i << 9;
for (int j = 0; j < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table31_2)
{
int op = fill + table31_2[j].opcode;
dynaOpTable31[op] = table31_2[j].Inst;
int op = fill + tpl.opcode;
dynaOpTable31[op] = tpl.Inst;
}
}
for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table19)
{
int op = table19[i].opcode;
dynaOpTable19[op] = table19[i].Inst;
int op = tpl.opcode;
dynaOpTable19[op] = tpl.Inst;
}
for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table59)
{
int op = table59[i].opcode;
dynaOpTable59[op] = table59[i].Inst;
int op = tpl.opcode;
dynaOpTable59[op] = tpl.Inst;
}
for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++)
for (auto& tpl : table63)
{
int op = table63[i].opcode;
dynaOpTable63[op] = table63[i].Inst;
int op = tpl.opcode;
dynaOpTable63[op] = tpl.Inst;
}
for (int i = 0; i < 32; i++)
{
int fill = i << 5;
for (int j = 0; j < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); j++)
for (auto& tpl : table63_2)
{
int op = fill + table63_2[j].opcode;
dynaOpTable63[op] = table63_2[j].Inst;
int op = fill + tpl.opcode;
dynaOpTable63[op] = tpl.Inst;
}
}

View File

@ -1124,14 +1124,14 @@ unsigned IRBuilder::getNumberOfOperands(InstLoc I) const {
static unsigned ZeroOp[] = {LoadCR, LoadLink, LoadMSR, LoadGReg, LoadCTR, InterpreterBranch, LoadCarry, RFIExit, LoadFReg, LoadFRegDENToZero, LoadGQR, Int3, };
static unsigned UOp[] = {StoreLink, BranchUncond, StoreCR, StoreMSR, StoreFPRF, StoreGReg, StoreCTR, Load8, Load16, Load32, SExt16, SExt8, Cntlzw, Not, StoreCarry, SystemCall, ShortIdleLoop, LoadSingle, LoadDouble, LoadPaired, StoreFReg, DupSingleToMReg, DupSingleToPacked, ExpandPackedToMReg, CompactMRegToPacked, FSNeg, FSRSqrt, FDNeg, FPDup0, FPDup1, FPNeg, DoubleToSingle, StoreGQR, StoreSRR, };
static unsigned BiOp[] = {BranchCond, IdleBranch, And, Xor, Sub, Or, Add, Mul, Rol, Shl, Shrl, Sarl, ICmpEq, ICmpNe, ICmpUgt, ICmpUlt, ICmpSgt, ICmpSlt, ICmpSge, ICmpSle, Store8, Store16, Store32, ICmpCRSigned, ICmpCRUnsigned, InterpreterFallback, StoreSingle, StoreDouble, StorePaired, InsertDoubleInMReg, FSMul, FSAdd, FSSub, FDMul, FDAdd, FDSub, FPAdd, FPMul, FPSub, FPMerge00, FPMerge01, FPMerge10, FPMerge11, FDCmpCR, };
for (size_t i = 0; i < sizeof(ZeroOp) / sizeof(ZeroOp[0]); ++i) {
numberOfOperands[ZeroOp[i]] = 0;
for (auto& op : ZeroOp) {
numberOfOperands[op] = 0;
}
for (size_t i = 0; i < sizeof(UOp) / sizeof(UOp[0]); ++i) {
numberOfOperands[UOp[i]] = 1;
for (auto& op : UOp) {
numberOfOperands[op] = 1;
}
for (size_t i = 0; i < sizeof(BiOp) / sizeof(BiOp[0]); ++i) {
numberOfOperands[BiOp[i]] = 2;
for (auto& op : BiOp) {
numberOfOperands[op] = 2;
}
}

View File

@ -162,22 +162,22 @@ namespace JitInterface
return;
}
fprintf(f.GetHandle(), "origAddr\tblkName\tcost\ttimeCost\tpercent\ttimePercent\tOvAllinBlkTime(ms)\tblkCodeSize\n");
for (unsigned int i = 0; i < stats.size(); i++)
for (auto& stat : stats)
{
const JitBlock *block = jit->GetBlockCache()->GetBlock(stats[i].blockNum);
const JitBlock *block = jit->GetBlockCache()->GetBlock(stat.blockNum);
if (block)
{
std::string name = g_symbolDB.GetDescription(block->originalAddress);
double percent = 100.0 * (double)stats[i].cost / (double)cost_sum;
double percent = 100.0 * (double)stat.cost / (double)cost_sum;
#ifdef _WIN32
double timePercent = 100.0 * (double)block->ticCounter / (double)timecost_sum;
fprintf(f.GetHandle(), "%08x\t%s\t%llu\t%llu\t%.2lf\t%llf\t%lf\t%i\n",
block->originalAddress, name.c_str(), stats[i].cost,
block->originalAddress, name.c_str(), stat.cost,
block->ticCounter, percent, timePercent,
(double)block->ticCounter*1000.0/(double)countsPerSec, block->codeSize);
#else
fprintf(f.GetHandle(), "%08x\t%s\t%llu\t???\t%.2lf\t???\t???\t%i\n",
block->originalAddress, name.c_str(), stats[i].cost, percent, block->codeSize);
block->originalAddress, name.c_str(), stat.cost, percent, block->codeSize);
#endif
}
}

View File

@ -196,9 +196,8 @@ void AnalyzeFunction2(Symbol *func)
u32 flags = func->flags;
bool nonleafcall = false;
for (size_t i = 0; i < func->calls.size(); i++)
for (auto c : func->calls)
{
SCall c = func->calls[i];
Symbol *called_func = g_symbolDB.GetSymbolFromAddr(c.function);
if (called_func && (called_func->flags & FFLAG_LEAF) == 0)
{
@ -345,10 +344,9 @@ u32 Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa,
if (it != inserted_asm_codes.end())
{
const std::vector<u32>& codes = it->second;
for (std::vector<u32>::const_iterator itCur = codes.begin(),
itEnd = codes.end(); itCur != itEnd; ++itCur)
for (u32 c : codes)
{
cst1_instructions.push(*itCur);
cst1_instructions.push(c);
}
inst = UGeckoInstruction(cst1_instructions.front());
cst1_instructions.pop();
@ -648,9 +646,8 @@ void FindFunctionsAfterBLR(PPCSymbolDB *func_db)
for (PPCSymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); ++iter)
funcAddrs.push_back(iter->second.address + iter->second.size);
for (vector<u32>::iterator iter = funcAddrs.begin(); iter != funcAddrs.end(); ++iter)
for (auto location : funcAddrs)
{
u32 location = *iter;
while (true)
{
if (PPCTables::IsValidInstruction(Memory::Read_Instruction(location)))

View File

@ -94,10 +94,10 @@ Symbol *PPCSymbolDB::GetSymbolFromAddr(u32 addr)
}
else
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter)
for (auto& p : functions)
{
if (addr >= iter->second.address && addr < iter->second.address + iter->second.size)
return &iter->second;
if (addr >= p.second.address && addr < p.second.address + p.second.size)
return &p.second;
}
}
return 0;
@ -114,18 +114,18 @@ const char *PPCSymbolDB::GetDescription(u32 addr)
void PPCSymbolDB::FillInCallers()
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter)
for (auto& p : functions)
{
iter->second.callers.clear();
p.second.callers.clear();
}
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter)
{
Symbol &f = iter->second;
for (size_t i = 0; i < f.calls.size(); i++)
for (auto& call : f.calls)
{
SCall NewCall(iter->first, f.calls[i].callAddress);
u32 FunctionAddress = f.calls[i].function;
SCall NewCall(iter->first, call.callAddress);
u32 FunctionAddress = call.function;
XFuncMap::iterator FuncIterator = functions.find(FunctionAddress);
if (FuncIterator != functions.end())

View File

@ -230,9 +230,9 @@ void LogCompiledInstructions()
#ifdef OPLOG
f.Open(StringFromFormat("%s" OP_TO_LOG "_at.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time), "w");
for (size_t i = 0; i < rsplocations.size(); i++)
for (auto& rsplocation : rsplocations)
{
fprintf(f.GetHandle(), OP_TO_LOG ": %08x\n", rsplocations[i]);
fprintf(f.GetHandle(), OP_TO_LOG ": %08x\n", rsplocation);
}
#endif

View File

@ -160,9 +160,9 @@ int GetEmptySlot(std::map<double, int> m)
for (int i = 1; i <= (int)NUM_STATES; i++)
{
bool found = false;
for (std::map<double, int>::iterator it = m.begin(); it != m.end(); it++)
for (auto& p : m)
{
if (it->second == i)
if (p.second == i)
{
found = true;
break;

View File

@ -234,10 +234,9 @@ bool ParseDisc()
PartitionGroup[x].PartitionsVec.push_back(Partition);
}
for (size_t i = 0; i < PartitionGroup[x].PartitionsVec.size(); i++)
for (auto& rPartition : PartitionGroup[x].PartitionsVec)
{
SPartition& rPartition = PartitionGroup[x].PartitionsVec.at(i);
const SPartitionHeader& rHeader = PartitionGroup[x].PartitionsVec.at(i).Header;
const SPartitionHeader& rHeader = rPartition.Header;
MarkAsUsed(rPartition.Offset, 0x2c0);

View File

@ -232,11 +232,11 @@ CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, cons
const SFileInfo*
CARCFile::FindFileInfo(std::string _rFullPath) const
{
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
for (auto& fileInfo : m_FileInfoVector)
{
if (!strcasecmp(m_FileInfoVector[i].m_FullPath, _rFullPath.c_str()))
if (!strcasecmp(fileInfo.m_FullPath, _rFullPath.c_str()))
{
return(&m_FileInfoVector[i]);
return(&fileInfo);
}
}

View File

@ -46,12 +46,12 @@ const char* CFileSystemGCWii::GetFileName(u64 _Address)
if (!m_Initialized)
InitFileSystem();
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
for (auto& fileInfo : m_FileInfoVector)
{
if ((m_FileInfoVector[i].m_Offset <= _Address) &&
((m_FileInfoVector[i].m_Offset + m_FileInfoVector[i].m_FileSize) > _Address))
if ((fileInfo.m_Offset <= _Address) &&
((fileInfo.m_Offset + fileInfo.m_FileSize) > _Address))
{
return m_FileInfoVector[i].m_FullPath;
return fileInfo.m_FullPath;
}
}
@ -222,8 +222,8 @@ size_t CFileSystemGCWii::GetFileList(std::vector<const SFileInfo *> &_rFilenames
PanicAlert("GetFileList : input list has contents?");
_rFilenames.clear();
_rFilenames.reserve(m_FileInfoVector.size());
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
_rFilenames.push_back(&m_FileInfoVector[i]);
for (auto& fileInfo : m_FileInfoVector)
_rFilenames.push_back(&fileInfo);
return m_FileInfoVector.size();
}
@ -232,10 +232,10 @@ const SFileInfo* CFileSystemGCWii::FindFileInfo(const char* _rFullPath)
if (!m_Initialized)
InitFileSystem();
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
for (auto& fileInfo : m_FileInfoVector)
{
if (!strcasecmp(m_FileInfoVector[i].m_FullPath, _rFullPath))
return &m_FileInfoVector[i];
if (!strcasecmp(fileInfo.m_FullPath, _rFullPath))
return &fileInfo;
}
return NULL;

View File

@ -44,14 +44,14 @@ CSharedContent::~CSharedContent()
std::string CSharedContent::GetFilenameFromSHA1(const u8* _pHash)
{
for (size_t i=0; i<m_Elements.size(); i++)
for (auto& Element : m_Elements)
{
if (memcmp(_pHash, m_Elements[i].SHA1Hash, 20) == 0)
if (memcmp(_pHash, Element.SHA1Hash, 20) == 0)
{
char szFilename[1024];
sprintf(szFilename, "%sshared1/%c%c%c%c%c%c%c%c.app", File::GetUserPath(D_WIIUSER_IDX).c_str(),
m_Elements[i].FileName[0], m_Elements[i].FileName[1], m_Elements[i].FileName[2], m_Elements[i].FileName[3],
m_Elements[i].FileName[4], m_Elements[i].FileName[5], m_Elements[i].FileName[6], m_Elements[i].FileName[7]);
Element.FileName[0], Element.FileName[1], Element.FileName[2], Element.FileName[3],
Element.FileName[4], Element.FileName[5], Element.FileName[6], Element.FileName[7]);
return szFilename;
}
}
@ -154,9 +154,9 @@ CNANDContentLoader::CNANDContentLoader(const std::string& _rName)
CNANDContentLoader::~CNANDContentLoader()
{
for (size_t i=0; i<m_Content.size(); i++)
for (auto& content : m_Content)
{
delete [] m_Content[i].m_pData;
delete [] content.m_pData;
}
m_Content.clear();
if (m_TIK)
@ -168,12 +168,11 @@ CNANDContentLoader::~CNANDContentLoader()
const SNANDContent* CNANDContentLoader::GetContentByIndex(int _Index) const
{
for (size_t i=0; i<m_Content.size(); i++)
for (auto& Content : m_Content)
{
const SNANDContent* pContent = &m_Content[i];
if (pContent->m_Index == _Index)
if (Content.m_Index == _Index)
{
return pContent;
return &Content;
}
}
return NULL;
@ -413,11 +412,11 @@ cUIDsys::~cUIDsys()
u32 cUIDsys::GetUIDFromTitle(u64 _Title)
{
for (size_t i=0; i<m_Elements.size(); i++)
for (auto& Element : m_Elements)
{
if (Common::swap64(_Title) == *(u64*)&(m_Elements[i].titleID))
if (Common::swap64(_Title) == *(u64*)&(Element.titleID))
{
return Common::swap32(m_Elements[i].UID);
return Common::swap32(Element.UID);
}
}
return 0;
@ -445,11 +444,11 @@ void cUIDsys::AddTitle(u64 _TitleID)
void cUIDsys::GetTitleIDs(std::vector<u64>& _TitleIDs, bool _owned)
{
for (size_t i = 0; i < m_Elements.size(); i++)
for (auto& Element : m_Elements)
{
if ((_owned && Common::CheckTitleTIK(Common::swap64(m_Elements[i].titleID))) ||
(!_owned && Common::CheckTitleTMD(Common::swap64(m_Elements[i].titleID))))
_TitleIDs.push_back(Common::swap64(m_Elements[i].titleID));
if ((_owned && Common::CheckTitleTIK(Common::swap64(Element.titleID))) ||
(!_owned && Common::CheckTitleTMD(Common::swap64(Element.titleID))))
_TitleIDs.push_back(Common::swap64(Element.titleID));
}
}

View File

@ -363,9 +363,9 @@ void CVolumeDirectory::BuildFST()
// write root entry
WriteEntryData(fstOffset, DIRECTORY_ENTRY, 0, 0, totalEntries);
for(std::vector<File::FSTEntry>::iterator iter = rootEntry.children.begin(); iter != rootEntry.children.end(); ++iter)
for(auto& entry : rootEntry.children)
{
WriteEntry(*iter, fstOffset, nameOffset, curDataAddress, rootOffset);
WriteEntry(entry, fstOffset, nameOffset, curDataAddress, rootOffset);
}
// overflow check
@ -459,9 +459,9 @@ void CVolumeDirectory::WriteEntry(const File::FSTEntry& entry, u32& fstOffset, u
WriteEntryData(fstOffset, DIRECTORY_ENTRY, nameOffset, parentEntryNum, (u32)(myEntryNum + entry.size + 1));
WriteEntryName(nameOffset, entry.virtualName);
for(std::vector<File::FSTEntry>::const_iterator iter = entry.children.begin(); iter != entry.children.end(); ++iter)
for(const auto& child : entry.children)
{
WriteEntry(*iter, fstOffset, nameOffset, dataOffset, myEntryNum);
WriteEntry(child, fstOffset, nameOffset, dataOffset, myEntryNum);
}
}
else

View File

@ -158,8 +158,8 @@ void CARCodeAddEdit::UpdateTextCtrl(ActionReplay::ARCode arCode)
if (arCode.name != "")
{
for (u32 i = 0; i < arCode.ops.size(); i++)
EditCheatCode->AppendText(wxString::Format(wxT("%08X %08X\n"), arCode.ops.at(i).cmd_addr, arCode.ops.at(i).value));
for (auto& op : arCode.ops)
EditCheatCode->AppendText(wxString::Format(wxT("%08X %08X\n"), op.cmd_addr, op.value));
}
else
{

View File

@ -185,9 +185,9 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
CreateGUIControls();
// Update selected ISO paths
for(u32 i = 0; i < SConfig::GetInstance().m_ISOFolder.size(); i++)
for(auto& folder : SConfig::GetInstance().m_ISOFolder)
{
ISOPaths->Append(StrToWxStr(SConfig::GetInstance().m_ISOFolder[i]));
ISOPaths->Append(StrToWxStr(folder));
}
}
@ -251,8 +251,8 @@ void CConfigMain::InitializeGUILists()
arrayStringFor_Framelimit.Add(wxString::Format(wxT("%i"), i));
// Emulator Engine
for (unsigned int a = 0; a < (sizeof(CPUCores) / sizeof(CPUCore)); ++a)
arrayStringFor_CPUEngine.Add(wxGetTranslation(CPUCores[a].name));
for (auto& CPUCores_a : CPUCores)
arrayStringFor_CPUEngine.Add(wxGetTranslation(CPUCores_a.name));
// DSP Engine
arrayStringFor_DSPEngine.Add(_("DSP HLE emulation (fast)"));

View File

@ -32,9 +32,8 @@ void CBreakPointView::Update()
char szBuffer[64];
const BreakPoints::TBreakPoints& rBreakPoints = PowerPC::breakpoints.GetBreakPoints();
for (size_t i = 0; i < rBreakPoints.size(); i++)
for (const auto& rBP : rBreakPoints)
{
const TBreakPoint& rBP = rBreakPoints[i];
if (!rBP.bTemporary)
{
wxString temp;
@ -59,10 +58,8 @@ void CBreakPointView::Update()
}
const MemChecks::TMemChecks& rMemChecks = PowerPC::memchecks.GetMemChecks();
for (size_t i = 0; i < rMemChecks.size(); i++)
for (const auto& rMemCheck : rMemChecks)
{
const TMemCheck& rMemCheck = rMemChecks[i];
wxString temp;
temp = StrToWxStr((rMemCheck.Break || rMemCheck.Log) ? "on" : " ");
int Item = InsertItem(0, temp);

View File

@ -296,9 +296,9 @@ void CCodeWindow::UpdateLists()
if (!symbol)
return;
for (int i = 0; i < (int)symbol->callers.size(); i++)
for (auto& call : symbol->callers)
{
u32 caller_addr = symbol->callers[i].callAddress;
u32 caller_addr = call.callAddress;
Symbol *caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr);
if (caller_symbol)
{
@ -309,9 +309,9 @@ void CCodeWindow::UpdateLists()
}
calls->Clear();
for (int i = 0; i < (int)symbol->calls.size(); i++)
for (auto& call : symbol->calls)
{
u32 call_addr = symbol->calls[i].function;
u32 call_addr = call.function;
Symbol *call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr);
if (call_symbol)
{
@ -332,10 +332,10 @@ void CCodeWindow::UpdateCallstack()
bool ret = Dolphin_Debugger::GetCallstack(stack);
for (size_t i = 0; i < stack.size(); i++)
for (auto& frame : stack)
{
int idx = callstack->Append(StrToWxStr(stack[i].Name));
callstack->SetClientData(idx, (void*)(u64)stack[i].vAddress);
int idx = callstack->Append(StrToWxStr(frame.Name));
callstack->SetClientData(idx, (void*)(u64)frame.vAddress);
}
if (!ret)
@ -552,8 +552,8 @@ void CCodeWindow::InitBitmaps()
m_Bitmaps[Toolbar_SetPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
// scale to 24x24 for toolbar
for (size_t n = 0; n < ToolbarDebugBitmapMax; n++)
m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(24, 24));
for (auto& bitmap : m_Bitmaps)
bitmap = wxBitmap(bitmap.ConvertToImage().Scale(24, 24));
}
void CCodeWindow::PopulateToolbar(wxAuiToolBar* toolBar)

View File

@ -294,9 +294,9 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
(mem_data&0xff0000)>>16,
(mem_data&0xff00)>>8,
mem_data&0xff};
for (size_t i = 0; i < 4; i++)
if (a[i] == '\0')
a[i] = ' ';
for (auto& word : a)
if (word == '\0')
word = ' ';
sprintf(dis, "%c%c%c%c", a[0], a[1], a[2], a[3]);
}
else if (viewAsType == VIEWAS_HEX)
@ -314,31 +314,31 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
debugger->readExtraMemory(memory, address+28)
};
for (int i = 0; i < 8; i++)
for (auto& word : mema)
{
char buf[32] = "";
switch (dataType)
{
case 0:
sprintf(buf, " %02X %02X %02X %02X",
((mema[i]&0xff000000)>>24)&0xFF,
((mema[i]&0xff0000)>>16)&0xFF,
((mema[i]&0xff00)>>8)&0xFF,
mema[i]&0xff);
((word&0xff000000)>>24)&0xFF,
((word&0xff0000)>>16)&0xFF,
((word&0xff00)>>8)&0xFF,
word&0xff);
break;
case 1:
sprintf(buf, " %02X%02X %02X%02X",
((mema[i]&0xff000000)>>24)&0xFF,
((mema[i]&0xff0000)>>16)&0xFF,
((mema[i]&0xff00)>>8)&0xFF,
mema[i]&0xff);
((word&0xff000000)>>24)&0xFF,
((word&0xff0000)>>16)&0xFF,
((word&0xff00)>>8)&0xFF,
word&0xff);
break;
case 2:
sprintf(buf, " %02X%02X%02X%02X",
((mema[i]&0xff000000)>>24)&0xFF,
((mema[i]&0xff0000)>>16)&0xFF,
((mema[i]&0xff00)>>8)&0xFF,
mema[i]&0xff);
((word&0xff000000)>>24)&0xFF,
((word&0xff0000)>>16)&0xFF,
((word&0xff00)>>8)&0xFF,
word&0xff);
break;
}
strcat(dis, buf);

View File

@ -917,8 +917,8 @@ wxString FifoPlayerDlg::CreateRecordingMemSizeLabel() const
for (int frameNum = 0; frameNum < file->GetFrameCount(); ++frameNum)
{
const vector<MemoryUpdate>& memUpdates = file->GetFrame(frameNum).memoryUpdates;
for (unsigned int i = 0; i < memUpdates.size(); ++i)
memBytes += memUpdates[i].size;
for (auto& memUpdate : memUpdates)
memBytes += memUpdate.size;
}
return CreateIntegerLabel(memBytes, _("Memory Byte"));

View File

@ -905,12 +905,12 @@ void CFrame::LoadIniPerspectives()
ini.Get("Perspectives", "Active", &ActivePerspective, 0);
SplitString(_Perspectives, ',', VPerspectives);
for (u32 i = 0; i < VPerspectives.size(); i++)
for (auto& VPerspective : VPerspectives)
{
SPerspectives Tmp;
std::string _Section, _Perspective, _Width, _Height;
std::string _Section, _Perspective, _Widths, _Heights;
std::vector<std::string> _SWidth, _SHeight;
Tmp.Name = VPerspectives[i];
Tmp.Name = VPerspective;
// Don't save a blank perspective
if (Tmp.Name.empty())
@ -922,22 +922,22 @@ void CFrame::LoadIniPerspectives()
"name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|"
"name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|"
"dock_size(5,0,0)=22|dock_size(4,0,0)=333|");
ini.Get(_Section.c_str(), "Width", &_Width, "70,25");
ini.Get(_Section.c_str(), "Height", &_Height, "80,80");
ini.Get(_Section.c_str(), "Width", &_Widths, "70,25");
ini.Get(_Section.c_str(), "Height", &_Heights, "80,80");
Tmp.Perspective = StrToWxStr(_Perspective);
SplitString(_Width, ',', _SWidth);
SplitString(_Height, ',', _SHeight);
for (u32 j = 0; j < _SWidth.size(); j++)
SplitString(_Widths, ',', _SWidth);
SplitString(_Heights, ',', _SHeight);
for (auto& Width : _SWidth)
{
int _Tmp;
if (TryParse(_SWidth[j].c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp);
if (TryParse(Width.c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp);
}
for (u32 j = 0; j < _SHeight.size(); j++)
for (auto& Height : _SHeight)
{
int _Tmp;
if (TryParse(_SHeight[j].c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp);
if (TryParse(Height.c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp);
}
Perspectives.push_back(Tmp);
}
@ -983,25 +983,25 @@ void CFrame::SaveIniPerspectives()
// Save perspective names
std::string STmp = "";
for (u32 i = 0; i < Perspectives.size(); i++)
for (auto& Perspective : Perspectives)
{
STmp += Perspectives[i].Name + ",";
STmp += Perspective.Name + ",";
}
STmp = STmp.substr(0, STmp.length()-1);
ini.Set("Perspectives", "Perspectives", STmp.c_str());
ini.Set("Perspectives", "Active", ActivePerspective);
// Save the perspectives
for (u32 i = 0; i < Perspectives.size(); i++)
for (auto& Perspective : Perspectives)
{
std::string _Section = "P - " + Perspectives[i].Name;
ini.Set(_Section.c_str(), "Perspective", WxStrToStr(Perspectives[i].Perspective));
std::string _Section = "P - " + Perspective.Name;
ini.Set(_Section.c_str(), "Perspective", WxStrToStr(Perspective.Perspective));
std::string SWidth = "", SHeight = "";
for (u32 j = 0; j < Perspectives[i].Width.size(); j++)
for (u32 j = 0; j < Perspective.Width.size(); j++)
{
SWidth += StringFromFormat("%i,", Perspectives[i].Width[j]);
SHeight += StringFromFormat("%i,", Perspectives[i].Height[j]);
SWidth += StringFromFormat("%i,", Perspective.Width[j]);
SHeight += StringFromFormat("%i,", Perspective.Height[j]);
}
// Remove the ending ","
SWidth = SWidth.substr(0, SWidth.length()-1);

View File

@ -1795,9 +1795,9 @@ void CFrame::GameListChanged(wxCommandEvent& event)
CFileSearch FileSearch(Extensions, Directories);
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
for (u32 i = 0; i < rFilenames.size(); i++)
for (auto& rFilename : rFilenames)
{
File::Delete(rFilenames[i]);
File::Delete(rFilename);
}
break;
}

View File

@ -475,15 +475,15 @@ void CGameListCtrl::ScanForISOs()
{
File::FSTEntry FST_Temp;
File::ScanDirectoryTree(Directories[i], FST_Temp);
for (u32 j = 0; j < FST_Temp.children.size(); j++)
for (auto& Entry : FST_Temp.children)
{
if (FST_Temp.children[j].isDirectory)
if (Entry.isDirectory)
{
bool duplicate = false;
for (u32 k = 0; k < Directories.size(); k++)
for (auto& Directory : Directories)
{
if (strcmp(Directories[k].c_str(),
FST_Temp.children[j].physicalName.c_str()) == 0)
if (strcmp(Directory.c_str(),
Entry.physicalName.c_str()) == 0)
{
duplicate = true;
break;
@ -491,7 +491,7 @@ void CGameListCtrl::ScanForISOs()
}
if (!duplicate)
Directories.push_back(
FST_Temp.children[j].physicalName.c_str());
Entry.physicalName.c_str());
}
}
}
@ -539,7 +539,7 @@ void CGameListCtrl::ScanForISOs()
if (dialog.WasCancelled())
break;
std::auto_ptr<GameListItem> iso_file(new GameListItem(rFilenames[i]));
std::unique_ptr<GameListItem> iso_file(new GameListItem(rFilenames[i]));
const GameListItem& ISOFile = *iso_file;
if (ISOFile.IsValid())
@ -603,13 +603,9 @@ void CGameListCtrl::ScanForISOs()
{
const std::vector<std::string> drives = cdio_get_devices();
for (std::vector<std::string>::const_iterator iter = drives.begin(); iter != drives.end(); ++iter)
for (const auto& drive : drives)
{
#ifdef __APPLE__
std::auto_ptr<GameListItem> gli(new GameListItem(*iter));
#else
std::unique_ptr<GameListItem> gli(new GameListItem(*iter));
#endif
std::unique_ptr<GameListItem> gli(new GameListItem(drive));
if (gli->IsValid())
m_ISOFiles.push_back(gli.release());

View File

@ -1223,9 +1223,8 @@ void CISOProperties::PatchList_Load()
PatchEngine::LoadPatchSection("OnFrame", onFrame, GameIniDefault, GameIniLocal);
u32 index = 0;
for (auto it = onFrame.begin(); it != onFrame.end(); ++it)
for (PatchEngine::Patch& p : onFrame)
{
PatchEngine::Patch p = *it;
Patches->Append(StrToWxStr(p.name));
Patches->Check(index, p.active);
if (!p.user_defined)
@ -1239,16 +1238,16 @@ void CISOProperties::PatchList_Save()
std::vector<std::string> lines;
std::vector<std::string> enabledLines;
u32 index = 0;
for (auto onFrame_it = onFrame.begin(); onFrame_it != onFrame.end(); ++onFrame_it)
for (PatchEngine::Patch& p : onFrame)
{
if (Patches->IsChecked(index))
enabledLines.push_back("$" + onFrame_it->name);
enabledLines.push_back("$" + p.name);
// Do not save default patches.
if (DefaultPatches.find(onFrame_it->name) == DefaultPatches.end())
if (DefaultPatches.find(p.name) == DefaultPatches.end())
{
lines.push_back("$" + onFrame_it->name);
for (auto iter2 = onFrame_it->entries.begin(); iter2 != onFrame_it->entries.end(); ++iter2)
lines.push_back("$" + p.name);
for (auto iter2 = p.entries.begin(); iter2 != p.entries.end(); ++iter2)
{
std::string temp = StringFromFormat("0x%08X:%s:0x%08X", iter2->address, PatchEngine::PatchTypeStrings[iter2->type], iter2->value);
lines.push_back(temp);
@ -1330,10 +1329,8 @@ void CISOProperties::ActionReplayList_Save()
std::vector<std::string> lines;
std::vector<std::string> enabledLines;
u32 index = 0;
for (auto iter = arCodes.begin(); iter != arCodes.end(); ++iter)
for (auto code : arCodes)
{
ActionReplay::ARCode code = *iter;
if (Cheats->IsChecked(index))
enabledLines.push_back("$" + code.name);
@ -1341,9 +1338,9 @@ void CISOProperties::ActionReplayList_Save()
if (DefaultCheats.find(code.name) == DefaultCheats.end())
{
lines.push_back("$" + code.name);
for (auto iter2 = code.ops.begin(); iter2 != code.ops.end(); ++iter2)
for (auto& op : code.ops)
{
lines.push_back(WxStrToStr(wxString::Format(wxT("%08X %08X"), iter2->cmd_addr, iter2->value)));
lines.push_back(WxStrToStr(wxString::Format(wxT("%08X %08X"), op.cmd_addr, op.value)));
}
}
++index;

View File

@ -905,14 +905,14 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
size_t col_size = 0;
wxBoxSizer* stacked_groups = NULL;
for (unsigned int i = 0; i < controller->groups.size(); ++i)
for (ControllerEmu::ControlGroup* group : controller->groups)
{
ControlGroupBox* control_group_box = new ControlGroupBox(controller->groups[i], parent, eventsink);
ControlGroupBox* control_group_box = new ControlGroupBox(group, parent, eventsink);
wxStaticBoxSizer *control_group =
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(controller->groups[i]->name)));
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->name)));
control_group->Add(control_group_box);
const size_t grp_size = controller->groups[i]->controls.size() + controller->groups[i]->settings.size();
const size_t grp_size = group->controls.size() + group->settings.size();
col_size += grp_size;
if (col_size > 8 || NULL == stacked_groups)
{

View File

@ -45,12 +45,12 @@ void CWiiSaveCrypted::ExportAllSaves()
std::string folder = StringFromFormat("%s/%08x/", titleFolder.c_str(), pathMask | i);
File::ScanDirectoryTree(folder, FST_Temp);
for (u32 j = 0; j < FST_Temp.children.size(); j++)
for (auto& entry : FST_Temp.children)
{
if (FST_Temp.children[j].isDirectory)
if (entry.isDirectory)
{
u32 gameid;
if (AsciiToHex(FST_Temp.children[j].virtualName.c_str(), gameid))
if (AsciiToHex(entry.virtualName.c_str(), gameid))
{
std::string bannerPath = StringFromFormat("%s%08x/data/banner.bin", folder.c_str(), gameid);
if (File::Exists(bannerPath))
@ -63,9 +63,9 @@ void CWiiSaveCrypted::ExportAllSaves()
}
}
SuccessAlertT("Found %x save files", (unsigned int) titles.size());
for (u32 i = 0; i < titles.size(); ++i)
for (auto& title : titles)
{
CWiiSaveCrypted* exportSave = new CWiiSaveCrypted("", titles[i]);
CWiiSaveCrypted* exportSave = new CWiiSaveCrypted("", title);
delete exportSave;
}
}
@ -581,25 +581,25 @@ void CWiiSaveCrypted::ScanForFiles(std::string savDir, std::vector<std::string>&
File::FSTEntry FST_Temp;
File::ScanDirectoryTree(Directories[i], FST_Temp);
for (u32 j = 0; j < FST_Temp.children.size(); j++)
for (auto& elem : FST_Temp.children)
{
if (strncmp(FST_Temp.children.at(j).virtualName.c_str(), "banner.bin", 10) != 0)
if (strncmp(elem.virtualName.c_str(), "banner.bin", 10) != 0)
{
(*_numFiles)++;
*_sizeFiles += FILE_HDR_SZ;
if (FST_Temp.children.at(j).isDirectory)
if (elem.isDirectory)
{
if ((FST_Temp.children.at(j).virtualName == "nocopy") || FST_Temp.children.at(j).virtualName == "nomove")
if ((elem.virtualName == "nocopy") || elem.virtualName == "nomove")
{
PanicAlert("This save will likely require homebrew tools to copy to a real wii");
}
Directories.push_back(FST_Temp.children.at(j).physicalName);
Directories.push_back(elem.physicalName);
}
else
{
FileList.push_back(FST_Temp.children.at(j).physicalName);
*_sizeFiles += ROUND_UP(FST_Temp.children.at(j).size, BLOCK_SZ);
FileList.push_back(elem.physicalName);
*_sizeFiles += ROUND_UP(elem.size, BLOCK_SZ);
}
}
}

View File

@ -622,8 +622,8 @@ PadMapDiag::PadMapDiag(wxWindow* const parent, PadMapping map[], PadMapping wiim
wxArrayString player_names;
player_names.Add(_("None"));
for (unsigned int i = 0; i < m_player_list.size(); i++)
player_names.Add(m_player_list[i]->name);
for (auto& player : m_player_list)
player_names.Add(player->name);
wxString wiimote_names[5];
wiimote_names[0] = _("None");

View File

@ -221,8 +221,8 @@ void ControllerEmu::SaveConfig(IniFile::Section *sec, const std::string& base)
ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup(_name, GROUP_TYPE_STICK)
{
for (unsigned int i = 0; i < 4; ++i)
controls.push_back(new Input(named_directions[i]));
for (auto& named_direction : named_directions)
controls.push_back(new Input(named_direction));
controls.push_back(new Input(_trans("Modifier")));
@ -290,8 +290,8 @@ ControllerEmu::Cursor::Cursor(const char* const _name)
: ControlGroup(_name, GROUP_TYPE_CURSOR)
, m_z(0)
{
for (unsigned int i = 0; i < 4; ++i)
controls.push_back(new Input(named_directions[i]));
for (auto& named_direction : named_directions)
controls.push_back(new Input(named_direction));
controls.push_back(new Input("Forward"));
controls.push_back(new Input("Backward"));
controls.push_back(new Input(_trans("Hide")));

View File

@ -222,9 +222,9 @@ Keyboard::Key::Key(IOHIDElementRef element, IOHIDDeviceRef device)
};
const uint32_t keycode = IOHIDElementGetUsage(m_element);
for (uint32_t i = 0; i < sizeof named_keys / sizeof *named_keys; i++)
if (named_keys[i].code == keycode) {
m_name = named_keys[i].name;
for (auto & named_key : named_keys)
if (named_key.code == keycode) {
m_name = named_key.name;
return;
}

View File

@ -160,12 +160,12 @@ void UDPWiimote::mainThread()
{
int maxfd=0;
FD_ZERO(&fds);
for (std::list<sock_t>::iterator i=d->sockfds.begin(); i!=d->sockfds.end(); i++)
for (auto& fd : d->sockfds)
{
FD_SET(*i,&fds);
FD_SET(fd,&fds);
#ifndef _WIN32
if (*i>=maxfd)
maxfd=(*i)+1;
if (fd>=maxfd)
maxfd=(fd)+1;
#endif
}
@ -194,11 +194,10 @@ void UDPWiimote::mainThread()
if (rt)
{
for (std::list<sock_t>::iterator i=d->sockfds.begin(); i!=d->sockfds.end(); i++)
for (sock_t fd : d->sockfds)
{
if (FD_ISSET(*i,&fds))
if (FD_ISSET(fd,&fds))
{
sock_t fd=*i;
u8 bf[64];
int size=60;
size_t addr_len;
@ -235,8 +234,8 @@ UDPWiimote::~UDPWiimote()
std::lock_guard<std::mutex> lk(d->termLock);
d->thread.join();
}
for (std::list<sock_t>::iterator i=d->sockfds.begin(); i!=d->sockfds.end(); i++)
close(*i);
for (auto& elem : d->sockfds)
close(elem);
close(d->bipv4_fd);
close(d->bipv6_fd);
cleanup;

View File

@ -112,9 +112,9 @@ void SamplerCache::SetParameters(GLuint sampler_id, const Params& params)
void SamplerCache::Clear()
{
for (auto it = m_cache.begin(); it != m_cache.end(); ++it)
for (auto& p : m_cache)
{
glDeleteSamplers(1, &it->second.sampler_id);
glDeleteSamplers(1, &p.second.sampler_id);
}
m_cache.clear();
}

View File

@ -88,9 +88,9 @@ TextureCache::TCacheEntry::~TCacheEntry()
{
if (texture)
{
for(int i=0; i<8; i++)
if(s_Textures[i] == texture)
s_Textures[i] = 0;
for(auto& gtex : s_Textures)
if(gtex == texture)
gtex = 0;
glDeleteTextures(1, &texture);
texture = 0;
}
@ -449,8 +449,8 @@ TextureCache::TextureCache()
s_ActiveTexture = -1;
s_NextStage = -1;
for(int i=0; i<8; i++)
s_Textures[i] = -1;
for(auto& gtex : s_Textures)
gtex = -1;
}
@ -459,9 +459,9 @@ TextureCache::~TextureCache()
s_ColorMatrixProgram.Destroy();
s_DepthMatrixProgram.Destroy();
for(std::map<u64, VBOCache>::iterator it = s_VBO.begin(); it != s_VBO.end(); it++) {
glDeleteBuffers(1, &it->second.vbo);
glDeleteVertexArrays(1, &it->second.vao);
for(auto& cache : s_VBO) {
glDeleteBuffers(1, &cache.second.vbo);
glDeleteVertexArrays(1, &cache.second.vao);
}
s_VBO.clear();
}

View File

@ -186,8 +186,8 @@ void Shutdown()
s_rgbToYuyvProgram.Destroy();
s_yuyvToRgbProgram.Destroy();
for (unsigned int i = 0; i < NUM_ENCODING_PROGRAMS; i++)
s_encodingPrograms[i].Destroy();
for (auto& program : s_encodingPrograms)
program.Destroy();
s_srcTexture = 0;
s_dstTexture = 0;

View File

@ -110,16 +110,16 @@ void GetShaders(std::vector<std::string> &shaders)
File::GetUserPath(D_SHADERS_IDX),
File::GetSysDirectory() + SHADERS_DIR DIR_SEP,
};
for (size_t i = 0; i < ArraySize(directories); ++i)
for (auto& directory : directories)
{
if (!File::IsDirectory(directories[i]))
if (!File::IsDirectory(directory))
continue;
File::FSTEntry entry;
File::ScanDirectoryTree(directories[i], entry);
for (u32 j = 0; j < entry.children.size(); j++)
File::ScanDirectoryTree(directory, entry);
for (auto& file : entry.children)
{
std::string name = entry.children[j].virtualName.c_str();
std::string name = file.virtualName.c_str();
if (name.size() < 5)
continue;
if (strcasecmp(name.substr(name.size() - 5).c_str(), ".glsl"))

View File

@ -55,8 +55,8 @@ namespace Clipper
void DoState(PointerWrap &p)
{
p.DoArray(m_ViewOffset,2);
for (int i = 0; i< NUM_CLIPPED_VERTICES; ++i)
ClippedVertices[i].DoState(p);
for (auto& ClippedVertice : ClippedVertices)
ClippedVertice.DoState(p);
}
void Init()

View File

@ -85,11 +85,11 @@ struct OutputVertexData
mvPosition.DoState(p);
p.Do(projectedPosition);
screenPosition.DoState(p);
for (int i = 0; i < 3;++i)
normal[i].DoState(p);
for (auto& vec : normal)
vec.DoState(p);
p.DoArray(color, sizeof color);
for (int i = 0; i < 8;++i)
texCoords[i].DoState(p);
for (auto& vec : texCoords)
vec.DoState(p);
}
};

View File

@ -54,12 +54,12 @@ void DoState(PointerWrap &p)
{
ZSlope.DoState(p);
WSlope.DoState(p);
for (int i=0;i<2;++i)
for (auto& ColorSlope : ColorSlopes)
for (int n=0; n<4; ++n)
ColorSlopes[i][n].DoState(p);
for (int i=0;i<8;++i)
ColorSlope[n].DoState(p);
for (auto& TexSlope : TexSlopes)
for (int n=0; n<3; ++n)
TexSlopes[i][n].DoState(p);
TexSlope[n].DoState(p);
p.Do(vertex0X);
p.Do(vertex0Y);
p.Do(vertexOffsetX);

View File

@ -75,15 +75,15 @@ namespace DriverDetails
break;
}
for(unsigned int a = 0; a < (sizeof(m_known_bugs) / sizeof(BugInfo)); ++a)
for(auto& bug : m_known_bugs)
{
if(
( m_known_bugs[a].m_vendor == m_vendor || m_known_bugs[a].m_vendor == VENDOR_ALL ) &&
( m_known_bugs[a].m_driver == m_driver || m_known_bugs[a].m_driver == DRIVER_ALL ) &&
( m_known_bugs[a].m_versionstart <= m_version || m_known_bugs[a].m_versionstart == -1 ) &&
( m_known_bugs[a].m_versionend > m_version || m_known_bugs[a].m_versionend == -1 )
( bug.m_vendor == m_vendor || bug.m_vendor == VENDOR_ALL ) &&
( bug.m_driver == m_driver || bug.m_driver == DRIVER_ALL ) &&
( bug.m_versionstart <= m_version || bug.m_versionstart == -1 ) &&
( bug.m_versionend > m_version || bug.m_versionend == -1 )
)
m_bugs.insert(std::make_pair(m_known_bugs[a].m_bug, m_known_bugs[a]));
m_bugs.insert(std::make_pair(bug.m_bug, bug));
}
}

View File

@ -33,21 +33,21 @@ void Init(const char *gameCode)
{
File::FSTEntry FST_Temp;
File::ScanDirectoryTree(Directories[i], FST_Temp);
for (u32 j = 0; j < FST_Temp.children.size(); j++)
for (auto& entry : FST_Temp.children)
{
if (FST_Temp.children.at(j).isDirectory)
if (entry.isDirectory)
{
bool duplicate = false;
for (u32 k = 0; k < Directories.size(); k++)
for (auto& Directory : Directories)
{
if (strcmp(Directories[k].c_str(), FST_Temp.children.at(j).physicalName.c_str()) == 0)
if (strcmp(Directory.c_str(), entry.physicalName.c_str()) == 0)
{
duplicate = true;
break;
}
}
if (!duplicate)
Directories.push_back(FST_Temp.children.at(j).physicalName.c_str());
Directories.push_back(entry.physicalName.c_str());
}
}
}
@ -66,13 +66,13 @@ void Init(const char *gameCode)
if (rFilenames.size() > 0)
{
for (u32 i = 0; i < rFilenames.size(); i++)
for (auto& rFilename : rFilenames)
{
std::string FileName;
SplitPath(rFilenames[i], NULL, &FileName, NULL);
SplitPath(rFilename, NULL, &FileName, NULL);
if (FileName.substr(0, strlen(code)).compare(code) == 0 && textureMap.find(FileName) == textureMap.end())
textureMap.insert(std::map<std::string, std::string>::value_type(FileName, rFilenames[i]));
textureMap.insert(std::map<std::string, std::string>::value_type(FileName, rFilename));
}
}
}

View File

@ -73,9 +73,9 @@ private:
{
size_t h = -1;
for (unsigned int i = 0; i < sizeof(vid) / sizeof(vid[0]); ++i)
for (auto word : vid)
{
h = h * 137 + vid[i];
h = h * 137 + word;
}
return h;

View File

@ -43,16 +43,16 @@ static VertexLoaderMap g_VertexLoaderMap;
void Init()
{
MarkAllDirty();
for (int i = 0; i < 8; i++)
g_VertexLoaders[i] = NULL;
for (auto& vertexLoader : g_VertexLoaders)
vertexLoader = NULL;
RecomputeCachedArraybases();
}
void Shutdown()
{
for (VertexLoaderMap::iterator iter = g_VertexLoaderMap.begin(); iter != g_VertexLoaderMap.end(); ++iter)
for (auto& p : g_VertexLoaderMap)
{
delete iter->second;
delete p.second;
}
g_VertexLoaderMap.clear();
}

View File

@ -50,11 +50,11 @@ void VideoBackend::PopulateList()
#endif
g_available_video_backends.push_back(backends[3] = new SW::VideoSoftware);
for (int i = 0; i < 4; ++i)
for (auto& backend : backends)
{
if (backends[i])
if (backend)
{
s_default_backend = g_video_backend = backends[i];
s_default_backend = g_video_backend = backend;
break;
}
}