[Scummvm-git-logs] scummvm master -> 5b1e2d502c3b1c7b4d22eab9fe975b5bf6c14025
sev-
noreply at scummvm.org
Thu Mar 27 05:48:26 UTC 2025
This automated email contains information about 58 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2255fb7d53 AUDIO: Use C++ 11 range-based for loops
ce51fd937f BACKENDS: Use C++ 11 range-based for loops
4c5adb95ba BASE: Use C++ 11 range-based for loops
177f04349a COMMON: Use C++ 11 range-based for loops
4e7752b923 GRAPHICS: Use C++ 11 range-based for loops
1921ebf02e ENGINES: Use C++ 11 range-based for loops
e157b7044e GUI: Use C++ 11 range-based for loops
2d9ec1ae70 IMAGE: Use C++ 11 range-based for loops
7cb70d585f VIDEO: Use C++ 11 range-based for loops
236c20fc57 GOB: Use C++ 11 range-based for loops
32ec1b9258 SAGA: Use C++ 11 range-based for loops
b90124c1e2 HADESCH: Use C++ 11 range-based for loops
27bb882eb2 ILLUSIONS: Use C++ 11 range-based for loops
85f33669e4 PRINCE: Use C++ 11 range-based for loops
ed39a2d2e9 BURIED: Use C++ 11 range-based for loops
dd94f27344 MADE: Use C++ 11 range-based for loops
ce1afedb43 AGOS: Use C++ 11 range-based for loops
9538b22f8a EFH: Use C++ 11 range-based for loops
9151366f62 CGE: Use C++ 11 range-based for loops
a61aec54db CGE2: Use C++ 11 range-based for loops
169fa99626 CHEWY: Use C++ 11 range-based for loops
fa43b13279 AGI: Use C++ 11 range-based for loops
49ae0d056d ACCESS: Use C++ 11 range-based for loops
0af1d397c3 AVALANCE: Use C++ 11 range-based for loops
2d86549c3f AGOS: Use C++ 11 range-based for loops
db5c5e853a ADL: Use C++ 11 range-based for loops
52b22ba636 BBVS: Use C++ 11 range-based for loops
b7530e0af0 DM: Use C++ 11 range-based for loops
9eee0e2be3 KINGDOM: Use C++ 11 range-based for loops
bd49804112 LILIPUT: Use C++ 11 range-based for loops
e8a321b152 SWORD1: Use C++ 11 range-based for loops
a2a8e23300 SWORD2: Use C++ 11 range-based for loops
155bba57d3 ASYLUM: Use C++ 11 range-based for loops
a90db8008f BAGEL: Use C++ 11 range-based for loops
8d6388e068 CRUISE: Use C++ 11 range-based for loops
ad27ff215c DGDS: Use C++ 11 range-based for loops
ce68bcf1c0 GROOVIE: Use C++ 11 range-based for loops
7c22ff1abd HADESCH: Use C++ 11 range-based for loops
79b605cd6c DRACI: Use C++ 11 range-based for loops
760511ca70 AGI: Use C++ 11 range-based for loops
c78ead8ce3 DRAGONS: Use C++ 11 range-based for loops
62dc9dcd8f VOYEUR: Use C++ 11 range-based for loops
bc064d97d1 AGI: Const correctness
83ced4731c DRAGONS: Const correctness
dbde06960c VOYEUR: Const correctness
2eeeabadda DRASCULA: Use C++ 11 range-based for loops
8a062f471d CINE: Use C++ 11 range-based for loops
5dc28a9d43 DREAMWEB: Use C++ 11 range-based for loops
fda6fc2723 FREESCAPE: Use C++ 11 range-based for loops
affc445f77 HOPKINS: Use C++ 11 range-based for loops
b680373e98 LAB: Use C++ 11 range-based for loops
7e99e9c3e2 ICB: Use C++ 11 range-based for loops
404d098e33 AUDIO: Use pointers when deleting inside range loops
3221471035 BACKENDS: Use pointers when deleting inside range loops
b0051b47b0 BASE: Use pointers when deleting inside range loops
a28cb792cf VIDEO: Use pointers when deleting inside range loops
1cfa228906 ENGINES: Use pointers when deleting inside range loops
5b1e2d502c COMMON: Use C++ 11 range-based for loops
Commit: 2255fb7d53494a6ed7bb7d1e99a380389f3e08ec
https://github.com/scummvm/scummvm/commit/2255fb7d53494a6ed7bb7d1e99a380389f3e08ec
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
AUDIO: Use C++ 11 range-based for loops
Changed paths:
audio/decoders/voc.cpp
audio/decoders/wma.cpp
audio/mididrv.cpp
audio/midiparser_qt.cpp
audio/mt32gm.cpp
audio/softsynth/fmtowns_pc98/towns_euphony.cpp
audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
audio/soundfont/rifffile.cpp
audio/soundfont/vab/psxspu.cpp
audio/soundfont/vgmsamp.cpp
diff --git a/audio/decoders/voc.cpp b/audio/decoders/voc.cpp
index 0fb80634080..bea26b136c7 100644
--- a/audio/decoders/voc.cpp
+++ b/audio/decoders/voc.cpp
@@ -431,25 +431,25 @@ void VocStream::preProcess() {
_length = Timestamp(0, _rate);
// Calculate the total play time and do some more sanity checks
- for (BlockList::const_iterator i = _blocks.begin(), end = _blocks.end(); i != end; ++i) {
+ for (const auto &curBlock : _blocks) {
// Check whether we found a block 8 which survived, this is not
// allowed to happen!
- if (i->code == 8) {
+ if (curBlock.code == 8) {
warning("VOC file contains unused block 8");
return;
}
// For now only use blocks with actual samples
- if (i->code != 1 && i->code != 9)
+ if (curBlock.code != 1 && curBlock.code != 9)
continue;
// Check the sample rate
- if (i->sampleBlock.rate != _rate) {
- warning("VOC file contains chunks with different sample rates (%d != %d)", _rate, i->sampleBlock.rate);
+ if (curBlock.sampleBlock.rate != _rate) {
+ warning("VOC file contains chunks with different sample rates (%d != %d)", _rate, curBlock.sampleBlock.rate);
return;
}
- _length = _length.addFrames(i->sampleBlock.samples);
+ _length = _length.addFrames(curBlock.sampleBlock.samples);
}
// Set the current block to the first block in the stream
diff --git a/audio/decoders/wma.cpp b/audio/decoders/wma.cpp
index 06f5a17e7fd..7f37c551af4 100644
--- a/audio/decoders/wma.cpp
+++ b/audio/decoders/wma.cpp
@@ -115,8 +115,8 @@ WMACodec::~WMACodec() {
delete _coefHuffman[i];
}
- for (Common::Array<Math::MDCT *>::iterator m = _mdct.begin(); m != _mdct.end(); ++m)
- delete *m;
+ for (auto &m : _mdct)
+ delete m;
}
void WMACodec::init(Common::SeekableReadStream *extraData) {
diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp
index e4efdc0220e..140eea0e07a 100644
--- a/audio/mididrv.cpp
+++ b/audio/mididrv.cpp
@@ -95,11 +95,11 @@ MusicType MidiDriver::getMusicType(MidiDriver::DeviceHandle handle) {
if (handle) {
const PluginList p = MusicMan.getPlugins();
- for (PluginList::const_iterator m = p.begin(); m != p.end(); m++) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) {
- if (handle == d->getHandle())
- return d->getMusicType();
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (handle == d.getHandle())
+ return d.getMusicType();
}
}
}
@@ -110,18 +110,18 @@ MusicType MidiDriver::getMusicType(MidiDriver::DeviceHandle handle) {
Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType type) {
if (handle) {
const PluginList p = MusicMan.getPlugins();
- for (PluginList::const_iterator m = p.begin(); m != p.end(); m++) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) {
- if (handle == d->getHandle()) {
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (handle == d.getHandle()) {
if (type == kDriverName)
- return d->getMusicDriverName();
+ return d.getMusicDriverName();
else if (type == kDriverId)
- return d->getMusicDriverId();
+ return d.getMusicDriverId();
else if (type == kDeviceName)
- return d->getCompleteName();
+ return d.getCompleteName();
else if (type == kDeviceId)
- return d->getCompleteId();
+ return d.getCompleteId();
else
return Common::String("auto");
}
@@ -310,11 +310,11 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// and there is no preferred MT32 or GM device selected either or if the detected device is unavailable we arrive here.
// If MT32 is preferred we try for the first available device with music type 'MT_MT32' (usually the mt32 emulator).
if (flags & MDT_PREFER_MT32) {
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (d->getMusicType() == MT_MT32) {
- hdl = d->getHandle();
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (d.getMusicType() == MT_MT32) {
+ hdl = d.getHandle();
if (checkDevice(hdl, checkFlags | MDCK_AUTO, true))
return hdl;
}
@@ -325,11 +325,11 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// Now we default to the first available device with music type 'MT_GM' if not
// MT-32 is preferred or if MT-32 is preferred but all other devices have failed.
if (!(flags & MDT_PREFER_MT32) || flags == (MDT_PREFER_MT32 | MDT_MIDI)) {
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (d->getMusicType() == MT_GM || d->getMusicType() == MT_GS) {
- hdl = d->getHandle();
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (d.getMusicType() == MT_GM || d.getMusicType() == MT_GS) {
+ hdl = d.getHandle();
if (checkDevice(hdl, checkFlags | MDCK_AUTO, true))
return hdl;
}
@@ -384,11 +384,11 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
tp = MT_AUTO;
}
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (d->getMusicType() == tp) {
- hdl = d->getHandle();
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (d.getMusicType() == tp) {
+ hdl = d.getHandle();
if (checkDevice(hdl, checkFlags, true))
return hdl;
}
@@ -402,8 +402,8 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) {
MidiDriver *driver = nullptr;
const PluginList p = MusicMan.getPlugins();
- for (PluginList::const_iterator m = p.begin(); m != p.end(); m++) {
- const MusicPluginObject &musicPlugin = (*m)->get<MusicPluginObject>();
+ for (const auto &m : p) {
+ const MusicPluginObject &musicPlugin = m->get<MusicPluginObject>();
if (getDeviceString(handle, MidiDriver::kDriverId).equals(musicPlugin.getId()))
musicPlugin.createInstance(&driver, handle);
}
@@ -413,8 +413,8 @@ MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) {
bool MidiDriver::checkDevice(MidiDriver::DeviceHandle handle, int flags, bool quiet) {
const PluginList p = MusicMan.getPlugins();
- for (PluginList::const_iterator m = p.begin(); m != p.end(); m++) {
- const MusicPluginObject &musicPlugin = (*m)->get<MusicPluginObject>();
+ for (const auto &m : p) {
+ const MusicPluginObject &musicPlugin = m->get<MusicPluginObject>();
if (getDeviceString(handle, MidiDriver::kDriverId).equals(musicPlugin.getId()))
return musicPlugin.checkDevice(handle, flags, quiet);
}
@@ -428,14 +428,14 @@ MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &ident
if (p.begin() == p.end())
error("MidiDriver::getDeviceHandle: Music plugins must be loaded prior to calling this method");
- for (PluginList::const_iterator m = p.begin(); m != p.end(); m++) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) {
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
// The music driver id isn't unique, but it will match
// driver's first device. This is useful when selecting
// the driver from the command line.
- if (identifier.equals(d->getMusicDriverId()) || identifier.equals(d->getCompleteId()) || identifier.equals(d->getCompleteName())) {
- return d->getHandle();
+ if (identifier.equals(d.getMusicDriverId()) || identifier.equals(d.getCompleteId()) || identifier.equals(d.getCompleteName())) {
+ return d.getHandle();
}
}
}
diff --git a/audio/midiparser_qt.cpp b/audio/midiparser_qt.cpp
index a30b11c1f5c..bf098f3828e 100644
--- a/audio/midiparser_qt.cpp
+++ b/audio/midiparser_qt.cpp
@@ -329,17 +329,17 @@ void MidiParser_QT::deallocateFreeChannel() {
}
void MidiParser_QT::deallocateChannel(byte channel) {
- for (ChannelMap::iterator it = _channelMap.begin(); it != _channelMap.end(); it++) {
- if (it->_value == channel) {
- _channelMap.erase(it);
+ for (auto &curChannel : _channelMap) {
+ if (curChannel._value == channel) {
+ _channelMap.erase(curChannel._key);
return;
}
}
}
bool MidiParser_QT::isChannelAllocated(byte channel) const {
- for (ChannelMap::const_iterator it = _channelMap.begin(); it != _channelMap.end(); it++)
- if (it->_value == channel)
+ for (const auto &curChannel : _channelMap)
+ if (curChannel._value == channel)
return true;
return false;
@@ -352,8 +352,8 @@ bool MidiParser_QT::allChannelsAllocated() const {
// 15? One of the allocated channels might be the percussion one
if (_channelMap.size() == 15)
- for (ChannelMap::const_iterator it = _channelMap.begin(); it != _channelMap.end(); it++)
- if (it->_value == 9)
+ for (const auto &channel : _channelMap)
+ if (channel._value == 9)
return false;
// 16 -> definitely all allocated
diff --git a/audio/mt32gm.cpp b/audio/mt32gm.cpp
index 626580b717d..b8ee9aac58e 100644
--- a/audio/mt32gm.cpp
+++ b/audio/mt32gm.cpp
@@ -387,9 +387,8 @@ bool MidiDriver_MT32GM::isReady(int8 source) {
// For a specific source, check if there is a SysEx for that source in the
// queue.
- for (Common::ListInternal::Iterator<SysExData> it = _sysExQueue.begin();
- it != _sysExQueue.end(); it++) {
- if (it->source == source)
+ for (auto &sysEx : _sysExQueue) {
+ if (sysEx.source == source)
return false;
}
diff --git a/audio/softsynth/fmtowns_pc98/towns_euphony.cpp b/audio/softsynth/fmtowns_pc98/towns_euphony.cpp
index 8165b5b0afb..4766146b7dc 100644
--- a/audio/softsynth/fmtowns_pc98/towns_euphony.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_euphony.cpp
@@ -78,8 +78,8 @@ EuphonyPlayer::~EuphonyPlayer() {
delete[] _partConfig_volume;
delete[] _partConfig_transpose;
- for (EuphonyEventsArray::iterator i = _euphonyEvents.begin(); i != _euphonyEvents.end(); ++i)
- delete *i;
+ for (auto &event : _euphonyEvents)
+ delete event;
}
bool EuphonyPlayer::init() {
diff --git a/audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp b/audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
index 44d8afc7d51..fbbcc9bac32 100644
--- a/audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
@@ -213,8 +213,8 @@ _sustain(false), _fading(false), _dataPtr(nullptr), _vbrModInitVal(0), _vbrModCu
#undef CONTROL
TownsPC98_MusicChannel::~TownsPC98_MusicChannel() {
- for (Common::Array<const ControlEvent*>::iterator i = _controlEvents.begin(); i != _controlEvents.end(); ++i)
- delete *i;
+ for (auto &event : _controlEvents)
+ delete event;
}
void TownsPC98_MusicChannel::reset() {
@@ -613,8 +613,8 @@ TownsPC98_MusicChannel(driver, regOffs, flgs, num, key, prt, id), _algorithm(0x8
#undef CONTROL
TownsPC98_MusicChannelSSG::~TownsPC98_MusicChannelSSG() {
- for (Common::Array<const ControlEvent*>::iterator i = _controlEvents.begin(); i != _controlEvents.end(); ++i)
- delete *i;
+ for (auto &event : _controlEvents)
+ delete event;
delete[] _envPatchData;
_envPatchData = nullptr;
}
@@ -1001,8 +1001,8 @@ TownsPC98_MusicChannel(driver, regOffs, flgs, num, key, prt, id) {
#undef CONTROL
TownsPC98_MusicChannelPCM::~TownsPC98_MusicChannelPCM() {
- for (Common::Array<const ControlEvent*>::iterator i = _controlEvents.begin(); i != _controlEvents.end(); ++i)
- delete *i;
+ for (auto &event : _controlEvents)
+ delete event;
}
void TownsPC98_MusicChannelPCM::loadData(uint8 *data) {
diff --git a/audio/soundfont/rifffile.cpp b/audio/soundfont/rifffile.cpp
index 6b7edfedc02..a0bb5f2cbb8 100644
--- a/audio/soundfont/rifffile.cpp
+++ b/audio/soundfont/rifffile.cpp
@@ -67,8 +67,8 @@ Chunk *ListTypeChunk::AddChildChunk(Chunk *ck) {
uint32 ListTypeChunk::GetSize() {
uint32 listChunkSize = 12; // id + size + "LIST"
- for (Common::List<Chunk *>::iterator iter = this->_childChunks.begin(); iter != _childChunks.end(); iter++)
- listChunkSize += (*iter)->GetSize();
+ for (auto &chunk : _childChunks)
+ listChunkSize += chunk->GetSize();
return GetPaddedSize(listChunkSize);
}
@@ -77,9 +77,9 @@ void ListTypeChunk::Write(uint8 *buffer) {
memcpy(buffer + 8, this->_type, 4);
uint32 bufOffset = 12;
- for (Common::List<Chunk *>::iterator iter = this->_childChunks.begin(); iter != _childChunks.end(); iter++) {
- (*iter)->Write(buffer + bufOffset);
- bufOffset += (*iter)->GetSize();
+ for (auto &chunk : _childChunks) {
+ chunk->Write(buffer + bufOffset);
+ bufOffset += chunk->GetSize();
}
uint32 unpaddedSize = bufOffset;
diff --git a/audio/soundfont/vab/psxspu.cpp b/audio/soundfont/vab/psxspu.cpp
index 9d471b0755f..1e9b18f86b9 100644
--- a/audio/soundfont/vab/psxspu.cpp
+++ b/audio/soundfont/vab/psxspu.cpp
@@ -189,10 +189,9 @@ bool PSXSampColl::GetSampleInfo() {
_unLength = i - _dwOffset;
} else {
uint32 sampleIndex = 0;
- for (Common::Array<SizeOffsetPair>::iterator it = _vagLocations.begin();
- it != _vagLocations.end(); ++it) {
- uint32 offSampStart = _dwOffset + it->offset;
- uint32 offDataEnd = offSampStart + it->size;
+ for (auto &vag : _vagLocations) {
+ uint32 offSampStart = _dwOffset + vag.offset;
+ uint32 offDataEnd = offSampStart + vag.size;
uint32 offSampEnd = offSampStart;
// detect loop end and ignore garbages like 00 07 77 77 77 77 77 etc.
@@ -207,8 +206,8 @@ bool PSXSampColl::GetSampleInfo() {
offSampEnd += 16;
} while (!lastBlock);
- PSXSamp *samp = new PSXSamp(this, _dwOffset + it->offset, it->size,
- _dwOffset + it->offset, offSampEnd - offSampStart, 1, 16,
+ PSXSamp *samp = new PSXSamp(this, _dwOffset + vag.offset, vag.size,
+ _dwOffset + vag.offset, offSampEnd - offSampStart, 1, 16,
44100, Common::String::format("Sample %d", sampleIndex));
_samples.push_back(samp);
sampleIndex++;
diff --git a/audio/soundfont/vgmsamp.cpp b/audio/soundfont/vgmsamp.cpp
index 0abba148b0a..95d2cfc4de2 100644
--- a/audio/soundfont/vgmsamp.cpp
+++ b/audio/soundfont/vgmsamp.cpp
@@ -96,9 +96,7 @@ bool VGMSampColl::Load() {
return false;
if (_unLength == 0) {
- for (Common::Array<VGMSamp *>::iterator itr = _samples.begin(); itr != _samples.end(); ++itr) {
- VGMSamp *samp = (*itr);
-
+ for (auto &samp : _samples) {
// Some formats can have negative sample offset
// For example, Konami's SNES format and Hudson's SNES format
// TODO: Fix negative sample offset without breaking instrument
Commit: ce51fd937f39b69aa905c47ccf1fb189e7545b23
https://github.com/scummvm/scummvm/commit/ce51fd937f39b69aa905c47ccf1fb189e7545b23
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
BACKENDS: Use C++ 11 range-based for loops
Changed paths:
backends/audiocd/default/default-audiocd.cpp
backends/cloud/savessyncrequest.cpp
backends/graphics/opengl/pipelines/libretro.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/keymapper/keymap.cpp
backends/keymapper/keymapper.cpp
backends/keymapper/remap-widget.cpp
backends/midi/alsa.cpp
backends/midi/seq.cpp
backends/midi/windows.cpp
backends/networking/curl/connectionmanager.cpp
backends/networking/sdl_net/handlers/filespagehandler.cpp
backends/networking/sdl_net/handlers/listajaxhandler.cpp
backends/networking/sdl_net/handlerutils.cpp
backends/platform/sdl/win32/win32.cpp
backends/vkeybd/image-map.cpp
backends/vkeybd/virtual-keyboard.cpp
diff --git a/backends/audiocd/default/default-audiocd.cpp b/backends/audiocd/default/default-audiocd.cpp
index dc685744646..4150ea6be2f 100644
--- a/backends/audiocd/default/default-audiocd.cpp
+++ b/backends/audiocd/default/default-audiocd.cpp
@@ -84,9 +84,9 @@ bool DefaultAudioCDManager::existExtractedCDAudioFiles(uint track) {
Common::Array<Common::String> trackNames;
fillPotentialTrackNames(trackNames, track);
- for (Common::Array<Common::String>::iterator i = trackNames.begin(); i != trackNames.end(); ++i) {
+ for (auto &trackName : trackNames) {
for (const char **ext = extensions; *ext; ++ext) {
- const Common::String &filename = Common::String::format("%s.%s", i->c_str(), *ext);
+ const Common::String &filename = Common::String::format("%s.%s", trackName.c_str(), *ext);
if (Common::File::exists(Common::Path(filename, '/'))) {
return true;
}
diff --git a/backends/cloud/savessyncrequest.cpp b/backends/cloud/savessyncrequest.cpp
index 25a5f8a3e52..13fb7a2cc8b 100644
--- a/backends/cloud/savessyncrequest.cpp
+++ b/backends/cloud/savessyncrequest.cpp
@@ -84,11 +84,11 @@ void SavesSyncRequest::directoryListedCallback(const Storage::ListDirectoryRespo
if (response.request) _date = response.request->date();
Common::HashMap<Common::String, bool> localFileNotAvailableInCloud;
- for (Common::HashMap<Common::String, uint32>::iterator i = _localFilesTimestamps.begin(); i != _localFilesTimestamps.end(); ++i) {
- localFileNotAvailableInCloud[i->_key] = true;
+ for (auto ×tamp : _localFilesTimestamps) {
+ localFileNotAvailableInCloud[timestamp._key] = true;
}
- //determine which files to download and which files to upload
+ // Determine which files to download and which files to upload
const Common::Array<StorageFile> &remoteFiles = response.value;
uint64 totalSize = 0;
debug(9, "SavesSyncRequest decisions:");
@@ -110,8 +110,8 @@ void SavesSyncRequest::directoryListedCallback(const Storage::ListDirectoryRespo
if (_localFilesTimestamps[name] == file.timestamp())
continue;
- //we actually can have some files not only with timestamp < remote
- //but also with timestamp > remote (when we have been using ANOTHER CLOUD and then switched back)
+ // We actually can have some files not only with timestamp < remote
+ // but also with timestamp > remote (when we have been using ANOTHER CLOUD and then switched back)
if (_localFilesTimestamps[name] > file.timestamp() || _localFilesTimestamps[name] == DefaultSaveFileManager::INVALID_TIMESTAMP)
_filesToUpload.push_back(file.name());
else
@@ -128,13 +128,13 @@ void SavesSyncRequest::directoryListedCallback(const Storage::ListDirectoryRespo
CloudMan.setStorageUsedSpace(CloudMan.getStorageIndex(), totalSize);
- //upload files which are unavailable in cloud
- for (Common::HashMap<Common::String, bool>::iterator i = localFileNotAvailableInCloud.begin(); i != localFileNotAvailableInCloud.end(); ++i) {
- if (i->_key == DefaultSaveFileManager::TIMESTAMPS_FILENAME || !CloudMan.canSyncFilename(i->_key))
+ // Upload files which are unavailable in cloud
+ for (auto &localFile : localFileNotAvailableInCloud) {
+ if (localFile._key == DefaultSaveFileManager::TIMESTAMPS_FILENAME || !CloudMan.canSyncFilename(localFile._key))
continue;
- if (i->_value) {
- _filesToUpload.push_back(i->_key);
- debug(9, "- uploading file %s, because it is not present on remote", i->_key.c_str());
+ if (localFile._value) {
+ _filesToUpload.push_back(localFile._key);
+ debug(9, "- uploading file %s, because it is not present on remote", localFile._key.c_str());
}
}
@@ -162,7 +162,7 @@ void SavesSyncRequest::directoryListedCallback(const Storage::ListDirectoryRespo
}
_totalFilesToHandle = _filesToDownload.size() + _filesToUpload.size();
- //start downloading files
+ // Start downloading files
if (!_filesToDownload.empty()) {
downloadNextFile();
} else {
@@ -181,7 +181,7 @@ void SavesSyncRequest::directoryListedErrorCallback(const Networking::ErrorRespo
if (error.failed) {
Common::JSONValue *value = Common::JSON::parse(error.response.c_str());
- // somehow OneDrive returns JSON with '.' in unexpected places, try fixing it
+ // Somehow OneDrive returns JSON with '.' in unexpected places, try fixing it
if (!value) {
Common::String fixedResponse = error.response;
for (uint32 i = 0; i < fixedResponse.size(); ++i) {
@@ -195,7 +195,7 @@ void SavesSyncRequest::directoryListedErrorCallback(const Networking::ErrorRespo
if (value->isObject()) {
Common::JSONObject object = value->asObject();
- //Dropbox-related error:
+ // Dropbox-related error:
if (object.contains("error_summary") && object.getVal("error_summary")->isString()) {
Common::String summary = object.getVal("error_summary")->asString();
if (summary.contains("not_found")) {
@@ -203,7 +203,7 @@ void SavesSyncRequest::directoryListedErrorCallback(const Networking::ErrorRespo
}
}
- //OneDrive-related error:
+ // OneDrive-related error:
if (object.contains("error") && object.getVal("error")->isObject()) {
Common::JSONObject errorNode = object.getVal("error")->asObject();
if (Networking::CurlJsonRequest::jsonContainsString(errorNode, "code", "SavesSyncRequest")) {
@@ -217,7 +217,7 @@ void SavesSyncRequest::directoryListedErrorCallback(const Networking::ErrorRespo
delete value;
}
- //Google Drive, Box and OneDrive-related ScummVM-based error
+ // Google Drive, Box and OneDrive-related ScummVM-based error
if (error.response.contains("subdirectory not found")) {
irrecoverable = false; //base "/ScummVM/" folder not found
} else if (error.response.contains("no such file found in its parent directory")) {
@@ -232,7 +232,7 @@ void SavesSyncRequest::directoryListedErrorCallback(const Networking::ErrorRespo
return;
}
- //we're lucky - user just lacks his "/cloud/" folder - let's create one
+ // We're lucky - user just lacks his "/cloud/" folder - let's create one
Common::String dir = _storage->savesDirectoryPath();
if (dir.lastChar() == '/')
dir.deleteLastChar();
diff --git a/backends/graphics/opengl/pipelines/libretro.cpp b/backends/graphics/opengl/pipelines/libretro.cpp
index a30d649afff..71aac01d36f 100644
--- a/backends/graphics/opengl/pipelines/libretro.cpp
+++ b/backends/graphics/opengl/pipelines/libretro.cpp
@@ -644,8 +644,8 @@ void LibRetroPipeline::setPipelineState() {
bool LibRetroPipeline::setupFBOs() {
// Setup the input targets sizes
- for (Common::Array<LibRetroTextureTarget>::iterator it = _inputTargets.begin(); it != _inputTargets.end(); it++) {
- if (!it->setScaledSize(_inputWidth, _inputHeight, _outputRect)) {
+ for (auto &inputTarget : _inputTargets) {
+ if (!inputTarget.setScaledSize(_inputWidth, _inputHeight, _outputRect)) {
return false;
}
}
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 26ae558d314..9867f925eb7 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -2680,10 +2680,10 @@ void SurfaceSdlGraphicsManager::displayMessageOnOSD(const Common::U32String &msg
Common::Array<Common::U32String> lines;
Common::U32String::const_iterator strLineItrBegin = msg.begin();
- for (Common::U32String::const_iterator itr = msg.begin(); itr != msg.end(); itr++) {
- if (*itr == '\n') {
+ for (const auto &itr : msg) {
+ if (itr == '\n') {
lines.push_back(Common::U32String(strLineItrBegin, itr));
- strLineItrBegin = itr + 1;
+ strLineItrBegin = &itr + 1;
}
}
if (strLineItrBegin != msg.end())
diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp
index 01e22af8e34..26d03b55c52 100644
--- a/backends/keymapper/keymap.cpp
+++ b/backends/keymapper/keymap.cpp
@@ -55,8 +55,8 @@ Keymap::Keymap(KeymapType type, const String &id, const String &description) :
}
Keymap::~Keymap() {
- for (ActionArray::iterator it = _actions.begin(); it != _actions.end(); ++it)
- delete *it;
+ for (auto &action : _actions)
+ delete action;
}
void Keymap::addAction(Action *action) {
@@ -78,15 +78,15 @@ void Keymap::registerMapping(Action *action, const HardwareInput &hwInput) {
void Keymap::unregisterMapping(Action *action) {
// Remove the action from all the input mappings
- for (HardwareActionMap::iterator itInput = _hwActionMap.begin(); itInput != _hwActionMap.end(); itInput++) {
- for (ActionArray::iterator itAction = itInput->_value.begin(); itAction != itInput->_value.end(); itAction++) {
- if (*itAction == action) {
- itInput->_value.erase(itAction);
+ for (auto &hwAction : _hwActionMap) {
+ for (auto &itAction : hwAction._value) {
+ if (itAction == action) {
+ hwAction._value.erase(&itAction);
break;
}
}
- if (itInput->_value.empty()) {
- _hwActionMap.erase(itInput);
+ if (hwAction._value.empty()) {
+ _hwActionMap.erase(hwAction._key);
}
}
}
@@ -110,10 +110,10 @@ struct HardwareInputTypeIdComparator {
Array<HardwareInput> Keymap::getActionMapping(const Action *action) const {
Array<HardwareInput> inputs;
- for (HardwareActionMap::iterator itInput = _hwActionMap.begin(); itInput != _hwActionMap.end(); itInput++) {
- for (ActionArray::iterator itAction = itInput->_value.begin(); itAction != itInput->_value.end(); itAction++) {
- if (*itAction == action) {
- inputs.push_back(itInput->_key);
+ for (auto &itInput : _hwActionMap) {
+ for (auto &itAction : itInput._value) {
+ if (itAction == action) {
+ inputs.push_back(itInput._key);
break;
}
}
@@ -126,9 +126,9 @@ Array<HardwareInput> Keymap::getActionMapping(const Action *action) const {
}
const Action *Keymap::findAction(const char *id) const {
- for (ActionArray::const_iterator it = _actions.begin(); it != _actions.end(); ++it) {
- if (strcmp((*it)->id, id) == 0)
- return *it;
+ for (const auto &action : _actions) {
+ if (strcmp(action->id, id) == 0)
+ return action;
}
return nullptr;
@@ -148,11 +148,11 @@ Keymap::KeymapMatch Keymap::getMappedActions(const Event &event, ActionArray &ac
if (normalizedKeystate.flags & KBD_NON_STICKY) {
// If no matching actions and non-sticky keyboard modifiers are down,
// check again for matches without the exact keyboard modifiers
- for (HardwareActionMap::const_iterator itInput = _hwActionMap.begin(); itInput != _hwActionMap.end(); ++itInput) {
- if (itInput->_key.type == kHardwareInputTypeKeyboard && itInput->_key.key.keycode == normalizedKeystate.keycode) {
- int flags = itInput->_key.key.flags;
+ for (const auto &itInput : _hwActionMap) {
+ if (itInput._key.type == kHardwareInputTypeKeyboard && itInput._key.key.keycode == normalizedKeystate.keycode) {
+ int flags = itInput._key.key.flags;
if (flags & KBD_NON_STICKY && (flags & normalizedKeystate.flags) == flags) {
- actions.push_back(itInput->_value);
+ actions.push_back(itInput._value);
return kKeymapMatchPartial;
}
}
@@ -280,8 +280,7 @@ void Keymap::loadMappings() {
String prefix = KEYMAP_KEY_PREFIX + _id + "_";
_hwActionMap.clear();
- for (ActionArray::const_iterator it = _actions.begin(); it != _actions.end(); ++it) {
- Action *action = *it;
+ for (auto &action : _actions) {
String confKey = prefix + action->id;
StringArray hwInputIds;
@@ -324,8 +323,7 @@ void Keymap::saveMappings() {
String prefix = KEYMAP_KEY_PREFIX + _id + "_";
- for (ActionArray::const_iterator it = _actions.begin(); it != _actions.end(); it++) {
- Action *action = *it;
+ for (const auto &action : _actions) {
Array<HardwareInput> mappedInputs = getActionMapping(action);
if (areMappingsIdentical(mappedInputs, getActionDefaultMappings(action))) {
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 4bc9af51453..68ab7e6560e 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -49,8 +49,8 @@ Keymapper::~Keymapper() {
}
void Keymapper::clear() {
- for (KeymapArray::iterator it = _keymaps.begin(); it != _keymaps.end(); it++) {
- delete *it;
+ for (auto &keymap : _keymaps) {
+ delete keymap;
}
_keymaps.clear();
@@ -155,9 +155,9 @@ void Keymapper::disableAllGameKeymaps() {
}
Keymap *Keymapper::getKeymap(const String &id) const {
- for (KeymapArray::const_iterator it = _keymaps.begin(); it != _keymaps.end(); it++) {
- if ((*it)->getId() == id) {
- return *it;
+ for (const auto &keymap : _keymaps) {
+ if (keymap->getId() == id) {
+ return keymap;
}
}
@@ -196,8 +196,8 @@ bool Keymapper::mapEvent(const Event &ev, List<Event> &mappedEvents) {
}
bool matchedAction = !actions.empty();
- for (Keymap::ActionArray::const_iterator it = actions.begin(); it != actions.end(); it++) {
- Event mappedEvent = executeAction(*it, ev);
+ for (const auto &action : actions) {
+ Event mappedEvent = executeAction(action, ev);
if (mappedEvent.type == EVENT_INVALID) {
continue;
}
diff --git a/backends/keymapper/remap-widget.cpp b/backends/keymapper/remap-widget.cpp
index 1f27d972cce..2c01d876920 100644
--- a/backends/keymapper/remap-widget.cpp
+++ b/backends/keymapper/remap-widget.cpp
@@ -275,10 +275,10 @@ void RemapWidget::handleTickle() {
void RemapWidget::loadKeymap() {
assert(_actions.empty());
- for (KeymapArray::const_iterator km = _keymapTable.begin(); km != _keymapTable.end(); km++) {
- for (Keymap::ActionArray::const_iterator it = (*km)->getActions().begin(); it != (*km)->getActions().end(); ++it) {
+ for (const auto &km : _keymapTable) {
+ for (Keymap::ActionArray::const_iterator it = km->getActions().begin(); it != km->getActions().end(); ++it) {
ActionRow row;
- row.keymap = *km;
+ row.keymap = km;
row.action = *it;
_actions.push_back(row);
diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp
index 43953ea8ded..b222a8997f1 100644
--- a/backends/midi/alsa.cpp
+++ b/backends/midi/alsa.cpp
@@ -424,8 +424,8 @@ MusicDevices AlsaMusicPlugin::getDevices() const {
// Add the remaining devices in the order they were found.
- for (d = alsaDevices.begin(); d != alsaDevices.end(); ++d)
- devices.push_back(MusicDevice(this, d->getName(), d->getType()));
+ for (auto &device : alsaDevices)
+ devices.push_back(MusicDevice(this, device.getName(), device.getType()));
return devices;
}
@@ -461,12 +461,12 @@ Common::Error AlsaMusicPlugin::createInstance(MidiDriver **mididriver, MidiDrive
if (!found && dev) {
AlsaDevices alsaDevices = getAlsaDevices();
- for (AlsaDevices::iterator d = alsaDevices.begin(); d != alsaDevices.end(); ++d) {
- MusicDevice device(this, d->getName(), d->getType());
+ for (auto &d : alsaDevices) {
+ MusicDevice device(this, d.getName(), d.getType());
if (device.getCompleteId().equals(MidiDriver::getDeviceString(dev, MidiDriver::kDeviceId))) {
found = true;
- seq_client = d->getClient();
+ seq_client = d.getClient();
seq_port = -1;
break;
}
diff --git a/backends/midi/seq.cpp b/backends/midi/seq.cpp
index 8f6d174fb17..6c50abaaee4 100644
--- a/backends/midi/seq.cpp
+++ b/backends/midi/seq.cpp
@@ -363,8 +363,8 @@ Common::Error SeqMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver
}
int devIndex = 0;
- for (MusicDevices::iterator d = devices.begin(); d != devices.end(); d++) {
- if (d->getCompleteId().equals(deviceIDString)) {
+ for (auto &d : devices) {
+ if (d.getCompleteId().equals(deviceIDString)) {
found = true;
isSynth = (devIndex >= firstSynthIndex);
port = ports[devIndex];
diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp
index efdee259c81..bfe88acd4b7 100644
--- a/backends/midi/windows.cpp
+++ b/backends/midi/windows.cpp
@@ -240,8 +240,8 @@ Common::Error WindowsMusicPlugin::createInstance(MidiDriver **mididriver, MidiDr
Common::String deviceIDString = MidiDriver::getDeviceString(dev, MidiDriver::kDeviceId);
MusicDevices i = getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) {
- if (d->getCompleteId().equals(deviceIDString)) {
+ for (auto &d : i) {
+ if (d.getCompleteId().equals(deviceIDString)) {
found = true;
break;
}
diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp
index c62333b3fc0..4d204cc1995 100644
--- a/backends/networking/curl/connectionmanager.cpp
+++ b/backends/networking/curl/connectionmanager.cpp
@@ -51,9 +51,9 @@ ConnectionManager::~ConnectionManager() {
//terminate all added requests which haven't been processed yet
_addedRequestsMutex.lock();
- for (Common::Array<RequestWithCallback>::iterator i = _addedRequests.begin(); i != _addedRequests.end(); ++i) {
- Request *request = i->request;
- RequestCallback callback = i->onDeleteCallback;
+ for (auto &curRequest : _addedRequests) {
+ Request *request = curRequest.request;
+ RequestCallback callback = curRequest.onDeleteCallback;
if (request)
request->finish();
delete request;
@@ -67,9 +67,9 @@ ConnectionManager::~ConnectionManager() {
//terminate all requests
_handleMutex.lock();
- for (Common::Array<RequestWithCallback>::iterator i = _requests.begin(); i != _requests.end(); ++i) {
- Request *request = i->request;
- RequestCallback callback = i->onDeleteCallback;
+ for (auto &curRequest : _requests) {
+ Request *request = curRequest.request;
+ RequestCallback callback = curRequest.onDeleteCallback;
if (request)
request->finish();
delete request;
@@ -194,8 +194,8 @@ void ConnectionManager::handle() {
void ConnectionManager::interateRequests() {
//add new requests
_addedRequestsMutex.lock();
- for (Common::Array<RequestWithCallback>::iterator i = _addedRequests.begin(); i != _addedRequests.end(); ++i) {
- _requests.push_back(*i);
+ for (auto &addedRequest : _addedRequests) {
+ _requests.push_back(addedRequest);
}
_addedRequests.clear();
_addedRequestsMutex.unlock();
diff --git a/backends/networking/sdl_net/handlers/filespagehandler.cpp b/backends/networking/sdl_net/handlers/filespagehandler.cpp
index dacc645f513..5de78b6425f 100644
--- a/backends/networking/sdl_net/handlers/filespagehandler.cpp
+++ b/backends/networking/sdl_net/handlers/filespagehandler.cpp
@@ -117,16 +117,16 @@ bool FilesPageHandler::listDirectory(const Common::String &path_, Common::String
}
// fill the content
- for (Common::FSList::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
- Common::String name = i->getName();
- if (i->isDirectory())
+ for (auto &i : _nodeContent) {
+ Common::String name = i.getName();
+ if (i.isDirectory())
name += "/";
- Common::Path relPath = i->getPath().relativeTo(baseFSPath);
+ Common::Path relPath = i.getPath().relativeTo(baseFSPath);
Common::String filePath(basePath);
filePath += relPath.toString('/');
- addItem(content, itemTemplate, detectType(i->isDirectory(), name), filePath, name);
+ addItem(content, itemTemplate, detectType(i.isDirectory(), name), filePath, name);
}
return true;
diff --git a/backends/networking/sdl_net/handlers/listajaxhandler.cpp b/backends/networking/sdl_net/handlers/listajaxhandler.cpp
index 5323c7d68bc..030df90dd87 100644
--- a/backends/networking/sdl_net/handlers/listajaxhandler.cpp
+++ b/backends/networking/sdl_net/handlers/listajaxhandler.cpp
@@ -83,16 +83,16 @@ Common::JSONObject ListAjaxHandler::listDirectory(const Common::String &path_) {
}
// fill the content
- for (Common::FSList::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
- Common::String name = i->getName();
- if (i->isDirectory())
+ for (auto &curNode : _nodeContent) {
+ Common::String name = curNode.getName();
+ if (curNode.isDirectory())
name += "/";
- Common::Path relPath = i->getPath().relativeTo(baseFSPath);
+ Common::Path relPath = curNode.getPath().relativeTo(baseFSPath);
Common::String filePath(basePath);
filePath += relPath.toString('/');
- addItem(itemsList, detectType(i->isDirectory(), name), filePath, name);
+ addItem(itemsList, detectType(curNode.isDirectory(), name), filePath, name);
}
successResult.setVal("items", new Common::JSONValue(itemsList));
diff --git a/backends/networking/sdl_net/handlerutils.cpp b/backends/networking/sdl_net/handlerutils.cpp
index f32d51814ac..c1ba080aa39 100644
--- a/backends/networking/sdl_net/handlerutils.cpp
+++ b/backends/networking/sdl_net/handlerutils.cpp
@@ -53,9 +53,8 @@ Common::Archive *HandlerUtils::getZipArchive() {
// then use SearchMan to find it
Common::ArchiveMemberList fileList;
SearchMan.listMatchingMembers(fileList, ARCHIVE_NAME);
- for (Common::ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) {
- Common::ArchiveMember const &m = **it;
- Common::SeekableReadStream *const stream = m.createReadStream();
+ for (auto &m : fileList) {
+ Common::SeekableReadStream *const stream = m->createReadStream();
Common::Archive *zipArchive = Common::makeZipArchive(stream);
if (zipArchive)
return zipArchive;
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index 695653394fa..a08c027b2ce 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -459,8 +459,8 @@ Win32ResourceArchive::Win32ResourceArchive() {
}
bool Win32ResourceArchive::hasFile(const Common::Path &path) const {
- for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i) {
- if (i->equalsIgnoreCase(path))
+ for (const auto &curPath : _files) {
+ if (curPath.equalsIgnoreCase(path))
return true;
}
diff --git a/backends/vkeybd/image-map.cpp b/backends/vkeybd/image-map.cpp
index e85aa958c89..28efa86b240 100644
--- a/backends/vkeybd/image-map.cpp
+++ b/backends/vkeybd/image-map.cpp
@@ -52,16 +52,16 @@ void ImageMap::removeArea(const String &id) {
}
void ImageMap::removeAllAreas() {
- for (AreaMap::iterator it = _areas.begin(); it != _areas.end(); ++it) {
- delete it->_value;
+ for (auto &area : _areas) {
+ delete area._value;
}
_areas.clear();
}
String ImageMap::findMapArea(int16 x, int16 y) {
- for (AreaMap::iterator it = _areas.begin(); it != _areas.end(); ++it) {
- if (it->_value->contains(x, y))
- return it->_key;
+ for (auto &area : _areas) {
+ if (area._value->contains(x, y))
+ return area._key;
}
return String();
diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp
index 8bdf517b162..18e44ade998 100644
--- a/backends/vkeybd/virtual-keyboard.cpp
+++ b/backends/vkeybd/virtual-keyboard.cpp
@@ -58,10 +58,9 @@ VirtualKeyboard::~VirtualKeyboard() {
}
void VirtualKeyboard::deleteEvents() {
- for (ModeMap::iterator it_m = _modes.begin(); it_m != _modes.end(); ++it_m) {
- VKEventMap &evt = it_m->_value.events;
- for (VKEventMap::iterator it_e = evt.begin(); it_e != evt.end(); ++it_e)
- delete it_e->_value;
+ for (auto &mode : _modes) {
+ for (auto &event : mode._value.events)
+ delete event._value;
}
}
Commit: 4c5adb95baf887093709cabbb5dd97e69c3274b5
https://github.com/scummvm/scummvm/commit/4c5adb95baf887093709cabbb5dd97e69c3274b5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
BASE: Use C++ 11 range-based for loops
Changed paths:
base/commandLine.cpp
base/main.cpp
base/plugins.cpp
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 3dcdd2b3e72..3a9b29241b6 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -1057,8 +1057,8 @@ static void listGames(const Common::String &engineID) {
"------------------------------ -----------------------------------------------------------\n");
const PluginList &plugins = EngineMan.getPlugins(PLUGIN_TYPE_ENGINE);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); ++iter) {
- const Plugin *p = EngineMan.findDetectionPlugin((*iter)->getName());
+ for (const auto &plugin : plugins) {
+ const Plugin *p = EngineMan.findDetectionPlugin(plugin->getName());
/* If for some reason, we can't find the MetaEngineDetection for this Engine, just ignore it */
if (!p) {
continue;
@@ -1066,8 +1066,8 @@ static void listGames(const Common::String &engineID) {
if (all || Common::find(engines.begin(), engines.end(), p->getName()) != engines.end()) {
PlainGameList list = p->get<MetaEngineDetection>().getSupportedGames();
- for (PlainGameList::const_iterator v = list.begin(); v != list.end(); ++v) {
- printf("%-30s %s\n", buildQualifiedGameName(p->get<MetaEngineDetection>().getName(), v->gameId).c_str(), v->description);
+ for (const auto &v : list) {
+ printf("%-30s %s\n", buildQualifiedGameName(p->get<MetaEngineDetection>().getName(), v.gameId).c_str(), v.description);
}
}
}
@@ -1086,13 +1086,13 @@ static void listAllGames(const Common::String &engineID) {
"------------------------------ -----------------------------------------------------------\n");
const PluginList &plugins = EngineMan.getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); ++iter) {
- const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+ for (const auto &plugin : plugins) {
+ const MetaEngineDetection &metaEngine = plugin->get<MetaEngineDetection>();
if (any || Common::find(engines.begin(), engines.end(), metaEngine.getName()) != engines.end()) {
PlainGameList list = metaEngine.getSupportedGames();
- for (PlainGameList::const_iterator v = list.begin(); v != list.end(); ++v) {
- printf("%-30s %s\n", buildQualifiedGameName(metaEngine.getName(), v->gameId).c_str(), v->description);
+ for (const auto &v : list) {
+ printf("%-30s %s\n", buildQualifiedGameName(metaEngine.getName(), v.gameId).c_str(), v.description);
}
}
}
@@ -1104,8 +1104,8 @@ static void listEngines() {
"--------------- ------------------------------------------------------\n");
const PluginList &plugins = EngineMan.getPlugins(PLUGIN_TYPE_ENGINE);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); ++iter) {
- const Plugin *p = EngineMan.findDetectionPlugin((*iter)->getName());
+ for (const auto &plugin : plugins) {
+ const Plugin *p = EngineMan.findDetectionPlugin(plugin->getName());
/* If for some reason, we can't find the MetaEngineDetection for this Engine, just ignore it */
if (!p) {
continue;
@@ -1121,8 +1121,8 @@ static void listAllEngines() {
"--------------- ------------------------------------------------------\n");
const PluginList &plugins = EngineMan.getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); ++iter) {
- const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+ for (const auto &plugin : plugins) {
+ const MetaEngineDetection &metaEngine = plugin->get<MetaEngineDetection>();
printf("%-15s %s\n", metaEngine.getName(), metaEngine.getEngineName());
}
}
@@ -1140,17 +1140,16 @@ static void listTargets(const Common::String &engineID) {
"-------------------- ------------------------------------------------------\n");
const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
- Common::ConfigManager::DomainMap::const_iterator iter;
Common::Array<Common::String> targets;
targets.reserve(domains.size());
- for (iter = domains.begin(); iter != domains.end(); ++iter) {
- Common::String name(iter->_key);
- Common::String description(iter->_value.getValOrDefault("description"));
+ for (const auto &domain : domains) {
+ Common::String name(domain._key);
+ Common::String description(domain._value.getValOrDefault("description"));
Common::String engine;
if (!any)
- engine = iter->_value.getValOrDefault("engineid");
+ engine = domain._value.getValOrDefault("engineid");
// If there's no description, fallback on the default description.
if (description.empty() || (!any && engine.empty())) {
@@ -1170,8 +1169,8 @@ static void listTargets(const Common::String &engineID) {
Common::sort(targets.begin(), targets.end());
- for (Common::Array<Common::String>::const_iterator i = targets.begin(), end = targets.end(); i != end; ++i)
- printf("%s\n", i->c_str());
+ for (const auto &target : targets)
+ printf("%s\n", target.c_str());
}
static void printStatistics(const Common::String &engineID) {
@@ -1189,11 +1188,11 @@ static void printStatistics(const Common::String &engineID) {
int targetCount = 0;
Common::HashMap<Common::String, int> engineTargetCount;
const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
- for (Common::ConfigManager::DomainMap::const_iterator iter = domains.begin(); iter != domains.end(); ++iter) {
+ for (const auto &domain : domains) {
if (!summary) {
- Common::String engine(iter->_value.getValOrDefault("engineid"));
+ Common::String engine(domain._value.getValOrDefault("engineid"));
if (engine.empty()) {
- QualifiedGameDescriptor g = EngineMan.findTarget(iter->_key);
+ QualifiedGameDescriptor g = EngineMan.findTarget(domain._key);
if (!g.engineId.empty())
engine = g.engineId;
}
@@ -1211,8 +1210,8 @@ static void printStatistics(const Common::String &engineID) {
bool approximation = false;
int engineCount = 0, gameCount = 0, variantCount = 0;
const PluginList &plugins = EngineMan.getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); ++iter) {
- const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+ for (const auto &plugin : plugins) {
+ const MetaEngineDetection &metaEngine = plugin->get<MetaEngineDetection>();
if (summary || all || Common::find(engines.begin(), engines.end(), metaEngine.getName()) != engines.end()) {
PlainGameList list = metaEngine.getSupportedGames();
++engineCount;
@@ -1259,8 +1258,8 @@ static void listDebugFlags(const Common::String &engineID) {
printDebugFlags(gDebugChannels);
else {
const PluginList &plugins = EngineMan.getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); ++iter) {
- const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+ for (const auto &plugin : plugins) {
+ const MetaEngineDetection &metaEngine = plugin->get<MetaEngineDetection>();
if (metaEngine.getName() == engineID) {
printf("Flag name Flag description \n");
printf("--------------- ------------------------------------------------------\n");
@@ -1278,8 +1277,8 @@ static void listAllEngineDebugFlags() {
printf("Flag name Flag description \n");
const PluginList &plugins = EngineMan.getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); ++iter) {
- const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+ for (const auto &plugin : plugins) {
+ const MetaEngineDetection &metaEngine = plugin->get<MetaEngineDetection>();
printf("--------------- ------------------------------------------------------\n");
printf("ID=%-12s Name=%s\n", metaEngine.getName(), metaEngine.getEngineName());
printDebugFlags(metaEngine.getDebugChannels());
@@ -1294,11 +1293,10 @@ static void assembleTargets(const Common::String &singleTarget, Common::Array<Co
// If no target is specified, list save games for all known targets
const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
- Common::ConfigManager::DomainMap::const_iterator iter;
targets.reserve(domains.size());
- for (iter = domains.begin(); iter != domains.end(); ++iter) {
- targets.push_back(iter->_key);
+ for (const auto &domain : domains) {
+ targets.push_back(domain._key);
}
}
@@ -1314,16 +1312,16 @@ static Common::Error listRecords(const Common::String &singleTarget) {
Common::String oldDomain = ConfMan.getActiveDomainName();
- for (Common::Array<Common::String>::const_iterator i = targets.begin(), end = targets.end(); i != end; ++i) {
+ for (const auto &target : targets) {
Common::String currentTarget;
QualifiedGameDescriptor game;
- if (ConfMan.hasGameDomain(*i)) {
+ if (ConfMan.hasGameDomain(target)) {
// The name is a known target
- currentTarget = *i;
- EngineMan.upgradeTargetIfNecessary(*i);
- game = EngineMan.findTarget(*i);
- } else if (game = findGameMatchingName(*i), !game.gameId.empty()) {
+ currentTarget = target;
+ EngineMan.upgradeTargetIfNecessary(target);
+ game = EngineMan.findTarget(target);
+ } else if (game = findGameMatchingName(target), !game.gameId.empty()) {
currentTarget = createTemporaryTarget(game.engineId, game.gameId);
} else {
return Common::Error(Common::kEnginePluginNotFound, Common::String::format("target '%s'", singleTarget.c_str()));
@@ -1336,9 +1334,9 @@ static Common::Error listRecords(const Common::String &singleTarget) {
if (files.empty()) {
continue;
}
- printf("Recordings for target '%s' (gameid '%s'):\n", i->c_str(), qualifiedGameId.c_str());
- for (Common::StringArray::const_iterator x = files.begin(); x != files.end(); ++x) {
- printf(" %s\n", x->c_str());
+ printf("Recordings for target '%s' (gameid '%s'):\n", target.c_str(), qualifiedGameId.c_str());
+ for (const auto &x : files) {
+ printf(" %s\n", x.c_str());
}
}
@@ -1368,18 +1366,18 @@ static Common::Error listSaves(const Common::String &singleTarget) {
Common::Array<GameTarget> gameTargets;
bool atLeastOneFound = false;
- for (Common::Array<Common::String>::const_iterator i = targets.begin(), end = targets.end(); i != end; ++i) {
+ for (const auto &target : targets) {
// Check whether there is either a game domain (i.e. a target) matching
// the specified game name, or alternatively whether there is a matching game id.
Common::String currentTarget;
QualifiedGameDescriptor game;
- if (ConfMan.hasGameDomain(*i)) {
+ if (ConfMan.hasGameDomain(target)) {
// The name is a known target
- currentTarget = *i;
- EngineMan.upgradeTargetIfNecessary(*i);
- game = EngineMan.findTarget(*i);
- } else if (game = findGameMatchingName(*i), !game.gameId.empty()) {
+ currentTarget = target;
+ EngineMan.upgradeTargetIfNecessary(target);
+ game = EngineMan.findTarget(target);
+ } else if (game = findGameMatchingName(target), !game.gameId.empty()) {
// The name is a known game id
currentTarget = createTemporaryTarget(game.engineId, game.gameId);
} else {
@@ -1393,59 +1391,59 @@ static Common::Error listSaves(const Common::String &singleTarget) {
PluginMan.unloadDetectionPlugin();
#endif
- for (Common::Array<GameTarget>::const_iterator i = gameTargets.begin(), end = gameTargets.end(); i != end; ++i) {
+ for (const auto &gameTarget : gameTargets) {
const Plugin *enginePlugin = nullptr;
// If we actually found a domain, we're going to change the domain
- ConfMan.setActiveDomain(i->target);
+ ConfMan.setActiveDomain(gameTarget.target);
- enginePlugin = PluginMan.findEnginePlugin(i->game.engineId);
+ enginePlugin = PluginMan.findEnginePlugin(gameTarget.game.engineId);
if (!enginePlugin) {
// If the target was specified, treat this as an error, and otherwise skip it.
if (!singleTarget.empty()) {
result = Common::Error(Common::kEnginePluginNotFound,
- Common::String::format("target '%s'", i->target.c_str()));
+ Common::String::format("target '%s'", gameTarget.target.c_str()));
break;
}
- printf("EnginePlugin could not be loaded for target '%s'\n", i->target.c_str());
+ printf("EnginePlugin could not be loaded for target '%s'\n", gameTarget.target.c_str());
continue;
}
const MetaEngine &metaEngine = enginePlugin->get<MetaEngine>();
- Common::String qualifiedGameId = buildQualifiedGameName(i->game.engineId, i->game.gameId);
+ Common::String qualifiedGameId = buildQualifiedGameName(gameTarget.game.engineId, gameTarget.game.gameId);
if (!metaEngine.hasFeature(MetaEngine::kSupportsListSaves)) {
// If the target was specified, treat this as an error, and otherwise skip it.
if (!singleTarget.empty()) {
// TODO: Include more info about the target (desc, engine name, ...) ???
result = Common::Error(Common::kEnginePluginNotSupportSaves,
- Common::String::format("target '%s', gameid '%s'", i->target.c_str(), qualifiedGameId.c_str()));
+ Common::String::format("target '%s', gameid '%s'", gameTarget.target.c_str(), qualifiedGameId.c_str()));
break;
}
continue;
}
// Query the plugin for a list of saved games
- SaveStateList saveList = metaEngine.listSaves(i->target.c_str());
+ SaveStateList saveList = metaEngine.listSaves(gameTarget.target.c_str());
if (!saveList.empty()) {
// TODO: Include more info about the target (desc, engine name, ...) ???
if (atLeastOneFound)
printf("\n");
- printf("Save states for target '%s' (gameid '%s'):\n", i->target.c_str(), qualifiedGameId.c_str());
+ printf("Save states for target '%s' (gameid '%s'):\n", gameTarget.target.c_str(), qualifiedGameId.c_str());
printf(" Slot Description \n"
" ---- ------------------------------------------------------\n");
- for (SaveStateList::const_iterator x = saveList.begin(); x != saveList.end(); ++x) {
- printf(" %-4d %s\n", x->getSaveSlot(), x->getDescription().encode().c_str());
+ for (const auto &x : saveList) {
+ printf(" %-4d %s\n", x.getSaveSlot(), x.getDescription().encode().c_str());
// TODO: Could also iterate over the full hashmap, printing all key-value pairs
}
atLeastOneFound = true;
} else {
// If the target was specified, indicate no save games were found for it. Otherwise just skip it.
if (!singleTarget.empty())
- printf("There are no save states for target '%s' (gameid '%s'):\n", i->target.c_str(), qualifiedGameId.c_str());
+ printf("There are no save states for target '%s' (gameid '%s'):\n", gameTarget.target.c_str(), qualifiedGameId.c_str());
}
}
@@ -1469,8 +1467,8 @@ static void listThemes() {
printf("Theme Description\n");
printf("-------------- ------------------------------------------------\n");
- for (ThList::const_iterator i = thList.begin(); i != thList.end(); ++i)
- printf("%-14s %s\n", i->id.c_str(), i->name.c_str());
+ for (const auto &theme : thList)
+ printf("%-14s %s\n", theme.id.c_str(), theme.name.c_str());
}
/** Lists all output devices */
@@ -1480,11 +1478,11 @@ static void listAudioDevices() {
printf("ID Description\n");
printf("------------------------------ ------------------------------------------------\n");
- for (PluginList::const_iterator i = pluginList.begin(), iend = pluginList.end(); i != iend; ++i) {
- const MusicPluginObject &musicObject = (*i)->get<MusicPluginObject>();
+ for (const auto &plugin : pluginList) {
+ const MusicPluginObject &musicObject = plugin->get<MusicPluginObject>();
MusicDevices deviceList = musicObject.getDevices();
- for (MusicDevices::iterator j = deviceList.begin(), jend = deviceList.end(); j != jend; ++j) {
- printf("%-30s %s\n", Common::String::format("\"%s\"", j->getCompleteId().c_str()).c_str(), j->getCompleteName().c_str());
+ for (auto &device : deviceList) {
+ printf("%-30s %s\n", Common::String::format("\"%s\"", device.getCompleteId().c_str()).c_str(), device.getCompleteName().c_str());
}
}
}
@@ -1498,8 +1496,8 @@ static void dumpAllDetectionEntries() {
printf("\tversion \"%s\"\n", gScummVMVersion);
printf(")\n\n");
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); iter++) {
- const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+ for (const auto &iter : plugins) {
+ const MetaEngineDetection &metaEngine = iter->get<MetaEngineDetection>();
metaEngine.dumpDetectionEntries();
}
}
@@ -1531,12 +1529,12 @@ static DetectedGames recListGames(const Common::FSNode &dir, const Common::Strin
if (recursive) {
Common::FSList files;
dir.getChildren(files, Common::FSNode::kListDirectoriesOnly);
- for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
- DetectedGames rec = recListGames(*file, engineId, gameId, recursive);
- for (DetectedGames::const_iterator game = rec.begin(); game != rec.end(); ++game) {
- if ((game->engineId == engineId && game->gameId == gameId)
+ for (const auto &file : files) {
+ DetectedGames rec = recListGames(file, engineId, gameId, recursive);
+ for (auto &game : rec) {
+ if ((game.engineId == engineId && game.gameId == gameId)
|| gameId.empty())
- list.push_back(*game);
+ list.push_back(game);
}
}
}
@@ -1564,11 +1562,11 @@ static Common::String detectGames(const Common::Path &path, const Common::String
// TODO this is not especially pretty
printf("GameID Description Full Path\n");
printf("------------------------------ ---------------------------------------------------------- ---------------------------------------------------------\n");
- for (DetectedGames::const_iterator v = candidates.begin(); v != candidates.end(); ++v) {
+ for (const auto &v : candidates) {
printf("%-30s %-58s %s\n",
- buildQualifiedGameName(v->engineId, v->gameId).c_str(),
- v->description.c_str(),
- v->path.toString(Common::Path::kNativeSeparator).c_str());
+ buildQualifiedGameName(v.engineId, v.gameId).c_str(),
+ v.description.c_str(),
+ v.path.toString(Common::Path::kNativeSeparator).c_str());
}
return buildQualifiedGameName(candidates[0].engineId, candidates[0].gameId);
@@ -1577,27 +1575,27 @@ static Common::String detectGames(const Common::Path &path, const Common::String
static int recAddGames(const Common::FSNode &dir, const Common::String &engineId, const Common::String &gameId, bool recursive) {
int count = 0;
DetectedGames list = getGameList(dir);
- for (DetectedGames::const_iterator v = list.begin(); v != list.end(); ++v) {
- if ((v->engineId != engineId || v->gameId != gameId)
+ for (const auto &v : list) {
+ if ((v.engineId != engineId || v.gameId != gameId)
&& !gameId.empty()) {
printf("Found %s, only adding %s per --game option, ignoring...\n",
- buildQualifiedGameName(v->engineId, v->gameId).c_str(),
+ buildQualifiedGameName(v.engineId, v.gameId).c_str(),
buildQualifiedGameName(engineId, gameId).c_str());
- } else if (ConfMan.hasGameDomain(v->preferredTarget)) {
+ } else if (ConfMan.hasGameDomain(v.preferredTarget)) {
// TODO Better check for game already added?
printf("Found %s, but has already been added, skipping\n",
- buildQualifiedGameName(v->engineId, v->gameId).c_str());
+ buildQualifiedGameName(v.engineId, v.gameId).c_str());
} else {
- Common::String target = EngineMan.createTargetForGame(*v);
+ Common::String target = EngineMan.createTargetForGame(v);
count++;
// Display added game info
printf("Game Added: \n Target: %s\n GameID: %s\n Name: %s\n Language: %s\n Platform: %s\n",
target.c_str(),
- buildQualifiedGameName(v->engineId, v->gameId).c_str(),
- v->description.c_str(),
- Common::getLanguageDescription(v->language),
- Common::getPlatformDescription(v->platform)
+ buildQualifiedGameName(v.engineId, v.gameId).c_str(),
+ v.description.c_str(),
+ Common::getLanguageDescription(v.language),
+ Common::getPlatformDescription(v.platform)
);
}
}
@@ -1605,8 +1603,8 @@ static int recAddGames(const Common::FSNode &dir, const Common::String &engineId
if (recursive) {
Common::FSList files;
if (dir.getChildren(files, Common::FSNode::kListDirectoriesOnly)) {
- for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
- count += recAddGames(*file, engineId, gameId, recursive);
+ for (const auto &file : files) {
+ count += recAddGames(file, engineId, gameId, recursive);
}
}
}
@@ -1709,12 +1707,11 @@ static void runDetectorTest() {
// whether the result agrees with the settings of the target.
const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
- Common::ConfigManager::DomainMap::const_iterator iter = domains.begin();
int success = 0, failure = 0;
- for (iter = domains.begin(); iter != domains.end(); ++iter) {
- Common::String name(iter->_key);
- Common::String gameid(iter->_value.getVal("gameid"));
- Common::Path path(Common::Path::fromConfig(iter->_value.getVal("path")));
+ for (const auto &domain : domains) {
+ Common::String name(domain._key);
+ Common::String gameid(domain._value.getVal("gameid"));
+ Common::Path path(Common::Path::fromConfig(domain._value.getVal("path")));
printf("Looking at target '%s', gameid '%s', path '%s' ...\n",
name.c_str(), gameid.c_str(), path.toString(Common::Path::kNativeSeparator).c_str());
if (path.empty()) {
@@ -1736,9 +1733,8 @@ static void runDetectorTest() {
DetectedGames candidates = detectionResults.listRecognizedGames();
bool gameidDiffers = false;
- DetectedGames::const_iterator x;
- for (x = candidates.begin(); x != candidates.end(); ++x) {
- gameidDiffers |= !gameid.equalsIgnoreCase(x->gameId);
+ for (const auto &candidate : candidates) {
+ gameidDiffers |= !gameid.equalsIgnoreCase(candidate.gameId);
}
if (candidates.empty()) {
@@ -1759,12 +1755,12 @@ static void runDetectorTest() {
success++;
}
- for (x = candidates.begin(); x != candidates.end(); ++x) {
+ for (auto &candidate : candidates) {
printf(" gameid '%s', desc '%s', language '%s', platform '%s'\n",
- x->gameId.c_str(),
- x->description.c_str(),
- Common::getLanguageDescription(x->language),
- Common::getPlatformDescription(x->platform));
+ candidate.gameId.c_str(),
+ candidate.description.c_str(),
+ Common::getLanguageDescription(candidate.language),
+ Common::getPlatformDescription(candidate.platform));
}
}
int total = domains.size();
@@ -1828,12 +1824,11 @@ void upgradeTargets() {
}
if (candidates.size() > 1) {
// Scan over all candidates, check if there is a unique match for gameid, language and platform
- DetectedGames::iterator x;
int matchesFound = 0;
- for (x = candidates.begin(); x != candidates.end(); ++x) {
- if (x->gameId == gameid && x->language == lang && x->platform == plat) {
+ for (auto &candidate : candidates) {
+ if (candidate.gameId == gameid && candidate.language == lang && candidate.platform == plat) {
matchesFound++;
- g = &(*x);
+ g = &(candidate);
}
}
if (matchesFound != 1) {
@@ -2161,25 +2156,25 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
nullptr
};
- for (Common::StringMap::const_iterator x = settings.begin(); x != settings.end(); ++x) {
- Common::String key(x->_key);
- Common::String value(x->_value);
+ for (const auto &x : settings) {
+ Common::String key(x._key);
+ Common::String value(x._value);
bool skip = false;
for (auto skipKey = skipSettings; *skipKey && !skip; ++skipKey)
- skip = (x->_key == *skipKey);
+ skip = (x._key == *skipKey);
if (skip)
continue;
// Replace any "-" in the key by "_" (e.g. change "save-slot" to "save_slot").
- for (Common::String::iterator c = key.begin(); c != key.end(); ++c)
- if (*c == '-')
- *c = '_';
+ for (auto &c : key)
+ if (c == '-')
+ c = '_';
// Store it into ConfMan.
bool useSessionDomain = false;
for (auto sessionKey = sessionSettings; *sessionKey && !useSessionDomain; ++sessionKey)
- useSessionDomain = (x->_key == *sessionKey);
+ useSessionDomain = (x._key == *sessionKey);
ConfMan.set(key, value, useSessionDomain ? Common::ConfigManager::kSessionDomain : Common::ConfigManager::kTransientDomain);
}
diff --git a/base/main.cpp b/base/main.cpp
index 40b7d2c2270..f1fa30eac0f 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -294,8 +294,8 @@ static Common::Error runGame(const Plugin *enginePlugin, OSystem &system, const
// Initialize any game-specific keymaps
Common::KeymapArray gameKeymaps = metaEngine.initKeymaps(target.c_str());
Common::Keymapper *keymapper = system.getEventManager()->getKeymapper();
- for (uint i = 0; i < gameKeymaps.size(); i++) {
- keymapper->addGameKeymap(gameKeymaps[i]);
+ for (auto &gameKeymap : gameKeymaps) {
+ keymapper->addGameKeymap(gameKeymap);
}
system.applyBackendSettings();
@@ -391,8 +391,8 @@ static void setupKeymapper(OSystem &system) {
// Get the platform-specific global keymap (if it exists)
KeymapArray platformKeymaps = system.getGlobalKeymaps();
- for (uint i = 0; i < platformKeymaps.size(); i++) {
- mapper->addGlobalKeymap(platformKeymaps[i]);
+ for (auto &platformKeymap : platformKeymaps) {
+ mapper->addGlobalKeymap(platformKeymap);
}
}
@@ -443,9 +443,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// Merge additional settings and command with command line. Command line has priority.
if (command.empty())
command = additionalCommand;
- for (Common::StringMap::const_iterator x = additionalSettings.begin(); x != additionalSettings.end(); ++x) {
- if (!settings.contains(x->_key))
- settings[x->_key] = x->_value;
+ for (const auto &additionalSetting : additionalSettings) {
+ if (!settings.contains(additionalSetting._key))
+ settings[additionalSetting._key] = additionalSetting._value;
}
}
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 7e93aea1f11..eca21ae2719 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -203,21 +203,20 @@ PluginList FilePluginProvider::getPlugins() {
if (!pluginsPath.empty())
pluginDirs.push_back(Common::FSNode(pluginsPath));
- Common::FSList::const_iterator dir;
- for (dir = pluginDirs.begin(); dir != pluginDirs.end(); ++dir) {
+ for (const auto &dir : pluginDirs) {
// Load all plugins.
// Scan for all plugins in this directory
Common::FSList files;
- if (!dir->getChildren(files, Common::FSNode::kListFilesOnly)) {
- debug(1, "Couldn't open plugin directory '%s'", dir->getPath().toString().c_str());
+ if (!dir.getChildren(files, Common::FSNode::kListFilesOnly)) {
+ debug(1, "Couldn't open plugin directory '%s'", dir.getPath().toString().c_str());
continue;
} else {
- debug(1, "Reading plugins from plugin directory '%s'", dir->getPath().toString().c_str());
+ debug(1, "Reading plugins from plugin directory '%s'", dir.getPath().toString().c_str());
}
- for (Common::FSList::const_iterator i = files.begin(); i != files.end(); ++i) {
- if (isPluginFilename(*i)) {
- pl.push_back(createPlugin(*i));
+ for (const auto &curFile : files) {
+ if (isPluginFilename(curFile)) {
+ pl.push_back(createPlugin(curFile));
}
}
}
@@ -277,10 +276,8 @@ PluginManager::~PluginManager() {
unloadAllPlugins();
// Delete the plugin providers
- for (ProviderList::iterator pp = _providers.begin();
- pp != _providers.end();
- ++pp) {
- delete *pp;
+ for (auto &pluginProvider : _providers) {
+ delete pluginProvider;
}
}
@@ -293,8 +290,8 @@ PluginManagerUncached::~PluginManagerUncached() {
// They are also referenced from _allEnginePlugins which we clean up here
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, nullptr, false);
- for (PluginList::iterator p = _allEnginePlugins.begin(); p != _allEnginePlugins.end(); ++p) {
- delete *p;
+ for (auto &enginePlugin : _allEnginePlugins) {
+ delete enginePlugin;
}
_allEnginePlugins.clear();
@@ -319,21 +316,19 @@ void PluginManagerUncached::init() {
bool foundDetectPlugin = false;
#endif
- for (ProviderList::iterator pp = _providers.begin();
- pp != _providers.end();
- ++pp) {
- PluginList pl((*pp)->getPlugins());
+ for (auto &pluginProvider : _providers) {
+ PluginList plugins(pluginProvider->getPlugins());
- for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) {
+ for (auto &curPlugin : plugins) {
// This is a 'hack' based on the assumption that we have no sound
// file plugins. Currently this is the case. If it changes, we
// should find a fast way of detecting whether a plugin is a
// music or an engine plugin.
#ifndef DETECTION_STATIC
- if (!foundDetectPlugin && (*pp)->isFilePluginProvider()) {
- Common::Path pName = (*p)->getFileName();
+ if (!foundDetectPlugin && pluginProvider->isFilePluginProvider()) {
+ Common::Path pName = curPlugin->getFileName();
if (pName.baseName().hasSuffixIgnoreCase(detectPluginName)) {
- _detectionPlugin = (*p);
+ _detectionPlugin = curPlugin;
foundDetectPlugin = true;
debug(9, "Detection plugin found!");
continue;
@@ -341,15 +336,15 @@ void PluginManagerUncached::init() {
}
#endif
- if ((*pp)->isFilePluginProvider()) {
- _allEnginePlugins.push_back(*p);
- } else if ((*p)->loadPlugin()) { // and this is the proper method
- if ((*p)->getType() == PLUGIN_TYPE_ENGINE) {
- (*p)->unloadPlugin();
- _allEnginePlugins.push_back(*p);
+ if (pluginProvider->isFilePluginProvider()) {
+ _allEnginePlugins.push_back(curPlugin);
+ } else if (curPlugin->loadPlugin()) { // and this is the proper method
+ if (curPlugin->getType() == PLUGIN_TYPE_ENGINE) {
+ curPlugin->unloadPlugin();
+ _allEnginePlugins.push_back(curPlugin);
} else { // add non-engine plugins to the 'in-memory' list
// these won't ever get unloaded
- addToPluginsInMemList(*p);
+ addToPluginsInMemList(curPlugin);
}
}
}
@@ -378,8 +373,8 @@ bool PluginManagerUncached::loadPluginFromEngineId(const Common::String &engineI
#ifdef PLUGIN_SUFFIX
tentativeEnginePluginFilename += PLUGIN_SUFFIX;
#endif
- for (PluginList::iterator p = _allEnginePlugins.begin(); p != _allEnginePlugins.end(); ++p) {
- Common::Path filename = (*p)->getFileName();
+ for (auto &enginePlugin : _allEnginePlugins) {
+ Common::Path filename = enginePlugin->getFileName();
if (filename.baseName().hasSuffixIgnoreCase(tentativeEnginePluginFilename)) {
if (loadPluginByFileName(filename)) {
return true;
@@ -398,11 +393,10 @@ bool PluginManagerUncached::loadPluginByFileName(const Common::Path &filename) {
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, nullptr, false);
- PluginList::iterator i;
- for (i = _allEnginePlugins.begin(); i != _allEnginePlugins.end(); ++i) {
- if ((*i)->getFileName() == filename && (*i)->loadPlugin()) {
- addToPluginsInMemList(*i);
- _currentPlugin = i;
+ for (auto &enginePlugin : _allEnginePlugins) {
+ if (enginePlugin->getFileName() == filename && enginePlugin->loadPlugin()) {
+ addToPluginsInMemList(enginePlugin);
+ _currentPlugin = &enginePlugin;
return true;
}
}
@@ -501,10 +495,8 @@ bool PluginManagerUncached::loadNextPlugin() {
* one plugin in memory at a time.
**/
void PluginManager::loadAllPlugins() {
- for (ProviderList::iterator pp = _providers.begin();
- pp != _providers.end();
- ++pp) {
- PluginList pl((*pp)->getPlugins());
+ for (auto &pluginProvider : _providers) {
+ PluginList pl(pluginProvider->getPlugins());
Common::for_each(pl.begin(), pl.end(), Common::bind1st(Common::mem_fun(&PluginManager::tryLoadPlugin), this));
}
@@ -515,10 +507,8 @@ void PluginManager::loadAllPlugins() {
*/
PluginList dpl = getPlugins(PLUGIN_TYPE_DETECTION);
_pluginsInMem[PLUGIN_TYPE_ENGINE_DETECTION].clear();
- for (PluginList::iterator it = dpl.begin();
- it != dpl.end();
- ++it) {
- const Detection &detectionConnect = (*it)->get<Detection>();
+ for (auto &plugin : dpl) {
+ const Detection &detectionConnect = plugin->get<Detection>();
const PluginList &pl = detectionConnect.getPlugins();
Common::for_each(pl.begin(), pl.end(), Common::bind1st(Common::mem_fun(&PluginManager::tryLoadPlugin), this));
}
@@ -526,24 +516,20 @@ void PluginManager::loadAllPlugins() {
}
void PluginManager::loadAllPluginsOfType(PluginType type) {
- for (ProviderList::iterator pp = _providers.begin();
- pp != _providers.end();
- ++pp) {
- PluginList pl((*pp)->getPlugins());
- for (PluginList::iterator p = pl.begin();
- p != pl.end();
- ++p) {
- if ((*p)->loadPlugin()) {
- if ((*p)->getType() == type) {
- addToPluginsInMemList((*p));
+ for (auto &pluginProvider : _providers) {
+ PluginList pluginList(pluginProvider->getPlugins());
+ for (auto &plugin : pluginList) {
+ if (plugin->loadPlugin()) {
+ if (plugin->getType() == type) {
+ addToPluginsInMemList(plugin);
} else {
// Plugin is wrong type
- (*p)->unloadPlugin();
- delete (*p);
+ plugin->unloadPlugin();
+ delete plugin;
}
} else {
// Plugin did not load
- delete (*p);
+ delete plugin;
}
}
}
@@ -556,13 +542,13 @@ void PluginManager::unloadAllPlugins() {
void PluginManager::unloadPluginsExcept(PluginType type, const Plugin *plugin, bool deletePlugin /*=true*/) {
Plugin *found = nullptr;
- for (PluginList::iterator p = _pluginsInMem[type].begin(); p != _pluginsInMem[type].end(); ++p) {
- if (*p == plugin) {
- found = *p;
+ for (auto &curPlugin : _pluginsInMem[type]) {
+ if (curPlugin == plugin) {
+ found = curPlugin;
} else {
- (*p)->unloadPlugin();
+ curPlugin->unloadPlugin();
if (deletePlugin) {
- delete *p;
+ delete curPlugin;
}
}
}
@@ -665,10 +651,9 @@ QualifiedGameList EngineManager::findGameInLoadedPlugins(const Common::String &g
const PluginList &plugins = getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
QualifiedGameList results;
- PluginList::const_iterator iter;
- for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
- const MetaEngineDetection &engine = (*iter)->get<MetaEngineDetection>();
+ for (const auto &plugin : plugins) {
+ const MetaEngineDetection &engine = plugin->get<MetaEngineDetection>();
DebugMan.addAllDebugChannels(engine.getDebugChannels());
PlainGameDescriptor pluginResult = engine.findGame(gameId.c_str());
@@ -682,20 +667,18 @@ QualifiedGameList EngineManager::findGameInLoadedPlugins(const Common::String &g
DetectionResults EngineManager::detectGames(const Common::FSList &fslist, uint32 skipADFlags, bool skipIncomplete) {
DetectedGames candidates;
- PluginList plugins;
- PluginList::const_iterator iter;
// MetaEngines are always loaded into memory, so, get them and
// run detection for all of them.
- plugins = getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
+ PluginList plugins = getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
// Clear md5 cache before each detection starts, just in case.
ADCacheMan.clear();
// Iterate over all known games and for each check if it might be
// the game in the presented directory.
- for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
- MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+ for (const auto &plugin : plugins) {
+ MetaEngineDetection &metaEngine = plugin->get<MetaEngineDetection>();
// set the debug flags
DebugMan.addAllDebugChannels(metaEngine.getDebugChannels());
DetectedGames engineCandidates = metaEngine.detectGames(fslist, skipADFlags, skipIncomplete);
@@ -759,9 +742,8 @@ Common::String EngineManager::createTargetForGame(const DetectedGame &game) {
addStringToConf("guioptions", game.getGUIOptions(), domain);
// Add any extra configuration keys
- for (Common::StringMap::iterator i = game._extraConfigEntries.begin();
- i != game._extraConfigEntries.end(); ++i)
- addStringToConf((*i)._key, (*i)._value, domain);
+ for (auto &extraConfigEntry : game._extraConfigEntries)
+ addStringToConf(extraConfigEntry._key, extraConfigEntry._value, domain);
// TODO: Setting the description field here has the drawback
// that the user does never notice when we upgrade our descriptions.
@@ -779,9 +761,9 @@ Common::String EngineManager::createTargetForGame(const DetectedGame &game) {
const Plugin *EngineManager::findDetectionPlugin(const Common::String &engineId) const {
const PluginList &plugins = getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); iter++)
- if (engineId == (*iter)->get<MetaEngineDetection>().getName())
- return *iter;
+ for (const auto &plugin : plugins)
+ if (engineId == plugin->get<MetaEngineDetection>().getName())
+ return plugin;
return nullptr;
}
@@ -789,9 +771,9 @@ const Plugin *EngineManager::findDetectionPlugin(const Common::String &engineId)
const Plugin *PluginManager::findLoadedPlugin(const Common::String &engineId) {
const PluginList &plugins = getPlugins(PLUGIN_TYPE_ENGINE);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); iter++)
- if (engineId == (*iter)->get<MetaEngine>().getName())
- return *iter;
+ for (const auto &plugin : plugins)
+ if (engineId == plugin->get<MetaEngine>().getName())
+ return plugin;
return nullptr;
}
@@ -985,9 +967,8 @@ const PluginList &ScalerManager::getPlugins() const {
uint ScalerManager::getMaxExtraPixels() const {
uint maxPixels = 0;
PluginList plugins = getPlugins();
- PluginList::iterator i = plugins.begin();
- for (; i != plugins.end(); ++i) {
- uint n = (*i)->get<ScalerPluginObject>().extraPixels();
+ for (auto &plugin : plugins) {
+ uint n = plugin->get<ScalerPluginObject>().extraPixels();
if (n > maxPixels) {
maxPixels = n;
}
@@ -997,9 +978,9 @@ uint ScalerManager::getMaxExtraPixels() const {
Plugin *ScalerManager::findScalerPlugin(const char *name) const {
const PluginList &plugins = getPlugins();
- for (PluginList::const_iterator i = plugins.begin(); i != plugins.end(); ++i) {
- if (!strcmp((*i)->get<ScalerPluginObject>().getName(), name)) {
- return *i;
+ for (const auto &plugin : plugins) {
+ if (!strcmp(plugin->get<ScalerPluginObject>().getName(), name)) {
+ return plugin;
}
}
@@ -1010,8 +991,8 @@ uint ScalerManager::findScalerPluginIndex(const char *name) const {
const PluginList &plugins = getPlugins();
uint index = 0;
- for (PluginList::const_iterator i = plugins.begin(); i != plugins.end(); ++i) {
- if (!strcmp((*i)->get<ScalerPluginObject>().getName(), name)) {
+ for (auto &plugin : plugins) {
+ if (!strcmp(plugin->get<ScalerPluginObject>().getName(), name)) {
return index;
}
index++;
Commit: 177f04349a685cde740fbd7e29a7b432504ac47c
https://github.com/scummvm/scummvm/commit/177f04349a685cde740fbd7e29a7b432504ac47c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
COMMON: Use C++ 11 range-based for loops
Changed paths:
common/archive.cpp
common/config-manager.cpp
common/events.cpp
common/file.cpp
common/formats/ini-file.cpp
common/formats/winexe_ne.cpp
common/fs.cpp
common/path.cpp
common/recorderfile.cpp
common/translation.cpp
common/zip-set.cpp
diff --git a/common/archive.cpp b/common/archive.cpp
index db488ddb50a..27494b41dd2 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -107,12 +107,11 @@ int Archive::listMatchingMembers(ArchiveMemberList &list, const Path &pattern, b
const char *wildcardExclusions = matchPathComponents ? NULL : pathSepString;
- ArchiveMemberList::const_iterator it = allNames.begin();
- for (; it != allNames.end(); ++it) {
+ for (const auto &archive : allNames) {
// TODO: We match case-insenstivie for now, our API does not define whether that's ok or not though...
// For our use case case-insensitive is probably what we want to have though.
- if ((*it)->getName().matchString(patternString, true, wildcardExclusions)) {
- list.push_back(*it);
+ if (archive->getName().matchString(patternString, true, wildcardExclusions)) {
+ list.push_back(archive);
matches++;
}
}
@@ -185,13 +184,13 @@ bool Archive::getChildren(const Common::Path &path, Common::Array<Common::String
if (!_fileMap.contains(pathNorm) && !_directoryMap.contains(pathNorm))
return false;
if (mode == kListDirectoriesOnly || mode == kListAll)
- for (SubfileSet::iterator its = _directoryMap[pathNorm].begin(); its != _directoryMap[pathNorm].end(); its++)
- if (hidden || its->_key.firstChar() != '.')
- list.push_back(its->_key);
+ for (auto &dir : _directoryMap[pathNorm])
+ if (hidden || dir._key.firstChar() != '.')
+ list.push_back(dir._key);
if (mode == kListFilesOnly || mode == kListAll)
- for (SubfileSet::iterator its = _fileMap[pathNorm].begin(); its != _fileMap[pathNorm].end(); its++)
- if (hidden || its->_key.firstChar() != '.')
- list.push_back(its->_key);
+ for (auto &file : _fileMap[pathNorm])
+ if (hidden || file._key.firstChar() != '.')
+ list.push_back(file._key);
return true;
}
@@ -207,9 +206,9 @@ void Archive::prepareMaps() const {
ArchiveMemberList list;
listMembers(list);
- for (ArchiveMemberList::iterator it = list.begin(); it != list.end(); it++) {
- Common::Path cur = (*it)->getPathInArchive().normalize();
- if (!(*it)->isDirectory()) {
+ for (auto &archive : list) {
+ Common::Path cur = archive->getPathInArchive().normalize();
+ if (!archive->isDirectory()) {
Common::Path parent = cur.getParent().normalize();
Common::String fname = cur.baseName();
_fileMap[parent][fname] = true;
@@ -224,10 +223,9 @@ void Archive::prepareMaps() const {
}
}
- for (AllfileMap::iterator itd = _directoryMap.begin();
- itd != _directoryMap.end(); itd++) {
- for (SubfileSet::iterator its = itd->_value.begin(); its != itd->_value.end(); its++) {
- _fileMap[itd->_key].erase(its->_key);
+ for (auto &dir : _directoryMap) {
+ for (auto &file : dir._value) {
+ _fileMap[dir._key].erase(file._key);
}
}
}
@@ -398,8 +396,8 @@ void SearchSet::addSubDirectoriesMatching(const FSNode &directory, String origPa
MatchList multipleMatches;
MatchList::iterator matchIter;
- for (FSList::const_iterator i = subDirs.begin(); i != subDirs.end(); ++i) {
- String name = i->getName();
+ for (const auto &subDir : subDirs) {
+ String name = subDir.getName();
if (matchString(name.c_str(), pattern.c_str(), ignoreCase)) {
matchIter = multipleMatches.find(name);
@@ -417,9 +415,9 @@ void SearchSet::addSubDirectoriesMatching(const FSNode &directory, String origPa
}
if (nextPattern.empty())
- addDirectory(name, *i, priority, depth, flat);
+ addDirectory(name, subDir, priority, depth, flat);
else
- addSubDirectoriesMatching(*i, nextPattern, ignoreCase, priority, depth, flat);
+ addSubDirectoriesMatching(subDir, nextPattern, ignoreCase, priority, depth, flat);
}
}
}
@@ -447,9 +445,9 @@ Archive *SearchSet::getArchive(const String &name) const {
}
void SearchSet::clear() {
- for (ArchiveNodeList::iterator i = _list.begin(); i != _list.end(); ++i) {
- if (i->_autoFree)
- delete i->_arc;
+ for (auto &archive : _list) {
+ if (archive._autoFree)
+ delete archive._arc;
}
_list.clear();
@@ -475,9 +473,8 @@ bool SearchSet::hasFile(const Path &path) const {
if (path.empty())
return false;
- ArchiveNodeList::const_iterator it = _list.begin();
- for (; it != _list.end(); ++it) {
- if (it->_arc->hasFile(path))
+ for (const auto &archive : _list) {
+ if (archive._arc->hasFile(path))
return true;
}
@@ -509,11 +506,10 @@ bool SearchSet::isPathDirectory(const Path &path) const {
bool SearchSet::getChildren(const Common::Path &path, Common::Array<Common::String> &list, ListMode mode, bool hidden) const {
bool hasAny = false;
- ArchiveNodeList::const_iterator it = _list.begin();
list.clear();
- for (; it != _list.end(); ++it) {
+ for (const auto &archive : _list) {
Common::Array<Common::String> tmpList;
- if (it->_arc->getChildren(path, tmpList, mode, hidden)) {
+ if (archive._arc->getChildren(path, tmpList, mode, hidden)) {
list.push_back(tmpList);
hasAny = true;
}
@@ -525,9 +521,8 @@ bool SearchSet::getChildren(const Common::Path &path, Common::Array<Common::Stri
int SearchSet::listMatchingMembers(ArchiveMemberList &list, const Path &pattern, bool matchPathComponents) const {
int matches = 0;
- ArchiveNodeList::const_iterator it = _list.begin();
- for (; it != _list.end(); ++it)
- matches += it->_arc->listMatchingMembers(list, pattern, matchPathComponents);
+ for (const auto &archive : _list)
+ matches += archive._arc->listMatchingMembers(list, pattern, matchPathComponents);
return matches;
}
@@ -535,12 +530,11 @@ int SearchSet::listMatchingMembers(ArchiveMemberList &list, const Path &pattern,
int SearchSet::listMatchingMembers(ArchiveMemberDetailsList &list, const Path &pattern, bool matchPathComponents) const {
int matches = 0;
- ArchiveNodeList::const_iterator it = _list.begin();
- for (; it != _list.end(); ++it) {
+ for (const auto &archive : _list) {
List<ArchiveMemberPtr> matchingMembers;
- matches += it->_arc->listMatchingMembers(matchingMembers, pattern, matchPathComponents);
+ matches += archive._arc->listMatchingMembers(matchingMembers, pattern, matchPathComponents);
for (ArchiveMemberPtr &member : matchingMembers)
- list.push_back(ArchiveMemberDetails(member, it->_name));
+ list.push_back(ArchiveMemberDetails(member, archive._name));
}
return matches;
@@ -549,9 +543,8 @@ int SearchSet::listMatchingMembers(ArchiveMemberDetailsList &list, const Path &p
int SearchSet::listMembers(ArchiveMemberList &list) const {
int matches = 0;
- ArchiveNodeList::const_iterator it = _list.begin();
- for (; it != _list.end(); ++it)
- matches += it->_arc->listMembers(list);
+ for (const auto &archive : _list)
+ matches += archive._arc->listMembers(list);
return matches;
}
@@ -560,13 +553,12 @@ const ArchiveMemberPtr SearchSet::getMember(const Path &path, Archive **containe
if (path.empty())
return ArchiveMemberPtr();
- ArchiveNodeList::const_iterator it = _list.begin();
- for (; it != _list.end(); ++it) {
- if (it->_arc->hasFile(path)) {
+ for (const auto &archive : _list) {
+ if (archive._arc->hasFile(path)) {
if (container) {
- *container = it->_arc;
+ *container = archive._arc;
}
- return it->_arc->getMember(path);
+ return archive._arc->getMember(path);
}
}
@@ -581,9 +573,8 @@ SeekableReadStream *SearchSet::createReadStreamForMember(const Path &path) const
if (path.empty())
return nullptr;
- ArchiveNodeList::const_iterator it = _list.begin();
- for (; it != _list.end(); ++it) {
- SeekableReadStream *stream = it->_arc->createReadStreamForMember(path);
+ for (const auto &archive : _list) {
+ SeekableReadStream *stream = archive._arc->createReadStreamForMember(path);
if (stream)
return stream;
}
@@ -595,9 +586,8 @@ SeekableReadStream *SearchSet::createReadStreamForMemberAltStream(const Path &pa
if (path.empty())
return nullptr;
- ArchiveNodeList::const_iterator it = _list.begin();
- for (; it != _list.end(); ++it) {
- SeekableReadStream *stream = it->_arc->createReadStreamForMemberAltStream(path, altStreamType);
+ for (const auto &archive : _list) {
+ SeekableReadStream *stream = archive._arc->createReadStreamForMemberAltStream(path, altStreamType);
if (stream)
return stream;
}
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index 1bd4c0cdda1..379cfeffe7d 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -316,27 +316,24 @@ void ConfigManager::flushToDisk() {
writeDomain(*stream, kCloudDomain, _cloudDomain);
#endif
- DomainMap::const_iterator d;
-
// Write the miscellaneous domains next
- for (d = _miscDomains.begin(); d != _miscDomains.end(); ++d) {
- writeDomain(*stream, d->_key, d->_value);
+ for (const auto &misc : _miscDomains) {
+ writeDomain(*stream, misc._key, misc._value);
}
// First write the domains in _domainSaveOrder, in that order.
// Note: It's possible for _domainSaveOrder to list domains which
// are not present anymore, so we validate each name.
- Array<String>::const_iterator i;
- for (i = _domainSaveOrder.begin(); i != _domainSaveOrder.end(); ++i) {
- if (_gameDomains.contains(*i)) {
- writeDomain(*stream, *i, _gameDomains[*i]);
+ for (const auto &domain : _domainSaveOrder) {
+ if (_gameDomains.contains(domain)) {
+ writeDomain(*stream, domain, _gameDomains[domain]);
}
}
// Now write the domains which haven't been written yet
- for (d = _gameDomains.begin(); d != _gameDomains.end(); ++d) {
- if (find(_domainSaveOrder.begin(), _domainSaveOrder.end(), d->_key) == _domainSaveOrder.end())
- writeDomain(*stream, d->_key, d->_value);
+ for (auto &domain : _gameDomains) {
+ if (find(_domainSaveOrder.begin(), _domainSaveOrder.end(), domain._key) == _domainSaveOrder.end())
+ writeDomain(*stream, domain._key, domain._value);
}
delete stream;
@@ -368,18 +365,17 @@ void ConfigManager::writeDomain(WriteStream &stream, const String &name, const D
stream.writeByte('\n');
// Write all key/value pairs in this domain, including comments
- Domain::const_iterator x;
- for (x = domain.begin(); x != domain.end(); ++x) {
- if (!x->_value.empty()) {
+ for (const auto &x : domain) {
+ if (!x._value.empty()) {
// Write comment (if any)
- if (domain.hasKVComment(x->_key)) {
- comment = domain.getKVComment(x->_key);
+ if (domain.hasKVComment(x._key)) {
+ comment = domain.getKVComment(x._key);
stream.writeString(comment);
}
// Write the key/value pair
- stream.writeString(x->_key);
+ stream.writeString(x._key);
stream.writeByte('=');
- stream.writeString(x->_value);
+ stream.writeString(x._value);
stream.writeByte('\n');
}
}
@@ -787,9 +783,8 @@ void ConfigManager::renameDomain(const String &oldName, const String &newName, D
// _gameDomains[newName].merge(_gameDomains[oldName]);
Domain &oldDom = map[oldName];
Domain &newDom = map[newName];
- Domain::const_iterator iter;
- for (iter = oldDom.begin(); iter != oldDom.end(); ++iter)
- newDom.setVal(iter->_key, iter->_value);
+ for (const auto &dom : oldDom)
+ newDom.setVal(dom._key, dom._value);
map.erase(oldName);
}
diff --git a/common/events.cpp b/common/events.cpp
index 64f733a581b..fbbf462d822 100644
--- a/common/events.cpp
+++ b/common/events.cpp
@@ -52,19 +52,19 @@ EventDispatcher::EventDispatcher() {
}
EventDispatcher::~EventDispatcher() {
- for (List<MapperEntry>::iterator i = _mappers.begin(); i != _mappers.end(); ++i) {
- if (i->autoFree)
- delete i->mapper;
+ for (auto &mapper : _mappers) {
+ if (mapper.autoFree)
+ delete mapper.mapper;
}
- for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
- if (i->autoFree)
- delete i->source;
+ for (auto &source : _sources) {
+ if (source.autoFree)
+ delete source.source;
}
- for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
- if (i->autoFree)
- delete i->observer;
+ for (auto &observer : _observers) {
+ if (observer.autoFree)
+ delete observer.observer;
}
}
@@ -74,13 +74,13 @@ void EventDispatcher::dispatch() {
dispatchPoll();
- for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
- if (i->ignore)
+ for (auto &source : _sources) {
+ if (source.ignore)
continue;
- while (i->source->pollEvent(event)) {
+ while (source.source->pollEvent(event)) {
// We only try to process the events via the setup event mapper, when
// we have a setup mapper and when the event source allows mapping.
- if (i->source->allowMapping()) {
+ if (source.source->allowMapping()) {
bool matchedAction = false;
// Backends may not produce directly action event types, those are meant
@@ -90,15 +90,14 @@ void EventDispatcher::dispatch() {
assert(event.type != EVENT_CUSTOM_ENGINE_ACTION_START);
assert(event.type != EVENT_CUSTOM_ENGINE_ACTION_END);
- for (List<MapperEntry>::iterator m = _mappers.begin(); m != _mappers.end(); ++m) {
+ for (auto &m : _mappers) {
if (!mappedEvents.empty())
mappedEvents.clear();
- if (!m->mapper->mapEvent(event, mappedEvents))
+ if (!m.mapper->mapEvent(event, mappedEvents))
continue;
- for (List<Event>::iterator j = mappedEvents.begin(); j != mappedEvents.end(); ++j) {
- const Event mappedEvent = *j;
+ for (auto &mappedEvent : mappedEvents) {
dispatchEvent(mappedEvent);
}
@@ -117,10 +116,10 @@ void EventDispatcher::dispatch() {
void EventDispatcher::clearEvents() {
Event event;
- for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
- if (i->ignore)
+ for (auto &source : _sources) {
+ if (source.ignore)
continue;
- while (i->source->pollEvent(event)) {}
+ while (source.source->pollEvent(event)) {}
}
}
@@ -169,8 +168,8 @@ void EventDispatcher::unregisterSource(EventSource *source) {
}
void EventDispatcher::ignoreSources(bool ignore) {
- for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
- i->ignore = ignore;
+ for (auto &source : _sources) {
+ source.ignore = ignore;
}
}
@@ -206,16 +205,16 @@ void EventDispatcher::unregisterObserver(EventObserver *obs) {
}
void EventDispatcher::dispatchEvent(const Event &event) {
- for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
- if (i->observer->notifyEvent(event))
+ for (auto &observer : _observers) {
+ if (observer.observer->notifyEvent(event))
break;
}
}
void EventDispatcher::dispatchPoll() {
- for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
- if (i->poll)
- i->observer->notifyPoll();
+ for (auto &observer : _observers) {
+ if (observer.poll)
+ observer.observer->notifyPoll();
}
}
diff --git a/common/file.cpp b/common/file.cpp
index c81f1763f02..62bfc0466cf 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -166,8 +166,8 @@ bool DumpFile::open(const Path &filename, bool createPath) {
StringArray components = dirname.splitComponents();
Common::Path subpath;
- for (StringArray::iterator it = components.begin(); it != components.end(); ++it) {
- subpath.appendInPlace(*it, Common::Path::kNoSeparator);
+ for (auto &component : components) {
+ subpath.appendInPlace(component, Common::Path::kNoSeparator);
// Add a trailing path separator
subpath.appendInPlace("/");
node = g_system->getFilesystemFactory()->makeFileNodePath(subpath.toString(Common::Path::kNativeSeparator));
diff --git a/common/formats/ini-file.cpp b/common/formats/ini-file.cpp
index a45ca600a96..a8826b95ab7 100644
--- a/common/formats/ini-file.cpp
+++ b/common/formats/ini-file.cpp
@@ -235,28 +235,28 @@ bool INIFile::saveToSaveFile(const String &filename) {
}
bool INIFile::saveToStream(WriteStream &stream) {
- for (List<Section>::iterator i = _sections.begin(); i != _sections.end(); ++i) {
+ for (auto &curSection : _sections) {
// Write out the section comment, if any
- if (! i->comment.empty()) {
- stream.writeString(i->comment);
+ if (!curSection.comment.empty()) {
+ stream.writeString(curSection.comment);
}
// Write out the section name
stream.writeByte('[');
- stream.writeString(i->name);
+ stream.writeString(curSection.name);
stream.writeByte(']');
stream.writeByte('\n');
// Write out the key/value pairs
- for (List<KeyValue>::iterator kv = i->keys.begin(); kv != i->keys.end(); ++kv) {
+ for (auto &kv : curSection.keys) {
// Write out the comment, if any
- if (! kv->comment.empty()) {
- stream.writeString(kv->comment);
+ if (!kv.comment.empty()) {
+ stream.writeString(kv.comment);
}
// Write out the key/value pair
- stream.writeString(kv->key);
+ stream.writeString(kv.key);
stream.writeByte('=');
- stream.writeString(kv->value);
+ stream.writeString(kv.value);
stream.writeByte('\n');
}
}
@@ -426,18 +426,18 @@ const INIFile::SectionKeyList INIFile::getKeys(const String §ion) const {
}
INIFile::Section *INIFile::getSection(const String §ion) {
- for (List<Section>::iterator i = _sections.begin(); i != _sections.end(); ++i) {
- if (section.equalsIgnoreCase(i->name)) {
- return &(*i);
+ for (auto &curSection : _sections) {
+ if (section.equalsIgnoreCase(curSection.name)) {
+ return &curSection;
}
}
return nullptr;
}
const INIFile::Section *INIFile::getSection(const String §ion) const {
- for (List<Section>::const_iterator i = _sections.begin(); i != _sections.end(); ++i) {
- if (section.equalsIgnoreCase(i->name)) {
- return &(*i);
+ for (const auto &curSection : _sections) {
+ if (section.equalsIgnoreCase(curSection.name)) {
+ return &curSection;
}
}
return nullptr;
@@ -448,18 +448,18 @@ bool INIFile::Section::hasKey(const String &key) const {
}
const INIFile::KeyValue* INIFile::Section::getKey(const String &key) const {
- for (List<KeyValue>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
- if (key.equalsIgnoreCase(i->key)) {
- return &(*i);
+ for (const auto &curKey : keys) {
+ if (key.equalsIgnoreCase(curKey.key)) {
+ return &curKey;
}
}
return nullptr;
}
void INIFile::Section::setKey(const String &key, const String &value) {
- for (List<KeyValue>::iterator i = keys.begin(); i != keys.end(); ++i) {
- if (key.equalsIgnoreCase(i->key)) {
- i->value = value;
+ for (auto &curKey : keys) {
+ if (key.equalsIgnoreCase(curKey.key)) {
+ curKey.value = value;
return;
}
}
diff --git a/common/formats/winexe_ne.cpp b/common/formats/winexe_ne.cpp
index cef2020cce7..502ec0c653f 100644
--- a/common/formats/winexe_ne.cpp
+++ b/common/formats/winexe_ne.cpp
@@ -256,14 +256,14 @@ String NEResources::getResourceString(SeekableReadStream &exe, uint32 offset) {
}
const NEResources::Resource *NEResources::findResource(const WinResourceID &type, const WinResourceID &id) const {
- for (List<Resource>::const_iterator it = _resources.begin(); it != _resources.end(); ++it) {
- if (it->type == type &&
- (it->id == id ||
+ for (const auto &resource : _resources) {
+ if (resource.type == type &&
+ (resource.id == id ||
(!_nameTable.empty() &&
- _nameTable.contains(it->type) &&
- _nameTable[it->type].contains(it->id) &&
- _nameTable[it->type][it->id] == id.toString())))
- return &*it;
+ _nameTable.contains(resource.type) &&
+ _nameTable[resource.type].contains(resource.id) &&
+ _nameTable[resource.type][resource.id] == id.toString())))
+ return &resource;
}
return nullptr;
diff --git a/common/fs.cpp b/common/fs.cpp
index c8360bec17a..df83cfa273e 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -149,14 +149,14 @@ bool FSNode::getChildren(FSList &fslist, ListMode mode, bool hidden) const {
if (!_realNode || !_realNode->isDirectory())
return false;
- AbstractFSList tmp;
+ AbstractFSList nodeList;
- if (!_realNode->getChildren(tmp, mode, hidden))
+ if (!_realNode->getChildren(nodeList, mode, hidden))
return false;
fslist.clear();
- for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i) {
- fslist.push_back(FSNode(*i));
+ for (auto &node : nodeList) {
+ fslist.push_back(FSNode(node));
}
return true;
@@ -430,12 +430,11 @@ void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const Path& pr
FSList list;
node.getChildren(list, FSNode::kListAll);
- FSList::iterator it = list.begin();
- for ( ; it != list.end(); ++it) {
- Path name = prefix.appendComponent(it->getRealName());
+ for (auto &curNode : list) {
+ Path name = prefix.appendComponent(curNode.getRealName());
// since the hashmap is case insensitive, we need to check for clashes when caching
- if (it->isDirectory()) {
+ if (curNode.isDirectory()) {
if (!_flat && _subDirCache.contains(name)) {
// Always warn in this case as it's when there are 2 directories at the same place with different case
// That means a problem in user installation as lookups are always done case insensitive
@@ -448,9 +447,9 @@ void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const Path& pr
Common::toPrintable(name.toString(Common::Path::kNativeSeparator)).c_str());
}
}
- cacheDirectoryRecursive(*it, depth - 1, _flat ? prefix : name);
- _subDirCache[name] = *it;
- _dirMapCache[prefix].push_back(it->getRealName());
+ cacheDirectoryRecursive(curNode, depth - 1, _flat ? prefix : name);
+ _subDirCache[name] = curNode;
+ _dirMapCache[prefix].push_back(curNode.getRealName());
}
} else {
if (_fileCache.contains(name)) {
@@ -459,8 +458,8 @@ void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const Path& pr
Common::toPrintable(name.toString(Common::Path::kNativeSeparator)).c_str());
}
} else {
- _fileCache[name] = *it;
- _fileMapCache[prefix].push_back(it->getRealName());
+ _fileCache[name] = curNode;
+ _fileMapCache[prefix].push_back(curNode.getRealName());
}
}
}
@@ -486,18 +485,18 @@ bool FSDirectory::getChildren(const Common::Path &path, Common::Array<Common::St
int matches = 0;
if (mode == kListDirectoriesOnly || mode == kListAll) {
- for (Array<String>::const_iterator it = _dirMapCache[pathNormalized].begin(); it != _dirMapCache[pathNormalized].end(); ++it) {
- if (hidden || it->firstChar() != '.') {
- list.push_back(*it);
+ for (const auto &dir : _dirMapCache[pathNormalized]) {
+ if (hidden || dir.firstChar() != '.') {
+ list.push_back(dir);
matches++;
}
}
}
if (mode == kListFilesOnly || mode == kListAll) {
- for (Array<String>::const_iterator it = _fileMapCache[pathNormalized].begin(); it != _fileMapCache[pathNormalized].end(); ++it) {
- if (hidden || it->firstChar() != '.') {
- list.push_back(*it);
+ for (const auto &file : _fileMapCache[pathNormalized]) {
+ if (hidden || file.firstChar() != '.') {
+ list.push_back(file);
matches++;
}
}
@@ -522,16 +521,16 @@ int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const Path &patter
patternStr = pattern.toString(pathSep);
auto addMatchingToList = [&](const NodeCache &nodeCache) {
- for (NodeCache::const_iterator it = nodeCache.begin(); it != nodeCache.end(); ++it) {
+ for (const auto &it : nodeCache) {
bool isMatch;
if (matchPathComponents) {
- Common::String keyStr = it->_key.toString(pathSep);
+ Common::String keyStr = it._key.toString(pathSep);
isMatch = keyStr.matchString(patternStr, true, wildCardExclusions);
} else
- isMatch = it->_key.matchPattern(pattern);
+ isMatch = it._key.matchPattern(pattern);
if (isMatch) {
- list.push_back(ArchiveMemberPtr(new FSDirectoryFile(it->_key, it->_value)));
+ list.push_back(ArchiveMemberPtr(new FSDirectoryFile(it._key, it._value)));
++matches;
}
}
@@ -553,14 +552,14 @@ int FSDirectory::listMembers(ArchiveMemberList &list) const {
ensureCached();
int files = 0;
- for (NodeCache::const_iterator it = _fileCache.begin(); it != _fileCache.end(); ++it) {
- list.push_back(ArchiveMemberPtr(new FSDirectoryFile(it->_key, it->_value)));
+ for (const auto &it : _fileCache) {
+ list.push_back(ArchiveMemberPtr(new FSDirectoryFile(it._key, it._value)));
++files;
}
if (_includeDirectories) {
- for (NodeCache::const_iterator it = _subDirCache.begin(); it != _subDirCache.end(); ++it) {
- list.push_back(ArchiveMemberPtr(new FSDirectoryFile(it->_key, it->_value)));
+ for (const auto &it : _subDirCache) {
+ list.push_back(ArchiveMemberPtr(new FSDirectoryFile(it._key, it._value)));
++files;
}
}
diff --git a/common/path.cpp b/common/path.cpp
index 65e451fea65..fc4c9aa2f0e 100644
--- a/common/path.cpp
+++ b/common/path.cpp
@@ -810,18 +810,18 @@ Path Path::normalize() const {
// Finally, assemble all components back into a path
bool addSep = hasLeadingSeparator;
- for (StringArray::const_iterator it = comps.begin(); it != comps.end(); it++) {
+ for (const auto &comp : comps) {
if (addSep) {
result._str += SEPARATOR;
}
addSep = true;
if (needEscape) {
- escape(result._str, kNoSeparator, it->c_str(), it->c_str() + it->size());
+ escape(result._str, kNoSeparator, comp.c_str(), comp.c_str() + comp.size());
} else if (needUnescape) {
- result._str += unescape(kNoSeparator, it->c_str(), it->c_str() + it->size());
+ result._str += unescape(kNoSeparator, comp.c_str(), comp.c_str() + comp.size());
} else {
- result._str += *it;
+ result._str += comp;
}
}
diff --git a/common/recorderfile.cpp b/common/recorderfile.cpp
index bbd2c360fe5..01713fae19b 100644
--- a/common/recorderfile.cpp
+++ b/common/recorderfile.cpp
@@ -525,37 +525,37 @@ void PlaybackFile::writeHeaderSection() {
void PlaybackFile::writeGameHash() {
uint32 hashSectionSize = 0;
- for (StringMap::iterator i = _header.hashRecords.begin(); i != _header.hashRecords.end(); ++i) {
- hashSectionSize = hashSectionSize + i->_key.size() + i->_value.size() + 8;
+ for (auto &record : _header.hashRecords) {
+ hashSectionSize = hashSectionSize + record._key.size() + record._value.size() + 8;
}
if (_header.hashRecords.size() == 0) {
return;
}
_writeStream->writeUint32BE(kHashSectionTag);
_writeStream->writeUint32BE(hashSectionSize);
- for (StringMap::iterator i = _header.hashRecords.begin(); i != _header.hashRecords.end(); ++i) {
+ for (auto &record : _header.hashRecords) {
_writeStream->writeUint32BE(kHashRecordTag);
- _writeStream->writeUint32BE(i->_key.size() + i->_value.size());
- _writeStream->writeString(i->_key);
- _writeStream->writeString(i->_value);
+ _writeStream->writeUint32BE(record._key.size() + record._value.size());
+ _writeStream->writeString(record._key);
+ _writeStream->writeString(record._value);
}
}
void PlaybackFile::writeRandomRecords() {
uint32 randomSectionSize = 0;
- for (RandomSeedsDictionary::iterator i = _header.randomSourceRecords.begin(); i != _header.randomSourceRecords.end(); ++i) {
- randomSectionSize = randomSectionSize + i->_key.size() + 12;
+ for (auto &record : _header.randomSourceRecords) {
+ randomSectionSize = randomSectionSize + record._key.size() + 12;
}
if (_header.randomSourceRecords.size() == 0) {
return;
}
_writeStream->writeUint32BE(kRandomSectionTag);
_writeStream->writeUint32BE(randomSectionSize);
- for (RandomSeedsDictionary::iterator i = _header.randomSourceRecords.begin(); i != _header.randomSourceRecords.end(); ++i) {
+ for (auto &record : _header.randomSourceRecords) {
_writeStream->writeUint32BE(kRandomRecordTag);
- _writeStream->writeUint32BE(i->_key.size() + 4);
- _writeStream->writeString(i->_key);
- _writeStream->writeUint32BE(i->_value);
+ _writeStream->writeUint32BE(record._key.size() + 4);
+ _writeStream->writeString(record._key);
+ _writeStream->writeUint32BE(record._value);
}
}
@@ -641,19 +641,19 @@ void PlaybackFile::writeEvent(const RecorderEvent &event) {
void PlaybackFile::writeGameSettings() {
_writeStream->writeUint32BE(kSettingsSectionTag);
uint32 settingsSectionSize = 0;
- for (StringMap::iterator i = _header.settingsRecords.begin(); i != _header.settingsRecords.end(); ++i) {
- settingsSectionSize += i->_key.size() + i->_value.size() + 24;
+ for (auto &record : _header.settingsRecords) {
+ settingsSectionSize += record._key.size() + record._value.size() + 24;
}
_writeStream->writeUint32BE(settingsSectionSize);
- for (StringMap::iterator i = _header.settingsRecords.begin(); i != _header.settingsRecords.end(); ++i) {
+ for (auto &record : _header.settingsRecords) {
_writeStream->writeUint32BE(kSettingsRecordTag);
- _writeStream->writeUint32BE(i->_key.size() + i->_value.size() + 16);
+ _writeStream->writeUint32BE(record._key.size() + record._value.size() + 16);
_writeStream->writeUint32BE(kSettingsRecordKeyTag);
- _writeStream->writeUint32BE(i->_key.size());
- _writeStream->writeString(i->_key);
+ _writeStream->writeUint32BE(record._key.size());
+ _writeStream->writeString(record._key);
_writeStream->writeUint32BE(kSettingsRecordValueTag);
- _writeStream->writeUint32BE(i->_value.size());
- _writeStream->writeString(i->_value);
+ _writeStream->writeUint32BE(record._value.size());
+ _writeStream->writeString(record._value);
}
}
@@ -764,23 +764,23 @@ void PlaybackFile::addSaveFile(const String &fileName, InSaveFile *saveStream) {
void PlaybackFile::writeSaveFilesSection() {
uint size = 0;
- for (HashMap<String, SaveFileBuffer>::iterator i = _header.saveFiles.begin(); i != _header.saveFiles.end(); ++i) {
- size += i->_value.size + i->_key.size() + 24;
+ for (auto &saveFile :_header.saveFiles) {
+ size += saveFile._value.size + saveFile._key.size() + 24;
}
if (size == 0) {
return;
}
_writeStream->writeSint32BE(kSaveTag);
_writeStream->writeSint32BE(size);
- for (HashMap<String, SaveFileBuffer>::iterator i = _header.saveFiles.begin(); i != _header.saveFiles.end(); ++i) {
+ for (auto &saveFile : _header.saveFiles) {
_writeStream->writeSint32BE(kSaveRecordTag);
- _writeStream->writeSint32BE(i->_key.size() + i->_value.size + 16);
+ _writeStream->writeSint32BE(saveFile._key.size() + saveFile._value.size + 16);
_writeStream->writeSint32BE(kSaveRecordNameTag);
- _writeStream->writeSint32BE(i->_key.size());
- _writeStream->writeString(i->_key);
+ _writeStream->writeSint32BE(saveFile._key.size());
+ _writeStream->writeString(saveFile._key);
_writeStream->writeSint32BE(kSaveRecordBufferTag);
- _writeStream->writeSint32BE(i->_value.size);
- _writeStream->write(i->_value.buffer, i->_value.size);
+ _writeStream->writeSint32BE(saveFile._value.size);
+ _writeStream->write(saveFile._value.buffer, saveFile._value.size);
}
}
diff --git a/common/translation.cpp b/common/translation.cpp
index 4c4f8e253a9..900466157b2 100644
--- a/common/translation.cpp
+++ b/common/translation.cpp
@@ -228,10 +228,9 @@ bool TranslationManager::openTranslationsFile(File &inFile) {
// Then try to open it using the SearchMan.
ArchiveMemberList fileList;
SearchMan.listMatchingMembers(fileList, Common::Path(_translationsFileName, Common::Path::kNoSeparator));
- for (ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) {
- ArchiveMember const &m = **it;
- SeekableReadStream *const stream = m.createReadStream();
- if (stream && inFile.open(stream, m.getName())) {
+ for (auto &m : fileList) {
+ SeekableReadStream *const stream = m->createReadStream();
+ if (stream && inFile.open(stream, m->getName())) {
if (checkHeader(inFile))
return true;
inFile.close();
@@ -266,8 +265,8 @@ bool TranslationManager::openTranslationsFile(const FSNode &node, File &inFile,
if (!node.getChildren(fileList, FSNode::kListDirectoriesOnly))
return false;
- for (FSList::iterator i = fileList.begin(); i != fileList.end(); ++i) {
- if (openTranslationsFile(*i, inFile, depth == -1 ? - 1 : depth - 1))
+ for (auto &file : fileList) {
+ if (openTranslationsFile(file, inFile, depth == -1 ? - 1 : depth - 1))
return true;
}
diff --git a/common/zip-set.cpp b/common/zip-set.cpp
index 34ff1d5c28b..b3064049ae5 100644
--- a/common/zip-set.cpp
+++ b/common/zip-set.cpp
@@ -44,13 +44,13 @@ bool generateZipSet(SearchSet &searchSet, const char *defaultFile, const char *p
iconDir->listMatchingMembers(iconFiles, packsMask);
sort(iconFiles.begin(), iconFiles.end(), ArchiveMemberListBackComparator());
- for (ArchiveMemberList::iterator ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
- dat = makeZipArchive((*ic)->createReadStream());
+ for (auto &ic : iconFiles) {
+ dat = makeZipArchive(ic->createReadStream());
if (dat) {
- searchSet.add((*ic)->getName(), dat);
+ searchSet.add(ic->getName(), dat);
changed = true;
- debug(2, "generateZipSet: Loaded pack file: %s", (*ic)->getName().c_str());
+ debug(2, "generateZipSet: Loaded pack file: %s", ic->getName().c_str());
}
}
Commit: 4e7752b92307048dc7a9ef8855aafecf8a5b25b9
https://github.com/scummvm/scummvm/commit/4e7752b92307048dc7a9ef8855aafecf8a5b25b9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
GRAPHICS: Use C++ 11 range-based for loops
Changed paths:
graphics/fonts/ttf.cpp
graphics/macgui/macfontmanager.cpp
graphics/macgui/macwindowmanager.cpp
graphics/scalerplugin.h
graphics/tinygl/zdirtyrect.cpp
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 9b8fb60548e..53c3d664555 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -995,9 +995,9 @@ Font *findTTFace(const Common::Array<Common::Path> &files, const Common::U32Stri
uint32 bestFaceId = (uint32) -1;
uint32 bestPenalty = (uint32) -1;
- for (Common::Array<Common::Path>::const_iterator it = files.begin(); it != files.end(); it++) {
+ for (const auto &curFile : files) {
Common::File *ttfFile = new Common::File();
- if (!ttfFile->open(*it)) {
+ if (!ttfFile->open(curFile)) {
delete ttfFile;
continue;
}
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index d2e6ee5b3d6..db656cb6239 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -231,8 +231,8 @@ void MacFontManager::loadFontsBDF() {
Common::ArchiveMemberList list;
dat->listMembers(list);
- for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
- Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getPathInArchive());
+ for (auto &archive : list) {
+ Common::SeekableReadStream *stream = dat->createReadStreamForMember(archive->getPathInArchive());
Graphics::BdfFont *font = Graphics::BdfFont::loadFont(*stream);
@@ -246,7 +246,7 @@ void MacFontManager::loadFontsBDF() {
macfont = new MacFont(_fontIds.getValOrDefault(font->getFamilyName(), kMacFontNonStandard), font->getFontSize(), parseFontSlant(font->getFontSlant()));
} else { // Get it from the file name
- fontName = (*it)->getName();
+ fontName = archive->getName();
// Trim the .bdf extension
for (int i = fontName.size() - 1; i >= 0; --i) {
@@ -289,8 +289,8 @@ void MacFontManager::loadFonts() {
Common::ArchiveMemberList list;
dat->listMembers(list);
- for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
- Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getPathInArchive());
+ for (auto &archive : list) {
+ Common::SeekableReadStream *stream = dat->createReadStreamForMember(archive->getPathInArchive());
loadFonts(stream);
}
@@ -317,9 +317,9 @@ void MacFontManager::loadJapaneseFonts() {
Common::ArchiveMemberList list;
dat->listMembers(list);
- for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
- Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getPathInArchive());
- Common::String fontName = (*it)->getName();
+ for (auto &archive : list) {
+ Common::SeekableReadStream *stream = dat->createReadStreamForMember(archive->getPathInArchive());
+ Common::String fontName = archive->getName();
// Trim the .ttf extension
for (int i = fontName.size() - 1; i >= 0; --i) {
@@ -362,12 +362,12 @@ void MacFontManager::loadFonts(const Common::Path &fileName) {
}
void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
- Common::MacResIDArray fonds = fontFile->getResIDArray(MKTAG('F','O','N','D'));
- if (fonds.size() > 0) {
- for (Common::Array<uint16>::iterator iterator = fonds.begin(); iterator != fonds.end(); ++iterator) {
- Common::SeekableReadStream *fond = fontFile->getResource(MKTAG('F', 'O', 'N', 'D'), *iterator);
+ Common::MacResIDArray fonts = fontFile->getResIDArray(MKTAG('F','O','N','D'));
+ if (fonts.size() > 0) {
+ for (auto &curFont : fonts) {
+ Common::SeekableReadStream *fond = fontFile->getResource(MKTAG('F', 'O', 'N', 'D'), curFont);
- Common::String familyName = fontFile->getResName(MKTAG('F', 'O', 'N', 'D'), *iterator);
+ Common::String familyName = fontFile->getResName(MKTAG('F', 'O', 'N', 'D'), curFont);
int familySlant = parseSlant(familyName);
familyName = cleanFontName(familyName);
@@ -794,9 +794,9 @@ int MacFontManager::getFontIdByName(Common::String name) {
if (_fontIds.contains(name))
return _fontIds[name];
- for (auto it = _fontIds.begin(); it != _fontIds.end(); it++) {
- if (it->_key.equalsIgnoreCase(name)) {
- return it->_value;
+ for (auto &fontId : _fontIds) {
+ if (fontId._key.equalsIgnoreCase(name)) {
+ return fontId._value;
}
}
return 1;
@@ -888,9 +888,9 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
// First we gather all font sizes for this font
Common::Array<MacFont *> sizes;
- for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) {
- if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == macFont.getSlant() && !i->_value->isGenerated())
- sizes.push_back(i->_value);
+ for (auto &font : _fontRegistry) {
+ if (font._value->getId() == macFont.getId() && font._value->getSlant() == macFont.getSlant() && !font._value->isGenerated())
+ sizes.push_back(font._value);
}
if (sizes.empty()) {
@@ -900,9 +900,9 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
}
// Now let's try to find a regular font
- for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) {
- if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == kMacFontRegular && !i->_value->isGenerated())
- sizes.push_back(i->_value);
+ for (auto &font : _fontRegistry) {
+ if (font._value->getId() == macFont.getId() && font._value->getSlant() == kMacFontRegular && !font._value->isGenerated())
+ sizes.push_back(font._value);
}
if (sizes.empty()) {
@@ -996,8 +996,8 @@ void MacFont::setFallback(const Font *font, Common::String name) {
void MacFontManager::printFontRegistry(int debugLevel, uint32 channel) {
debugC(debugLevel, channel, "Font Registry: %d items", _fontRegistry.size());
- for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) {
- MacFont *f = i->_value;
+ for (auto &font : _fontRegistry) {
+ MacFont *f = font._value;
debugC(debugLevel, channel, "name: '%s' gen:%c ttf:%c ID: %d size: %d slant: %d fallback: '%s'",
toPrintable(f->getName()).c_str(), f->isGenerated() ? 'y' : 'n', f->isTrueType() ? 'y' : 'n',
f->getId(), f->getSize(), f->getSlant(), toPrintable(f->getFallbackName()).c_str());
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index c896d4e34ed..e610d1245a5 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -957,8 +957,8 @@ void MacWindowManager::draw() {
bool forceRedraw = _fullRefresh;
if (!forceRedraw && dirtyRects.size()) {
- for (Common::Array<Common::Rect>::iterator dirty = dirtyRects.begin(); dirty != dirtyRects.end(); dirty++) {
- if (clip.intersects(*dirty)) {
+ for (auto &dirty : dirtyRects) {
+ if (clip.intersects(dirty)) {
forceRedraw = true;
break;
}
@@ -1021,8 +1021,8 @@ void MacWindowManager::draw() {
else {
// add intersection check with menu
bool menuRedraw = false;
- for (Common::Array<Common::Rect>::iterator dirty = dirtyRects.begin(); dirty != dirtyRects.end(); dirty++) {
- if (_menu->checkIntersects(*dirty)) {
+ for (auto &dirty : dirtyRects) {
+ if (_menu->checkIntersects(dirty)) {
menuRedraw = true;
break;
}
diff --git a/graphics/scalerplugin.h b/graphics/scalerplugin.h
index bc1425322a2..463d4fb0d20 100644
--- a/graphics/scalerplugin.h
+++ b/graphics/scalerplugin.h
@@ -158,8 +158,8 @@ public:
bool hasFactor(uint factor) const {
const Common::Array<uint> &factors = getFactors();
- for (Common::Array<uint>::const_iterator it = factors.begin(); it != factors.end(); it++) {
- if ((*it) == factor)
+ for (const auto &curFactor : factors) {
+ if (curFactor == factor)
return true;
}
diff --git a/graphics/tinygl/zdirtyrect.cpp b/graphics/tinygl/zdirtyrect.cpp
index e6ab707291f..42ff6c99900 100644
--- a/graphics/tinygl/zdirtyrect.cpp
+++ b/graphics/tinygl/zdirtyrect.cpp
@@ -95,13 +95,12 @@ void GLContext::disposeResources() {
}
void GLContext::disposeDrawCallLists() {
- typedef Common::List<DrawCall *>::const_iterator DrawCallIterator;
- for (DrawCallIterator it = _previousFrameDrawCallsQueue.begin(); it != _previousFrameDrawCallsQueue.end(); ++it) {
- delete *it;
+ for (const auto &drawCall : _previousFrameDrawCallsQueue) {
+ delete drawCall;
}
_previousFrameDrawCallsQueue.clear();
- for (DrawCallIterator it = _drawCallsQueue.begin(); it != _drawCallsQueue.end(); ++it) {
- delete *it;
+ for (auto &drawCall : _drawCallsQueue) {
+ delete drawCall;
}
_drawCallsQueue.clear();
}
@@ -144,9 +143,9 @@ void GLContext::presentBufferDirtyRects(Common::List<Common::Rect> &dirtyAreas)
}
// This loop increases outer rectangle coordinates to favor merging of adjacent rectangles.
- for (RectangleIterator it = rectangles.begin(); it != rectangles.end(); ++it) {
- (*it).rectangle.right++;
- (*it).rectangle.bottom++;
+ for (auto &rect : rectangles) {
+ rect.rectangle.right++;
+ rect.rectangle.bottom++;
}
// Merge coalesce dirty rects.
@@ -182,22 +181,22 @@ void GLContext::presentBufferDirtyRects(Common::List<Common::Rect> &dirtyAreas)
}
}
- for (RectangleIterator it1 = rectangles.begin(); it1 != rectangles.end(); ++it1) {
- (*it1).rectangle.clip(renderRect);
+ for (auto &rect : rectangles) {
+ rect.rectangle.clip(renderRect);
}
if (!rectangles.empty()) {
- for (RectangleIterator itRect = rectangles.begin(); itRect != rectangles.end(); ++itRect) {
- dirtyAreas.push_back((*itRect).rectangle);
+ for (auto &rect : rectangles) {
+ dirtyAreas.push_back(rect.rectangle);
}
// Execute draw calls.
- for (DrawCallIterator it = _drawCallsQueue.begin(); it != _drawCallsQueue.end(); ++it) {
- Common::Rect drawCallRegion = (*it)->getDirtyRegion();
- for (RectangleIterator itRect = rectangles.begin(); itRect != rectangles.end(); ++itRect) {
- Common::Rect dirtyRegion = (*itRect).rectangle;
+ for (auto &drawCall : _drawCallsQueue) {
+ Common::Rect drawCallRegion = drawCall->getDirtyRegion();
+ for (auto &rect : rectangles) {
+ Common::Rect dirtyRegion = rect.rectangle;
if (dirtyRegion.intersects(drawCallRegion)) {
- (*it)->execute(dirtyRegion, true);
+ drawCall->execute(dirtyRegion, true);
}
}
}
@@ -211,8 +210,8 @@ void GLContext::presentBufferDirtyRects(Common::List<Common::Rect> &dirtyAreas)
fb->enableBlending(false);
fb->enableAlphaTest(false);
- for (RectangleIterator it = rectangles.begin(); it != rectangles.end(); ++it) {
- debugDrawRectangle((*it).rectangle, (*it).r, (*it).g, (*it).b);
+ for (auto &rect : rectangles) {
+ debugDrawRectangle(rect.rectangle, rect.r, rect.g, rect.b);
}
fb->enableBlending(blending_enabled);
@@ -221,8 +220,8 @@ void GLContext::presentBufferDirtyRects(Common::List<Common::Rect> &dirtyAreas)
}
// Dispose not necessary draw calls.
- for (DrawCallIterator it = _previousFrameDrawCallsQueue.begin(); it != _previousFrameDrawCallsQueue.end(); ++it) {
- delete *it;
+ for (auto &p : _previousFrameDrawCallsQueue) {
+ delete p;
}
_previousFrameDrawCallsQueue = _drawCallsQueue;
@@ -235,13 +234,11 @@ void GLContext::presentBufferDirtyRects(Common::List<Common::Rect> &dirtyAreas)
}
void GLContext::presentBufferSimple(Common::List<Common::Rect> &dirtyAreas) {
- typedef Common::List<DrawCall *>::const_iterator DrawCallIterator;
-
dirtyAreas.push_back(Common::Rect(fb->getPixelBufferWidth(), fb->getPixelBufferHeight()));
- for (DrawCallIterator it = _drawCallsQueue.begin(); it != _drawCallsQueue.end(); ++it) {
- (*it)->execute(true);
- delete *it;
+ for (const auto &drawCall : _drawCallsQueue) {
+ drawCall->execute(true);
+ delete drawCall;
}
_drawCallsQueue.clear();
Commit: 1921ebf02e57b928fced8be21ca1b28a501b985b
https://github.com/scummvm/scummvm/commit/1921ebf02e57b928fced8be21ca1b28a501b985b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
ENGINES: Use C++ 11 range-based for loops
Changed paths:
engines/achievements.cpp
engines/advancedDetector.cpp
engines/engine.cpp
engines/game.cpp
engines/metaengine.cpp
diff --git a/engines/achievements.cpp b/engines/achievements.cpp
index e5e0cd5de7c..d5a5a1720d4 100644
--- a/engines/achievements.cpp
+++ b/engines/achievements.cpp
@@ -148,20 +148,20 @@ bool AchievementsManager::loadAchievementsData(const char *platform, const char
_achievements.clear();
INIFile::SectionList sections = cfgFile.getSections();
- for (Common::INIFile::SectionList::const_iterator section = sections.begin(); section != sections.end(); ++section) {
- if (!(section->name.hasPrefix("achievements:"))) {
+ for (const auto §ion : sections) {
+ if (!(section.name.hasPrefix("achievements:"))) {
continue;
}
- String lang = section->name.substr(13); //strlen("achievements:")
+ String lang = section.name.substr(13); //strlen("achievements:")
for (int i = 0; i < 256; i++) {
String prefix = String::format("item_%d", i);
- String id = section->getKey(prefix + "_id") ? section->getKey(prefix + "_id")->value : "";
- String title = section->getKey(prefix + "_title") ? section->getKey(prefix + "_title")->value : "";
- String comment = section->getKey(prefix + "_comment") ? section->getKey(prefix + "_comment")->value : "";
- String hidden = section->getKey(prefix + "_hidden") ? section->getKey(prefix + "_hidden")->value : "";
+ String id = section.getKey(prefix + "_id") ? section.getKey(prefix + "_id")->value : "";
+ String title = section.getKey(prefix + "_title") ? section.getKey(prefix + "_title")->value : "";
+ String comment = section.getKey(prefix + "_comment") ? section.getKey(prefix + "_comment")->value : "";
+ String hidden = section.getKey(prefix + "_hidden") ? section.getKey(prefix + "_hidden")->value : "";
if (id.empty()) {
break;
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 416516b94c4..96816966bef 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -54,8 +54,8 @@ public:
int listMembers(Common::ArchiveMemberList &list) const override {
int files = 0;
- for (AdvancedMetaEngineDetectionBase::FileMap::const_iterator it = _fileMap.begin(); it != _fileMap.end(); ++it) {
- list.push_back(Common::ArchiveMemberPtr(new Common::FSNode(it->_value)));
+ for (const auto &file : _fileMap) {
+ list.push_back(Common::ArchiveMemberPtr(new Common::FSNode(file._value)));
++files;
}
@@ -416,8 +416,8 @@ Common::Error AdvancedMetaEngineDetectionBase::identifyGame(DetectedGame &game,
Common::StringArray dirs = getPathsFromEntry(agdDesc.desc);
Common::FSNode gameDataDir = Common::FSNode(ConfMan.getPath("path"));
- for (auto d = dirs.begin(); d != dirs.end(); ++d)
- SearchMan.addSubDirectoryMatching(gameDataDir, *d, 0, _fullPathGlobsDepth);
+ for (auto &curDir : dirs)
+ SearchMan.addSubDirectoryMatching(gameDataDir, curDir, 0, _fullPathGlobsDepth);
}
game = toDetectedGame(agdDesc);
@@ -433,16 +433,16 @@ void AdvancedMetaEngineDetectionBase::composeFileHashMap(FileMap &allFiles, cons
if (fslist.empty())
return;
- for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- Common::String efname = Common::punycode_encodefilename(file->getName());
+ for (const auto &file : fslist) {
+ Common::String efname = Common::punycode_encodefilename(file.getName());
Common::Path tstr = ((_flags & kADFlagMatchFullPaths) ? parentName : Common::Path()).appendComponent(efname);
- if (file->isDirectory()) {
+ if (file.isDirectory()) {
if (!_globsMap.contains(efname))
continue;
Common::FSList files;
- if (!file->getChildren(files, Common::FSNode::kListAll))
+ if (!file.getChildren(files, Common::FSNode::kListAll))
continue;
composeFileHashMap(allFiles, files, depth - 1, tstr);
@@ -457,8 +457,8 @@ void AdvancedMetaEngineDetectionBase::composeFileHashMap(FileMap &allFiles, cons
debugC(9, kDebugGlobalDetection, "$$ ['%s'] ['%s'] in '%s", tstr.toString().c_str(), efname.c_str(), firstPathComponents(fslist.front().getPath().toString(), '/').c_str());
- allFiles[tstr] = *file; // Record the presence of this file
- allFiles[Common::Path(efname, Common::Path::kNoSeparator)] = *file; // ...and its file name
+ allFiles[tstr] = file; // Record the presence of this file
+ allFiles[Common::Path(efname, Common::Path::kNoSeparator)] = file; // ...and its file name
}
}
@@ -1167,8 +1167,8 @@ Common::Error AdvancedMetaEngineBase::createInstance(OSystem *syst, Engine **eng
debug("Running %s", gameDescriptor.description.c_str());
Common::Array<Common::Path> filenames;
- for (FilePropertiesMap::const_iterator i = gameDescriptor.matchedFiles.begin(); i != gameDescriptor.matchedFiles.end(); ++i) {
- filenames.push_back(i->_key);
+ for (const auto &file : gameDescriptor.matchedFiles) {
+ filenames.push_back(file._key);
}
Common::sort(filenames.begin(), filenames.end());
for (uint i = 0; i < filenames.size(); ++i) {
diff --git a/engines/engine.cpp b/engines/engine.cpp
index bd37122427b..9ebe737d13c 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -468,10 +468,10 @@ void initGraphics(int width, int height, const Graphics::PixelFormat *format) {
*/
inline Graphics::PixelFormat findCompatibleFormat(const Common::List<Graphics::PixelFormat> &backend, const Common::List<Graphics::PixelFormat> &frontend) {
#ifdef USE_RGB_COLOR
- for (Common::List<Graphics::PixelFormat>::const_iterator i = backend.begin(); i != backend.end(); ++i) {
- for (Common::List<Graphics::PixelFormat>::const_iterator j = frontend.begin(); j != frontend.end(); ++j) {
- if (*i == *j)
- return *i;
+ for (const auto &back : backend) {
+ for (auto &front : frontend) {
+ if (back == front)
+ return back;
}
}
#endif
diff --git a/engines/game.cpp b/engines/game.cpp
index 016c3e48688..2586e8a1e02 100644
--- a/engines/game.cpp
+++ b/engines/game.cpp
@@ -242,9 +242,9 @@ Common::U32String generateUnknownGameReport(const DetectedGames &detectedGames,
report += game.preferredTarget;
// Consolidate matched files across all engines and detection entries
- for (FilePropertiesMap::const_iterator it = game.matchedFiles.begin(); it != game.matchedFiles.end(); it++) {
- Common::String key = Common::String::format("%s:%s", md5PropToCachePrefix(it->_value.md5prop).c_str(), it->_key.punycodeEncode().toString('/').c_str());
- matchedFiles.setVal(key, it->_value);
+ for (const auto &file : game.matchedFiles) {
+ Common::String key = Common::String::format("%s:%s", md5PropToCachePrefix(file._value.md5prop).c_str(), file._key.punycodeEncode().toString('/').c_str());
+ matchedFiles.setVal(key, file._value);
}
}
@@ -255,8 +255,8 @@ Common::U32String generateUnknownGameReport(const DetectedGames &detectedGames,
report += Common::U32String("\n\n");
Common::StringArray filenames;
- for (CachedPropertiesMap::const_iterator file = matchedFiles.begin(); file != matchedFiles.end(); ++file) {
- filenames.push_back(file->_key);
+ for (const auto &file : matchedFiles) {
+ filenames.push_back(file._key);
}
Common::sort(filenames.begin(), filenames.end());
for (uint i = 0; i < filenames.size(); ++i) {
diff --git a/engines/metaengine.cpp b/engines/metaengine.cpp
index e1edb41d911..54817148599 100644
--- a/engines/metaengine.cpp
+++ b/engines/metaengine.cpp
@@ -373,9 +373,9 @@ SaveStateList MetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &file : filenames) {
// Obtain the last 2/3 digits of the filename, since they correspond to the save slot
- const char *slotStr = file->c_str() + file->size() - 2;
+ const char *slotStr = file.c_str() + file.size() - 2;
const char *prev = slotStr - 1;
if (*prev >= '0' && *prev <= '9')
slotStr = prev;
@@ -401,8 +401,8 @@ SaveStateList MetaEngine::listSaves(const char *target, bool saveMode) const {
return saveList;
// Check to see if an autosave is present
- for (SaveStateList::iterator it = saveList.begin(); it != saveList.end(); ++it) {
- int slot = it->getSaveSlot();
+ for (auto &save : saveList) {
+ int slot = save.getSaveSlot();
if (slot == autosaveSlot) {
// It has an autosave
return saveList;
Commit: e157b7044e0588e0178b21cc2c6edf6b6084fe56
https://github.com/scummvm/scummvm/commit/e157b7044e0588e0178b21cc2c6edf6b6084fe56
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
GUI: Use C++ 11 range-based for loops
Changed paths:
gui/EventRecorder.cpp
gui/ThemeEngine.cpp
gui/about.cpp
gui/browser.cpp
gui/debugger.cpp
gui/downloaddialog.cpp
gui/filebrowser-dialog.cpp
gui/integrity-dialog.cpp
gui/launcher.cpp
gui/massadd.cpp
gui/options.cpp
gui/recorderdialog.cpp
gui/remotebrowser.cpp
gui/saveload-dialog.cpp
gui/widget.cpp
gui/widgets/list.cpp
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index 62940b45209..1929508dbca 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -776,8 +776,8 @@ bool EventRecorder::switchMode() {
SaveStateList saveList = plugin->get<MetaEngine>().listSaves(target.c_str());
int emptySlot = 1;
- for (SaveStateList::const_iterator x = saveList.begin(); x != saveList.end(); ++x) {
- int saveSlot = x->getSaveSlot();
+ for (const auto &x : saveList) {
+ int saveSlot = x.getSaveSlot();
if (saveSlot == 0) {
continue;
}
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index c5feb63aae6..44d6c9487ed 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -247,8 +247,8 @@ ThemeEngine::~ThemeEngine() {
unloadExtraFont();
// Release all graphics surfaces
- for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) {
- Graphics::ManagedSurface *surf = i->_value;
+ for (auto &bitmap : _bitmaps) {
+ Graphics::ManagedSurface *surf = bitmap._value;
if (surf) {
surf->free();
delete surf;
@@ -382,8 +382,8 @@ void ThemeEngine::refresh() {
// Flush all bitmaps if the overlay pixel format changed.
if (_overlayFormat != _system->getOverlayFormat() || _needScaleRefresh) {
- for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) {
- Graphics::ManagedSurface *surf = i->_value;
+ for (auto &bitmap : _bitmaps) {
+ Graphics::ManagedSurface *surf = bitmap._value;
if (surf) {
surf->free();
delete surf;
@@ -889,17 +889,17 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeId) {
//
// Loop over all STX files, load and parse them
//
- for (Common::ArchiveMemberList::iterator i = members.begin(); i != members.end(); ++i) {
- assert((*i)->getName().hasSuffix(".stx"));
+ for (auto &member : members) {
+ assert(member->getName().hasSuffix(".stx"));
- if (_parser->loadStream((*i)->createReadStream()) == false) {
- warning("Failed to load STX file '%s'", (*i)->getName().c_str());
+ if (_parser->loadStream(member->createReadStream()) == false) {
+ warning("Failed to load STX file '%s'", member->getName().c_str());
_parser->close();
return false;
}
if (_parser->parse() == false) {
- warning("Failed to parse STX file '%s'", (*i)->getName().c_str());
+ warning("Failed to parse STX file '%s'", member->getName().c_str());
_parser->close();
return false;
}
@@ -1983,9 +1983,9 @@ void ThemeEngine::listUsableThemes(Common::List<ThemeDescriptor> &list) {
// in the config file we can not do any better currently.
Common::List<ThemeDescriptor> output;
- for (Common::List<ThemeDescriptor>::const_iterator i = list.begin(); i != list.end(); ++i) {
- if (Common::find_if(output.begin(), output.end(), TDComparator(i->id)) == output.end())
- output.push_back(*i);
+ for (const auto &theme : list) {
+ if (Common::find_if(output.begin(), output.end(), TDComparator(theme.id)) == output.end())
+ output.push_back(theme);
}
list = output;
@@ -2041,15 +2041,15 @@ void ThemeEngine::listUsableThemes(const Common::FSNode &node, Common::List<Them
if (!node.getChildren(fileList, Common::FSNode::kListFilesOnly))
return;
- for (Common::FSList::iterator i = fileList.begin(); i != fileList.end(); ++i) {
+ for (auto &file : fileList) {
// We will only process zip files for now
- if (!i->getPath().baseName().matchString("*.zip", true))
+ if (!file.getPath().baseName().matchString("*.zip", true))
continue;
td.name.clear();
- if (themeConfigUsable(*i, td.name)) {
- td.filename = i->getPath();
- td.id = i->getName();
+ if (themeConfigUsable(file, td.name)) {
+ td.filename = file.getPath();
+ td.id = file.getName();
// If the name of the node object also contains
// the ".zip" suffix, we will strip it.
@@ -2101,9 +2101,9 @@ Common::Path ThemeEngine::getThemeFile(const Common::String &id) {
Common::List<ThemeDescriptor> list;
listUsableThemes(list);
- for (Common::List<ThemeDescriptor>::const_iterator i = list.begin(); i != list.end(); ++i) {
- if (id.equalsIgnoreCase(i->id))
- return i->filename;
+ for (const auto &theme : list) {
+ if (id.equalsIgnoreCase(theme.id))
+ return theme.filename;
}
warning("Could not find theme '%s' falling back to builtin", id.c_str());
@@ -2139,9 +2139,9 @@ Common::String ThemeEngine::getThemeId(const Common::Path &filename) {
Common::List<ThemeDescriptor> list;
listUsableThemes(list);
- for (Common::List<ThemeDescriptor>::const_iterator i = list.begin(); i != list.end(); ++i) {
- if (filename.equalsIgnoreCase(i->filename))
- return i->id;
+ for (const auto &theme : list) {
+ if (filename.equalsIgnoreCase(theme.filename))
+ return theme.id;
}
return "builtin";
diff --git a/gui/about.cpp b/gui/about.cpp
index 73d52dff076..8d28c9b1314 100644
--- a/gui/about.cpp
+++ b/gui/about.cpp
@@ -171,20 +171,20 @@ AboutDialog::AboutDialog(bool inGame)
break;
}
const PluginList &plugins = EngineMan.getPlugins(PLUGIN_TYPE_ENGINE);
- for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); ++iter) {
- enginesDetected.push_back((*iter)->getName());
+ for (const auto &plugin : plugins) {
+ enginesDetected.push_back(plugin->getName());
}
} while (!inGame && PluginMan.loadNextPlugin());
if (!inGame) PluginMan.loadDetectionPlugin();
- for (Common::StringArray::iterator iter = enginesDetected.begin(); iter != enginesDetected.end(); iter++) {
+ for (auto &engine : enginesDetected) {
Common::String str;
- const Plugin *p = EngineMan.findDetectionPlugin(*iter);
+ const Plugin *p = EngineMan.findDetectionPlugin(engine);
if (!p) {
- if (!inGame) warning("Cannot find plugin for %s", iter->c_str());
+ if (!inGame) warning("Cannot find plugin for %s", engine.c_str());
continue;
}
@@ -219,8 +219,8 @@ void AboutDialog::addLine(const Common::U32String &str) {
Common::U32StringArray wrappedLines;
g_gui.getFont().wordWrapText(renderStr, _w - 2 * _xOff, wrappedLines);
- for (Common::U32StringArray::const_iterator i = wrappedLines.begin(); i != wrappedLines.end(); ++i) {
- _lines.push_back(format + *i);
+ for (const auto &line : wrappedLines) {
+ _lines.push_back(format + line);
}
}
}
diff --git a/gui/browser.cpp b/gui/browser.cpp
index 30d29058a24..a5d75b7294c 100644
--- a/gui/browser.cpp
+++ b/gui/browser.cpp
@@ -203,18 +203,18 @@ void BrowserDialog::updateListing() {
// Populate the ListWidget
Common::U32StringArray list;
Common::U32String color = ListWidget::getThemeColor(ThemeEngine::kFontColorNormal);
- for (Common::FSList::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
+ for (auto &node : _nodeContent) {
if (_isDirBrowser) {
- if (i->isDirectory())
+ if (node.isDirectory())
color = ListWidget::getThemeColor(ThemeEngine::kFontColorNormal);
else
color = ListWidget::getThemeColor(ThemeEngine::kFontColorAlternate);
}
- if (i->isDirectory())
- list.push_back(color + ListWidget::escapeString(Common::U32String(i->getName()) + "/"));
+ if (node.isDirectory())
+ list.push_back(color + ListWidget::escapeString(Common::U32String(node.getName()) + "/"));
else
- list.push_back(color + ListWidget::escapeString(Common::U32String(i->getName())));
+ list.push_back(color + ListWidget::escapeString(Common::U32String(node.getName())));
}
_fileList->setList(list);
diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index 469b11eb63d..7b445933432 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -679,14 +679,14 @@ bool Debugger::cmdMd5(int argc, const char **argv) {
debugPrintf("File '%s' not found\n", filename.c_str());
} else {
sort(list.begin(), list.end(), ArchiveMemberLess());
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- Common::SeekableReadStream *stream = (*iter)->createReadStream();
+ for (auto &archive : list) {
+ Common::SeekableReadStream *stream = archive->createReadStream();
if (tail && stream->size() > length)
stream->seek(-length, SEEK_END);
Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
if (length != 0 && length < stream->size())
md5 += Common::String::format(" (%s %d bytes)", tail ? "last" : "first", length);
- debugPrintf("%s: %s, %llu bytes\n", (*iter)->getName().c_str(), md5.c_str(), (unsigned long long)stream->size());
+ debugPrintf("%s: %s, %llu bytes\n", archive->getName().c_str(), md5.c_str(), (unsigned long long)stream->size());
delete stream;
}
}
@@ -785,11 +785,11 @@ bool Debugger::cmdDebugFlagsList(int argc, const char **argv) {
debugPrintf("No engine debug levels\n");
return true;
}
- for (Common::DebugManager::DebugChannelList::const_iterator i = debugLevels.begin(); i != debugLevels.end(); ++i) {
- bool enabled = DebugMan.isDebugChannelEnabled(i->channel);
+ for (const auto &debugLevel : debugLevels) {
+ bool enabled = DebugMan.isDebugChannelEnabled(debugLevel.channel);
debugPrintf("%c%s - %s (%s)\n", enabled ? '+' : ' ',
- i->name.c_str(), i->description.c_str(),
+ debugLevel.name.c_str(), debugLevel.description.c_str(),
enabled ? "enabled" : "disabled");
}
debugPrintf("\n");
diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp
index 540cd58c7e4..f58f2484d63 100644
--- a/gui/downloaddialog.cpp
+++ b/gui/downloaddialog.cpp
@@ -120,13 +120,13 @@ bool DownloadDialog::selectDirectories() {
return false;
}
- //first user should select remote directory to download
+ // First, the user should select the remote directory to download
if (_remoteBrowser->runModal() <= 0)
return false;
Cloud::StorageFile remoteDirectory = _remoteBrowser->getResult();
- //now user should select local directory to download into
+ // Now, the user should select the local directory to download into
if (_browser->runModal() <= 0)
return false;
@@ -138,11 +138,11 @@ bool DownloadDialog::selectDirectories() {
return false;
}
- //check that there is no file with the remote directory's name in the local one
- for (Common::FSList::iterator i = files.begin(); i != files.end(); ++i) {
- if (i->getName().equalsIgnoreCase(remoteDirectory.name())) {
- //if there is, ask user whether it's OK
- if (!i->isDirectory()) {
+ // Check that there is no file with the remote directory's name in the local one
+ for (auto &file : files) {
+ if (file.getName().equalsIgnoreCase(remoteDirectory.name())) {
+ // If there is, ask user whether it's OK
+ if (!file.isDirectory()) {
GUI::MessageDialog alert(_("Cannot create a directory to download - the specified directory has a file with the same name."), _("OK"));
alert.runModal();
return false;
@@ -158,7 +158,7 @@ bool DownloadDialog::selectDirectories() {
}
}
- //make a local path
+ // Make a local path
Common::Path localPath = dir.getPath();
localPath = localPath.appendComponent(remoteDirectory.name());
diff --git a/gui/filebrowser-dialog.cpp b/gui/filebrowser-dialog.cpp
index 2af533a726b..88f690c0e5e 100644
--- a/gui/filebrowser-dialog.cpp
+++ b/gui/filebrowser-dialog.cpp
@@ -149,8 +149,8 @@ void FileBrowserDialog::updateListing() {
Common::StringArray filenames = saveFileMan->listSavefiles(_fileMask);
Common::sort(filenames.begin(), filenames.end());
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
- list.push_back(Common::U32String(*file));
+ for (const auto &file : filenames) {
+ list.push_back(Common::U32String(file));
}
_fileList->setList(list);
diff --git a/gui/integrity-dialog.cpp b/gui/integrity-dialog.cpp
index 65b9ba941bc..eee08aedabb 100644
--- a/gui/integrity-dialog.cpp
+++ b/gui/integrity-dialog.cpp
@@ -291,9 +291,7 @@ void IntegrityDialog::calculateTotalSize(Common::Path gamePath) {
return;
// Process the files and subdirectories in the current directory recursively
- for (Common::FSList::const_iterator it = fileList.begin(); it != fileList.end(); it++) {
- const Common::FSNode &entry = *it;
-
+ for (const auto &entry : fileList) {
if (entry.isDirectory())
calculateTotalSize(entry.getPath());
else {
@@ -320,9 +318,7 @@ Common::Array<Common::StringArray> IntegrityDialog::generateChecksums(Common::Pa
return {};
// Process the files and subdirectories in the current directory recursively
- for (Common::FSList::const_iterator it = fileList.begin(); it != fileList.end(); it++) {
- const Common::FSNode &entry = *it;
-
+ for (const auto &entry : fileList) {
if (entry.isDirectory())
generateChecksums(entry.getPath(), fileChecksums);
else {
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 5182c8c42cf..5a8ceca327a 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -199,13 +199,13 @@ LauncherDialog::LauncherDialog(const Common::String &dialogName)
g_gui.lockIconsSet();
g_gui.getIconsSet().listMatchingMembers(mdFiles, "*.xml");
- for (Common::ArchiveMemberList::iterator md = mdFiles.begin(); md != mdFiles.end(); ++md) {
- if (_metadataParser.loadStream((*md)->createReadStream()) == false) {
- warning("Failed to load XML file '%s'", (*md)->getDisplayName().encode().c_str());
+ for (auto &md : mdFiles) {
+ if (_metadataParser.loadStream(md->createReadStream()) == false) {
+ warning("Failed to load XML file '%s'", md->getDisplayName().encode().c_str());
_metadataParser.close();
}
if (_metadataParser.parse() == false) {
- warning("Failed to parse XML file '%s'", (*md)->getDisplayName().encode().c_str());
+ warning("Failed to parse XML file '%s'", md->getDisplayName().encode().c_str());
}
_metadataParser.close();
}
@@ -568,25 +568,25 @@ void LauncherDialog::loadGame(int item) {
Common::Array<LauncherEntry> LauncherDialog::generateEntries(const Common::ConfigManager::DomainMap &domains) {
Common::Array<LauncherEntry> domainList;
- for (Common::ConfigManager::DomainMap::const_iterator iter = domains.begin(); iter != domains.end(); ++iter) {
+ for (const auto &domain : domains) {
// Do not list temporary targets added when starting a game from the command line
- if (iter->_value.contains("id_came_from_command_line"))
+ if (domain._value.contains("id_came_from_command_line"))
continue;
Common::String description;
Common::String title;
- if (!iter->_value.tryGetVal("description", description)) {
- QualifiedGameDescriptor g = EngineMan.findTarget(iter->_key);
+ if (!domain._value.tryGetVal("description", description)) {
+ QualifiedGameDescriptor g = EngineMan.findTarget(domain._key);
if (!g.description.empty())
description = g.description;
}
- Common::String engineid = iter->_value.getValOrDefault("engineid");
+ Common::String engineid = domain._value.getValOrDefault("engineid");
Common::String gameid;
- if (!iter->_value.tryGetVal("gameid", gameid)) {
- gameid = iter->_key;
+ if (!domain._value.tryGetVal("gameid", gameid)) {
+ gameid = domain._key;
}
Common::StringMap &engineMap = _engines[engineid];
@@ -607,13 +607,13 @@ Common::Array<LauncherEntry> LauncherDialog::generateEntries(const Common::Confi
title += " (Demo)";
if (description.empty()) {
- description = Common::String::format("Unknown (target %s, gameid %s)", iter->_key.c_str(), gameid.c_str());
+ description = Common::String::format("Unknown (target %s, gameid %s)", domain._key.c_str(), gameid.c_str());
}
if (title.empty())
title = description;
if (!description.empty())
- domainList.push_back(LauncherEntry(iter->_key, engineid, gameid, description, title, &iter->_value));
+ domainList.push_back(LauncherEntry(domain._key, engineid, gameid, description, title, &domain._value));
}
// Now sort the list in dictionary order
@@ -1145,12 +1145,12 @@ void LauncherSimple::updateListing(int selPos) {
Common::Array<LauncherEntry> domainList = generateEntries(domains);
// And fill out our structures
- for (Common::Array<LauncherEntry>::const_iterator iter = domainList.begin(); iter != domainList.end(); ++iter) {
+ for (const auto &curDomain : domainList) {
color = ThemeEngine::kFontColorNormal;
if (scanEntries) {
Common::String path;
- if (!iter->domain->tryGetVal("path", path) || !Common::FSNode(Common::Path::fromConfig(path)).isDirectory()) {
+ if (!curDomain.domain->tryGetVal("path", path) || !Common::FSNode(Common::Path::fromConfig(path)).isDirectory()) {
color = ThemeEngine::kFontColorAlternate;
// If more conditions which grey out entries are added we should consider
// enabling this so that it is easy to spot why a certain game entry cannot
@@ -1159,10 +1159,10 @@ void LauncherSimple::updateListing(int selPos) {
// description += Common::String::format(" (%s)", _("Not found"));
}
}
- Common::U32String gameDesc = GUI::ListWidget::getThemeColor(color) + Common::U32String(iter->description);
+ Common::U32String gameDesc = GUI::ListWidget::getThemeColor(color) + Common::U32String(curDomain.description);
l.push_back(gameDesc);
- _domains.push_back(iter->key);
+ _domains.push_back(curDomain.key);
}
const int oldSel = _list->getSelected();
@@ -1197,15 +1197,15 @@ void LauncherSimple::groupEntries(const Common::Array<LauncherEntry> &metadata)
_list->setGroupsVisibility(true);
switch (_groupBy) {
case kGroupByFirstLetter: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- attrs.push_back(iter->description.substr(0, 1));
+ for (const auto &entry : metadata) {
+ attrs.push_back(entry.description.substr(0, 1));
}
_list->setGroupHeaderFormat(Common::U32String(""), Common::U32String("..."));
break;
}
case kGroupByEngine: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- attrs.push_back(iter->engineid);
+ for (const auto &entry : metadata) {
+ attrs.push_back(entry.engineid);
}
_list->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
// I18N: List grouping when no engine is specified
@@ -1221,8 +1221,8 @@ void LauncherSimple::groupEntries(const Common::Array<LauncherEntry> &metadata)
break;
}
case kGroupByCompany: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- attrs.push_back(_metadataParser._gameInfo[buildQualifiedGameName(iter->engineid, iter->gameid)].company_id);
+ for (const auto &entry : metadata) {
+ attrs.push_back(_metadataParser._gameInfo[buildQualifiedGameName(entry.engineid, entry.gameid)].company_id);
}
_list->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
// I18N: List grouping when no publisher is specified
@@ -1238,8 +1238,8 @@ void LauncherSimple::groupEntries(const Common::Array<LauncherEntry> &metadata)
break;
}
case kGroupBySeries: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- attrs.push_back(_metadataParser._gameInfo[buildQualifiedGameName(iter->engineid, iter->gameid)].series_id);
+ for (const auto &entry : metadata) {
+ attrs.push_back(_metadataParser._gameInfo[buildQualifiedGameName(entry.engineid, entry.gameid)].series_id);
}
_list->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
// I18N: List group when no game series is specified
@@ -1251,8 +1251,8 @@ void LauncherSimple::groupEntries(const Common::Array<LauncherEntry> &metadata)
break;
}
case kGroupByLanguage: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- Common::U32String language = iter->domain->getValOrDefault(Common::String("language"));
+ for (const auto &entry : metadata) {
+ Common::U32String language = entry.domain->getValOrDefault(Common::String("language"));
attrs.push_back(language);
}
_list->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
@@ -1265,8 +1265,8 @@ void LauncherSimple::groupEntries(const Common::Array<LauncherEntry> &metadata)
break;
}
case kGroupByPlatform: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- Common::U32String platform = iter->domain->getValOrDefault(Common::String("Platform"));
+ for (const auto &entry : metadata) {
+ Common::U32String platform = entry.domain->getValOrDefault(Common::String("Platform"));
attrs.push_back(platform);
}
_list->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
@@ -1279,8 +1279,8 @@ void LauncherSimple::groupEntries(const Common::Array<LauncherEntry> &metadata)
break;
}
case kGroupByYear: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- Common::U32String year = _metadataParser._gameInfo[buildQualifiedGameName(iter->engineid, iter->gameid)].year;
+ for (const auto &entry : metadata) {
+ Common::U32String year = _metadataParser._gameInfo[buildQualifiedGameName(entry.engineid, entry.gameid)].year;
attrs.push_back(year);
if (!metadataNames.contains(year))
@@ -1393,15 +1393,15 @@ void LauncherGrid::groupEntries(const Common::Array<LauncherEntry> &metadata) {
Common::StringMap metadataNames;
switch (_groupBy) {
case kGroupByFirstLetter: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- attrs.push_back(iter->title.substr(0, 1));
+ for (const auto &entry : metadata) {
+ attrs.push_back(entry.title.substr(0, 1));
}
_grid->setGroupHeaderFormat(Common::U32String(""), Common::U32String("..."));
break;
}
case kGroupByEngine: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- attrs.push_back(iter->engineid);
+ for (const auto &entry : metadata) {
+ attrs.push_back(entry.engineid);
}
_grid->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
// I18N: List grouping when no engine is specified
@@ -1417,8 +1417,8 @@ void LauncherGrid::groupEntries(const Common::Array<LauncherEntry> &metadata) {
break;
}
case kGroupByCompany: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- attrs.push_back(_metadataParser._gameInfo[buildQualifiedGameName(iter->engineid, iter->gameid)].company_id);
+ for (const auto &entry : metadata) {
+ attrs.push_back(_metadataParser._gameInfo[buildQualifiedGameName(entry.engineid, entry.gameid)].company_id);
}
_grid->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
// I18N: List group when no publisher is specified
@@ -1434,8 +1434,8 @@ void LauncherGrid::groupEntries(const Common::Array<LauncherEntry> &metadata) {
break;
}
case kGroupBySeries: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- attrs.push_back(_metadataParser._gameInfo[buildQualifiedGameName(iter->engineid, iter->gameid)].series_id);
+ for (const auto &entry : metadata) {
+ attrs.push_back(_metadataParser._gameInfo[buildQualifiedGameName(entry.engineid, entry.gameid)].series_id);
}
_grid->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
// I18N: List grouping when no game series is specified
@@ -1447,8 +1447,8 @@ void LauncherGrid::groupEntries(const Common::Array<LauncherEntry> &metadata) {
break;
}
case kGroupByLanguage: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- Common::U32String language = iter->domain->getValOrDefault(Common::String("language"));
+ for (const auto &entry : metadata) {
+ Common::U32String language = entry.domain->getValOrDefault(Common::String("language"));
attrs.push_back(language);
}
_grid->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
@@ -1461,8 +1461,8 @@ void LauncherGrid::groupEntries(const Common::Array<LauncherEntry> &metadata) {
break;
}
case kGroupByPlatform: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- Common::U32String platform = iter->domain->getValOrDefault(Common::String("Platform"));
+ for (const auto &entry : metadata) {
+ Common::U32String platform = entry.domain->getValOrDefault(Common::String("Platform"));
attrs.push_back(platform);
}
_grid->setGroupHeaderFormat(Common::U32String(""), Common::U32String(""));
@@ -1475,8 +1475,8 @@ void LauncherGrid::groupEntries(const Common::Array<LauncherEntry> &metadata) {
break;
}
case kGroupByYear: {
- for (Common::Array<LauncherEntry>::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) {
- Common::U32String year = _metadataParser._gameInfo[buildQualifiedGameName(iter->engineid, iter->gameid)].year;
+ for (const auto &entry : metadata) {
+ Common::U32String year = _metadataParser._gameInfo[buildQualifiedGameName(entry.engineid, entry.gameid)].year;
attrs.push_back(year);
if (!metadataNames.contains(year))
@@ -1584,21 +1584,21 @@ void LauncherGrid::updateListing(int selPos) {
Common::Array<GridItemInfo> gridList;
int k = 0;
- for (Common::Array<LauncherEntry>::const_iterator iter = domainList.begin(); iter != domainList.end(); ++iter) {
- Common::String gameid = iter->domain->getVal("gameid");
+ for (const auto &curDomain : domainList) {
+ Common::String gameid = curDomain.domain->getVal("gameid");
Common::String engineid = "UNK";
Common::String language = "XX";
Common::String platform;
Common::String extra;
Common::String path;
bool valid_path = false;
- iter->domain->tryGetVal("engineid", engineid);
- iter->domain->tryGetVal("language", language);
- iter->domain->tryGetVal("platform", platform);
- iter->domain->tryGetVal("extra", extra);
- valid_path = (!iter->domain->tryGetVal("path", path) || !Common::FSNode(Common::Path::fromConfig(path)).isDirectory()) ? false : true;
- gridList.push_back(GridItemInfo(k++, engineid, gameid, iter->description, iter->title, extra, Common::parseLanguage(language), Common::parsePlatform(platform), valid_path));
- _domains.push_back(iter->key);
+ curDomain.domain->tryGetVal("engineid", engineid);
+ curDomain.domain->tryGetVal("language", language);
+ curDomain.domain->tryGetVal("platform", platform);
+ curDomain.domain->tryGetVal("extra", extra);
+ valid_path = (!curDomain.domain->tryGetVal("path", path) || !Common::FSNode(Common::Path::fromConfig(path)).isDirectory()) ? false : true;
+ gridList.push_back(GridItemInfo(k++, engineid, gameid, curDomain.description, curDomain.title, extra, Common::parseLanguage(language), Common::parsePlatform(platform), valid_path));
+ _domains.push_back(curDomain.key);
}
const int oldSel = _grid->getSelected();
diff --git a/gui/massadd.cpp b/gui/massadd.cpp
index 1c90a19aa63..1eddf6d9879 100644
--- a/gui/massadd.cpp
+++ b/gui/massadd.cpp
@@ -135,13 +135,13 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
// people who want to edit their config file by hand after a mass add.
Common::sort(_games.begin(), _games.end(), GameTargetLess());
// Add all the detected games to the config
- for (DetectedGames::iterator iter = _games.begin(); iter != _games.end(); ++iter) {
+ for (auto &game : _games) {
// Make sure the game is selected
- if (iter->isSelected) {
+ if (game.isSelected) {
debug(1, " Added gameid '%s', desc '%s'",
- iter->gameId.c_str(),
- iter->description.c_str());
- iter->gameId = EngineMan.createTargetForGame(*iter);
+ game.gameId.c_str(),
+ game.description.c_str());
+ game.gameId = EngineMan.createTargetForGame(game);
}
}
@@ -213,8 +213,8 @@ void MassAddDialog::handleTickle() {
//
// However, we only add games which are not already in the config file.
DetectedGames candidates = detectionResults.listRecognizedGames();
- for (DetectedGames::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) {
- const DetectedGame &result = *cand;
+ for (const auto &cand : candidates) {
+ const DetectedGame &result = cand;
Common::Path path = dir.getPath();
path.removeTrailingSeparators();
@@ -226,9 +226,9 @@ void MassAddDialog::handleTickle() {
bool duplicate = false;
const Common::StringArray &targets = _pathToTargets[path];
- for (Common::StringArray::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) {
+ for (const auto &target : targets) {
// If the engineid, gameid, platform and language match -> skip it
- Common::ConfigManager::Domain *dom = ConfMan.getDomain(*iter);
+ Common::ConfigManager::Domain *dom = ConfMan.getDomain(target);
assert(dom);
if ((!dom->contains("engineid") || (*dom)["engineid"] == result.engineId) &&
@@ -256,9 +256,9 @@ void MassAddDialog::handleTickle() {
updateGameList();
// Recurse into all subdirs
- for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
- if (file->isDirectory()) {
- _scanStack.push(*file);
+ for (const auto &file : files) {
+ if (file.isDirectory()) {
+ _scanStack.push(file);
_dirTotal++;
}
diff --git a/gui/options.cpp b/gui/options.cpp
index 448195bfe3d..43baa0ae08b 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -1773,21 +1773,21 @@ void OptionsDialog::addAudioControls(GuiObject *boss, const Common::String &pref
bool hasMidiDefined = (strpbrk(_guioptions.c_str(), allFlags.c_str()) != nullptr);
const PluginList p = MusicMan.getPlugins();
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- Common::String deviceGuiOption = MidiDriver::musicType2GUIO(d->getMusicType());
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ Common::String deviceGuiOption = MidiDriver::musicType2GUIO(d.getMusicType());
- if ((_domain == Common::ConfigManager::kApplicationDomain && d->getMusicType() != MT_TOWNS // global dialog - skip useless FM-Towns, C64, Amiga, AppleIIGS, Macintosh and SegaCD options there
- && d->getMusicType() != MT_C64 && d->getMusicType() != MT_AMIGA && d->getMusicType() != MT_APPLEIIGS && d->getMusicType() != MT_PC98 && d->getMusicType() != MT_MACINTOSH && d->getMusicType() != MT_SEGACD)
+ if ((_domain == Common::ConfigManager::kApplicationDomain && d.getMusicType() != MT_TOWNS // global dialog - skip useless FM-Towns, C64, Amiga, AppleIIGS, Macintosh and SegaCD options there
+ && d.getMusicType() != MT_C64 && d.getMusicType() != MT_AMIGA && d.getMusicType() != MT_APPLEIIGS && d.getMusicType() != MT_PC98 && d.getMusicType() != MT_MACINTOSH && d.getMusicType() != MT_SEGACD)
|| (_domain != Common::ConfigManager::kApplicationDomain && !hasMidiDefined) // No flags are specified
|| (_guioptions.contains(deviceGuiOption)) // flag is present
// HACK/FIXME: For now we have to show GM devices, even when the game only has GUIO_MIDIMT32 set,
// else we would not show for example external devices connected via ALSA, since they are always
// marked as General MIDI device.
|| (deviceGuiOption.contains(GUIO_MIDIGM) && (_guioptions.contains(GUIO_MIDIMT32)))
- || d->getMusicDriverId() == "auto" || d->getMusicDriverId() == "null") // always add default and null device
- _midiPopUp->appendEntry(_(d->getCompleteName()), d->getHandle());
+ || d.getMusicDriverId() == "auto" || d.getMusicDriverId() == "null") // always add default and null device
+ _midiPopUp->appendEntry(_(d.getCompleteName()), d.getHandle());
}
}
@@ -1815,22 +1815,22 @@ void OptionsDialog::addMIDIControls(GuiObject *boss, const Common::String &prefi
const PluginList p = MusicMan.getPlugins();
// Make sure the null device is the first one in the list to avoid undesired
// auto detection for users who don't have a saved setting yet.
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (d->getMusicDriverId() == "null")
- _gmDevicePopUp->appendEntry(_("Don't use General MIDI music"), d->getHandle());
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (d.getMusicDriverId() == "null")
+ _gmDevicePopUp->appendEntry(_("Don't use General MIDI music"), d.getHandle());
}
}
// Now we add the other devices.
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (d->getMusicType() >= MT_GM) {
- if (d->getMusicType() != MT_MT32)
- _gmDevicePopUp->appendEntry(d->getCompleteName(), d->getHandle());
- } else if (d->getMusicDriverId() == "auto") {
- _gmDevicePopUp->appendEntry(_("Use first available device"), d->getHandle());
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (d.getMusicType() >= MT_GM) {
+ if (d.getMusicType() != MT_MT32)
+ _gmDevicePopUp->appendEntry(d.getCompleteName(), d.getHandle());
+ } else if (d.getMusicDriverId() == "auto") {
+ _gmDevicePopUp->appendEntry(_("Use first available device"), d.getHandle());
}
}
}
@@ -1885,21 +1885,21 @@ void OptionsDialog::addMT32Controls(GuiObject *boss, const Common::String &prefi
const PluginList p = MusicMan.getPlugins();
// Make sure the null device is the first one in the list to avoid undesired
// auto detection for users who don't have a saved setting yet.
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (d->getMusicDriverId() == "null")
- _mt32DevicePopUp->appendEntry(_("Don't use Roland MT-32 music"), d->getHandle());
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (d.getMusicDriverId() == "null")
+ _mt32DevicePopUp->appendEntry(_("Don't use Roland MT-32 music"), d.getHandle());
}
}
// Now we add the other devices.
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (d->getMusicType() >= MT_GM)
- _mt32DevicePopUp->appendEntry(d->getCompleteName(), d->getHandle());
- else if (d->getMusicDriverId() == "auto")
- _mt32DevicePopUp->appendEntry(_("Use first available device"), d->getHandle());
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (d.getMusicType() >= MT_GM)
+ _mt32DevicePopUp->appendEntry(d.getCompleteName(), d.getHandle());
+ else if (d.getMusicDriverId() == "auto")
+ _mt32DevicePopUp->appendEntry(_("Use first available device"), d.getHandle());
}
}
@@ -2004,11 +2004,11 @@ bool OptionsDialog::loadMusicDeviceSetting(PopUpWidget *popup, Common::String se
const Common::String drv = ConfMan.get(setting, (_domain != Common::ConfigManager::kApplicationDomain && !ConfMan.hasKey(setting, _domain)) ? Common::ConfigManager::kApplicationDomain : _domain);
const PluginList p = MusicMan.getPlugins();
- for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) {
- MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (setting.empty() ? (preferredType == d->getMusicType()) : (drv == d->getCompleteId())) {
- popup->setSelectedTag(d->getHandle());
+ for (const auto &m : p) {
+ MusicDevices i = m->get<MusicPluginObject>().getDevices();
+ for (auto &d : i) {
+ if (setting.empty() ? (preferredType == d.getMusicType()) : (drv == d.getCompleteId())) {
+ popup->setSelectedTag(d.getHandle());
return popup->getSelected() != -1;
}
}
@@ -2026,9 +2026,9 @@ void OptionsDialog::saveMusicDeviceSetting(PopUpWidget *popup, Common::String se
bool found = false;
for (PluginList::const_iterator m = p.begin(); m != p.end() && !found; ++m) {
MusicDevices i = (*m)->get<MusicPluginObject>().getDevices();
- for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
- if (d->getHandle() == popup->getSelectedTag()) {
- ConfMan.set(setting, d->getCompleteId(), _domain);
+ for (auto &d : i) {
+ if (d.getHandle() == popup->getSelectedTag()) {
+ ConfMan.set(setting, d.getCompleteId(), _domain);
found = true;
break;
}
@@ -2137,8 +2137,8 @@ void OptionsDialog::updateScaleFactors(uint32 tag) {
const Common::Array<uint> &factors = scalerPlugins[tag]->get<ScalerPluginObject>().getFactors();
_scaleFactorPopUp->clearEntries();
- for (Common::Array<uint>::const_iterator it = factors.begin(); it != factors.end(); it++) {
- _scaleFactorPopUp->appendEntry(Common::U32String::format("%dx", (*it)), (*it));
+ for (const auto &factor : factors) {
+ _scaleFactorPopUp->appendEntry(Common::U32String::format("%dx", factor), factor);
}
if (g_system->getScaler() == tag) {
diff --git a/gui/recorderdialog.cpp b/gui/recorderdialog.cpp
index c2d9f7557a9..fa3616eb019 100644
--- a/gui/recorderdialog.cpp
+++ b/gui/recorderdialog.cpp
@@ -260,8 +260,8 @@ void RecorderDialog::updateList() {
Common::U32StringArray namesList;
Common::sort(files.begin(), files.end());
_fileHeaders.clear();
- for (Common::StringArray::iterator i = files.begin(); i != files.end(); ++i) {
- if (file.openRead(*i)) {
+ for (auto &curFile : files) {
+ if (file.openRead(curFile)) {
namesList.push_back(file.getHeader().name);
_fileHeaders.push_back(file.getHeader());
}
diff --git a/gui/remotebrowser.cpp b/gui/remotebrowser.cpp
index 17bc74054cf..c0221f01caf 100644
--- a/gui/remotebrowser.cpp
+++ b/gui/remotebrowser.cpp
@@ -144,11 +144,11 @@ void RemoteBrowserDialog::updateListing() {
if (!_navigationLocked) {
// Populate the ListWidget
Common::U32StringArray list;
- for (Common::Array<Cloud::StorageFile>::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
- if (i->isDirectory()) {
- list.push_back(ListWidget::getThemeColor(ThemeEngine::kFontColorNormal) + Common::U32String(i->name() + "/"));
+ for (auto &node : _nodeContent) {
+ if (node.isDirectory()) {
+ list.push_back(ListWidget::getThemeColor(ThemeEngine::kFontColorNormal) + Common::U32String(node.name() + "/"));
} else {
- list.push_back(ListWidget::getThemeColor(ThemeEngine::kFontColorAlternate) + Common::U32String(i->name()));
+ list.push_back(ListWidget::getThemeColor(ThemeEngine::kFontColorAlternate) + Common::U32String(node.name()));
}
}
diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index a7795956ba0..a8ec970bb0e 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -749,9 +749,9 @@ void SaveLoadChooserSimple::updateSaveList(bool external) {
Common::U32StringArray saveNames;
ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal;
Common::U32String emptyDesc;
- for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) {
+ for (const auto &x : _saveList) {
// Handle gaps in the list of save games
- saveSlot = x->getSaveSlot();
+ saveSlot = x.getSaveSlot();
if (curSlot < saveSlot) {
while (curSlot < saveSlot) {
SaveStateDescriptor dummySave(_metaEngine, curSlot, "");
@@ -761,21 +761,21 @@ void SaveLoadChooserSimple::updateSaveList(bool external) {
}
// Sync the save list iterator
- for (x = _saveList.begin(); x != _saveList.end(); ++x) {
- if (x->getSaveSlot() == saveSlot)
+ for (auto &y : _saveList) {
+ if (y.getSaveSlot() == saveSlot)
break;
}
}
// Show "Untitled saved game" for empty/whitespace saved game descriptions
- Common::U32String description = x->getDescription();
+ Common::U32String description = x.getDescription();
Common::U32String trimmedDescription = description;
trimmedDescription.trim();
if (trimmedDescription.empty()) {
description = _("Untitled saved game");
color = ThemeEngine::kFontColorAlternate;
} else {
- color = x->getLocked() ? ThemeEngine::kFontColorAlternate : ThemeEngine::kFontColorNormal;
+ color = x.getLocked() ? ThemeEngine::kFontColorAlternate : ThemeEngine::kFontColorNormal;
}
saveNames.push_back(GUI::ListWidget::getThemeColor(color) + description);
@@ -948,8 +948,8 @@ void SaveLoadChooserGrid::open() {
if (_saveMode) {
int lastSlot = -1;
_nextFreeSaveSlot = -1;
- for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) {
- const int curSlot = x->getSaveSlot();
+ for (const auto &x : _saveList) {
+ const int curSlot = x.getSaveSlot();
// In case there was a gap found use the slot.
if (lastSlot + 1 < curSlot) {
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 36612d2a64e..8e0e77858d1 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -264,9 +264,9 @@ uint8 Widget::parseHotkey(const Common::U32String &label) {
Common::U32String Widget::cleanupHotkey(const Common::U32String &label) {
Common::U32String res("");
- for (Common::U32String::const_iterator itr = label.begin(); itr != label.end(); itr++) {
- if (*itr != '~') {
- res += *itr;
+ for (const auto &itr : label) {
+ if (itr != '~') {
+ res += itr;
}
}
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index f8b99fb434e..46aa057bfe2 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -362,8 +362,8 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
int newSelectedItem = 0;
int bestMatch = 0;
bool stop;
- for (Common::U32StringArray::const_iterator i = _list.begin(); i != _list.end(); ++i) {
- const int match = matchingCharsIgnoringCase(stripGUIformatting(*i).encode().c_str(), _quickSelectStr.c_str(), stop, _dictionarySelect);
+ for (const auto &entry : _list) {
+ const int match = matchingCharsIgnoringCase(stripGUIformatting(entry).encode().c_str(), _quickSelectStr.c_str(), stop, _dictionarySelect);
if (match > bestMatch || stop) {
_selectedItem = newSelectedItem;
bestMatch = match;
Commit: 2d9ec1ae70ce2ecf4ef3fa8a98c738293e707291
https://github.com/scummvm/scummvm/commit/2d9ec1ae70ce2ecf4ef3fa8a98c738293e707291
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
IMAGE: Use C++ 11 range-based for loops
Changed paths:
image/codecs/cdtoons.cpp
diff --git a/image/codecs/cdtoons.cpp b/image/codecs/cdtoons.cpp
index 0037f67c7ae..b0a027ccc1f 100644
--- a/image/codecs/cdtoons.cpp
+++ b/image/codecs/cdtoons.cpp
@@ -61,8 +61,8 @@ CDToonsDecoder::~CDToonsDecoder() {
_surface->free();
delete _surface;
- for (Common::HashMap<uint16, CDToonsBlock>::iterator i = _blocks.begin(); i != _blocks.end(); i++)
- delete[] i->_value.data;
+ for (auto &block : _blocks)
+ delete[] block._value.data;
}
Graphics::Surface *CDToonsDecoder::decodeFrame(Common::SeekableReadStream &stream) {
Commit: 7cb70d585f82cf48181a774c0b510e231ce9062d
https://github.com/scummvm/scummvm/commit/7cb70d585f82cf48181a774c0b510e231ce9062d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
VIDEO: Use C++ 11 range-based for loops
Changed paths:
video/coktel_decoder.cpp
video/flic_decoder.cpp
video/paco_decoder.cpp
video/subtitles.cpp
video/video_decoder.cpp
diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp
index 0202b8e5393..559f9d3c523 100644
--- a/video/coktel_decoder.cpp
+++ b/video/coktel_decoder.cpp
@@ -2909,35 +2909,35 @@ bool VMDDecoder::hasEmbeddedFiles() const {
}
bool VMDDecoder::hasEmbeddedFile(const Common::String &fileName) const {
- for (Common::Array<File>::const_iterator file = _files.begin(); file != _files.end(); ++file)
- if (!file->name.compareToIgnoreCase(fileName))
+ for (const auto &file : _files)
+ if (!file.name.compareToIgnoreCase(fileName))
return true;
return false;
}
Common::SeekableReadStream *VMDDecoder::getEmbeddedFile(const Common::String &fileName) const {
- const File *file = 0;
+ const File *file = nullptr;
- for (Common::Array<File>::const_iterator it = _files.begin(); it != _files.end(); ++it)
- if (!it->name.compareToIgnoreCase(fileName)) {
- file = &*it;
+ for (const auto &curFile : _files)
+ if (!curFile.name.compareToIgnoreCase(fileName)) {
+ file = &curFile;
break;
}
if (!file)
- return 0;
+ return nullptr;
if ((file->size - 20) != file->realSize) {
warning("VMDDecoder::getEmbeddedFile(): Sizes for \"%s\" differ! (%d, %d)",
fileName.c_str(), (file->size - 20), file->realSize);
- return 0;
+ return nullptr;
}
if (!_stream->seek(file->offset)) {
warning("VMDDecoder::getEmbeddedFile(): Can't seek to offset %d to (file \"%s\")",
file->offset, fileName.c_str());
- return 0;
+ return nullptr;
}
byte *data = (byte *) malloc(file->realSize);
@@ -2945,7 +2945,7 @@ Common::SeekableReadStream *VMDDecoder::getEmbeddedFile(const Common::String &fi
free(data);
warning("VMDDecoder::getEmbeddedFile(): Couldn't read %d bytes (file \"%s\")",
file->realSize, fileName.c_str());
- return 0;
+ return nullptr;
}
Common::MemoryReadStream *stream =
diff --git a/video/flic_decoder.cpp b/video/flic_decoder.cpp
index 2d2677e7e19..9e78e405711 100644
--- a/video/flic_decoder.cpp
+++ b/video/flic_decoder.cpp
@@ -255,10 +255,10 @@ void FlicDecoder::FlicVideoTrack::handleFrame() {
}
void FlicDecoder::FlicVideoTrack::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) {
- for (Common::List<Common::Rect>::const_iterator it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
- for (int y = (*it).top; y < (*it).bottom; ++y) {
- const int x = (*it).left;
- memcpy(dst + y * pitch + x, (byte *)_surface->getBasePtr(x, y), (*it).right - x);
+ for (const auto &dirtyRect : _dirtyRects) {
+ for (int y = dirtyRect.top; y < dirtyRect.bottom; ++y) {
+ const int x = dirtyRect.left;
+ memcpy(dst + y * pitch + x, (byte *)_surface->getBasePtr(x, y), dirtyRect.right - x);
}
}
diff --git a/video/paco_decoder.cpp b/video/paco_decoder.cpp
index 47db0b13591..fecc686c10f 100644
--- a/video/paco_decoder.cpp
+++ b/video/paco_decoder.cpp
@@ -579,10 +579,10 @@ void PacoDecoder::PacoVideoTrack::handleFrame(Common::SeekableReadStream *fileSt
}
void PacoDecoder::PacoVideoTrack::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) {
- for (Common::List<Common::Rect>::const_iterator it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
- for (int y = (*it).top; y < (*it).bottom; ++y) {
- const int x = (*it).left;
- memcpy(dst + y * pitch + x, (byte *)_surface->getBasePtr(x, y), (*it).right - x);
+ for (const auto &dirtyRect : _dirtyRects) {
+ for (int y = dirtyRect.top; y < dirtyRect.bottom; ++y) {
+ const int x = dirtyRect.left;
+ memcpy(dst + y * pitch + x, (byte *)_surface->getBasePtr(x, y), dirtyRect.right - x);
}
}
clearDirtyRects();
diff --git a/video/subtitles.cpp b/video/subtitles.cpp
index 9ad9664b26e..a7b75401150 100644
--- a/video/subtitles.cpp
+++ b/video/subtitles.cpp
@@ -43,8 +43,8 @@ SRTParser::~SRTParser() {
}
void SRTParser::cleanup() {
- for (Common::Array<SRTEntry *>::const_iterator item = _entries.begin(); item != _entries.end(); ++item)
- delete *item;
+ for (const auto &item : _entries)
+ delete item;
_entries.clear();
}
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index 3037dcf94f2..5ad185eeb04 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -54,8 +54,8 @@ void VideoDecoder::close() {
if (isPlaying())
stop();
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- delete *it;
+ for (auto &track : _tracks)
+ delete track;
_tracks.clear();
_internalTracks.clear();
@@ -93,8 +93,8 @@ bool VideoDecoder::loadFile(const Common::Path &filename) {
bool VideoDecoder::needsUpdate() const {
bool hasVideo = false;
bool hasAudio = false;
- for (auto &it : _tracks) {
- switch (it->getTrackType()) {
+ for (auto &track : _tracks) {
+ switch (track->getTrackType()) {
case Track::kTrackTypeAudio:
hasAudio = true;
break;
@@ -136,11 +136,11 @@ void VideoDecoder::pauseVideo(bool pause) {
if (_pauseLevel == 1 && pause) {
_pauseStartTime = g_system->getMillis(); // Store the starting time from pausing to keep it for later
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- (*it)->pause(true);
+ for (auto &track : _tracks)
+ track->pause(true);
} else if (_pauseLevel == 0) {
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- (*it)->pause(false);
+ for (auto &track : _tracks)
+ track->pause(false);
_startTime += (g_system->getMillis() - _pauseStartTime);
}
@@ -154,17 +154,17 @@ void VideoDecoder::resetPauseStartTime() {
void VideoDecoder::setVolume(byte volume) {
_audioVolume = volume;
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
- ((AudioTrack *)*it)->setVolume(_audioVolume);
+ for (auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio)
+ ((AudioTrack *)track)->setVolume(_audioVolume);
}
void VideoDecoder::setBalance(int8 balance) {
_audioBalance = balance;
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
- ((AudioTrack *)*it)->setBalance(_audioBalance);
+ for (auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio)
+ ((AudioTrack *)track)->setBalance(_audioBalance);
}
Audio::Mixer::SoundType VideoDecoder::getSoundType() const {
@@ -174,9 +174,9 @@ Audio::Mixer::SoundType VideoDecoder::getSoundType() const {
void VideoDecoder::setSoundType(Audio::Mixer::SoundType soundType) {
_soundType = soundType;
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
- ((AudioTrack *)*it)->setSoundType(_soundType);
+ for (auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio)
+ ((AudioTrack *)track)->setSoundType(_soundType);
}
bool VideoDecoder::isVideoLoaded() const {
@@ -184,25 +184,25 @@ bool VideoDecoder::isVideoLoaded() const {
}
uint16 VideoDecoder::getWidth() const {
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeVideo)
- return ((VideoTrack *)*it)->getWidth();
+ for (const auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeVideo)
+ return ((VideoTrack *)track)->getWidth();
return 0;
}
uint16 VideoDecoder::getHeight() const {
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeVideo)
- return ((VideoTrack *)*it)->getHeight();
+ for (const auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeVideo)
+ return ((VideoTrack *)track)->getHeight();
return 0;
}
Graphics::PixelFormat VideoDecoder::getPixelFormat() const {
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeVideo)
- return ((VideoTrack *)*it)->getPixelFormat();
+ for (const auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeVideo)
+ return ((VideoTrack *)track)->getPixelFormat();
return Graphics::PixelFormat();
}
@@ -238,9 +238,9 @@ bool VideoDecoder::setReverse(bool reverse) {
return false;
// Attempt to make sure all the tracks are in the requested direction
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if ((*it)->getTrackType() == Track::kTrackTypeVideo && ((VideoTrack *)*it)->isReversed() != reverse) {
- if (!((VideoTrack *)*it)->setReverse(reverse))
+ for (auto &track : _tracks) {
+ if (track->getTrackType() == Track::kTrackTypeVideo && ((VideoTrack *)track)->isReversed() != reverse) {
+ if (!((VideoTrack *)track)->setReverse(reverse))
return false;
_needsUpdate = true; // force an update
@@ -259,9 +259,9 @@ const byte *VideoDecoder::getPalette() {
int VideoDecoder::getCurFrame() const {
int32 frame = -1;
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeVideo)
- frame += ((VideoTrack *)*it)->getCurFrame() + 1;
+ for (const auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeVideo)
+ frame += ((VideoTrack *)track)->getCurFrame() + 1;
return frame;
}
@@ -269,9 +269,9 @@ int VideoDecoder::getCurFrame() const {
uint32 VideoDecoder::getFrameCount() const {
int count = 0;
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeVideo)
- count += ((VideoTrack *)*it)->getFrameCount();
+ for (const auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeVideo)
+ count += ((VideoTrack *)track)->getFrameCount();
return count;
}
@@ -284,9 +284,9 @@ uint32 VideoDecoder::getTime() const {
return MAX<int>((_playbackRate * (_pauseStartTime - _startTime)).toInt(), 0);
if (useAudioSync()) {
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if ((*it)->getTrackType() == Track::kTrackTypeAudio && !(*it)->endOfTrack()) {
- uint32 time = (((const AudioTrack *)*it)->getRunningTime() * _playbackRate).toInt();
+ for (const auto &track : _tracks) {
+ if (track->getTrackType() == Track::kTrackTypeAudio && !track->endOfTrack()) {
+ uint32 time = (((const AudioTrack *)track)->getRunningTime() * _playbackRate).toInt();
if (time != 0)
return time + _lastTimeChange.msecs();
@@ -320,9 +320,7 @@ uint32 VideoDecoder::getTimeToNextFrame() const {
}
bool VideoDecoder::endOfVideo() const {
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- const Track *track = *it;
-
+ for (const auto &track : _tracks) {
bool videoEndTimeReached = _endTimeSet && track->getTrackType() == Track::kTrackTypeVideo && ((const VideoTrack *)track)->getNextFrameStartTime() >= (uint)_endTime.msecs();
bool endReached = track->endOfTrack() || (isPlaying() && videoEndTimeReached);
if (!endReached)
@@ -336,8 +334,8 @@ bool VideoDecoder::isRewindable() const {
if (!isVideoLoaded())
return false;
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if (!(*it)->isRewindable())
+ for (const auto &track : _tracks)
+ if (!track->isRewindable())
return false;
return true;
@@ -351,8 +349,8 @@ bool VideoDecoder::rewind() {
if (isPlaying())
stopAudio();
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if (!(*it)->rewind())
+ for (auto &track : _tracks)
+ if (!track->rewind())
return false;
// Now that we've rewound, start all tracks again
@@ -370,8 +368,8 @@ bool VideoDecoder::isSeekable() const {
if (!isVideoLoaded())
return false;
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if (!(*it)->isSeekable())
+ for (const auto &track : _tracks)
+ if (!track->isSeekable())
return false;
return true;
@@ -390,8 +388,8 @@ bool VideoDecoder::seek(const Audio::Timestamp &time) {
return false;
// Seek any external track too
- for (TrackListIterator it = _externalTracks.begin(); it != _externalTracks.end(); it++)
- if (!(*it)->seek(time))
+ for (auto &track : _externalTracks)
+ if (!track->seek(time))
return false;
_lastTimeChange = time;
@@ -413,24 +411,24 @@ bool VideoDecoder::seekToFrame(uint frame) {
if (!isSeekable())
return false;
- VideoTrack *track = 0;
+ VideoTrack *videoTrack = 0;
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
+ for (auto &track : _tracks) {
+ if (track->getTrackType() == Track::kTrackTypeVideo) {
// We only allow seeking by frame when one video track
// is present
- if (track)
+ if (videoTrack)
return false;
- track = (VideoTrack *)*it;
+ videoTrack = (VideoTrack *)track;
}
}
// If we didn't find a video track, we can't seek by frame (of course)
- if (!track)
+ if (!videoTrack)
return false;
- Audio::Timestamp time = track->getFrameTime(frame);
+ Audio::Timestamp time = videoTrack->getFrameTime(frame);
if (time < 0)
return false;
@@ -466,8 +464,8 @@ void VideoDecoder::stop() {
_pauseLevel = 0;
// Reset the pause state of the tracks too
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- (*it)->pause(false);
+ for (auto &track : _tracks)
+ track->pause(false);
}
void VideoDecoder::setRate(const Common::Rational &rate) {
@@ -516,8 +514,8 @@ bool VideoDecoder::isPlaying() const {
Audio::Timestamp VideoDecoder::getDuration() const {
Audio::Timestamp maxDuration(0, 1000);
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- Audio::Timestamp duration = (*it)->getDuration();
+ for (const auto &track : _tracks) {
+ Audio::Timestamp duration = track->getDuration();
if (duration > maxDuration)
maxDuration = duration;
@@ -527,8 +525,8 @@ Audio::Timestamp VideoDecoder::getDuration() const {
}
bool VideoDecoder::seekIntern(const Audio::Timestamp &time) {
- for (TrackList::iterator it = _internalTracks.begin(); it != _internalTracks.end(); it++)
- if (!(*it)->seek(time))
+ for (auto &track : _internalTracks)
+ if (!track->seek(time))
return false;
return true;
@@ -541,9 +539,9 @@ bool VideoDecoder::setDitheringPalette(const byte *palette) {
bool result = false;
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if ((*it)->getTrackType() == Track::kTrackTypeVideo && ((VideoTrack *)*it)->canDither()) {
- ((VideoTrack *)*it)->setDither(palette);
+ for (auto &track : _tracks) {
+ if (track->getTrackType() == Track::kTrackTypeVideo && ((VideoTrack *)track)->canDither()) {
+ ((VideoTrack *)track)->setDither(palette);
result = true;
}
}
@@ -558,9 +556,9 @@ bool VideoDecoder::setOutputPixelFormat(const Graphics::PixelFormat &format) {
bool result = false;
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
- if (((VideoTrack *)*it)->setOutputPixelFormat(format))
+ for (auto &track : _tracks) {
+ if (track->getTrackType() == Track::kTrackTypeVideo) {
+ if (((VideoTrack *)track)->setOutputPixelFormat(format))
result = true;
}
}
@@ -569,8 +567,8 @@ bool VideoDecoder::setOutputPixelFormat(const Graphics::PixelFormat &format) {
}
bool VideoDecoder::setOutputPixelFormats(const Common::List<Graphics::PixelFormat> &formatList) {
- for (Common::List<Graphics::PixelFormat>::const_iterator i = formatList.begin(); i != formatList.end(); ++i) {
- if (setOutputPixelFormat(*i))
+ for (const auto &format : formatList) {
+ if (setOutputPixelFormat(format))
return true;
}
return false;
@@ -893,8 +891,8 @@ bool VideoDecoder::setAudioTrack(int index) {
uint VideoDecoder::getAudioTrackCount() const {
uint count = 0;
- for (TrackList::const_iterator it = _internalTracks.begin(); it != _internalTracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
+ for (const auto &track : _internalTracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio)
count++;
return count;
@@ -924,23 +922,23 @@ void VideoDecoder::setEndTime(const Audio::Timestamp &endTime) {
}
void VideoDecoder::setEndFrame(uint frame) {
- VideoTrack *track = 0;
+ VideoTrack *videoTrack = nullptr;
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
+ for (auto &track : _tracks) {
+ if (track->getTrackType() == Track::kTrackTypeVideo) {
// We only allow this when one video track is present
- if (track)
+ if (videoTrack)
return;
- track = (VideoTrack *)*it;
+ videoTrack = (VideoTrack *)track;
}
}
// If we didn't find a video track, we can't set the final frame (of course)
- if (!track)
+ if (!videoTrack)
return;
- Audio::Timestamp time = track->getFrameTime(frame + 1);
+ Audio::Timestamp time = videoTrack->getFrameTime(frame + 1);
if (time < 0)
return;
@@ -972,8 +970,8 @@ const VideoDecoder::Track *VideoDecoder::getTrack(uint track) const {
}
bool VideoDecoder::endOfVideoTracks() const {
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeVideo && !(*it)->endOfTrack())
+ for (const auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeVideo && !track->endOfTrack())
return false;
return true;
@@ -983,14 +981,14 @@ VideoDecoder::VideoTrack *VideoDecoder::findNextVideoTrack() {
_nextVideoTrack = 0;
uint32 bestTime = 0xFFFFFFFF;
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if ((*it)->getTrackType() == Track::kTrackTypeVideo && !(*it)->endOfTrack()) {
- VideoTrack *track = (VideoTrack *)*it;
- uint32 time = track->getNextFrameStartTime();
+ for (auto &track : _tracks) {
+ if (track->getTrackType() == Track::kTrackTypeVideo && !track->endOfTrack()) {
+ VideoTrack *videoTrack = (VideoTrack *)track;
+ uint32 time = videoTrack->getNextFrameStartTime();
if (time < bestTime) {
bestTime = time;
- _nextVideoTrack = track;
+ _nextVideoTrack = videoTrack;
}
}
}
@@ -1006,42 +1004,42 @@ void VideoDecoder::startAudio() {
return;
}
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
- ((AudioTrack *)*it)->start();
+ for (auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio)
+ ((AudioTrack *)track)->start();
}
void VideoDecoder::stopAudio() {
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
- ((AudioTrack *)*it)->stop();
+ for (auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio)
+ ((AudioTrack *)track)->stop();
}
void VideoDecoder::setAudioRate(Common::Rational rate) {
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio) {
- ((AudioTrack *)*it)->setRate(rate);
+ for (auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio) {
+ ((AudioTrack *)track)->setRate(rate);
}
}
void VideoDecoder::startAudioLimit(const Audio::Timestamp &limit) {
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
- ((AudioTrack *)*it)->start(limit);
+ for (auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio)
+ ((AudioTrack *)track)->start(limit);
}
bool VideoDecoder::hasFramesLeft() const {
// This is similar to endOfVideo(), except it doesn't take Audio into account (and returns true if not the end of the video)
// This is only used for needsUpdate() atm so that setEndTime() works properly
// And unlike endOfVideoTracks(), this takes into account _endTime
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if ((*it)->getTrackType() != Track::kTrackTypeVideo)
+ for (const auto &track : _tracks) {
+ if (track->getTrackType() != Track::kTrackTypeVideo)
continue;
- const VideoTrack *track = (const VideoTrack *)*it;
+ const VideoTrack *videoTrack = (const VideoTrack *)track;
- bool videoEndTimeReached = _endTimeSet && track->getNextFrameStartTime() >= (uint)_endTime.msecs();
- bool endReached = track->endOfTrack() || (isPlaying() && videoEndTimeReached);
+ bool videoEndTimeReached = _endTimeSet && videoTrack->getNextFrameStartTime() >= (uint)_endTime.msecs();
+ bool endReached = videoTrack->endOfTrack() || (isPlaying() && videoEndTimeReached);
if (!endReached)
return true;
}
@@ -1050,8 +1048,8 @@ bool VideoDecoder::hasFramesLeft() const {
}
bool VideoDecoder::hasAudio() const {
- for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
+ for (const auto &track : _tracks)
+ if (track->getTrackType() == Track::kTrackTypeAudio)
return true;
return false;
Commit: 236c20fc57b24ace844ce41d3663a148e5ae6a66
https://github.com/scummvm/scummvm/commit/236c20fc57b24ace844ce41d3663a148e5ae6a66
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
GOB: Use C++ 11 range-based for loops
Changed paths:
engines/gob/anifile.cpp
engines/gob/minigames/geisha/penetration.cpp
engines/gob/pregob/gctfile.cpp
engines/gob/pregob/seqfile.cpp
engines/gob/pregob/txtfile.cpp
engines/gob/rxyfile.cpp
engines/gob/save/savefile.cpp
engines/gob/sound/adlplayer.cpp
engines/gob/sound/musplayer.cpp
diff --git a/engines/gob/anifile.cpp b/engines/gob/anifile.cpp
index 0ff08c0f577..a1feb8a07ae 100644
--- a/engines/gob/anifile.cpp
+++ b/engines/gob/anifile.cpp
@@ -164,17 +164,17 @@ void ANIFile::loadAnimation(Animation &animation, FrameArray &frames,
area.left = area.top = 0x7FFF;
area.right = area.bottom = -0x7FFF;
- for (ChunkList::const_iterator c = frame.begin(); c != frame.end(); ++c) {
+ for (const auto &c : frame) {
uint16 cL, cT, cR, cB;
- if (!getCoordinates(c->layer, c->part, cL, cT, cR, cB))
+ if (!getCoordinates(c.layer, c.part, cL, cT, cR, cB))
continue;
const uint16 width = cR - cL + 1;
const uint16 height = cB - cT + 1;
- const uint16 l = c->x;
- const uint16 t = c->y;
+ const uint16 l = c.x;
+ const uint16 t = c.y;
const uint16 r = l + width - 1;
const uint16 b = t + height - 1;
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp
index 9a464114355..668b66fd15c 100644
--- a/engines/gob/minigames/geisha/penetration.cpp
+++ b/engines/gob/minigames/geisha/penetration.cpp
@@ -1334,20 +1334,20 @@ void Penetration::checkShields() {
}
void Penetration::checkMouths() {
- for (Common::List<ManagedMouth>::iterator m = _mouths.begin(); m != _mouths.end(); ++m) {
- if (!m->mouth->isDeactivated())
+ for (auto &curMouth : _mouths) {
+ if (!curMouth.mouth->isDeactivated())
continue;
- if ((( m->tileX == _sub->tileX) && (m->tileY == _sub->tileY)) ||
- (((m->tileX + 1) == _sub->tileX) && (m->tileY == _sub->tileY))) {
+ if ((( curMouth.tileX == _sub->tileX) && (curMouth.tileY == _sub->tileY)) ||
+ (((curMouth.tileX + 1) == _sub->tileX) && (curMouth.tileY == _sub->tileY))) {
- m->mouth->activate();
+ curMouth.mouth->activate();
// Play the mouth sound and do health gain/loss
- if (m->type == kMouthTypeBite) {
+ if (curMouth.type == kMouthTypeBite) {
_vm->_sound->blasterPlay(&_soundBite, 1, 0);
healthLose(230);
- } else if (m->type == kMouthTypeKiss) {
+ } else if (curMouth.type == kMouthTypeKiss) {
_vm->_sound->blasterPlay(&_soundKiss, 1, 0);
healthGain(120);
}
@@ -1359,8 +1359,8 @@ void Penetration::checkExits() {
if (!_sub->sub->canMove())
return;
- for (Common::List<MapObject>::iterator e = _exits.begin(); e != _exits.end(); ++e) {
- if ((e->tileX == _sub->tileX) && (e->tileY == _sub->tileY)) {
+ for (auto &ex : _exits) {
+ if ((ex.tileX == _sub->tileX) && (ex.tileY == _sub->tileY)) {
_sub->setMapFromTilePosition();
_sub->sub->leave();
diff --git a/engines/gob/pregob/gctfile.cpp b/engines/gob/pregob/gctfile.cpp
index deeb58d3744..d4c7fa2250d 100644
--- a/engines/gob/pregob/gctfile.cpp
+++ b/engines/gob/pregob/gctfile.cpp
@@ -56,20 +56,20 @@ void GCTFile::load(Common::SeekableReadStream &gct) {
const uint16 itemCount = gct.readUint16LE();
_items.resize(itemCount);
- for (Items::iterator i = _items.begin(); i != _items.end(); ++i) {
+ for (auto &item : _items) {
const uint16 selector = gct.readUint16LE();
const uint16 lineCount = gct.readUint16LE();
- i->selector = selector;
- i->lines.resize(lineCount);
+ item.selector = selector;
+ item.lines.resize(lineCount);
}
// Read all item lines
- for (Items::iterator i = _items.begin(); i != _items.end(); ++i) {
- for (Lines::iterator l = i->lines.begin(); l != i->lines.end(); ++l) {
+ for (auto &item : _items) {
+ for (auto &line : item.lines) {
const uint16 lineSize = gct.readUint16LE();
- readLine(gct, *l, lineSize);
+ readLine(gct, line, lineSize);
}
}
@@ -177,13 +177,13 @@ Common::String GCTFile::getLineText(const Line &line) const {
Common::String text;
// Go over all chunks in this line
- for (Chunks::const_iterator c = line.chunks.begin(); c != line.chunks.end(); ++c) {
+ for (const auto &chunk : line.chunks) {
// A chunk is either a direct string, or a reference to another item
- if (c->type == kChunkTypeItem) {
+ if (chunk.type == kChunkTypeItem) {
Common::List<Common::String> lines;
- getItemText(c->item, lines);
+ getItemText(chunk.item, lines);
if (lines.empty())
continue;
@@ -191,8 +191,8 @@ Common::String GCTFile::getLineText(const Line &line) const {
warning("GCTFile::getLineText(): Referenced item has multiple lines");
text += lines.front();
- } else if (c->type == kChunkTypeString)
- text += c->text;
+ } else if (chunk.type == kChunkTypeString)
+ text += chunk.text;
}
return text;
diff --git a/engines/gob/pregob/seqfile.cpp b/engines/gob/pregob/seqfile.cpp
index d1c7e111ebe..b8875444f90 100644
--- a/engines/gob/pregob/seqfile.cpp
+++ b/engines/gob/pregob/seqfile.cpp
@@ -144,13 +144,13 @@ const ANIFile *SEQFile::findANI(uint16 index, uint16 &animation) {
if (index == 0xFFFF)
return nullptr;
- for (Animations::const_iterator a = _animations.begin(); a != _animations.end(); ++a) {
- if (index < (*a)->getAnimationCount()) {
+ for (const auto &anim : _animations) {
+ if (index < anim->getAnimationCount()) {
animation = index;
- return *a;
+ return anim;
}
- index -= (*a)->getAnimationCount();
+ index -= anim->getAnimationCount();
}
return nullptr;
@@ -214,11 +214,11 @@ void SEQFile::play(bool abortable, uint16 endFrame, uint16 frameRate) {
// Loop
bool looped = false;
- for (Loops::iterator l = _loops.begin(); l != _loops.end(); ++l) {
- if ((l->endFrame == _frame) && (l->currentLoop < l->loopCount)) {
- _frame = l->startFrame;
+ for (auto &loop : _loops) {
+ if ((loop.endFrame == _frame) && (loop.currentLoop < loop.loopCount)) {
+ _frame = loop.startFrame;
- l->currentLoop++;
+ loop.currentLoop++;
looped = true;
}
}
@@ -241,39 +241,39 @@ void SEQFile::playFrame() {
clearAnims();
// Handle background keys, directly updating the background
- for (BackgroundKeys::const_iterator b = _bgKeys.begin(); b != _bgKeys.end(); ++b) {
- if (!b->background || (b->frame != _frame))
+ for (const auto &bg : _bgKeys) {
+ if (!bg.background || (bg.frame != _frame))
continue;
- b->background->draw(*_vm->_draw->_backSurface);
+ bg.background->draw(*_vm->_draw->_backSurface);
_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199);
}
// Handle the animation keys, updating the objects
- for (AnimationKeys::const_iterator a = _animKeys.begin(); a != _animKeys.end(); ++a) {
- if (a->frame != _frame)
+ for (const auto &anim : _animKeys) {
+ if (anim.frame != _frame)
continue;
- Object &object = _objects[a->object];
+ Object &object = _objects[anim.object];
delete object.object;
object.object = nullptr;
// No valid animation => remove
- if ((a->animation == 0xFFFF) || !a->ani)
+ if ((anim.animation == 0xFFFF) || !anim.ani)
continue;
// Change the animation
- object.object = new ANIObject(*a->ani);
+ object.object = new ANIObject(*anim.ani);
- object.object->setAnimation(a->animation);
- object.object->setPosition(a->x, a->y);
+ object.object->setAnimation(anim.animation);
+ object.object->setPosition(anim.x, anim.y);
object.object->setVisible(true);
object.object->setPause(false);
- object.order = a->order;
+ object.order = anim.order;
}
// Draw the animations
@@ -323,13 +323,13 @@ void SEQFile::drawAnims() {
Objects objects = getOrderedObjects();
// Draw the animation frames and advance the animation
- for (Objects::iterator o = objects.begin(); o != objects.end(); ++o) {
+ for (auto &obj : objects) {
int16 left, top, right, bottom;
- if (o->object->draw(*_vm->_draw->_backSurface, left, top, right, bottom))
+ if (obj.object->draw(*_vm->_draw->_backSurface, left, top, right, bottom))
_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
- o->object->advance();
+ obj.object->advance();
}
}
diff --git a/engines/gob/pregob/txtfile.cpp b/engines/gob/pregob/txtfile.cpp
index a3f830722a6..899f1070dbb 100644
--- a/engines/gob/pregob/txtfile.cpp
+++ b/engines/gob/pregob/txtfile.cpp
@@ -78,11 +78,11 @@ bool TXTFile::draw(Surface &surface, int16 &left, int16 &top, int16 &right, int1
resizeBuffer(right - left + 1, bottom - top + 1);
saveScreen(surface, left, top, right, bottom);
- for (LineArray::const_iterator l = _lines.begin(); l != _lines.end(); ++l) {
- if (l->font >= fontCount)
+ for (const auto &line : _lines) {
+ if (line.font >= fontCount)
continue;
- fonts[l->font]->drawString(l->text, l->x, l->y, (color < 0) ? l->color : color, 0, true, surface);
+ fonts[line.font]->drawString(line.text, line.x, line.y, (color < 0) ? line.color : color, 0, true, surface);
}
return true;
diff --git a/engines/gob/rxyfile.cpp b/engines/gob/rxyfile.cpp
index c08cb87d498..13b79e5b4c3 100644
--- a/engines/gob/rxyfile.cpp
+++ b/engines/gob/rxyfile.cpp
@@ -87,15 +87,15 @@ void RXYFile::load(Common::SeekableReadStreamEndian &rxy) {
uint16 count = (rxy.size() - 2) / 8;
_coords.resize(count);
- for (CoordArray::iterator c = _coords.begin(); c != _coords.end(); ++c) {
- c->left = rxy.readUint16();
- c->right = rxy.readUint16();
- c->top = rxy.readUint16();
- c->bottom = rxy.readUint16();
-
- if (c->left != 0xFFFF) {
- _width = MAX<uint16>(_width , c->right + 1);
- _height = MAX<uint16>(_height, c->bottom + 1);
+ for (auto &coord : _coords) {
+ coord.left = rxy.readUint16();
+ coord.right = rxy.readUint16();
+ coord.top = rxy.readUint16();
+ coord.bottom = rxy.readUint16();
+
+ if (coord.left != 0xFFFF) {
+ _width = MAX<uint16>(_width , coord.right + 1);
+ _height = MAX<uint16>(_height, coord.bottom + 1);
}
}
}
diff --git a/engines/gob/save/savefile.cpp b/engines/gob/save/savefile.cpp
index 91216217c62..c3c636bc837 100644
--- a/engines/gob/save/savefile.cpp
+++ b/engines/gob/save/savefile.cpp
@@ -730,11 +730,9 @@ bool SaveContainer::read(Common::ReadStream &stream) {
_header.setSize(calcSize());
// Iterate over all parts
- for (PartIterator it = _parts.begin(); it != _parts.end(); ++it) {
- Part *&p = *it;
-
+ for (auto &part : _parts) {
// Read the part
- if (stream.read(p->data, p->size) != p->size) {
+ if (stream.read(part->data, part->size) != part->size) {
clear();
return false;
}
@@ -752,24 +750,22 @@ bool SaveContainer::write(Common::WriteStream &stream) const {
stream.writeUint32LE(_partCount);
// Iterate over all parts
- for (PartConstIterator it = _parts.begin(); it != _parts.end(); ++it) {
+ for (auto &part : _parts) {
// Part doesn't actually exist => error
- if (!*it)
+ if (!part)
return false;
// Write the part's size
- stream.writeUint32LE((*it)->size);
+ stream.writeUint32LE(part->size);
}
if (!flushStream(stream))
return false;
// Iterate over all parts
- for (PartConstIterator it = _parts.begin(); it != _parts.end(); ++it) {
- Part * const &p = *it;
-
+ for (auto &part : _parts) {
// Write the part
- if (stream.write(p->data, p->size) != p->size)
+ if (stream.write(part->data, part->size) != part->size)
return false;
}
diff --git a/engines/gob/sound/adlplayer.cpp b/engines/gob/sound/adlplayer.cpp
index 0eaf0470c95..6cd7d9f856f 100644
--- a/engines/gob/sound/adlplayer.cpp
+++ b/engines/gob/sound/adlplayer.cpp
@@ -203,9 +203,9 @@ bool ADLPlayer::readHeader(Common::SeekableReadStream &adl, int &timbreCount) {
bool ADLPlayer::readTimbres(Common::SeekableReadStream &adl, int timbreCount) {
_timbres.resize(timbreCount);
- for (Common::Array<Timbre>::iterator t = _timbres.begin(); t != _timbres.end(); ++t) {
+ for (auto &timbre : _timbres) {
for (int i = 0; i < (kOperatorsPerVoice * kParamCount); i++)
- t->startParams[i] = adl.readUint16LE();
+ timbre.startParams[i] = adl.readUint16LE();
}
if (adl.err()) {
diff --git a/engines/gob/sound/musplayer.cpp b/engines/gob/sound/musplayer.cpp
index dafffc1dc4b..4186a8649fb 100644
--- a/engines/gob/sound/musplayer.cpp
+++ b/engines/gob/sound/musplayer.cpp
@@ -268,8 +268,8 @@ bool MUSPlayer::readSNDTimbres(Common::SeekableReadStream &snd, int timbreCount,
// Read names
byte nameBuffer[10];
- for (Common::Array<Timbre>::iterator t = _timbres.begin(); t != _timbres.end(); ++t) {
- if (!readString(snd, t->name, nameBuffer, 9)) {
+ for (auto &timbre : _timbres) {
+ if (!readString(snd, timbre.name, nameBuffer, 9)) {
warning("MUSPlayer::readMUSTimbres(): Failed to read timbre name");
return false;
}
@@ -281,9 +281,9 @@ bool MUSPlayer::readSNDTimbres(Common::SeekableReadStream &snd, int timbreCount,
}
// Read parameters
- for (Common::Array<Timbre>::iterator t = _timbres.begin(); t != _timbres.end(); ++t) {
+ for (auto &timbre : _timbres) {
for (int i = 0; i < (kOperatorsPerVoice * kParamCount); i++)
- t->params[i] = snd.readUint16LE();
+ timbre.params[i] = snd.readUint16LE();
}
return true;
Commit: 32ec1b925845a6c7cf2923bc615d53af7dd10d6c
https://github.com/scummvm/scummvm/commit/32ec1b925845a6c7cf2923bc615d53af7dd10d6c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
SAGA: Use C++ 11 range-based for loops
Changed paths:
engines/saga/actor.cpp
engines/saga/actor_walk.cpp
engines/saga/events.cpp
engines/saga/metaengine.cpp
engines/saga/objectmap.cpp
engines/saga/palanim.cpp
engines/saga/render.cpp
engines/saga/resource.cpp
engines/saga/scene.cpp
diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp
index 194ead0b574..8e05516d3bf 100644
--- a/engines/saga/actor.cpp
+++ b/engines/saga/actor.cpp
@@ -311,19 +311,19 @@ void Actor::loadFrameList(int frameListResourceId, ActorFrameSequences &frames)
ByteArrayReadStreamEndian readS(resourceData, _actorContext->isBigEndian());
- for (ActorFrameSequences::iterator frame = frames.begin(); frame != frames.end(); ++frame) {
+ for (auto &frame : frames) {
for (int orient = 0; orient < ACTOR_DIRECTIONS_COUNT; orient++) {
// Load all four orientations
- frame->directions[orient].frameIndex = readS.readUint16();
+ frame.directions[orient].frameIndex = readS.readUint16();
if (_vm->getGameId() == GID_ITE) {
- frame->directions[orient].frameCount = readS.readSint16();
+ frame.directions[orient].frameCount = readS.readSint16();
} else {
- frame->directions[orient].frameCount = readS.readByte();
+ frame.directions[orient].frameCount = readS.readByte();
readS.readByte();
}
- if (frame->directions[orient].frameCount < 0)
- warning("frameCount < 0 (%d)", frame->directions[orient].frameCount);
- debug(9, "frameIndex %d frameCount %d", frame->directions[orient].frameIndex, frame->directions[orient].frameCount);
+ if (frame.directions[orient].frameCount < 0)
+ warning("frameCount < 0 (%d)", frame.directions[orient].frameCount);
+ debug(9, "frameIndex %d frameCount %d", frame.directions[orient].frameIndex, frame.directions[orient].frameCount);
}
}
}
@@ -456,9 +456,9 @@ void Actor::loadActorList(int protagonistIdx, int actorCount, int actorsResource
_actors[protagonistIdx]._flags |= kProtagonist | kExtended;
- for (ActorDataArray::iterator actor = _actors.begin(); actor != _actors.end(); ++actor) {
+ for (auto &actor : _actors) {
//if (actor->_flags & kProtagonist) {
- loadActorResources(actor);
+ loadActorResources(&actor);
//break;
//}
}
@@ -990,29 +990,29 @@ void Actor::createDrawOrderList() {
}
_drawOrderList.clear();
- for (ActorDataArray::iterator actor = _actors.begin(); actor != _actors.end(); ++actor) {
+ for (auto &actor : _actors) {
- if (!actor->_inScene)
+ if (!actor._inScene)
continue;
- if (calcScreenPosition(actor)) {
- drawOrderListAdd(actor, compareFunction);
+ if (calcScreenPosition(&actor)) {
+ drawOrderListAdd(&actor, compareFunction);
}
}
- for (ObjectDataArray::iterator obj = _objs.begin(); obj != _objs.end(); ++obj) {
- if (obj->_sceneNumber != _vm->_scene->currentSceneNumber())
+ for (auto &obj : _objs) {
+ if (obj._sceneNumber != _vm->_scene->currentSceneNumber())
continue;
// WORKAROUND for a bug found in the original interpreter of IHNM
// If an object's x or y value is negative, don't draw it
// Scripts set negative values for an object's x and y when it shouldn't
// be drawn anymore (i.e. when it's picked up or used)
- if (obj->_location.x < 0 || obj->_location.y < 0)
+ if (obj._location.x < 0 || obj._location.y < 0)
continue;
- if (calcScreenPosition(obj)) {
- drawOrderListAdd(obj, compareFunction);
+ if (calcScreenPosition(&obj)) {
+ drawOrderListAdd(&obj, compareFunction);
}
}
}
@@ -1247,12 +1247,12 @@ void Actor::saveState(Common::OutSaveFile *out) {
out->writeSint16LE(getProtagState());
- for (ActorDataArray::iterator actor = _actors.begin(); actor != _actors.end(); ++actor) {
- actor->saveState(out);
+ for (auto &actor : _actors) {
+ actor.saveState(out);
}
- for (ObjectDataArray::iterator obj = _objs.begin(); obj != _objs.end(); ++obj) {
- obj->saveState(out);
+ for (auto &obj : _objs) {
+ obj.saveState(out);
}
}
@@ -1263,12 +1263,12 @@ void Actor::loadState(Common::InSaveFile *in) {
setProtagState(protagState);
}
- for (ActorDataArray::iterator actor = _actors.begin(); actor != _actors.end(); ++actor) {
- actor->loadState(_vm->getCurrentLoadVersion(), in);
+ for (auto &actor : _actors) {
+ actor.loadState(_vm->getCurrentLoadVersion(), in);
}
- for (ObjectDataArray::iterator obj = _objs.begin(); obj != _objs.end(); ++obj) {
- obj->loadState(in);
+ for (auto &obj : _objs) {
+ obj.loadState(in);
}
}
diff --git a/engines/saga/actor_walk.cpp b/engines/saga/actor_walk.cpp
index ed7e0ae9581..b98fe179883 100644
--- a/engines/saga/actor_walk.cpp
+++ b/engines/saga/actor_walk.cpp
@@ -191,26 +191,26 @@ void Actor::updateActorsScene(int actorsEntrance) {
_activeSpeech.playing = false;
_protagonist = nullptr;
- for (ActorDataArray::iterator actor = _actors.begin(); actor != _actors.end(); ++actor) {
- actor->_lastZone = nullptr;
- actor->_inScene = false;
- actor->_spriteList.clear();
- if ((actor->_flags & (kProtagonist | kFollower)) || (actor->_index == 0)) {
- if (actor->_flags & kProtagonist) {
- actor->_finalTarget = actor->_location;
- _centerActor = _protagonist = actor;
+ for (auto &actor : _actors) {
+ actor._lastZone = nullptr;
+ actor._inScene = false;
+ actor._spriteList.clear();
+ if ((actor._flags & (kProtagonist | kFollower)) || (actor._index == 0)) {
+ if (actor._flags & kProtagonist) {
+ actor._finalTarget = actor._location;
+ _centerActor = _protagonist = &actor;
} else if (_vm->getGameId() == GID_ITE &&
_vm->_scene->currentSceneResourceId() == ITE_SCENE_OVERMAP) {
continue;
}
- actor->_sceneNumber = _vm->_scene->currentSceneNumber();
+ actor._sceneNumber = _vm->_scene->currentSceneNumber();
}
- if (actor->_sceneNumber == _vm->_scene->currentSceneNumber()) {
- actor->_inScene = true;
- actor->_actionCycle = (_vm->_rnd.getRandomNumber(7) & 0x7) * 4; // 1/8th chance
- if (actor->_currentAction != kActionFreeze) {
- actor->_currentAction = kActionWait;
+ if (actor._sceneNumber == _vm->_scene->currentSceneNumber()) {
+ actor._inScene = true;
+ actor._actionCycle = (_vm->_rnd.getRandomNumber(7) & 0x7) * 4; // 1/8th chance
+ if (actor._currentAction != kActionFreeze) {
+ actor._currentAction = kActionWait;
}
}
}
@@ -258,16 +258,16 @@ void Actor::updateActorsScene(int actorsEntrance) {
followerDirection = _protagonist->_facingDirection + 3;
calcScreenPosition(_protagonist);
- for (ActorDataArray::iterator actor = _actors.begin(); actor != _actors.end(); ++actor) {
- if (actor->_flags & (kFollower)) {
- actor->_facingDirection = actor->_actionDirection = _protagonist->_facingDirection;
- actor->_currentAction = kActionWait;
- actor->_walkStepsCount = actor->_walkStepIndex = 0;
- actor->_location.z = _protagonist->_location.z;
+ for (auto &actor : _actors) {
+ if (actor._flags & (kFollower)) {
+ actor._facingDirection = actor._actionDirection = _protagonist->_facingDirection;
+ actor._currentAction = kActionWait;
+ actor._walkStepsCount = actor._walkStepIndex = 0;
+ actor._location.z = _protagonist->_location.z;
if (_vm->_scene->getFlags() & kSceneFlagISO) {
- _vm->_isoMap->placeOnTileMap(_protagonist->_location, actor->_location, 3, followerDirection & 0x07);
+ _vm->_isoMap->placeOnTileMap(_protagonist->_location, actor._location, 3, followerDirection & 0x07);
} else {
followerDirection &= 0x07;
@@ -300,7 +300,7 @@ void Actor::updateActorsScene(int actorsEntrance) {
}
}
- actor->_location = possibleLocation;
+ actor._location = possibleLocation;
}
followerDirection += 2;
}
@@ -325,79 +325,79 @@ void Actor::handleActions(int msec, bool setup) {
Point hitPoint;
Location pickLocation;
- for (ActorDataArray::iterator actor = _actors.begin(); actor != _actors.end(); ++actor) {
- if (!actor->_inScene)
+ for (auto &actor : _actors) {
+ if (!actor._inScene)
continue;
- if ((_vm->getGameId() == GID_ITE) && (actor->_index == ACTOR_DRAGON_INDEX)) {
- moveDragon(actor);
+ if ((_vm->getGameId() == GID_ITE) && (actor._index == ACTOR_DRAGON_INDEX)) {
+ moveDragon(&actor);
continue;
}
- switch (actor->_currentAction) {
+ switch (actor._currentAction) {
case kActionWait:
- if (!setup && (actor->_flags & kFollower)) {
- followProtagonist(actor);
- if (actor->_currentAction != kActionWait)
+ if (!setup && (actor._flags & kFollower)) {
+ followProtagonist(&actor);
+ if (actor._currentAction != kActionWait)
break;
}
- if (actor->_targetObject != ID_NOTHING) {
- actorFaceTowardsObject(actor->_id, actor->_targetObject);
+ if (actor._targetObject != ID_NOTHING) {
+ actorFaceTowardsObject(actor._id, actor._targetObject);
}
- if (actor->_flags & kCycle) {
- frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameStand));
+ if (actor._flags & kCycle) {
+ frameRange = getActorFrameRange(actor._id, getFrameType(kFrameStand));
if (frameRange->frameCount > 0) {
- actor->_actionCycle++;
- actor->_actionCycle = (actor->_actionCycle) % frameRange->frameCount;
+ actor._actionCycle++;
+ actor._actionCycle = (actor._actionCycle) % frameRange->frameCount;
} else {
- actor->_actionCycle = 0;
+ actor._actionCycle = 0;
}
- actor->_frameNumber = frameRange->frameIndex + actor->_actionCycle;
+ actor._frameNumber = frameRange->frameIndex + actor._actionCycle;
break;
}
- if ((actor->_actionCycle & 3) == 0) {
- actor->cycleWrap(100);
+ if ((actor._actionCycle & 3) == 0) {
+ actor.cycleWrap(100);
- frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameWait));
- if ((frameRange->frameCount < 1 || actor->_actionCycle > 33))
- frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameStand));
+ frameRange = getActorFrameRange(actor._id, getFrameType(kFrameWait));
+ if ((frameRange->frameCount < 1 || actor._actionCycle > 33))
+ frameRange = getActorFrameRange(actor._id, getFrameType(kFrameStand));
if (frameRange->frameCount) {
- actor->_frameNumber = frameRange->frameIndex + (uint16)_vm->_rnd.getRandomNumber(frameRange->frameCount - 1);
+ actor._frameNumber = frameRange->frameIndex + (uint16)_vm->_rnd.getRandomNumber(frameRange->frameCount - 1);
} else {
- actor->_frameNumber = frameRange->frameIndex;
+ actor._frameNumber = frameRange->frameIndex;
}
}
- actor->_actionCycle++;
+ actor._actionCycle++;
break;
case kActionWalkToPoint:
case kActionWalkToLink:
if (_vm->_scene->getFlags() & kSceneFlagISO) {
- actor->_partialTarget.delta(actor->_location, delta);
+ actor._partialTarget.delta(actor._location, delta);
while ((delta.u() == 0) && (delta.v() == 0)) {
- if ((actor == _protagonist) && (_vm->mouseButtonPressed())) {
+ if ((&actor == _protagonist) && (_vm->mouseButtonPressed())) {
_vm->_isoMap->screenPointToTileCoords(_vm->mousePos(), pickLocation);
if (!actorWalkTo(_protagonist->_id, pickLocation)) {
break;
}
- } else if (!_vm->_isoMap->nextTileTarget(actor) && !actorEndWalk(actor->_id, true)) {
+ } else if (!_vm->_isoMap->nextTileTarget(&actor) && !actorEndWalk(actor._id, true)) {
break;
}
- actor->_partialTarget.delta(actor->_location, delta);
- actor->_partialTarget.z = 0;
+ actor._partialTarget.delta(actor._location, delta);
+ actor._partialTarget.z = 0;
}
- if (actor->_flags & kFastest) {
+ if (actor._flags & kFastest) {
speed = 8;
- } else if (actor->_flags & kFaster) {
+ } else if (actor._flags & kFaster) {
speed = 6;
} else {
speed = 4;
@@ -407,7 +407,7 @@ void Actor::handleActions(int msec, bool setup) {
speed = 2;
}
- if ((actor->_actionDirection == 2) || (actor->_actionDirection == 6)) {
+ if ((actor._actionDirection == 2) || (actor._actionDirection == 6)) {
speed = speed / 2;
}
@@ -431,41 +431,41 @@ void Actor::handleActions(int msec, bool setup) {
}
}
- actor->_location.add(addDelta);
+ actor._location.add(addDelta);
} else {
- actor->_partialTarget.delta(actor->_location, delta);
+ actor._partialTarget.delta(actor._location, delta);
while ((delta.x == 0) && (delta.y == 0)) {
- if (actor->_walkStepIndex >= actor->_walkStepsCount) {
- actorEndWalk(actor->_id, true);
+ if (actor._walkStepIndex >= actor._walkStepsCount) {
+ actorEndWalk(actor._id, true);
return; // break out of select case
}
- actor->_partialTarget.fromScreenPoint(actor->_walkStepsPoints[actor->_walkStepIndex++]);
+ actor._partialTarget.fromScreenPoint(actor._walkStepsPoints[actor._walkStepIndex++]);
if (_vm->getGameId() == GID_ITE) {
- if (actor->_partialTarget.x > 224 * 2 * ACTOR_LMULT) {
- actor->_partialTarget.x -= 256 * 2 * ACTOR_LMULT;
+ if (actor._partialTarget.x > 224 * 2 * ACTOR_LMULT) {
+ actor._partialTarget.x -= 256 * 2 * ACTOR_LMULT;
}
} else {
- if (actor->_partialTarget.x > 224 * 4 * ACTOR_LMULT) {
- actor->_partialTarget.x -= 256 * 4 * ACTOR_LMULT;
+ if (actor._partialTarget.x > 224 * 4 * ACTOR_LMULT) {
+ actor._partialTarget.x -= 256 * 4 * ACTOR_LMULT;
}
}
- actor->_partialTarget.delta(actor->_location, delta);
+ actor._partialTarget.delta(actor._location, delta);
if (ABS(delta.y) > ABS(delta.x)) {
- actor->_actionDirection = delta.y > 0 ? kDirDown : kDirUp;
+ actor._actionDirection = delta.y > 0 ? kDirDown : kDirUp;
} else {
- actor->_actionDirection = delta.x > 0 ? kDirRight : kDirLeft;
+ actor._actionDirection = delta.x > 0 ? kDirRight : kDirLeft;
}
}
if (_vm->getGameId() == GID_ITE)
- speed = (ACTOR_LMULT * 2 * actor->_screenScale + 63) / 256;
+ speed = (ACTOR_LMULT * 2 * actor._screenScale + 63) / 256;
else
- speed = (ACTOR_SPEED * actor->_screenScale + 128) >> 8;
+ speed = (ACTOR_SPEED * actor._screenScale + 128) >> 8;
if (speed < 1)
speed = 1;
@@ -473,7 +473,7 @@ void Actor::handleActions(int msec, bool setup) {
if (_vm->getGameId() == GID_IHNM)
speed = speed / 2;
- if ((actor->_actionDirection == kDirUp) || (actor->_actionDirection == kDirDown)) {
+ if ((actor._actionDirection == kDirUp) || (actor._actionDirection == kDirDown)) {
addDelta.y = CLIP<int>(delta.y, -speed, speed);
if (addDelta.y == delta.y) {
addDelta.x = delta.x;
@@ -481,7 +481,7 @@ void Actor::handleActions(int msec, bool setup) {
addDelta.x = delta.x * addDelta.y;
addDelta.x += (addDelta.x > 0) ? (delta.y / 2) : (-delta.y / 2);
addDelta.x /= delta.y;
- actor->_facingDirection = actor->_actionDirection;
+ actor._facingDirection = actor._actionDirection;
}
} else {
addDelta.x = CLIP<int>(delta.x, -2 * speed, 2 * speed);
@@ -491,80 +491,80 @@ void Actor::handleActions(int msec, bool setup) {
addDelta.y = delta.y * addDelta.x;
addDelta.y += (addDelta.y > 0) ? (delta.x / 2) : (-delta.x / 2);
addDelta.y /= delta.x;
- actor->_facingDirection = actor->_actionDirection;
+ actor._facingDirection = actor._actionDirection;
}
}
- actor->_location.add(addDelta);
+ actor._location.add(addDelta);
}
- if (actor->_actorFlags & kActorBackwards) {
- actor->_facingDirection = (actor->_actionDirection + 4) & 7;
- actor->_actionCycle--;
+ if (actor._actorFlags & kActorBackwards) {
+ actor._facingDirection = (actor._actionDirection + 4) & 7;
+ actor._actionCycle--;
} else {
- actor->_actionCycle++;
+ actor._actionCycle++;
}
- frameRange = getActorFrameRange(actor->_id, actor->_walkFrameSequence);
+ frameRange = getActorFrameRange(actor._id, actor._walkFrameSequence);
- if (actor->_actionCycle < 0) {
- actor->_actionCycle = frameRange->frameCount - 1;
- } else if (actor->_actionCycle >= frameRange->frameCount) {
- actor->_actionCycle = 0;
+ if (actor._actionCycle < 0) {
+ actor._actionCycle = frameRange->frameCount - 1;
+ } else if (actor._actionCycle >= frameRange->frameCount) {
+ actor._actionCycle = 0;
}
- actor->_frameNumber = frameRange->frameIndex + actor->_actionCycle;
+ actor._frameNumber = frameRange->frameIndex + actor._actionCycle;
break;
case kActionWalkDir:
if (_vm->_scene->getFlags() & kSceneFlagISO) {
- actor->_location.u() += tileDirectionLUT[actor->_actionDirection][0];
- actor->_location.v() += tileDirectionLUT[actor->_actionDirection][1];
+ actor._location.u() += tileDirectionLUT[actor._actionDirection][0];
+ actor._location.v() += tileDirectionLUT[actor._actionDirection][1];
- frameRange = getActorFrameRange(actor->_id, actor->_walkFrameSequence);
+ frameRange = getActorFrameRange(actor._id, actor._walkFrameSequence);
- actor->_actionCycle++;
- actor->cycleWrap(frameRange->frameCount);
- actor->_frameNumber = frameRange->frameIndex + actor->_actionCycle;
+ actor._actionCycle++;
+ actor.cycleWrap(frameRange->frameCount);
+ actor._frameNumber = frameRange->frameIndex + actor._actionCycle;
} else {
if (_vm->getGameId() == GID_ITE) {
- actor->_location.x += directionLUT[actor->_actionDirection][0] * 2;
- actor->_location.y += directionLUT[actor->_actionDirection][1] * 2;
+ actor._location.x += directionLUT[actor._actionDirection][0] * 2;
+ actor._location.y += directionLUT[actor._actionDirection][1] * 2;
} else {
// FIXME: The original does not multiply by 8 here, but we do
- actor->_location.x += (directionLUT[actor->_actionDirection][0] * 8 * actor->_screenScale + 128) >> 8;
- actor->_location.y += (directionLUT[actor->_actionDirection][1] * 8 * actor->_screenScale + 128) >> 8;
+ actor._location.x += (directionLUT[actor._actionDirection][0] * 8 * actor._screenScale + 128) >> 8;
+ actor._location.y += (directionLUT[actor._actionDirection][1] * 8 * actor._screenScale + 128) >> 8;
}
- frameRange = getActorFrameRange(actor->_id, actor->_walkFrameSequence);
- actor->_actionCycle++;
- actor->cycleWrap(frameRange->frameCount);
- actor->_frameNumber = frameRange->frameIndex + actor->_actionCycle;
+ frameRange = getActorFrameRange(actor._id, actor._walkFrameSequence);
+ actor._actionCycle++;
+ actor.cycleWrap(frameRange->frameCount);
+ actor._frameNumber = frameRange->frameIndex + actor._actionCycle;
}
break;
case kActionSpeak:
- actor->_actionCycle++;
- actor->cycleWrap(64);
+ actor._actionCycle++;
+ actor.cycleWrap(64);
- frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameGesture));
- if (actor->_actionCycle >= frameRange->frameCount) {
- if (actor->_actionCycle & 1)
+ frameRange = getActorFrameRange(actor._id, getFrameType(kFrameGesture));
+ if (actor._actionCycle >= frameRange->frameCount) {
+ if (actor._actionCycle & 1)
break;
- frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameSpeak));
+ frameRange = getActorFrameRange(actor._id, getFrameType(kFrameSpeak));
state = (uint16)_vm->_rnd.getRandomNumber(frameRange->frameCount);
if (state == 0) {
- frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameStand));
+ frameRange = getActorFrameRange(actor._id, getFrameType(kFrameStand));
} else {
state--;
}
} else {
- state = actor->_actionCycle;
+ state = actor._actionCycle;
}
- actor->_frameNumber = frameRange->frameIndex + state;
+ actor._frameNumber = frameRange->frameIndex + state;
break;
case kActionAccept:
@@ -574,105 +574,105 @@ void Actor::handleActions(int msec, bool setup) {
case kActionCycleFrames:
case kActionPongFrames:
- if (actor->_cycleTimeCount > 0) {
- actor->_cycleTimeCount--;
+ if (actor._cycleTimeCount > 0) {
+ actor._cycleTimeCount--;
break;
}
- actor->_cycleTimeCount = actor->_cycleDelay;
- actor->_actionCycle++;
+ actor._cycleTimeCount = actor._cycleDelay;
+ actor._actionCycle++;
- frameRange = getActorFrameRange(actor->_id, actor->_cycleFrameSequence);
+ frameRange = getActorFrameRange(actor._id, actor._cycleFrameSequence);
- if (actor->_currentAction == kActionPongFrames) {
- if (actor->_actionCycle >= frameRange->frameCount * 2 - 2) {
- if (actor->_actorFlags & kActorContinuous) {
- actor->_actionCycle = 0;
+ if (actor._currentAction == kActionPongFrames) {
+ if (actor._actionCycle >= frameRange->frameCount * 2 - 2) {
+ if (actor._actorFlags & kActorContinuous) {
+ actor._actionCycle = 0;
} else {
- actor->_currentAction = kActionFreeze;
+ actor._currentAction = kActionFreeze;
break;
}
}
- state = actor->_actionCycle;
+ state = actor._actionCycle;
if (state >= frameRange->frameCount) {
state = frameRange->frameCount * 2 - 2 - state;
}
} else {
- if (actor->_actionCycle >= frameRange->frameCount) {
- if (actor->_actorFlags & kActorContinuous) {
- actor->_actionCycle = 0;
+ if (actor._actionCycle >= frameRange->frameCount) {
+ if (actor._actorFlags & kActorContinuous) {
+ actor._actionCycle = 0;
} else {
- actor->_currentAction = kActionFreeze;
+ actor._currentAction = kActionFreeze;
break;
}
}
- state = actor->_actionCycle;
+ state = actor._actionCycle;
}
- if (frameRange->frameCount && (actor->_actorFlags & kActorRandom)) {
+ if (frameRange->frameCount && (actor._actorFlags & kActorRandom)) {
state = _vm->_rnd.getRandomNumber(frameRange->frameCount - 1);
}
- if (actor->_actorFlags & kActorBackwards) {
- actor->_frameNumber = frameRange->frameIndex + frameRange->frameCount - 1 - state;
+ if (actor._actorFlags & kActorBackwards) {
+ actor._frameNumber = frameRange->frameIndex + frameRange->frameCount - 1 - state;
} else {
- actor->_frameNumber = frameRange->frameIndex + state;
+ actor._frameNumber = frameRange->frameIndex + state;
}
break;
case kActionFall:
- if (actor->_actionCycle > 0) {
- framesLeft = actor->_actionCycle--;
- actor->_finalTarget.delta(actor->_location, delta);
+ if (actor._actionCycle > 0) {
+ framesLeft = actor._actionCycle--;
+ actor._finalTarget.delta(actor._location, delta);
delta.x /= framesLeft;
delta.y /= framesLeft;
- actor->_location.addXY(delta);
- actor->_fallVelocity += actor->_fallAcceleration;
- actor->_fallPosition += actor->_fallVelocity;
- actor->_location.z = actor->_fallPosition >> 4;
+ actor._location.addXY(delta);
+ actor._fallVelocity += actor._fallAcceleration;
+ actor._fallPosition += actor._fallVelocity;
+ actor._location.z = actor._fallPosition >> 4;
} else {
- actor->_location = actor->_finalTarget;
- actor->_currentAction = kActionFreeze;
- _vm->_script->wakeUpActorThread(kWaitTypeWalk, actor);
+ actor._location = actor._finalTarget;
+ actor._currentAction = kActionFreeze;
+ _vm->_script->wakeUpActorThread(kWaitTypeWalk, &actor);
}
break;
case kActionClimb:
- actor->_cycleDelay++;
- if (actor->_cycleDelay & 3) {
+ actor._cycleDelay++;
+ if (actor._cycleDelay & 3) {
break;
}
- if (actor->_location.z >= actor->_finalTarget.z + ACTOR_CLIMB_SPEED) {
- actor->_location.z -= ACTOR_CLIMB_SPEED;
- actor->_actionCycle--;
- } else if (actor->_location.z <= actor->_finalTarget.z - ACTOR_CLIMB_SPEED) {
- actor->_location.z += ACTOR_CLIMB_SPEED;
- actor->_actionCycle++;
+ if (actor._location.z >= actor._finalTarget.z + ACTOR_CLIMB_SPEED) {
+ actor._location.z -= ACTOR_CLIMB_SPEED;
+ actor._actionCycle--;
+ } else if (actor._location.z <= actor._finalTarget.z - ACTOR_CLIMB_SPEED) {
+ actor._location.z += ACTOR_CLIMB_SPEED;
+ actor._actionCycle++;
} else {
- actor->_location.z = actor->_finalTarget.z;
- actor->_currentAction = kActionFreeze;
- _vm->_script->wakeUpActorThread(kWaitTypeWalk, actor);
+ actor._location.z = actor._finalTarget.z;
+ actor._currentAction = kActionFreeze;
+ _vm->_script->wakeUpActorThread(kWaitTypeWalk, &actor);
}
- frameRange = getActorFrameRange(actor->_id, actor->_cycleFrameSequence);
+ frameRange = getActorFrameRange(actor._id, actor._cycleFrameSequence);
- if (actor->_actionCycle < 0) {
- actor->_actionCycle = frameRange->frameCount - 1;
+ if (actor._actionCycle < 0) {
+ actor._actionCycle = frameRange->frameCount - 1;
}
- actor->cycleWrap(frameRange->frameCount);
- actor->_frameNumber = frameRange->frameIndex + actor->_actionCycle;
+ actor.cycleWrap(frameRange->frameCount);
+ actor._frameNumber = frameRange->frameIndex + actor._actionCycle;
break;
}
- if ((actor->_currentAction >= kActionWalkToPoint) && (actor->_currentAction <= kActionWalkDir)) {
+ if ((actor._currentAction >= kActionWalkToPoint) && (actor._currentAction <= kActionWalkDir)) {
hitZone = nullptr;
if (_vm->_scene->getFlags() & kSceneFlagISO) {
- actor->_location.toScreenPointUV(hitPoint);
+ actor._location.toScreenPointUV(hitPoint);
} else {
- actor->_location.toScreenPointXY(hitPoint);
+ actor._location.toScreenPointXY(hitPoint);
}
hitZoneIndex = _vm->_scene->_actionMap->hitTest(hitPoint);
if (hitZoneIndex != -1) {
@@ -691,16 +691,16 @@ void Actor::handleActions(int msec, bool setup) {
hitZone = nullptr;
}
- if (hitZone != actor->_lastZone) {
- if (actor->_lastZone)
- stepZoneAction(actor, actor->_lastZone, true, false);
- actor->_lastZone = hitZone;
+ if (hitZone != actor._lastZone) {
+ if (actor._lastZone)
+ stepZoneAction(&actor, actor._lastZone, true, false);
+ actor._lastZone = hitZone;
// WORKAROUND for graphics glitch in the rat caves. Don't do this step zone action in the rat caves
// (room 51) for hitzone 24577 (the door with the copy protection) to avoid the glitch. This glitch
// happens because the copy protection is supposed to kick in at this point, but it's bypassed
// (with permission from Wyrmkeep Entertainment)
if (hitZone && !(_vm->getGameId() == GID_ITE && _vm->_scene->currentSceneNumber() == 51 && hitZone->getHitZoneId() == 24577)) {
- stepZoneAction(actor, hitZone, false, false);
+ stepZoneAction(&actor, hitZone, false, false);
}
}
}
@@ -965,13 +965,15 @@ bool Actor::actorWalkTo(uint16 actorId, const Location &toLocation) {
collision.x = ACTOR_COLLISION_WIDTH * actor->_screenScale / (256 * 2);
collision.y = ACTOR_COLLISION_HEIGHT * actor->_screenScale / (256 * 2);
- for (ActorDataArray::iterator anotherActor = _actors.begin(); (anotherActor != _actors.end()) && (_barrierCount < ACTOR_BARRIERS_MAX); ++anotherActor) {
- if (!anotherActor->_inScene)
+ for (auto &anotherActor : _actors) {
+ if (_barrierCount >= ACTOR_BARRIERS_MAX)
+ break;
+ if (!anotherActor._inScene)
continue;
- if (anotherActor == actor)
+ if (&anotherActor == actor)
continue;
- anotherActorScreenPosition = anotherActor->_screenPosition;
+ anotherActorScreenPosition = anotherActor._screenPosition;
testBox.left = (anotherActorScreenPosition.x - collision.x) & ~1;
testBox.right = (anotherActorScreenPosition.x + collision.x) & ~1;
testBox.top = anotherActorScreenPosition.y - collision.y;
diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp
index 988227a2d17..22c147f8f50 100644
--- a/engines/saga/events.cpp
+++ b/engines/saga/events.cpp
@@ -641,11 +641,11 @@ void Events::freeList() {
void Events::processEventTime(long msec) {
uint16 event_count = 0;
- for (EventList::iterator eventi = _eventList.begin(); eventi != _eventList.end(); ++eventi) {
- eventi->front().time -= msec;
+ for (auto &eventi : _eventList) {
+ eventi.front().time -= msec;
event_count++;
- if (eventi->front().type == kEvTImmediate)
+ if (eventi.front().type == kEvTImmediate)
break;
if (event_count > EVENT_WARNINGCOUNT) {
diff --git a/engines/saga/metaengine.cpp b/engines/saga/metaengine.cpp
index 92bf214895c..befe5a150c8 100644
--- a/engines/saga/metaengine.cpp
+++ b/engines/saga/metaengine.cpp
@@ -156,12 +156,12 @@ SaveStateList SagaMetaEngine::listSaves(const char *target) const {
SaveStateList saveList;
int slotNum = 0;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &file : filenames) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
- slotNum = atoi(file->c_str() + file->size() - 2);
+ slotNum = atoi(file.c_str() + file.size() - 2);
if (slotNum >= 0 && slotNum < MAX_SAVES) {
- Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = saveFileMan->openForLoading(file);
if (in) {
for (int i = 0; i < 3; i++)
in->readUint32BE();
diff --git a/engines/saga/objectmap.cpp b/engines/saga/objectmap.cpp
index f59416a8ba1..1ff36039c5b 100644
--- a/engines/saga/objectmap.cpp
+++ b/engines/saga/objectmap.cpp
@@ -50,22 +50,22 @@ void HitZone::load(SagaEngine *vm, Common::MemoryReadStreamEndian *readStream, i
_nameIndex = readStream->readUint16();
_scriptNumber = readStream->readUint16();
- for (ClickAreas::iterator i = _clickAreas.begin(); i != _clickAreas.end(); ++i) {
- i->resize(readStream->readUint16LE());
+ for (auto &area : _clickAreas) {
+ area.resize(readStream->readUint16LE());
- assert(!i->empty());
+ assert(!area.empty());
- for (ClickArea::iterator j = i->begin(); j != i->end(); ++j) {
- j->x = readStream->readSint16();
- j->y = readStream->readSint16();
+ for (auto &point : area) {
+ point.x = readStream->readSint16();
+ point.y = readStream->readSint16();
// WORKAROUND: bug #2154: "ITE: Riff ignores command in Ferret merchant center"
// Apparently ITE Mac version has bug in game data. Both ObjectMap and ActionMap
// for exit area are little taller (y = 123) and thus Riff goes to exit
// when clicked on barrel of nails.
if (vm->getGameId() == GID_ITE) {
- if (sceneNumber == 18 && index == 0 && (i == _clickAreas.begin()) && (j == i->begin()) && j->y == 123) {
- j->y = 129;
+ if (sceneNumber == 18 && index == 0 && (&area == _clickAreas.begin()) && (&point == area.begin()) && point.y == 123) {
+ point.y = 129;
}
}
}
@@ -73,9 +73,9 @@ void HitZone::load(SagaEngine *vm, Common::MemoryReadStreamEndian *readStream, i
}
bool HitZone::getSpecialPoint(Point &specialPoint) const {
- for (ClickAreas::const_iterator i = _clickAreas.begin(); i != _clickAreas.end(); ++i) {
- if (i->size() == 1) {
- specialPoint = (*i)[0];
+ for (const auto &area : _clickAreas) {
+ if (area.size() == 1) {
+ specialPoint = area[0];
return true;
}
}
@@ -87,12 +87,12 @@ bool HitZone::hitTest(const Point &testPoint) {
uint pointsCount;
if (_flags & kHitZoneEnabled) {
- for (ClickAreas::const_iterator i = _clickAreas.begin(); i != _clickAreas.end(); ++i) {
- pointsCount = i->size();
+ for (const auto &area : _clickAreas) {
+ pointsCount = area.size();
if (pointsCount < 2) {
continue;
}
- points = &i->front();
+ points = &area.front();
if (pointsCount == 2) {
// Hit-test a box region
if ((testPoint.x >= points[0].x) &&
@@ -121,9 +121,9 @@ void HitZone::draw(SagaEngine *vm, int color) {
Point specialPoint1;
Point specialPoint2;
- for (ClickAreas::const_iterator i = _clickAreas.begin(); i != _clickAreas.end(); ++i) {
- pointsCount = i->size();
- points = &i->front();
+ for (const auto &area : _clickAreas) {
+ pointsCount = area.size();
+ points = &area.front();
if (vm->_scene->getFlags() & kSceneFlagISO) {
tmpPoints.resize(pointsCount);
for (j = 0; j < pointsCount; j++) {
@@ -178,8 +178,8 @@ void ObjectMap::load(const ByteArray &resourceData) {
_hitZoneList.resize(readS.readUint16());
int idx = 0;
- for (HitZoneArray::iterator i = _hitZoneList.begin(); i != _hitZoneList.end(); ++i) {
- i->load(_vm, &readS, idx++, _vm->_scene->currentSceneNumber());
+ for (auto &hitZone : _hitZoneList) {
+ hitZone.load(_vm, &readS, idx++, _vm->_scene->currentSceneNumber());
}
}
@@ -204,7 +204,7 @@ void ObjectMap::draw(const Point& testPoint, int color, int color2) {
hitZoneIndex = hitTest(pickPoint);
- for (HitZoneArray::iterator i = _hitZoneList.begin(); i != _hitZoneList.end(); ++i) {
+ for (auto &i : _hitZoneList) {
i->draw(_vm, (hitZoneIndex == i->getIndex()) ? color2 : color);
}
@@ -220,9 +220,9 @@ void ObjectMap::draw(const Point& testPoint, int color, int color2) {
int ObjectMap::hitTest(const Point& testPoint) {
// Loop through all scene objects
- for (HitZoneArray::iterator i = _hitZoneList.begin(); i != _hitZoneList.end(); ++i) {
- if (i->hitTest(testPoint)) {
- return i->getIndex();
+ for (auto &hitZone : _hitZoneList) {
+ if (hitZone.hitTest(testPoint)) {
+ return hitZone.getIndex();
}
}
diff --git a/engines/saga/palanim.cpp b/engines/saga/palanim.cpp
index 3ade383cdd2..e65bd51ccac 100644
--- a/engines/saga/palanim.cpp
+++ b/engines/saga/palanim.cpp
@@ -51,25 +51,25 @@ void PalAnim::loadPalAnim(const ByteArray &resourceData) {
debug(3, "PalAnim::loadPalAnim(): Loading %d PALANIM entries.", _entries.size());
- for (Common::Array<PalanimEntry>::iterator i = _entries.begin(); i != _entries.end(); ++i) {
+ for (auto &palAnimEntry : _entries) {
- i->cycle = 0;
+ palAnimEntry.cycle = 0;
- i->colors.resize(readS.readUint16());
- debug(2, "PalAnim::loadPalAnim(): Loading %d SAGA_COLOR structures.", i->colors.size());
+ palAnimEntry.colors.resize(readS.readUint16());
+ debug(2, "PalAnim::loadPalAnim(): Loading %d SAGA_COLOR structures.", palAnimEntry.colors.size());
- i->palIndex.resize(readS.readUint16());
- debug(2, "PalAnim::loadPalAnim(): Loading %d palette indices.\n", i->palIndex.size());
+ palAnimEntry.palIndex.resize(readS.readUint16());
+ debug(2, "PalAnim::loadPalAnim(): Loading %d palette indices.\n", palAnimEntry.palIndex.size());
- for (uint j = 0; j < i->palIndex.size(); j++) {
- i->palIndex[j] = readS.readByte();
+ for (uint j = 0; j < palAnimEntry.palIndex.size(); j++) {
+ palAnimEntry.palIndex[j] = readS.readByte();
}
- for (Common::Array<Color>::iterator j = i->colors.begin(); j != i->colors.end(); ++j) {
- j->red = readS.readByte();
- j->green = readS.readByte();
- j->blue = readS.readByte();
+ for (auto &color : palAnimEntry.colors) {
+ color.red = readS.readByte();
+ color.green = readS.readByte();
+ color.blue = readS.readByte();
}
}
}
@@ -105,21 +105,21 @@ void PalAnim::cycleStep(int vectortime) {
_vm->_gfx->getCurrentPal(pal);
- for (Common::Array<PalanimEntry>::iterator i = _entries.begin(); i != _entries.end(); ++i) {
- cycle = i->cycle;
- cycleLimit = i->colors.size();
- for (j = 0; j < i->palIndex.size(); j++) {
- palIndex = i->palIndex[j];
+ for (auto &palAnimEntry : _entries) {
+ cycle = palAnimEntry.cycle;
+ cycleLimit = palAnimEntry.colors.size();
+ for (j = 0; j < palAnimEntry.palIndex.size(); j++) {
+ palIndex = palAnimEntry.palIndex[j];
colIndex = (cycle + j) % cycleLimit;
- pal[palIndex].red = (byte) i->colors[colIndex].red;
- pal[palIndex].green = (byte) i->colors[colIndex].green;
- pal[palIndex].blue = (byte) i->colors[colIndex].blue;
+ pal[palIndex].red = (byte) palAnimEntry.colors[colIndex].red;
+ pal[palIndex].green = (byte) palAnimEntry.colors[colIndex].green;
+ pal[palIndex].blue = (byte) palAnimEntry.colors[colIndex].blue;
}
- i->cycle++;
+ palAnimEntry.cycle++;
- if (i->cycle == cycleLimit) {
- i->cycle = 0;
+ if (palAnimEntry.cycle == cycleLimit) {
+ palAnimEntry.cycle = 0;
}
}
diff --git a/engines/saga/render.cpp b/engines/saga/render.cpp
index a9511d46c75..84c068c15d1 100644
--- a/engines/saga/render.cpp
+++ b/engines/saga/render.cpp
@@ -273,10 +273,10 @@ void Render::maskSplitScreen() {
void Render::restoreChangedRects() {
maskSplitScreen();
if (!_fullRefresh) {
- for (Common::List<Common::Rect>::const_iterator it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
+ for (const auto &dirty : _dirtyRects) {
//_backGroundSurface.frameRect(*it, 1); // DEBUG
if (_vm->_interface->getFadeMode() != kFadeOut) {
- mCopyRectToScreen(it->left, it->top, it->width(), it->height());
+ mCopyRectToScreen(dirty.left, dirty.top, dirty.width(), dirty.height());
}
}
}
@@ -286,10 +286,10 @@ void Render::restoreChangedRects() {
void Render::drawDirtyRects() {
maskSplitScreen();
if (!_fullRefresh) {
- for (Common::List<Common::Rect>::const_iterator it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
+ for (const auto &dirty : _dirtyRects) {
//_backGroundSurface.frameRect(*it, 2); // DEBUG
if (_vm->_interface->getFadeMode() != kFadeOut) {
- mCopyRectToScreen(it->left, it->top, it->width(), it->height());
+ mCopyRectToScreen(dirty.left, dirty.top, dirty.width(), dirty.height());
}
}
} else {
diff --git a/engines/saga/resource.cpp b/engines/saga/resource.cpp
index 5f41ad7e071..defa5cbf936 100644
--- a/engines/saga/resource.cpp
+++ b/engines/saga/resource.cpp
@@ -454,9 +454,9 @@ bool Resource::createContexts() {
break;
}
- for (ResourceContextList::iterator i = _contexts.begin(); i != _contexts.end(); ++i) {
- if (!(*i)->load(_vm, this)) {
- warning("Cannot load context %s", (*i)->_fileName);
+ for (auto &context : _contexts) {
+ if (!context->load(_vm, this)) {
+ warning("Cannot load context %s", context->_fileName);
return false;
}
}
@@ -549,8 +549,7 @@ void Resource::loadResource(ResourceContext *context, uint32 resourceId, ByteArr
}
ResourceContext *Resource::getContext(uint16 fileType, int serial) {
- for (ResourceContextList::const_iterator i = _contexts.begin(); i != _contexts.end(); ++i) {
- ResourceContext * context = *i;
+ for (const auto &context : _contexts) {
if ((context->fileType() & fileType) && (context->serial() == serial)) {
return context;
}
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp
index 551ac08f5e9..308839af3ad 100644
--- a/engines/saga/scene.cpp
+++ b/engines/saga/scene.cpp
@@ -180,7 +180,7 @@ Scene::Scene(SagaEngine *vm) : _vm(vm) {
gDebugLevel = backUpDebugLevel;
debug(DUMP_SCENES_LEVEL, "Dump Scene: number %i, descriptor resourceId %i, resourceList resourceId %i", i, _sceneLUT[i], _sceneDescription.resourceListResourceId);
debug(DUMP_SCENES_LEVEL, "\tresourceListCount %i", (int)resourceList.size());
- for (SceneResourceDataArray::iterator j = resourceList.begin(); j != resourceList.end(); ++j) {
+ for (auto &j : resourceList) {
if (j->resourceType >= typesCount) {
error("wrong resource type %i", j->resourceType);
}
@@ -223,14 +223,14 @@ void Scene::getResourceTypes(SAGAResourceTypes *&types, int &typesCount) {
}
void Scene::drawTextList() {
- for (TextList::iterator entry = _textList.begin(); entry != _textList.end(); ++entry) {
+ for (auto &entry : _textList) {
- if (entry->display) {
+ if (entry.display) {
- if (entry->useRect) {
- _vm->_font->textDrawRect(entry->font, entry->text, entry->rect, _vm->KnownColor2ColorId(entry->knownColor), _vm->KnownColor2ColorId(entry->effectKnownColor), entry->flags);
+ if (entry.useRect) {
+ _vm->_font->textDrawRect(entry.font, entry.text, entry.rect, _vm->KnownColor2ColorId(entry.knownColor), _vm->KnownColor2ColorId(entry.effectKnownColor), entry.flags);
} else {
- _vm->_font->textDraw(entry->font, entry->text, entry->point, _vm->KnownColor2ColorId(entry->knownColor), _vm->KnownColor2ColorId(entry->effectKnownColor), entry->flags);
+ _vm->_font->textDraw(entry.font, entry.text, entry.point, _vm->KnownColor2ColorId(entry.knownColor), _vm->KnownColor2ColorId(entry.effectKnownColor), entry.flags);
}
}
}
@@ -896,11 +896,11 @@ void Scene::loadSceneResourceList(uint32 resourceId, SceneResourceDataArray &res
// resource table
debug(3, "Loading scene resource list");
- for (SceneResourceDataArray::iterator resource = resourceList.begin(); resource != resourceList.end(); ++resource) {
- resource->resourceId = readS.readUint16();
- resource->resourceType = readS.readUint16();
+ for (auto &resource : resourceList) {
+ resource.resourceId = readS.readUint16();
+ resource.resourceType = readS.readUint16();
// demo version may contain invalid resourceId
- resource->invalid = !_sceneContext->validResourceId(resource->resourceId);
+ resource.invalid = !_sceneContext->validResourceId(resource.resourceId);
}
}
@@ -916,39 +916,39 @@ void Scene::processSceneResources(SceneResourceDataArray &resourceList, SceneLoa
getResourceTypes(types, typesCount);
// Process the scene resource list
- for (SceneResourceDataArray::iterator resource = resourceList.begin(); resource != resourceList.end(); ++resource) {
- if (resource->invalid) {
+ for (auto &resource : resourceList) {
+ if (resource.invalid) {
continue;
}
- _vm->_resource->loadResource(_sceneContext, resource->resourceId, resourceData);
+ _vm->_resource->loadResource(_sceneContext, resource.resourceId, resourceData);
if (resourceData.size() >= 6) {
if (!memcmp(resourceData.getBuffer(), "DUMMY!", 6)) {
- resource->invalid = true;
- warning("DUMMY resource %i", resource->resourceId);
+ resource.invalid = true;
+ warning("DUMMY resource %i", resource.resourceId);
}
}
// Thos resources are bogus. Skip them
if (_vm->isITEAmiga() && resourceData.size() == 12 && memcmp(resourceData.getBuffer(), "ECHO is on\r\n", 12) == 0) {
- resource->invalid = true;
- warning("DUMMY resource %i", resource->resourceId);
+ resource.invalid = true;
+ warning("DUMMY resource %i", resource.resourceId);
}
- if (resource->invalid) {
+ if (resource.invalid) {
continue;
}
- if (resource->resourceType >= typesCount) {
- error("Scene::processSceneResources() wrong resource type %i", resource->resourceType);
+ if (resource.resourceType >= typesCount) {
+ error("Scene::processSceneResources() wrong resource type %i", resource.resourceType);
}
- resType = types[resource->resourceType];
+ resType = types[resource.resourceType];
switch (resType) {
case SAGA_UNKNOWN:
- warning("UNKNOWN resourceType %i", resource->resourceType);
+ warning("UNKNOWN resourceType %i", resource.resourceType);
break;
case SAGA_ACTOR:
//for (a = actorsInScene; a; a = a->nextInScene)
@@ -970,7 +970,7 @@ void Scene::processSceneResources(SceneResourceDataArray &resourceList, SceneLoa
_bg.buffer,
&_bg.w,
&_bg.h)) {
- error("Scene::processSceneResources() Error loading background resource %i", resource->resourceId);
+ error("Scene::processSceneResources() Error loading background resource %i", resource.resourceId);
}
_bg.loaded = true;
@@ -1038,7 +1038,7 @@ void Scene::processSceneResources(SceneResourceDataArray &resourceList, SceneLoa
break;
case SAGA_ANIM:
{
- uint16 animId = resource->resourceType - 14;
+ uint16 animId = resource.resourceType - 14;
debug(3, "Loading animation resource animId=%i", animId);
_vm->_anim->load(animId, resourceData);
}
@@ -1061,7 +1061,7 @@ void Scene::processSceneResources(SceneResourceDataArray &resourceList, SceneLoa
break;
case SAGA_FACES:
if (_vm->getGameId() == GID_ITE)
- _vm->_interface->loadScenePortraits(resource->resourceId);
+ _vm->_interface->loadScenePortraits(resource.resourceId);
break;
case SAGA_PALETTE:
{
@@ -1086,7 +1086,7 @@ void Scene::processSceneResources(SceneResourceDataArray &resourceList, SceneLoa
}
break;
default:
- error("Scene::ProcessSceneResources() Encountered unknown resource type %i", resource->resourceType);
+ error("Scene::ProcessSceneResources() Encountered unknown resource type %i", resource.resourceType);
break;
}
}
Commit: b90124c1e22542580acf5953c590f4a73fcae7c1
https://github.com/scummvm/scummvm/commit/b90124c1e22542580acf5953c590f4a73fcae7c1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
HADESCH: Use C++ 11 range-based for loops
Changed paths:
engines/hadesch/hadesch.cpp
engines/hadesch/video.cpp
diff --git a/engines/hadesch/hadesch.cpp b/engines/hadesch/hadesch.cpp
index 2a842a6ef3a..6836436b625 100644
--- a/engines/hadesch/hadesch.cpp
+++ b/engines/hadesch/hadesch.cpp
@@ -958,12 +958,12 @@ Common::Array<HadeschSaveDescriptor> HadeschEngine::getHadeschSavesList() {
filenames = saveFileMan->listSavefiles(pattern);
Common::Array<HadeschSaveDescriptor> saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &file : filenames) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
+ int slotNum = atoi(file.c_str() + file.size() - 3);
if (slotNum >= 0) {
- Common::ScopedPtr<Common::InSaveFile> in(saveFileMan->openForLoading(*file));
+ Common::ScopedPtr<Common::InSaveFile> in(saveFileMan->openForLoading(file));
if (!in) {
continue;
}
diff --git a/engines/hadesch/video.cpp b/engines/hadesch/video.cpp
index 2bbb5fa3aef..42bca6f7298 100644
--- a/engines/hadesch/video.cpp
+++ b/engines/hadesch/video.cpp
@@ -176,37 +176,37 @@ void VideoRoom::disableHotzone(const Common::String &name) {
}
void VideoRoom::setLayerEnabled(const LayerId &name, bool val) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name)
- it->isEnabled = val;
+ for (auto &layer : _layers) {
+ if (layer.name == name)
+ layer.isEnabled = val;
}
}
void VideoRoom::setLayerParallax(const LayerId &name, int val) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name)
- it->parallax = val;
+ for (auto &layer : _layers) {
+ if (layer.name == name)
+ layer.parallax = val;
}
}
void VideoRoom::setColorScale(const LayerId &name, int val) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name)
- it->colorScale = val;
+ for (auto &layer : _layers) {
+ if (layer.name == name)
+ layer.colorScale = val;
}
}
void VideoRoom::setScale(const LayerId &name, int val) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name)
- it->scale = val;
+ for (auto &layer : _layers) {
+ if (layer.name == name)
+ layer.scale = val;
}
}
int VideoRoom::getNumFrames(const LayerId &name) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name)
- return it->renderable->getNumFrames();
+ for (auto &layer : _layers) {
+ if (layer.name == name)
+ return layer.renderable->getNumFrames();
}
return 0;
@@ -239,8 +239,8 @@ void VideoRoom::startAnimationInternal(const LayerId &name, int zValue, int mspe
}
// This is slow but should rarely happen
if (!modifiedZ.empty()) {
- for (Common::Array<Layer>::iterator it = modifiedZ.begin(); it != modifiedZ.end(); it++) {
- _layers.insert(*it);
+ for (auto &it : modifiedZ) {
+ _layers.insert(it);
}
}
}
@@ -254,9 +254,9 @@ void VideoRoom::selectFrame(const LayerId &name, int zValue, int frame, Common::
}
PodImage VideoRoom::getLayerFrame(const Hadesch::LayerId &name) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name) {
- return it->renderable->getFrame(g_vm->getCurrentTime());
+ for (auto &layer : _layers) {
+ if (layer.name == name) {
+ return layer.renderable->getFrame(g_vm->getCurrentTime());
}
}
@@ -264,9 +264,9 @@ PodImage VideoRoom::getLayerFrame(const Hadesch::LayerId &name) {
}
int VideoRoom::getAnimFrameNum(const Hadesch::LayerId &name) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name) {
- return it->renderable->getAnimationFrameNum(g_vm->getCurrentTime());
+ for (auto &layer : _layers) {
+ if (layer.name == name) {
+ return layer.renderable->getAnimationFrameNum(g_vm->getCurrentTime());
}
}
@@ -274,9 +274,9 @@ int VideoRoom::getAnimFrameNum(const Hadesch::LayerId &name) {
}
void VideoRoom::stopAnim(const LayerId &name) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name) {
- it->isEnabled = false;
+ for (auto &layer : _layers) {
+ if (layer.name == name) {
+ layer.isEnabled = false;
}
}
for (unsigned i = 0; i < _anims.size(); i++) {
@@ -298,8 +298,8 @@ void VideoRoom::purgeAnim(const LayerId &name) {
void VideoRoom::dumpLayers() {
debug("Current layers:");
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- debug(" %s %s", it->name.getDebug().c_str(), it->isEnabled ? "enabled" : "disabled");
+ for (auto &layer : _layers) {
+ debug(" %s %s", layer.name.getDebug().c_str(), layer.isEnabled ? "enabled" : "disabled");
}
}
@@ -323,8 +323,8 @@ void VideoRoom::unpause() {
}
bool VideoRoom::doesLayerExist(const LayerId &name) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name) {
+ for (auto &layer : _layers) {
+ if (layer.name == name) {
return true;
}
}
@@ -332,9 +332,9 @@ bool VideoRoom::doesLayerExist(const LayerId &name) {
}
bool VideoRoom::isAnimationFinished(const LayerId &name, int time) {
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++) {
- if (it->name == name) {
- return it->renderable->isAnimationFinished(time);
+ for (auto &layer : _layers) {
+ if (layer.name == name) {
+ return layer.renderable->isAnimationFinished(time);
}
}
Commit: 27bb882eb28eb77887424534a72f0ee47419347e
https://github.com/scummvm/scummvm/commit/27bb882eb28eb77887424534a72f0ee47419347e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
ILLUSIONS: Use C++ 11 range-based for loops
Changed paths:
engines/illusions/actor.cpp
engines/illusions/bbdou/bbdou_inventory.cpp
engines/illusions/bbdou/bbdou_menukeys.cpp
engines/illusions/bbdou/bbdou_specialcode.cpp
engines/illusions/dictionary.h
engines/illusions/duckman/duckman_specialcode.cpp
engines/illusions/graphics.cpp
engines/illusions/input.cpp
engines/illusions/menusystem.cpp
engines/illusions/metaengine.cpp
engines/illusions/resources/actorresource.cpp
engines/illusions/resources/backgroundresource.cpp
engines/illusions/resources/talkresource.cpp
engines/illusions/resourcesystem.cpp
engines/illusions/sound.cpp
engines/illusions/textdrawer.cpp
engines/illusions/thread.cpp
engines/illusions/updatefunctions.cpp
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index ac8c3ffc1e9..a8753e5e54b 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -1220,8 +1220,7 @@ void Controls::destroyDialogItems() {
}
void Controls::threadIsDead(uint32 threadId) {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
if (control->_actor &&
(control->_actor->_notifyThreadId1 == threadId || control->_actor->_notifyId3C == threadId)) {
control->_actor->_notifyThreadId1 = 0;
@@ -1231,8 +1230,7 @@ void Controls::threadIsDead(uint32 threadId) {
}
void Controls::pauseControls() {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
++control->_pauseCtr;
if (control->_pauseCtr == 1)
control->pause();
@@ -1240,8 +1238,7 @@ void Controls::pauseControls() {
}
void Controls::unpauseControls() {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
--control->_pauseCtr;
if (control->_pauseCtr == 0)
control->unpause();
@@ -1249,8 +1246,7 @@ void Controls::unpauseControls() {
}
void Controls::pauseControlsBySceneId(uint32 sceneId) {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
if (control->_sceneId == sceneId) {
++control->_pauseCtr;
if (control->_pauseCtr == 1)
@@ -1260,8 +1256,7 @@ void Controls::pauseControlsBySceneId(uint32 sceneId) {
}
void Controls::unpauseControlsBySceneId(uint32 sceneId) {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
if (control->_sceneId == sceneId) {
--control->_pauseCtr;
if (control->_pauseCtr == 0)
@@ -1275,8 +1270,7 @@ bool Controls::getOverlappedObject(Control *control, Common::Point pt, Control *
uint32 foundPriority = 0;
uint32 minPriorityExt = _vm->getPriorityFromBase(minPriority);
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *testControl = *it;
+ for (auto &testControl : _controls) {
if (testControl != control && testControl->_pauseCtr == 0 &&
(testControl->_flags & 1) && !(testControl->_flags & 0x10) &&
(!testControl->_actor || (testControl->_actor->_flags & Illusions::ACTOR_FLAG_IS_VISIBLE))) {
@@ -1309,8 +1303,7 @@ bool Controls::getOverlappedObjectAccurate(Control *control, Common::Point pt, C
uint32 foundPriority = 0;
uint32 minPriorityExt = _vm->getPriorityFromBase(minPriority);
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *testControl = *it;
+ for (auto &testControl : _controls) {
if (testControl != control && testControl->_pauseCtr == 0 &&
(testControl->_flags & 1) && !(testControl->_flags & 0x10) &&
(!testControl->_actor || (testControl->_actor->_flags & Illusions::ACTOR_FLAG_IS_VISIBLE))) {
@@ -1341,8 +1334,7 @@ bool Controls::getOverlappedObjectAccurate(Control *control, Common::Point pt, C
bool Controls::getDialogItemAtPos(Control *control, Common::Point pt, Control **outOverlappedControl) {
Control *foundControl = nullptr;
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *testControl = *it;
+ for (auto &testControl : _controls) {
if (testControl != control && testControl->_pauseCtr == 0 &&
(testControl->_flags & 1) && (testControl->_flags & 4)) {
Common::Rect collisionRect;
@@ -1358,8 +1350,7 @@ bool Controls::getDialogItemAtPos(Control *control, Common::Point pt, Control **
bool Controls::getOverlappedWalkObject(Control *control, Common::Point pt, Control **outOverlappedControl) {
Control *foundControl = nullptr;
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *testControl = *it;
+ for (auto &testControl : _controls) {
if (testControl != control && testControl->_pauseCtr == 0 &&
(testControl->_flags & 1)) {
Common::Rect collisionRect;
@@ -1380,8 +1371,7 @@ void Controls::destroyControl(Control *control) {
}
bool Controls::findNamedPoint(uint32 namedPointId, Common::Point &pt) {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
if (control->_pauseCtr == 0 && control->_actor && control->_actor->findNamedPoint(namedPointId, pt))
return true;
}
@@ -1485,8 +1475,7 @@ void Controls::destroyControlInternal(Control *control) {
}
void Controls::disappearActors() {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
if (control->_flags & 4 && control->_pauseCtr == 0) {
control->disappearActor();
}
@@ -1498,8 +1487,7 @@ void Controls::disappearActors() {
}
void Controls::appearActors() {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
if (control->_flags & 4 && control->_pauseCtr == 0) {
control->appearActor();
}
@@ -1511,8 +1499,7 @@ void Controls::appearActors() {
}
void Controls::pauseActors(uint32 objectId) {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
if (control->_actor && control->_objectId != objectId) {
control->_actor->pause();
}
@@ -1520,8 +1507,7 @@ void Controls::pauseActors(uint32 objectId) {
}
void Controls::unpauseActors(uint32 objectId) {
- for (ItemsIterator it = _controls.begin(); it != _controls.end(); ++it) {
- Control *control = *it;
+ for (auto &control : _controls) {
if (control->_actor && control->_objectId != objectId) {
control->_actor->unpause();
}
diff --git a/engines/illusions/bbdou/bbdou_inventory.cpp b/engines/illusions/bbdou/bbdou_inventory.cpp
index 55bc6b3b51d..5c25610eab4 100644
--- a/engines/illusions/bbdou/bbdou_inventory.cpp
+++ b/engines/illusions/bbdou/bbdou_inventory.cpp
@@ -64,9 +64,9 @@ void InventoryBag::registerInventorySlot(uint32 namedPointId) {
bool InventoryBag::addInventoryItem(InventoryItem *inventoryItem, InventorySlot *inventorySlot) {
// NOTE Skipped support for multiple items per slot, not used in BBDOU
if (!inventorySlot) {
- for (InventorySlotsIterator it = _inventorySlots.begin(); it != _inventorySlots.end(); ++it) {
- if (!(*it)->_inventoryItem) {
- inventorySlot = *it;
+ for (auto &slot : _inventorySlots) {
+ if (!slot->_inventoryItem) {
+ inventorySlot = slot;
break;
}
}
@@ -79,9 +79,9 @@ bool InventoryBag::addInventoryItem(InventoryItem *inventoryItem, InventorySlot
}
void InventoryBag::removeInventoryItem(InventoryItem *inventoryItem) {
- for (InventorySlotsIterator it = _inventorySlots.begin(); it != _inventorySlots.end(); ++it) {
- if ((*it)->_inventoryItem && (*it)->_inventoryItem->_objectId == inventoryItem->_objectId)
- (*it)->_inventoryItem = nullptr;
+ for (auto &slot : _inventorySlots) {
+ if (slot->_inventoryItem && slot->_inventoryItem->_objectId == inventoryItem->_objectId)
+ slot->_inventoryItem = nullptr;
}
}
@@ -128,8 +128,7 @@ InventorySlot *InventoryBag::getInventorySlot(uint32 objectId) {
InventorySlot *InventoryBag::findClosestSlot(Common::Point putPos, int index) {
uint minDistance = 0xFFFFFFFF;
InventorySlot *minDistanceSlot = nullptr;
- for (InventorySlotsIterator it = _inventorySlots.begin(); it != _inventorySlots.end(); ++it) {
- InventorySlot *inventorySlot = *it;
+ for (auto &inventorySlot : _inventorySlots) {
Common::Point slotPos = _vm->getNamedPointPosition(inventorySlot->_namedPointId);
uint currDistance = (slotPos.y - putPos.y) * (slotPos.y - putPos.y) + (slotPos.x - putPos.x) * (slotPos.x - putPos.x);
if (currDistance < minDistance) {
@@ -287,12 +286,11 @@ void BbdouInventory::refresh() {
}
void BbdouInventory::buildItems(InventoryBag *inventoryBag) {
- for (InventoryItemsIterator it = _inventoryItems.begin(); it != _inventoryItems.end(); ++it) {
- (*it)->_timesPresent = 0;
+ for (auto &inventoryItem : _inventoryItems) {
+ inventoryItem->_timesPresent = 0;
}
inventoryBag->buildItems();
- for (InventoryItemsIterator it = _inventoryItems.begin(); it != _inventoryItems.end(); ++it) {
- InventoryItem *inventoryItem = *it;
+ for (auto &inventoryItem : _inventoryItems) {
if (inventoryItem->_assigned && !inventoryItem->_flag &&
inventoryItem->_timesPresent == 0 &&
inventoryItem->_objectId != _bbdou->_cursor->_data._holdingObjectId)
@@ -301,8 +299,7 @@ void BbdouInventory::buildItems(InventoryBag *inventoryBag) {
}
void BbdouInventory::clear() {
- for (InventoryItemsIterator it = _inventoryItems.begin(); it != _inventoryItems.end(); ++it) {
- InventoryItem *inventoryItem = *it;
+ for (auto &inventoryItem : _inventoryItems) {
inventoryItem->_assigned = false;
inventoryItem->_flag = false;
}
diff --git a/engines/illusions/bbdou/bbdou_menukeys.cpp b/engines/illusions/bbdou/bbdou_menukeys.cpp
index 1472b9d84fc..283c776898b 100644
--- a/engines/illusions/bbdou/bbdou_menukeys.cpp
+++ b/engines/illusions/bbdou/bbdou_menukeys.cpp
@@ -46,8 +46,7 @@ void BBDOUMenuKeys::addMenuKey(uint bitMask, uint32 threadId) {
void BBDOUMenuKeys::update() {
if (_vm->_screen->isDisplayOn() && !_vm->_menuSystem->isActive()) {
- for (MenuKeys::iterator it = _menuKeys.begin(); it != _menuKeys.end(); ++it) {
- const MenuKey &menuKey = *it;
+ for (auto &menuKey : _menuKeys) {
if (_vm->_input->pollButton(menuKey.bitMask)) {
_vm->startScriptThread(menuKey.threadId, 0, 0, 0, 0);
break;
diff --git a/engines/illusions/bbdou/bbdou_specialcode.cpp b/engines/illusions/bbdou/bbdou_specialcode.cpp
index 860ebd34c65..ea81f71d502 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.cpp
+++ b/engines/illusions/bbdou/bbdou_specialcode.cpp
@@ -162,8 +162,8 @@ BbdouSpecialCode::~BbdouSpecialCode() {
delete _cursor;
delete _bubble;
- for (MapIterator it = _map.begin(); it != _map.end(); ++it) {
- delete (*it)._value;
+ for (auto &it : _map) {
+ delete it._value;
}
}
diff --git a/engines/illusions/dictionary.h b/engines/illusions/dictionary.h
index 723cd918af0..ebc5b3dd704 100644
--- a/engines/illusions/dictionary.h
+++ b/engines/illusions/dictionary.h
@@ -43,8 +43,8 @@ protected:
public:
~DictionaryHashMap() {
- for (MapIterator it = _map.begin(); it != _map.end(); ++it) {
- delete it->_value;
+ for (auto &it : _map) {
+ delete it._value;
}
}
diff --git a/engines/illusions/duckman/duckman_specialcode.cpp b/engines/illusions/duckman/duckman_specialcode.cpp
index 01a518694e6..350c0c24281 100644
--- a/engines/illusions/duckman/duckman_specialcode.cpp
+++ b/engines/illusions/duckman/duckman_specialcode.cpp
@@ -60,8 +60,8 @@ DuckmanSpecialCode::~DuckmanSpecialCode() {
delete _inventory;
delete _credits;
- for (SpecialCodeMap::iterator it = _specialCodeMap.begin(); it != _specialCodeMap.end(); ++it) {
- delete (*it)._value;
+ for (auto &it : _specialCodeMap) {
+ delete it._value;
}
}
diff --git a/engines/illusions/graphics.cpp b/engines/illusions/graphics.cpp
index 1395a68fd19..9b6569fc396 100644
--- a/engines/illusions/graphics.cpp
+++ b/engines/illusions/graphics.cpp
@@ -53,9 +53,9 @@ void NamedPoint::load(Common::SeekableReadStream &stream) {
// NamedPoints
bool NamedPoints::findNamedPoint(uint32 namedPointId, Common::Point &pt) {
- for (ItemsIterator it = _namedPoints.begin(); it != _namedPoints.end(); ++it) {
- if ((*it)._namedPointId == namedPointId) {
- pt = (*it)._pt;
+ for (auto &namedPoint : _namedPoints) {
+ if (namedPoint._namedPointId == namedPointId) {
+ pt = namedPoint._pt;
return true;
}
}
diff --git a/engines/illusions/input.cpp b/engines/illusions/input.cpp
index 0b0dde9eb8c..d8a764ca759 100644
--- a/engines/illusions/input.cpp
+++ b/engines/illusions/input.cpp
@@ -64,8 +64,7 @@ InputEvent& InputEvent::addMouseButton(int mouseButton) {
uint InputEvent::handle(Common::CustomEventType action, int mouseButton, bool down) {
uint newKeys = 0;
- for (KeyMap::iterator it = _keyMap.begin(); it != _keyMap.end(); ++it) {
- KeyMapping &keyMapping = *it;
+ for (auto &keyMapping : _keyMap) {
if ((keyMapping._action != kActionNone && keyMapping._action == action) ||
(keyMapping._mouseButton != MOUSE_NONE && keyMapping._mouseButton == mouseButton)) {
if (down && !keyMapping._down) {
diff --git a/engines/illusions/menusystem.cpp b/engines/illusions/menusystem.cpp
index 7cea1ecaae6..8b7e7c03c50 100644
--- a/engines/illusions/menusystem.cpp
+++ b/engines/illusions/menusystem.cpp
@@ -58,8 +58,8 @@ BaseMenu::BaseMenu(BaseMenuSystem *menuSystem, uint32 fontId, byte backgroundCol
}
BaseMenu::~BaseMenu() {
- for (MenuItems::iterator it = _menuItems.begin(); it != _menuItems.end(); ++it) {
- delete *it;
+ for (auto &menuItem : _menuItems) {
+ delete menuItem;
}
}
diff --git a/engines/illusions/metaengine.cpp b/engines/illusions/metaengine.cpp
index 4f67a7d990e..f4c7eef9250 100644
--- a/engines/illusions/metaengine.cpp
+++ b/engines/illusions/metaengine.cpp
@@ -175,11 +175,11 @@ SaveStateList IllusionsMetaEngine::listSaves(const char *target) const {
Common::StringArray filenames;
filenames = saveFileMan->listSavefiles(pattern.c_str());
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &file : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
+ int slotNum = atoi(file.c_str() + file.size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ Common::InSaveFile *in = saveFileMan->openForLoading(file.c_str());
if (in) {
if (Illusions::IllusionsEngine::readSaveHeader(in, header) == Illusions::IllusionsEngine::kRSHENoError) {
saveList.push_back(SaveStateDescriptor(this, slotNum, header.description));
diff --git a/engines/illusions/resources/actorresource.cpp b/engines/illusions/resources/actorresource.cpp
index 9660385b077..922e347d006 100644
--- a/engines/illusions/resources/actorresource.cpp
+++ b/engines/illusions/resources/actorresource.cpp
@@ -272,22 +272,21 @@ void ActorInstanceList::removeActorInstance(ActorInstance *actorInstance) {
}
void ActorInstanceList::pauseBySceneId(uint32 sceneId) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_sceneId == sceneId)
- (*it)->pause();
+ for (auto &it : _items) {
+ if (it->_sceneId == sceneId)
+ it->pause();
}
}
void ActorInstanceList::unpauseBySceneId(uint32 sceneId) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_sceneId == sceneId)
- (*it)->unpause();
+ for (auto &it : _items) {
+ if (it->_sceneId == sceneId)
+ it->unpause();
}
}
FramesList *ActorInstanceList::findSequenceFrames(Sequence *sequence) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- ActorInstance *actorInstance = *it;
+ for (auto &actorInstance : _items) {
if (actorInstance->_pauseCtr <= 0 && actorInstance->_actorResource->containsSequence(sequence))
return &actorInstance->_actorResource->_frames;
}
@@ -295,16 +294,15 @@ FramesList *ActorInstanceList::findSequenceFrames(Sequence *sequence) {
}
ActorInstance *ActorInstanceList::findActorByResource(ActorResource *actorResource) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_actorResource == actorResource)
- return (*it);
+ for (auto &it : _items) {
+ if (it->_actorResource == actorResource)
+ return (it);
}
return nullptr;
}
bool ActorInstanceList::findNamedPoint(uint32 namedPointId, Common::Point &pt) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- ActorInstance *actorInstance = *it;
+ for (auto &actorInstance : _items) {
if (actorInstance->_pauseCtr == 0 && actorInstance->_actorResource->findNamedPoint(namedPointId, pt))
return true;
}
diff --git a/engines/illusions/resources/backgroundresource.cpp b/engines/illusions/resources/backgroundresource.cpp
index 37f29505d27..4894c74f9a4 100644
--- a/engines/illusions/resources/backgroundresource.cpp
+++ b/engines/illusions/resources/backgroundresource.cpp
@@ -583,31 +583,31 @@ void BackgroundInstanceList::removeBackgroundInstance(BackgroundInstance *backgr
}
void BackgroundInstanceList::pauseBySceneId(uint32 sceneId) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_sceneId == sceneId)
- (*it)->pause();
+ for (auto &item : _items) {
+ if (item->_sceneId == sceneId)
+ item->pause();
}
}
void BackgroundInstanceList::unpauseBySceneId(uint32 sceneId) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_sceneId == sceneId)
- (*it)->unpause();
+ for (auto &item : _items) {
+ if (item->_sceneId == sceneId)
+ item->unpause();
}
}
BackgroundInstance *BackgroundInstanceList::findActiveBackgroundInstance() {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_pauseCtr == 0)
- return (*it);
+ for (auto &item : _items) {
+ if (item->_pauseCtr == 0)
+ return item;
}
return nullptr;
}
BackgroundInstance *BackgroundInstanceList::findBackgroundByResource(BackgroundResource *backgroundResource) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_bgRes == backgroundResource)
- return (*it);
+ for (auto &item : _items) {
+ if (item->_bgRes == backgroundResource)
+ return item;
}
return nullptr;
}
diff --git a/engines/illusions/resources/talkresource.cpp b/engines/illusions/resources/talkresource.cpp
index f2f5b68f273..65f8a7f984c 100644
--- a/engines/illusions/resources/talkresource.cpp
+++ b/engines/illusions/resources/talkresource.cpp
@@ -148,17 +148,17 @@ void TalkInstanceList::removeTalkInstance(TalkInstance *talkInstance) {
}
TalkInstance *TalkInstanceList::findTalkItem(uint32 talkId) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_talkId == talkId)
- return (*it);
+ for (auto &item : _items) {
+ if (item->_talkId == talkId)
+ return item;
}
return nullptr;
}
TalkInstance *TalkInstanceList::findTalkItemBySceneId(uint32 sceneId) {
- for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) {
- if ((*it)->_sceneId == sceneId)
- return (*it);
+ for (auto &item : _items) {
+ if (item->_sceneId == sceneId)
+ return item;
}
return nullptr;
}
diff --git a/engines/illusions/resourcesystem.cpp b/engines/illusions/resourcesystem.cpp
index 279f5918433..7c25920501f 100644
--- a/engines/illusions/resourcesystem.cpp
+++ b/engines/illusions/resourcesystem.cpp
@@ -65,8 +65,8 @@ ResourceSystem::ResourceSystem(IllusionsEngine *vm)
ResourceSystem::~ResourceSystem() {
// Delete all registered resource loaders
- for (ResourceLoadersMapIterator it = _resourceLoaders.begin(); it != _resourceLoaders.end(); ++it) {
- delete (*it)._value;
+ for (auto &resourceLoader : _resourceLoaders) {
+ delete resourceLoader._value;
}
}
@@ -126,8 +126,8 @@ void ResourceSystem::unloadSceneResources(uint32 sceneId1, uint32 sceneId2) {
}
void ResourceSystem::unloadAllResources() {
- for (ResourcesArrayIterator it = _resources.begin(); it != _resources.end(); ++it) {
- delete (*it);
+ for (auto &resource : _resources) {
+ delete resource;
}
_resources.clear();
}
diff --git a/engines/illusions/sound.cpp b/engines/illusions/sound.cpp
index fb3a1219bc9..41da7279e41 100644
--- a/engines/illusions/sound.cpp
+++ b/engines/illusions/sound.cpp
@@ -470,8 +470,7 @@ void SoundMan::stopSound(uint32 soundEffectId) {
}
void SoundMan::stopLoopingSounds() {
- for (SoundListIterator it = _sounds.begin(); it != _sounds.end(); ++it) {
- Sound *sound = *it;
+ for (auto &sound : _sounds) {
if (sound->isPlaying() && sound->isLooping()) {
sound->stop();
}
@@ -491,9 +490,9 @@ void SoundMan::unloadSounds(uint32 soundGroupId) {
}
Sound *SoundMan::getSound(uint32 soundEffectId) {
- for (SoundListIterator it = _sounds.begin(); it != _sounds.end(); ++it) {
- if ((*it)->_soundEffectId == soundEffectId)
- return *it;
+ for (auto &sound : _sounds) {
+ if (sound->_soundEffectId == soundEffectId)
+ return sound;
}
return nullptr;
}
diff --git a/engines/illusions/textdrawer.cpp b/engines/illusions/textdrawer.cpp
index 07d3f57192f..95102d65d91 100644
--- a/engines/illusions/textdrawer.cpp
+++ b/engines/illusions/textdrawer.cpp
@@ -58,8 +58,7 @@ void TextDrawer::drawText(Screen *screen, Graphics::Surface *surface, uint16 bac
y = 4;
}
- for (Common::Array<TextLine>::iterator it = _textLines.begin(); it != _textLines.end(); ++it) {
- const TextLine &textLine = *it;
+ for (auto &textLine : _textLines) {
if (textLine._text) {
screen->drawText(_font, surface, textLine._x + x, textLine._y + y, textLine._text, textLine._length);
if (_textFlags & TEXT_FLAG_BORDER_DECORATION) {
diff --git a/engines/illusions/thread.cpp b/engines/illusions/thread.cpp
index 6728690946b..e2240c84254 100644
--- a/engines/illusions/thread.cpp
+++ b/engines/illusions/thread.cpp
@@ -163,9 +163,9 @@ void ThreadList::updateThreads() {
}
Thread *ThreadList::findThread(uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- if ((*it)->_threadId == threadId && !(*it)->_terminated)
- return (*it);
+ for (auto &thread : _threads) {
+ if (thread->_threadId == threadId && !thread->_terminated)
+ return thread;
}
return nullptr;
}
@@ -183,112 +183,98 @@ void ThreadList::notifyId(uint32 threadId) {
}
void ThreadList::notifyTimerThreads(uint32 callingThreadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_type == kTTTimerThread && thread->_callingThreadId == callingThreadId)
thread->notify();
}
}
void ThreadList::suspendTimerThreads(uint32 callingThreadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_type == kTTTimerThread && thread->_callingThreadId == callingThreadId)
thread->suspend();
}
}
void ThreadList::terminateThreads(uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_threadId != threadId)
thread->terminate();
}
}
void ThreadList::terminateActiveThreads(uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_pauseCtr <= 0 && thread->_threadId != threadId)
thread->terminate();
}
}
void ThreadList::terminateThreadsBySceneId(uint32 sceneId, uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_sceneId == sceneId && thread->_threadId != threadId)
thread->terminate();
}
}
void ThreadList::suspendThreadsBySceneId(uint32 sceneId, uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_sceneId == sceneId && thread->_threadId != threadId)
thread->suspend();
}
}
void ThreadList::notifyThreads(uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_threadId != threadId)
thread->notify();
}
}
void ThreadList::notifyThreadsBySceneId(uint32 sceneId, uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_sceneId == sceneId && thread->_threadId != threadId)
thread->notify();
}
}
void ThreadList::pauseThreads(uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_threadId != threadId)
thread->pause();
}
}
void ThreadList::unpauseThreads(uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_threadId != threadId)
thread->unpause();
}
}
void ThreadList::suspendThreads(uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_threadId != threadId)
thread->suspend();
}
}
void ThreadList::resumeThreads(uint32 threadId) {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_threadId != threadId)
thread->resume();
}
}
void ThreadList::endTalkThreads() {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_type == kTTTalkThread)
thread->terminate();
}
}
void ThreadList::endTalkThreadsNoNotify() {
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (thread->_type == kTTTalkThread && thread->_callingThreadId == 0)
thread->terminate();
}
@@ -311,8 +297,7 @@ void ThreadList::killThread(uint32 threadId) {
if (!thread)
return;
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *childThread = *it;
+ for (auto &childThread : _threads) {
if (childThread->_callingThreadId == threadId)
killThread(childThread->_threadId);
}
@@ -334,8 +319,7 @@ uint32 ThreadList::getThreadSceneId(uint32 threadId) {
bool ThreadList::isActiveThread(int msgNum) {
// Check if at least one thread returns a non-null value for the message
- for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
- Thread *thread = *it;
+ for (auto &thread : _threads) {
if (!thread->_terminated && thread->_pauseCtr <= 0 &&
thread->sendMessage(msgNum, 0) != 0)
return true;
diff --git a/engines/illusions/updatefunctions.cpp b/engines/illusions/updatefunctions.cpp
index 463cf583634..e4b273b593d 100644
--- a/engines/illusions/updatefunctions.cpp
+++ b/engines/illusions/updatefunctions.cpp
@@ -34,8 +34,8 @@ UpdateFunctions::UpdateFunctions() {
UpdateFunctions::~UpdateFunctions() {
// Free update functions
- for (UpdateFunctionListIterator it = _updateFunctions.begin(); it != _updateFunctions.end(); ++it) {
- delete *it;
+ for (auto &updateFunction : _updateFunctions) {
+ delete updateFunction;
}
}
@@ -73,9 +73,9 @@ void UpdateFunctions::update() {
}
void UpdateFunctions::terminateByScene(uint32 sceneId) {
- for (UpdateFunctionListIterator it = _updateFunctions.begin(); it != _updateFunctions.end(); ++it) {
- if ((*it)->_sceneId == sceneId)
- (*it)->terminate();
+ for (auto &updateFunction : _updateFunctions) {
+ if (updateFunction->_sceneId == sceneId)
+ updateFunction->terminate();
}
}
Commit: 85f33669e455b6ddbe2a49ad2ab30a5ca045e0cc
https://github.com/scummvm/scummvm/commit/85f33669e455b6ddbe2a49ad2ab30a5ca045e0cc
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
PRINCE: Use C++ 11 range-based for loops
Changed paths:
engines/prince/archive.cpp
engines/prince/metaengine.cpp
diff --git a/engines/prince/archive.cpp b/engines/prince/archive.cpp
index 45a8e8c660f..2808a188f78 100644
--- a/engines/prince/archive.cpp
+++ b/engines/prince/archive.cpp
@@ -138,8 +138,8 @@ bool PtcArchive::hasFile(const Common::Path &path) const {
int PtcArchive::listMembers(Common::ArchiveMemberList &list) const {
int matches = 0;
- for (FileMap::const_iterator it = _items.begin(); it != _items.end(); ++it) {
- list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_key, *this)));
+ for (const auto &item : _items) {
+ list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(item._key, *this)));
matches++;
}
diff --git a/engines/prince/metaengine.cpp b/engines/prince/metaengine.cpp
index 3160b12145a..c0ba7dd2787 100644
--- a/engines/prince/metaengine.cpp
+++ b/engines/prince/metaengine.cpp
@@ -86,13 +86,13 @@ SaveStateList PrinceMetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); filename++) {
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(filename->c_str() + filename->size() - 3);
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= 99) {
- Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
+ Common::InSaveFile *file = saveFileMan->openForLoading(filename);
if (file) {
Prince::SavegameHeader header;
Commit: ed39a2d2e99af07cfa738e099604d0d1ac77b0f1
https://github.com/scummvm/scummvm/commit/ed39a2d2e99af07cfa738e099604d0d1ac77b0f1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
BURIED: Use C++ 11 range-based for loops
Changed paths:
engines/buried/avi_frames.cpp
engines/buried/buried.cpp
engines/buried/saveload.cpp
engines/buried/window.cpp
diff --git a/engines/buried/avi_frames.cpp b/engines/buried/avi_frames.cpp
index 5aff1f55204..88457488251 100644
--- a/engines/buried/avi_frames.cpp
+++ b/engines/buried/avi_frames.cpp
@@ -171,10 +171,10 @@ bool AVIFrames::flushFrameCache() {
if (_cachedFrames.empty())
return false;
- for (FrameList::iterator it = _cachedFrames.begin(); it != _cachedFrames.end(); ++it) {
- if (it->frame) {
- it->frame->free();
- delete it->frame;
+ for (auto &cachedFrame : _cachedFrames) {
+ if (cachedFrame.frame) {
+ cachedFrame.frame->free();
+ delete cachedFrame.frame;
}
}
@@ -182,9 +182,9 @@ bool AVIFrames::flushFrameCache() {
}
const Graphics::Surface *AVIFrames::retrieveFrameFromCache(int frameIndex) const {
- for (FrameList::const_iterator it = _cachedFrames.begin(); it != _cachedFrames.end(); ++it)
- if (it->index == frameIndex)
- return it->frame;
+ for (const auto &cachedFrame : _cachedFrames)
+ if (cachedFrame.index == frameIndex)
+ return cachedFrame.frame;
return nullptr;
}
diff --git a/engines/buried/buried.cpp b/engines/buried/buried.cpp
index 960fe253e84..107f9cdba1e 100644
--- a/engines/buried/buried.cpp
+++ b/engines/buried/buried.cpp
@@ -315,8 +315,8 @@ void BuriedEngine::removeVideo(VideoWindow *window) {
}
void BuriedEngine::updateVideos() {
- for (VideoList::iterator it = _videos.begin(); it != _videos.end(); ++it)
- (*it)->updateVideo();
+ for (auto &video : _videos)
+ video->updateVideo();
}
void BuriedEngine::postMessageToWindow(Window *dest, Message *message) {
@@ -380,15 +380,15 @@ void BuriedEngine::sendAllMessages() {
// Generate a timer message
bool ranTimer = false;
- for (TimerMap::iterator it = _timers.begin(); it != _timers.end(); ++it) {
+ for (auto &timer : _timers) {
uint32 time = g_system->getMillis();
- if (time >= it->_value.nextTrigger) {
+ if (time >= timer._value.nextTrigger) {
// Adjust the trigger to be what the next one would be, after
// all the current triggers would be called.
- uint32 triggerCount = (time - it->_value.nextTrigger + it->_value.period) / it->_value.period;
- it->_value.nextTrigger += triggerCount * it->_value.period;
- it->_value.owner->sendMessage(new TimerMessage(it->_key));
+ uint32 triggerCount = (time - timer._value.nextTrigger + timer._value.period) / timer._value.period;
+ timer._value.nextTrigger += triggerCount * timer._value.period;
+ timer._value.owner->sendMessage(new TimerMessage(timer._key));
ranTimer = true;
break;
}
@@ -434,8 +434,8 @@ bool BuriedEngine::hasMessage(Window *window, int messageBegin, int messageEnd)
// Implementation note: This doesn't currently handle timers, but would on real Windows.
// Buried doesn't check for timer messages being present, so it's skipped.
- for (MessageQueue::const_iterator it = _messageQueue.begin(); it != _messageQueue.end(); ++it)
- if ((!window || it->dest == window) && it->message->getMessageType() >= messageBegin && it->message->getMessageType() <= messageEnd)
+ for (const auto &curMessage : _messageQueue)
+ if ((!window || curMessage.dest == window) && curMessage.message->getMessageType() >= messageBegin && curMessage.message->getMessageType() <= messageEnd)
return true;
return false;
@@ -567,20 +567,20 @@ void BuriedEngine::pauseEngineIntern(bool pause) {
if (pause) {
_sound->pause(true);
- for (VideoList::iterator it = _videos.begin(); it != _videos.end(); ++it)
- (*it)->pauseVideo();
+ for (auto &video : _videos)
+ video->pauseVideo();
_pauseStartTime = g_system->getMillis();
} else {
_sound->pause(false);
- for (VideoList::iterator it = _videos.begin(); it != _videos.end(); ++it)
- (*it)->resumeVideo();
+ for (auto &video : _videos)
+ video->resumeVideo();
uint32 timeDiff = g_system->getMillis() - _pauseStartTime;
- for (TimerMap::iterator it = _timers.begin(); it != _timers.end(); ++it)
- it->_value.nextTrigger += timeDiff;
+ for (auto &timer : _timers)
+ timer._value.nextTrigger += timeDiff;
}
}
diff --git a/engines/buried/saveload.cpp b/engines/buried/saveload.cpp
index a36ab70dba2..88decd61893 100644
--- a/engines/buried/saveload.cpp
+++ b/engines/buried/saveload.cpp
@@ -87,7 +87,7 @@ void BuriedEngine::checkForOriginalSavedGames() {
return;
// Convert every save slot we find with the original naming scheme
- for (Common::StringArray::const_iterator file = fileNames.begin(); file != fileNames.end(); ++file) {
+ for (auto &file : fileNames) {
int slotNum = 1;
if (newFileNames.size() > 0) {
Common::String lastFile = newFileNames.back();
@@ -96,7 +96,7 @@ void BuriedEngine::checkForOriginalSavedGames() {
}
Common::String newFile = getMetaEngine()->getSavegameFile(slotNum);
- convertSavedGame(*file, newFile);
+ convertSavedGame(file, newFile);
newFileNames.push_back(newFile);
}
}
diff --git a/engines/buried/window.cpp b/engines/buried/window.cpp
index fc42751f9f5..31676d410fc 100644
--- a/engines/buried/window.cpp
+++ b/engines/buried/window.cpp
@@ -141,12 +141,12 @@ void Window::updateWindow() {
onPaint();
// Draw children
- for (WindowList::iterator it = _children.begin(); it != _children.end(); ++it)
- (*it)->updateWindow();
+ for (auto &child : _children)
+ child->updateWindow();
// Draw top-most children
- for (WindowList::iterator it = _topMostChildren.begin(); it != _topMostChildren.end(); ++it)
- (*it)->updateWindow();
+ for (auto &child : _topMostChildren)
+ child->updateWindow();
}
void Window::setWindowPos(const Window *insertAfter, int x, int y, int width, int height, uint flags) {
Commit: dd94f27344dd8bf24cf390f0dec18727208155da
https://github.com/scummvm/scummvm/commit/dd94f27344dd8bf24cf390f0dec18727208155da
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
MADE: Use C++ 11 range-based for loops
Changed paths:
engines/made/resource.cpp
diff --git a/engines/made/resource.cpp b/engines/made/resource.cpp
index c67574626c5..cf7945c71fe 100644
--- a/engines/made/resource.cpp
+++ b/engines/made/resource.cpp
@@ -575,8 +575,8 @@ void ResourceReader::tossResourceFromCache(ResourceSlot *slot) {
void ResourceReader::purgeCache() {
debug(2, "ResourceReader::purgeCache()");
- for (ResMap::const_iterator resTypeIter = _resSlots.begin(); resTypeIter != _resSlots.end(); ++resTypeIter) {
- ResourceSlots *slots = (*resTypeIter)._value;
+ for (const auto &res : _resSlots) {
+ ResourceSlots *slots = res._value;
for (ResourceSlots::iterator slotIter = slots->begin(); slotIter != slots->end(); ++slotIter) {
ResourceSlot *slot = &(*slotIter);
if (slot->refCount <= 0 && slot->res) {
Commit: ce1afedb43fd25536bcc832ff8b6d67a614294bf
https://github.com/scummvm/scummvm/commit/ce1afedb43fd25536bcc832ff8b6d67a614294bf
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
AGOS: Use C++ 11 range-based for loops
Changed paths:
engines/agos/charset-fontdata.cpp
engines/agos/metaengine.cpp
diff --git a/engines/agos/charset-fontdata.cpp b/engines/agos/charset-fontdata.cpp
index 193986e3d40..31af93f93f3 100644
--- a/engines/agos/charset-fontdata.cpp
+++ b/engines/agos/charset-fontdata.cpp
@@ -3060,13 +3060,13 @@ void AGOSEngine_Elvira1::addHiResTextDirtyRect(Common::Rect rect) {
rect.right >>= 1;
rect.bottom <<= 1;
- for (Common::Array<Common::Rect>::iterator i = _sjisTextFields.begin(); i != _sjisTextFields.end(); ++i) {
+ for (auto &i : _sjisTextFields) {
// Merge rects if it makes sense, but only once.
- if (rect.left <= i->right && rect.right >= i->left && rect.top <= i->bottom && rect.bottom >= i->top) {
- i->left = MIN<int16>(i->left, rect.left);
- i->top = MIN<int16>(i->top, rect.top);
- i->right = MAX<int16>(i->right, rect.right);
- i->bottom = MAX<int16>(i->bottom, rect.bottom);
+ if (rect.left <= i.right && rect.right >= i.left && rect.top <= i.bottom && rect.bottom >= i.top) {
+ i.left = MIN<int16>(i.left, rect.left);
+ i.top = MIN<int16>(i.top, rect.top);
+ i.right = MAX<int16>(i.right, rect.right);
+ i.bottom = MAX<int16>(i.bottom, rect.bottom);
return;
}
}
@@ -3082,17 +3082,17 @@ void AGOSEngine_Elvira1::clearHiResTextLayer() {
assert(p);
if (_sjisTextFields.size() < 10) {
- for (Common::Array<Common::Rect>::iterator i = _sjisTextFields.begin(); i != _sjisTextFields.end(); ++i) {
- uint16 w = i->width();
+ for (auto &i : _sjisTextFields) {
+ uint16 w = i.width();
uint16 ptch = _scaleBuf->pitch >> 2;
- uint32 *dst = (uint32*)p + i->top * ptch + i->left;
- for (uint32 *end = dst + i->height() * ptch; dst < end; dst += ptch)
+ uint32 *dst = (uint32*)p + i.top * ptch + i.left;
+ for (uint32 *end = dst + i.height() * ptch; dst < end; dst += ptch)
Common::fill<uint32*, uint32>(dst, &dst[w], 0);
- i->left <<= 1;
- i->top >>= 1;
- i->right <<= 1;
- i->bottom >>= 1;
- updateBackendSurface(i);
+ i.left <<= 1;
+ i.top >>= 1;
+ i.right <<= 1;
+ i.bottom >>= 1;
+ updateBackendSurface(&i);
}
} else {
memset(p, 0, _scaleBuf->w * _scaleBuf->h);
diff --git a/engines/agos/metaengine.cpp b/engines/agos/metaengine.cpp
index be2d509013b..9046e80a0e0 100644
--- a/engines/agos/metaengine.cpp
+++ b/engines/agos/metaengine.cpp
@@ -195,14 +195,14 @@ SaveStateList AgosMetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &file : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
+ int slotNum = atoi(file.c_str() + file.size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = saveFileMan->openForLoading(file);
if (in) {
- saveDesc = file->c_str();
+ saveDesc = file.c_str();
saveList.push_back(SaveStateDescriptor(this, slotNum, saveDesc));
delete in;
}
Commit: 9538b22f8a8b75d29a253b7a95ef1ddac3bcd34e
https://github.com/scummvm/scummvm/commit/9538b22f8a8b75d29a253b7a95ef1ddac3bcd34e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
EFH: Use C++ 11 range-based for loops
Changed paths:
engines/efh/metaengine.cpp
diff --git a/engines/efh/metaengine.cpp b/engines/efh/metaengine.cpp
index 2c8eac9e39b..e240a199481 100644
--- a/engines/efh/metaengine.cpp
+++ b/engines/efh/metaengine.cpp
@@ -101,14 +101,14 @@ SaveStateList EfhMetaEngine::listSaves(const char *target) const {
SaveStateList saveList;
char slot[3];
- for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
- slot[0] = filename->c_str()[filename->size() - 2];
- slot[1] = filename->c_str()[filename->size() - 1];
+ for (const auto &filename : filenames) {
+ slot[0] = filename.c_str()[filename.size() - 2];
+ slot[1] = filename.c_str()[filename.size() - 1];
slot[2] = '\0';
// Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot
int slotNum = atoi(slot);
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
- Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
+ Common::InSaveFile *file = saveFileMan->openForLoading(filename);
if (file) {
uint32 sign = file->readUint32LE();
uint8 saveVersion = file->readByte();
Commit: 9151366f62ad40e544357f7f2907d749e37c25c9
https://github.com/scummvm/scummvm/commit/9151366f62ad40e544357f7f2907d749e37c25c9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
CGE: Use C++ 11 range-based for loops
Changed paths:
engines/cge/metaengine.cpp
diff --git a/engines/cge/metaengine.cpp b/engines/cge/metaengine.cpp
index 5042a9eb4e9..26a9d7028cd 100644
--- a/engines/cge/metaengine.cpp
+++ b/engines/cge/metaengine.cpp
@@ -117,13 +117,13 @@ SaveStateList CGEMetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(filename->c_str() + filename->size() - 3);
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= 99) {
- Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
+ Common::InSaveFile *file = saveFileMan->openForLoading(filename);
if (file) {
CGE::SavegameHeader header;
Commit: a61aec54dba3fc6a817fa8bd19ed621475542296
https://github.com/scummvm/scummvm/commit/a61aec54dba3fc6a817fa8bd19ed621475542296
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
CGE2: Use C++ 11 range-based for loops
Changed paths:
engines/cge2/metaengine.cpp
diff --git a/engines/cge2/metaengine.cpp b/engines/cge2/metaengine.cpp
index 91e85d4a938..0004c1bb120 100644
--- a/engines/cge2/metaengine.cpp
+++ b/engines/cge2/metaengine.cpp
@@ -130,13 +130,13 @@ SaveStateList CGE2MetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(filename->c_str() + filename->size() - 3);
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= 99) {
- Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
+ Common::InSaveFile *file = saveFileMan->openForLoading(filename);
if (file) {
CGE2::SavegameHeader header;
Commit: 169fa99626fda58de0dd68b1fce17dd662116654
https://github.com/scummvm/scummvm/commit/169fa99626fda58de0dd68b1fce17dd662116654
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
CHEWY: Use C++ 11 range-based for loops
Changed paths:
engines/chewy/audio/chewy_voc.cpp
engines/chewy/events.cpp
diff --git a/engines/chewy/audio/chewy_voc.cpp b/engines/chewy/audio/chewy_voc.cpp
index 80aadbc9fd1..3081c25b610 100644
--- a/engines/chewy/audio/chewy_voc.cpp
+++ b/engines/chewy/audio/chewy_voc.cpp
@@ -32,15 +32,15 @@ ChewyVocStream::ChewyVocStream(Common::SeekableReadStream* stream, DisposeAfterU
void ChewyVocStream::removeHeaders() {
// Check the sample blocks for non-standard headers.
- for (BlockList::iterator i = _blocks.begin(), end = _blocks.end(); i != end; ++i) {
- if (i->code == 1 && i->sampleBlock.samples > 80) {
+ for (auto &block : _blocks) {
+ if (block.code == 1 && block.sampleBlock.samples > 80) {
// Found a sample block. Check for the headers.
int headerSize = 0;
if (_stream->readUint32BE() == FOURCC_RIFF) {
// Found a RIFF header.
headerSize = 44;
} else {
- _stream->seek(i->sampleBlock.offset + 76);
+ _stream->seek(block.sampleBlock.offset + 76);
if (_stream->readUint32BE() == FOURCC_SCRS) {
// Found an SCRS (?) header.
headerSize = 80;
@@ -49,8 +49,8 @@ void ChewyVocStream::removeHeaders() {
if (headerSize > 0) {
// Move the offset past the header and adjust the length.
- i->sampleBlock.offset += headerSize;
- i->sampleBlock.samples -= headerSize;
+ block.sampleBlock.offset += headerSize;
+ block.sampleBlock.samples -= headerSize;
_length = _length.addFrames(-headerSize);
}
}
diff --git a/engines/chewy/events.cpp b/engines/chewy/events.cpp
index bff6caeadab..c2115271b29 100644
--- a/engines/chewy/events.cpp
+++ b/engines/chewy/events.cpp
@@ -53,8 +53,7 @@ void EventsManager::timer_handler() {
void EventsManager::checkTimers() {
uint32 currTime = g_system->getMillis();
- for (TimerList::iterator it = _timers.begin(); it != _timers.end(); ++it) {
- TimerRecord &rec = *it;
+ for (auto &rec : _timers) {
if (currTime >= rec._nextFrameTime) {
rec._proc();
rec._nextFrameTime = currTime + rec._interval;
Commit: fa43b1327970db52ee150cfbaf8f4c301840e76d
https://github.com/scummvm/scummvm/commit/fa43b1327970db52ee150cfbaf8f4c301840e76d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
AGI: Use C++ 11 range-based for loops
Changed paths:
engines/agi/console.cpp
engines/agi/loader_v3.cpp
engines/agi/menu.cpp
engines/agi/metaengine.cpp
engines/agi/saveload.cpp
engines/agi/sprite.cpp
engines/agi/systemui.cpp
diff --git a/engines/agi/console.cpp b/engines/agi/console.cpp
index ec18fb447c6..011b8da54dc 100644
--- a/engines/agi/console.cpp
+++ b/engines/agi/console.cpp
@@ -384,16 +384,15 @@ bool Console::Cmd_BT(int argc, const char **argv) {
debugPrintf("Current script: %d\nStack depth: %d\n", _vm->_game.curLogicNr, _vm->_game.execStack.size());
uint8 p[CMD_BSIZE] = { 0 };
- Common::Array<ScriptPos>::iterator it;
- for (it = _vm->_game.execStack.begin(); it != _vm->_game.execStack.end(); ++it) {
- uint8 *code = _vm->_game.logics[it->script].data;
- uint8 op = code[it->curIP];
+ for (auto &entry : _vm->_game.execStack) {
+ uint8 *code = _vm->_game.logics[entry.script].data;
+ uint8 op = code[entry.curIP];
int parameterSize = opCodes[op].parameterSize;
- memmove(p, &code[it->curIP], parameterSize);
+ memmove(p, &code[entry.curIP], parameterSize);
memset(p + parameterSize, 0, CMD_BSIZE - parameterSize);
- debugPrintf("%d(%d): %s(", it->script, it->curIP, opCodes[op].name);
+ debugPrintf("%d(%d): %s(", entry.script, entry.curIP, opCodes[op].name);
for (int i = 0; i < parameterSize; i++)
debugPrintf("%d, ", p[i]);
diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp
index 97530330306..c5c191b29e3 100644
--- a/engines/agi/loader_v3.cpp
+++ b/engines/agi/loader_v3.cpp
@@ -42,8 +42,8 @@ void AgiLoader_v3::init() {
return;
}
- for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- Common::String fileName = file->getName();
+ for (const auto &file : fslist) {
+ Common::String fileName = file.getName();
if (fileName.size() > 3 && fileName.hasSuffixIgnoreCase("dir")) {
_name = fileName.substr(0, fileName.size() - 3);
_name.toLowercase();
diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp
index b667e869aed..39d276aaf1c 100644
--- a/engines/agi/menu.cpp
+++ b/engines/agi/menu.cpp
@@ -58,12 +58,12 @@ GfxMenu::GfxMenu(AgiEngine *vm, GfxMgr *gfx, PictureMgr *picture, TextMgr *text)
}
GfxMenu::~GfxMenu() {
- for (GuiMenuArray::iterator itemIter = _array.begin(); itemIter != _array.end(); ++itemIter)
- delete *itemIter;
+ for (auto &menu : _array)
+ delete menu;
_array.clear();
- for (GuiMenuItemArray::iterator menuIter = _itemArray.begin(); menuIter != _itemArray.end(); ++menuIter)
- delete *menuIter;
+ for (auto &menuItem : _itemArray)
+ delete menuItem;
_itemArray.clear();
}
@@ -170,9 +170,9 @@ void GfxMenu::submit() {
// WORKAROUND: For Apple II gs we add a Speed menu
if (_vm->getPlatform() == Common::kPlatformApple2GS && ConfMan.getBool("apple2gs_speedmenu")) {
uint16 maxControllerSlot = 0;
- for (GuiMenuItemArray::iterator menuIter = _itemArray.begin(); menuIter != _itemArray.end(); ++menuIter)
- if ((*menuIter)->controllerSlot > maxControllerSlot)
- maxControllerSlot = (*menuIter)->controllerSlot;
+ for (auto &menuItem : _itemArray)
+ if (menuItem->controllerSlot > maxControllerSlot)
+ maxControllerSlot = menuItem->controllerSlot;
for (uint16 curMapping = 0; curMapping < MAX_CONTROLLER_KEYMAPPINGS; curMapping++)
if (_vm->_game.controllerKeyMapping[curMapping].controllerSlot > maxControllerSlot)
maxControllerSlot = _vm->_game.controllerKeyMapping[curMapping].controllerSlot;
@@ -279,28 +279,16 @@ void GfxMenu::itemDisable(uint16 controllerSlot) {
}
void GfxMenu::itemEnableDisable(uint16 controllerSlot, bool enabled) {
- GuiMenuItemArray::iterator listIterator = _itemArray.begin();
- GuiMenuItemArray::iterator listEnd = _itemArray.end();
-
- while (listIterator != listEnd) {
- GuiMenuItemEntry *menuItemEntry = *listIterator;
- if (menuItemEntry->controllerSlot == controllerSlot) {
- menuItemEntry->enabled = enabled;
+ for (auto &menuItem : _itemArray) {
+ if (menuItem->controllerSlot == controllerSlot) {
+ menuItem->enabled = enabled;
}
-
- ++listIterator;
}
}
void GfxMenu::itemEnableAll() {
- GuiMenuItemArray::iterator listIterator = _itemArray.begin();
- GuiMenuItemArray::iterator listEnd = _itemArray.end();
-
- while (listIterator != listEnd) {
- GuiMenuItemEntry *menuItemEntry = *listIterator;
- menuItemEntry->enabled = true;
-
- ++listIterator;
+ for (auto &menuItem : _itemArray) {
+ menuItem->enabled = true;
}
}
diff --git a/engines/agi/metaengine.cpp b/engines/agi/metaengine.cpp
index 2d10bc543cf..00f4cc9d5f9 100644
--- a/engines/agi/metaengine.cpp
+++ b/engines/agi/metaengine.cpp
@@ -279,12 +279,12 @@ SaveStateList AgiMetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &file : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNr = atoi(file->c_str() + file->size() - 3);
+ int slotNr = atoi(file.c_str() + file.size() - 3);
if (slotNr >= 0 && slotNr <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = saveFileMan->openForLoading(file);
if (in) {
uint32 type = in->readUint32BE();
char description[31];
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 4c960c3b8fa..d5f8a2b1dc9 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -833,22 +833,20 @@ SavedGameSlotIdArray AgiEngine::getSavegameSlotIds() {
// search for saved game filenames...
filenames = _saveFileMan->listSavefiles(_targetName + ".###");
- Common::StringArray::iterator it;
- Common::StringArray::iterator end = filenames.end();
-
// convert to lower-case, just to be sure
- for (it = filenames.begin(); it != end; it++) {
- it->toLowercase();
+ for (auto &file : filenames) {
+ file.toLowercase();
}
+
// sort
Common::sort(filenames.begin(), filenames.end());
// now extract slot-Ids
- for (it = filenames.begin(); it != end; it++) {
- slotId = atoi(it->c_str() + numberPos);
-
+ for (auto &file : filenames) {
+ slotId = atoi(file.c_str() + numberPos);
slotIdArray.push_back(slotId);
}
+
return slotIdArray;
}
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index 849857f27e9..69770eadd10 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -193,17 +193,9 @@ void SpritesMgr::eraseSprites() {
* Draw all sprites in the given list.
*/
void SpritesMgr::drawSprites(SpriteList &spriteList) {
- SpriteList::iterator iter;
-// warning("drawSprites");
-
- for (iter = spriteList.begin(); iter != spriteList.end(); ++iter) {
- Sprite &sprite = *iter;
- ScreenObjEntry *screenObj = sprite.screenObjPtr;
-
+ for (auto &sprite : spriteList) {
_gfx->block_save(sprite.xPos, sprite.yPos, sprite.xSize, sprite.ySize, sprite.backgroundBuffer);
- //debugC(8, kDebugLevelSprites, "drawSprites(): s->v->entry = %d (prio %d)", s->viewPtr->entry, s->viewPtr->priority);
-// warning("sprite %d (view %d), priority %d, sort %d, givenOrder %d", screenObj->objectNr, screenObj->currentView, screenObj->priority, sprite.sortOrder, sprite.givenOrderNr);
- drawCel(screenObj);
+ drawCel(sprite.screenObjPtr);
}
}
@@ -358,11 +350,9 @@ void SpritesMgr::showSprite(ScreenObjEntry *screenObj) {
}
void SpritesMgr::showSprites(SpriteList &spriteList) {
- SpriteList::iterator iter;
- ScreenObjEntry *screenObjPtr = nullptr;
+ ScreenObjEntry *screenObjPtr;
- for (iter = spriteList.begin(); iter != spriteList.end(); ++iter) {
- Sprite &sprite = *iter;
+ for (auto &sprite : spriteList) {
screenObjPtr = sprite.screenObjPtr;
showSprite(screenObjPtr);
diff --git a/engines/agi/systemui.cpp b/engines/agi/systemui.cpp
index 426dfefd0aa..2b981e21a43 100644
--- a/engines/agi/systemui.cpp
+++ b/engines/agi/systemui.cpp
@@ -605,8 +605,7 @@ void SystemUI::createSavedGameDisplayText(char *destDisplayText, const char *act
void SystemUI::readSavedGameSlots(bool filterNonexistant, bool withAutoSaveSlot) {
SavedGameSlotIdArray slotIdArray;
int16 lastSlotId = -1;
- int16 curSlotId = 0;
- int16 loopSlotId = 0;
+ int16 loopSlotId;
SystemUISavedGameEntry savedGameEntry;
Common::String saveDescription;
uint32 saveDate = 0;
@@ -623,12 +622,7 @@ void SystemUI::readSavedGameSlots(bool filterNonexistant, bool withAutoSaveSlot)
slotIdArray = _vm->getSavegameSlotIds();
slotIdArray.push_back(SYSTEMUI_SAVEDGAME_MAXIMUM_SLOTS); // so that the loop will process all slots
- SavedGameSlotIdArray::iterator it;
- SavedGameSlotIdArray::iterator end = slotIdArray.end();
-
- for (it = slotIdArray.begin(); it != end; ++it) {
- curSlotId = *it;
-
+ for (auto &curSlotId : slotIdArray) {
assert(curSlotId > lastSlotId); // safety check
if (curSlotId == 0) {
Commit: 49ae0d056dbc6a4f0b46048f19aeaa5175441d8d
https://github.com/scummvm/scummvm/commit/49ae0d056dbc6a4f0b46048f19aeaa5175441d8d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
ACCESS: Use C++ 11 range-based for loops
Changed paths:
engines/access/metaengine.cpp
diff --git a/engines/access/metaengine.cpp b/engines/access/metaengine.cpp
index 233e620f30f..e03a5a9fd27 100644
--- a/engines/access/metaengine.cpp
+++ b/engines/access/metaengine.cpp
@@ -116,20 +116,18 @@ Common::Error AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, c
SaveStateList AccessMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::StringArray filenames;
Common::String saveDesc;
Common::String pattern = Common::String::format("%s.0##", target);
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
Access::AccessSavegameHeader header;
-
- filenames = saveFileMan->listSavefiles(pattern);
-
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
- const char *ext = strrchr(file->c_str(), '.');
+
+ for (const auto &filename : filenames) {
+ const char *ext = strrchr(filename.c_str(), '.');
int slot = ext ? atoi(ext + 1) : -1;
if (slot >= 0 && slot < MAX_SAVES) {
- Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename);
if (in) {
if (Access::AccessEngine::readSavegameHeader(in, header))
Commit: 0af1d397c3c4c8a8094121e71840fc6261d546e4
https://github.com/scummvm/scummvm/commit/0af1d397c3c4c8a8094121e71840fc6261d546e4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
AVALANCE: Use C++ 11 range-based for loops
Changed paths:
engines/avalanche/metaengine.cpp
diff --git a/engines/avalanche/metaengine.cpp b/engines/avalanche/metaengine.cpp
index 5c55fcfd5a2..bd08b82c215 100644
--- a/engines/avalanche/metaengine.cpp
+++ b/engines/avalanche/metaengine.cpp
@@ -93,11 +93,10 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
- const Common::String &fname = *filename;
- int slotNum = atoi(fname.c_str() + fname.size() - 3);
+ for (const auto &filename : filenames) {
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
- Common::InSaveFile *file = saveFileMan->openForLoading(fname);
+ Common::InSaveFile *file = saveFileMan->openForLoading(filename);
if (file) {
// Check for our signature.
uint32 signature = file->readUint32LE();
Commit: 2d86549c3fc43fbfe168f1c04e5b49282c083f46
https://github.com/scummvm/scummvm/commit/2d86549c3fc43fbfe168f1c04e5b49282c083f46
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
AGOS: Use C++ 11 range-based for loops
Changed paths:
engines/agos/saveload.cpp
diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp
index b2095d1e468..62c9518ce7b 100644
--- a/engines/agos/saveload.cpp
+++ b/engines/agos/saveload.cpp
@@ -35,8 +35,7 @@ namespace AGOS {
// FIXME: This code counts savegames, but callers in many cases assume
// that the return value + 1 indicates an empty slot.
int AGOSEngine::countSaveGames() {
- Common::StringArray filenames;
- uint s, numSaveGames = 1;
+ uint numSaveGames = 1;
int slotNum;
bool marks[256];
@@ -45,20 +44,20 @@ int AGOSEngine::countSaveGames() {
Common::String tmp = genSaveName(998);
assert(tmp.size() >= 4 && tmp[tmp.size()-4] == '.');
Common::String prefix = Common::String(tmp.c_str(), tmp.size()-3) + "*";
+ Common::StringArray filenames = _saveFileMan->listSavefiles(prefix);
memset(marks, false, 256 * sizeof(bool)); //assume no savegames for this title
- filenames = _saveFileMan->listSavefiles(prefix);
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file){
- //Obtain the last 3 digits of the filename, since they correspond to the save slot
- assert(file->size() >= 4);
- slotNum = atoi(file->c_str() + file->size() - 3);
+ for (const auto &filename : filenames){
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ assert(filename.size() >= 4);
+ slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum < 256)
marks[slotNum] = true; //mark this slot as valid
}
// locate first empty slot
- for (s = 1; s < 256; s++) {
+ for (uint s = 1; s < 256; s++) {
if (marks[s])
numSaveGames++;
}
Commit: db5c5e853a84b2ce14648eb995ec84e0fd7c983c
https://github.com/scummvm/scummvm/commit/db5c5e853a84b2ce14648eb995ec84e0fd7c983c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
ADL: Use C++ 11 range-based for loops
Changed paths:
engines/adl/adl.cpp
engines/adl/adl_v2.cpp
engines/adl/adl_v3.cpp
engines/adl/adl_v4.cpp
engines/adl/adl_v5.cpp
engines/adl/console.cpp
engines/adl/display.cpp
engines/adl/hires1.cpp
engines/adl/hires5.cpp
engines/adl/hires6.cpp
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 05ff6f6ffc7..7ecf997e8cd 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -434,11 +434,10 @@ void AdlEngine::removeCommand(Commands &commands, uint idx) {
}
Command &AdlEngine::getCommand(Commands &commands, uint idx) {
- Commands::iterator cmds;
uint i = 0;
- for (cmds = commands.begin(); cmds != commands.end(); ++cmds) {
+ for (auto &cmd : commands) {
if (i++ == idx)
- return *cmds;
+ return cmd;
}
error("Command %d not found", idx);
@@ -470,13 +469,11 @@ bool AdlEngine::isInputValid(byte verb, byte noun, bool &is_any) {
}
bool AdlEngine::isInputValid(const Commands &commands, byte verb, byte noun, bool &is_any) {
- Commands::const_iterator cmd;
-
is_any = false;
- for (cmd = commands.begin(); cmd != commands.end(); ++cmd) {
- Common::ScopedPtr<ScriptEnv> env(createScriptEnv(*cmd, _state.room, verb, noun));
+ for (const auto &cmd : commands) {
+ Common::ScopedPtr<ScriptEnv> env(createScriptEnv(cmd, _state.room, verb, noun));
if (matchCommand(*env)) {
- if (cmd->verb == IDI_ANY || cmd->noun == IDI_ANY)
+ if (cmd.verb == IDI_ANY || cmd.noun == IDI_ANY)
is_any = true;
return true;
}
@@ -642,21 +639,17 @@ Room &AdlEngine::getCurRoom() {
}
const Item &AdlEngine::getItem(uint i) const {
- Common::List<Item>::const_iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- if (item->id == i)
- return *item;
+ for (const auto &item : _state.items)
+ if (item.id == i)
+ return item;
error("Item %i not found", i);
}
Item &AdlEngine::getItem(uint i) {
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- if (item->id == i)
- return *item;
+ for (auto &item : _state.items)
+ if (item.id == i)
+ return item;
error("Item %i not found", i);
}
@@ -676,25 +669,22 @@ void AdlEngine::setVar(uint i, byte value) {
}
void AdlEngine::takeItem(byte noun) {
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun == noun && item->room == _state.room && item->region == _state.region) {
- if (item->state == IDI_ITEM_DOESNT_MOVE) {
+ for (auto &item : _state.items) {
+ if (item.noun == noun && item.room == _state.room && item.region == _state.region) {
+ if (item.state == IDI_ITEM_DOESNT_MOVE) {
printMessage(_messageIds.itemDoesntMove);
return;
}
- if (item->state == IDI_ITEM_DROPPED) {
- item->room = IDI_ANY;
+ if (item.state == IDI_ITEM_DROPPED) {
+ item.room = IDI_ANY;
return;
}
- Common::Array<byte>::const_iterator pic;
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture) {
- item->room = IDI_ANY;
- item->state = IDI_ITEM_DROPPED;
+ for (const auto &pic : item.roomPictures) {
+ if (pic == getCurRoom().curPicture) {
+ item.room = IDI_ANY;
+ item.state = IDI_ITEM_DROPPED;
return;
}
}
@@ -705,13 +695,11 @@ void AdlEngine::takeItem(byte noun) {
}
void AdlEngine::dropItem(byte noun) {
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun == noun && item->room == IDI_ANY) {
- item->room = _state.room;
- item->region = _state.region;
- item->state = IDI_ITEM_DROPPED;
+ for (auto &item : _state.items) {
+ if (item.noun == noun && item.room == IDI_ANY) {
+ item.room = _state.room;
+ item.region = _state.region;
+ item.state = IDI_ITEM_DROPPED;
return;
}
}
@@ -885,13 +873,12 @@ void AdlEngine::loadState(Common::ReadStream &stream) {
if (size != _state.items.size())
error("Item count mismatch (expected %i; found %i)", _state.items.size(), size);
- Common::List<Item>::iterator item;
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- item->room = stream.readByte();
- item->picture = stream.readByte();
- item->position.x = stream.readByte();
- item->position.y = stream.readByte();
- item->state = stream.readByte();
+ for (auto &item : _state.items) {
+ item.room = stream.readByte();
+ item.picture = stream.readByte();
+ item.position.x = stream.readByte();
+ item.position.y = stream.readByte();
+ item.state = stream.readByte();
}
size = stream.readUint32BE();
@@ -966,13 +953,12 @@ void AdlEngine::saveState(Common::WriteStream &stream) {
}
stream.writeUint32BE(_state.items.size());
- Common::List<Item>::const_iterator item;
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- stream.writeByte(item->room);
- stream.writeByte(item->picture);
- stream.writeByte(item->position.x);
- stream.writeByte(item->position.y);
- stream.writeByte(item->state);
+ for (const auto &item : _state.items) {
+ stream.writeByte(item.room);
+ stream.writeByte(item.picture);
+ stream.writeByte(item.position.x);
+ stream.writeByte(item.position.y);
+ stream.writeByte(item.state);
}
stream.writeUint32BE(_state.vars.size());
@@ -1038,19 +1024,17 @@ bool AdlEngine::canSaveGameStateCurrently(Common::U32String *msg) {
if (!_canSaveNow)
return false;
- Commands::const_iterator cmd;
-
// Here we check whether or not the game currently accepts the command
// "SAVE GAME". This prevents saving via the GMM in situations where
// it wouldn't otherwise be possible to do so.
- for (cmd = _roomData.commands.begin(); cmd != _roomData.commands.end(); ++cmd) {
- Common::ScopedPtr<ScriptEnv> env(createScriptEnv(*cmd, _state.room, _saveVerb, _saveNoun));
+ for (const auto &cmd : _roomData.commands) {
+ Common::ScopedPtr<ScriptEnv> env(createScriptEnv(cmd, _state.room, _saveVerb, _saveNoun));
if (matchCommand(*env))
return env->op() == IDO_ACT_SAVE;
}
- for (cmd = _roomCommands.begin(); cmd != _roomCommands.end(); ++cmd) {
- Common::ScopedPtr<ScriptEnv> env(createScriptEnv(*cmd, _state.room, _saveVerb, _saveNoun));
+ for (const auto &cmd : _roomCommands) {
+ Common::ScopedPtr<ScriptEnv> env(createScriptEnv(cmd, _state.room, _saveVerb, _saveNoun));
if (matchCommand(*env))
return env->op() == IDO_ACT_SAVE;
}
@@ -1261,11 +1245,9 @@ int AdlEngine::o_varSet(ScriptEnv &e) {
int AdlEngine::o_listInv(ScriptEnv &e) {
OP_DEBUG_0("\tLIST_INVENTORY()");
- Common::List<Item>::const_iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- if (item->room == IDI_ANY)
- printString(getItemDescription(*item));
+ for (const auto &item : _state.items)
+ if (item.room == IDI_ANY)
+ printString(getItemDescription(item));
return 0;
}
@@ -1482,10 +1464,8 @@ void AdlEngine::doActions(ScriptEnv &env) {
}
bool AdlEngine::doOneCommand(const Commands &commands, byte verb, byte noun) {
- Commands::const_iterator cmd;
-
- for (cmd = commands.begin(); cmd != commands.end(); ++cmd) {
- Common::ScopedPtr<ScriptEnv> env(createScriptEnv(*cmd, _state.room, verb, noun));
+ for (const auto &cmd : commands) {
+ Common::ScopedPtr<ScriptEnv> env(createScriptEnv(cmd, _state.room, verb, noun));
if (matchCommand(*env)) {
doActions(*env);
return true;
@@ -1501,10 +1481,8 @@ bool AdlEngine::doOneCommand(const Commands &commands, byte verb, byte noun) {
}
void AdlEngine::doAllCommands(const Commands &commands, byte verb, byte noun) {
- Commands::const_iterator cmd;
-
- for (cmd = commands.begin(); cmd != commands.end(); ++cmd) {
- Common::ScopedPtr<ScriptEnv> env(createScriptEnv(*cmd, _state.room, verb, noun));
+ for (const auto &cmd : commands) {
+ Common::ScopedPtr<ScriptEnv> env(createScriptEnv(cmd, _state.room, verb, noun));
if (matchCommand(*env)) {
doActions(*env);
// The original long jumps on restart, so we need to abort here
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp
index cd3aabd8ba5..ebd59c6e1c7 100644
--- a/engines/adl/adl_v2.cpp
+++ b/engines/adl/adl_v2.cpp
@@ -281,9 +281,8 @@ void AdlEngine_v2::showRoom() {
_itemRemoved = false;
_itemsOnScreen = 0;
- Common::List<Item>::iterator item;
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- item->isOnScreen = false;
+ for (auto &item : _state.items)
+ item.isOnScreen = false;
}
if (!_state.isDark)
@@ -295,23 +294,20 @@ void AdlEngine_v2::showRoom() {
// TODO: Merge this into AdlEngine?
void AdlEngine_v2::takeItem(byte noun) {
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun == noun && item->room == _state.room && item->region == _state.region) {
- if (item->state == IDI_ITEM_DOESNT_MOVE) {
+ for (auto &item : _state.items) {
+ if (item.noun == noun && item.room == _state.room && item.region == _state.region) {
+ if (item.state == IDI_ITEM_DOESNT_MOVE) {
printMessage(_messageIds.itemDoesntMove);
return;
}
bool itemIsHere = false;
- if (item->state == IDI_ITEM_DROPPED) {
+ if (item.state == IDI_ITEM_DROPPED) {
itemIsHere = true;
} else {
- Common::Array<byte>::const_iterator pic;
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture || *pic == IDI_ANY) {
+ for (const auto &pic : item.roomPictures) {
+ if (pic == getCurRoom().curPicture || pic == IDI_ANY) {
itemIsHere = true;
break;
}
@@ -320,9 +316,9 @@ void AdlEngine_v2::takeItem(byte noun) {
if (itemIsHere) {
if (!isInventoryFull()) {
- item->room = IDI_ANY;
+ item.room = IDI_ANY;
_itemRemoved = true;
- item->state = IDI_ITEM_DROPPED;
+ item.state = IDI_ITEM_DROPPED;
}
return;
}
@@ -333,22 +329,18 @@ void AdlEngine_v2::takeItem(byte noun) {
}
void AdlEngine_v2::drawItems() {
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
+ for (auto &item : _state.items) {
// Skip items not in this room
- if (item->region == _state.region && item->room == _state.room && !item->isOnScreen) {
- if (item->state == IDI_ITEM_DROPPED) {
+ if (item.region == _state.region && item.room == _state.room && !item.isOnScreen) {
+ if (item.state == IDI_ITEM_DROPPED) {
// Draw dropped item if in normal view
if (getCurRoom().picture == getCurRoom().curPicture && _itemsOnScreen < _itemOffsets.size())
- drawItem(*item, _itemOffsets[_itemsOnScreen++]);
+ drawItem(item, _itemOffsets[_itemsOnScreen++]);
} else {
// Draw fixed item if current view is in the pic list
- Common::Array<byte>::const_iterator pic;
-
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == _state.curPicture || *pic == IDI_ANY) {
- drawItem(*item, item->position);
+ for (const auto &pic : item.roomPictures) {
+ if (pic == _state.curPicture || pic == IDI_ANY) {
+ drawItem(item, item.position);
break;
}
}
@@ -474,10 +466,8 @@ int AdlEngine_v2::o_isRandomGT(ScriptEnv &e) {
int AdlEngine_v2::o_isNounNotInRoom(ScriptEnv &e) {
OP_DEBUG_1("\t&& NO_SUCH_ITEMS_IN_ROOM(%s)", itemRoomStr(e.arg(1)).c_str());
- Common::List<Item>::const_iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- if (item->noun == e.getNoun() && (item->room == roomArg(e.arg(1))))
+ for (const auto &item : _state.items)
+ if (item.noun == e.getNoun() && (item.room == roomArg(e.arg(1))))
return -1;
return 1;
@@ -486,10 +476,8 @@ int AdlEngine_v2::o_isNounNotInRoom(ScriptEnv &e) {
int AdlEngine_v2::o_isCarryingSomething(ScriptEnv &e) {
OP_DEBUG_0("\t&& IS_CARRYING_SOMETHING()");
- Common::List<Item>::const_iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- if (item->room == IDI_ANY)
+ for (const auto &item : _state.items)
+ if (item.room == IDI_ANY)
return 0;
return -1;
}
@@ -536,13 +524,11 @@ int AdlEngine_v2::o_moveAllItems(ScriptEnv &e) {
byte room2 = roomArg(e.arg(2));
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- if (item->room == room1) {
- item->room = room2;
+ for (auto &item : _state.items)
+ if (item.room == room1) {
+ item.room = room2;
if (room1 == IDI_ANY)
- item->state = IDI_ITEM_DROPPED;
+ item.state = IDI_ITEM_DROPPED;
}
return 2;
diff --git a/engines/adl/adl_v3.cpp b/engines/adl/adl_v3.cpp
index eec9768cb95..3dad9bccbc1 100644
--- a/engines/adl/adl_v3.cpp
+++ b/engines/adl/adl_v3.cpp
@@ -58,15 +58,13 @@ void AdlEngine_v3::loadItemDescriptions(Common::SeekableReadStream &stream, byte
int AdlEngine_v3::o_isNounNotInRoom(ScriptEnv &e) {
OP_DEBUG_1("\t&& NO_SUCH_ITEMS_IN_ROOM(%s)", itemRoomStr(e.arg(1)).c_str());
- Common::List<Item>::const_iterator item;
-
bool isAnItem = false;
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun == e.getNoun()) {
+ for (const auto &item : _state.items) {
+ if (item.noun == e.getNoun()) {
isAnItem = true;
- if (item->room == roomArg(e.arg(1)))
+ if (item.room == roomArg(e.arg(1)))
return -1;
}
}
diff --git a/engines/adl/adl_v4.cpp b/engines/adl/adl_v4.cpp
index 79cce6c2027..e537e09ca34 100644
--- a/engines/adl/adl_v4.cpp
+++ b/engines/adl/adl_v4.cpp
@@ -90,35 +90,32 @@ void AdlEngine_v4::loadState(Common::ReadStream &stream) {
if (size != _state.regions.size())
error("Region count mismatch (expected %i; found %i)", _state.regions.size(), size);
- Common::Array<Region>::iterator region;
- for (region = _state.regions.begin(); region != _state.regions.end(); ++region) {
+ for (auto ®ion : _state.regions) {
size = stream.readUint32BE();
- if (size != region->rooms.size())
- error("Room count mismatch (expected %i; found %i)", region->rooms.size(), size);
+ if (size != region.rooms.size())
+ error("Room count mismatch (expected %i; found %i)", region.rooms.size(), size);
- Common::Array<RoomState>::iterator room;
- for (room = region->rooms.begin(); room != region->rooms.end(); ++room) {
- room->picture = stream.readByte();
- room->isFirstTime = stream.readByte();
+ for (auto &room : region.rooms) {
+ room.picture = stream.readByte();
+ room.isFirstTime = stream.readByte();
}
size = stream.readUint32BE();
- if (size != region->vars.size())
- error("Variable count mismatch (expected %i; found %i)", region->vars.size(), size);
+ if (size != region.vars.size())
+ error("Variable count mismatch (expected %i; found %i)", region.vars.size(), size);
- for (uint i = 0; i < region->vars.size(); ++i)
- region->vars[i] = stream.readByte();
+ for (uint i = 0; i < region.vars.size(); ++i)
+ region.vars[i] = stream.readByte();
}
size = stream.readUint32BE();
if (size != _state.items.size())
error("Item count mismatch (expected %i; found %i)", _state.items.size(), size);
- Common::List<Item>::iterator item;
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- item->room = stream.readByte();
- item->region = stream.readByte();
- item->state = stream.readByte();
+ for (auto &item : _state.items) {
+ item.room = stream.readByte();
+ item.region = stream.readByte();
+ item.state = stream.readByte();
}
size = stream.readUint32BE();
@@ -147,26 +144,23 @@ void AdlEngine_v4::saveState(Common::WriteStream &stream) {
stream.writeByte(_state.prevRegion);
stream.writeUint32BE(_state.regions.size());
- Common::Array<Region>::const_iterator region;
- for (region = _state.regions.begin(); region != _state.regions.end(); ++region) {
- stream.writeUint32BE(region->rooms.size());
- Common::Array<RoomState>::const_iterator room;
- for (room = region->rooms.begin(); room != region->rooms.end(); ++room) {
- stream.writeByte(room->picture);
- stream.writeByte(room->isFirstTime);
+ for (const auto ®ion : _state.regions) {
+ stream.writeUint32BE(region.rooms.size());
+ for (const auto &room : region.rooms) {
+ stream.writeByte(room.picture);
+ stream.writeByte(room.isFirstTime);
}
- stream.writeUint32BE(region->vars.size());
- for (uint i = 0; i < region->vars.size(); ++i)
- stream.writeByte(region->vars[i]);
+ stream.writeUint32BE(region.vars.size());
+ for (uint i = 0; i < region.vars.size(); ++i)
+ stream.writeByte(region.vars[i]);
}
stream.writeUint32BE(_state.items.size());
- Common::List<Item>::const_iterator item;
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- stream.writeByte(item->room);
- stream.writeByte(item->region);
- stream.writeByte(item->state);
+ for (const auto &item : _state.items) {
+ stream.writeByte(item.room);
+ stream.writeByte(item.region);
+ stream.writeByte(item.state);
}
stream.writeUint32BE(_state.vars.size() - getRegion(1).vars.size());
@@ -491,28 +485,26 @@ int AdlEngine_v4::o_moveAllItems(ScriptEnv &e) {
byte room2 = roomArg(e.arg(2));
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (room1 != item->room)
+ for (auto &item : _state.items) {
+ if (room1 != item.room)
continue;
if (room1 != IDI_ANY) {
- if (_state.region != item->region)
+ if (_state.region != item.region)
continue;
if (room2 == IDI_ANY) {
if (isInventoryFull())
break;
- if (item->state == IDI_ITEM_DOESNT_MOVE)
+ if (item.state == IDI_ITEM_DOESNT_MOVE)
continue;
}
}
- item->room = room2;
- item->region = _state.region;
+ item.room = room2;
+ item.region = _state.region;
if (room1 == IDI_ANY)
- item->state = IDI_ITEM_DROPPED;
+ item.state = IDI_ITEM_DROPPED;
}
return 2;
diff --git a/engines/adl/adl_v5.cpp b/engines/adl/adl_v5.cpp
index d29737d883c..04d202c9946 100644
--- a/engines/adl/adl_v5.cpp
+++ b/engines/adl/adl_v5.cpp
@@ -78,15 +78,13 @@ void AdlEngine_v5::setupOpcodeTables() {
int AdlEngine_v5::o_isNounNotInRoom(ScriptEnv &e) {
OP_DEBUG_1("\t&& NO_SUCH_ITEMS_IN_ROOM(%s)", itemRoomStr(e.arg(1)).c_str());
- Common::List<Item>::const_iterator item;
-
setVar(24, 0);
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- if (item->noun == e.getNoun()) {
+ for (const auto &item : _state.items)
+ if (item.noun == e.getNoun()) {
setVar(24, 1);
- if (item->room == roomArg(e.arg(1)))
+ if (item.room == roomArg(e.arg(1)))
return -1;
}
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp
index 35ea60a01e1..c005e07dbea 100644
--- a/engines/adl/console.cpp
+++ b/engines/adl/console.cpp
@@ -101,16 +101,15 @@ bool Console::Cmd_ValidCommands(int argc, const char **argv) {
return true;
}
- WordMap::const_iterator verb, noun;
bool is_any;
- for (verb = _engine->_verbs.begin(); verb != _engine->_verbs.end(); ++verb) {
- for (noun = _engine->_nouns.begin(); noun != _engine->_nouns.end(); ++noun) {
- if (_engine->isInputValid(verb->_value, noun->_value, is_any) && !is_any)
- debugPrintf("%s %s\n", toAscii(verb->_key).c_str(), toAscii(noun->_key).c_str());
+ for (const auto &verb : _engine->_verbs) {
+ for (const auto &noun : _engine->_nouns) {
+ if (_engine->isInputValid(verb._value, noun._value, is_any) && !is_any)
+ debugPrintf("%s %s\n", toAscii(verb._key).c_str(), toAscii(noun._key).c_str());
}
- if (_engine->isInputValid(verb->_value, IDI_ANY, is_any))
- debugPrintf("%s *\n", toAscii(verb->_key).c_str());
+ if (_engine->isInputValid(verb._value, IDI_ANY, is_any))
+ debugPrintf("%s *\n", toAscii(verb._key).c_str());
}
if (_engine->isInputValid(IDI_ANY, IDI_ANY, is_any))
debugPrintf("* *\n");
@@ -247,10 +246,8 @@ bool Console::Cmd_Items(int argc, const char **argv) {
return true;
}
- Common::List<Item>::const_iterator item;
-
- for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item)
- printItem(*item);
+ for (const auto &item : _engine->_state.items)
+ printItem(item);
return true;
}
@@ -261,8 +258,6 @@ bool Console::Cmd_GiveItem(int argc, const char **argv) {
return true;
}
- Common::List<Item>::iterator item;
-
char *end;
uint id = strtoul(argv[1], &end, 0);
@@ -278,9 +273,9 @@ bool Console::Cmd_GiveItem(int argc, const char **argv) {
byte noun = _engine->_nouns[name];
- for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item) {
- if (item->noun == noun)
- matches.push_back(&*item);
+ for (auto &item : _engine->_state.items) {
+ if (item.noun == noun)
+ matches.push_back(&item);
}
if (matches.size() == 0) {
@@ -300,9 +295,9 @@ bool Console::Cmd_GiveItem(int argc, const char **argv) {
return true;
}
- for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item)
- if (item->id == id) {
- item->room = IDI_ANY;
+ for (auto &item : _engine->_state.items)
+ if (item.id == id) {
+ item.room = IDI_ANY;
debugPrintf("OK\n");
return true;
}
@@ -381,10 +376,9 @@ void Console::printItem(const Item &item) {
void Console::printWordMap(const WordMap &wordMap) {
Common::StringArray words;
- WordMap::const_iterator verb;
- for (verb = wordMap.begin(); verb != wordMap.end(); ++verb)
- words.push_back(Common::String::format("%s: %3d", toAscii(verb->_key).c_str(), wordMap[verb->_key]));
+ for (const auto &verb : wordMap)
+ words.push_back(Common::String::format("%s: %3d", toAscii(verb._key).c_str(), wordMap[verb._key]));
Common::sort(words.begin(), words.end());
diff --git a/engines/adl/display.cpp b/engines/adl/display.cpp
index 34b13d7626a..ef59f4a4086 100644
--- a/engines/adl/display.cpp
+++ b/engines/adl/display.cpp
@@ -74,17 +74,15 @@ void Display::moveCursorTo(const Common::Point &pos) {
}
void Display::printString(const Common::String &str) {
- Common::String::const_iterator c;
- for (c = str.begin(); c != str.end(); ++c)
- printChar(*c);
+ for (const auto &c : str)
+ printChar(c);
renderText();
}
void Display::printAsciiString(const Common::String &str) {
- Common::String::const_iterator c;
- for (c = str.begin(); c != str.end(); ++c)
- printChar(asciiToNative(*c));
+ for (const auto &c : str)
+ printChar(asciiToNative(c));
renderText();
}
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index 6a6c2865e8e..e1f40768185 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -468,26 +468,22 @@ void HiRes1Engine::printMessage(uint idx) {
}
void HiRes1Engine::drawItems() {
- Common::List<Item>::iterator item;
-
uint dropped = 0;
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
+ for (auto &item : _state.items) {
// Skip items not in this room
- if (item->room != _state.room)
+ if (item.room != _state.room)
continue;
- if (item->state == IDI_ITEM_DROPPED) {
+ if (item.state == IDI_ITEM_DROPPED) {
// Draw dropped item if in normal view
if (getCurRoom().picture == getCurRoom().curPicture)
- drawItem(*item, _itemOffsets[dropped++]);
+ drawItem(item, _itemOffsets[dropped++]);
} else {
// Draw fixed item if current view is in the pic list
- Common::Array<byte>::const_iterator pic;
-
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture) {
- drawItem(*item, item->position);
+ for (const auto &pic : item.roomPictures) {
+ if (pic == getCurRoom().curPicture) {
+ drawItem(item, item.position);
break;
}
}
diff --git a/engines/adl/hires5.cpp b/engines/adl/hires5.cpp
index 8441573809c..029b505a43c 100644
--- a/engines/adl/hires5.cpp
+++ b/engines/adl/hires5.cpp
@@ -147,12 +147,11 @@ void HiRes5Engine::setupOpcodeTables() {
}
bool HiRes5Engine::isInventoryFull() {
- Common::List<Item>::const_iterator item;
byte weight = 0;
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->room == IDI_ANY)
- weight += item->description;
+ for (const auto &item : _state.items) {
+ if (item.room == IDI_ANY)
+ weight += item.description;
}
if (weight >= 100) {
@@ -199,15 +198,14 @@ int HiRes5Engine::o_checkItemTimeLimits(ScriptEnv &e) {
OP_DEBUG_1("\tCHECK_ITEM_TIME_LIMITS(VARS[%d])", e.arg(1));
bool lostAnItem = false;
- Common::List<Item>::iterator item;
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- const byte room = item->room;
- const byte region = item->region;
+ for (auto &item : _state.items) {
+ const byte room = item.room;
+ const byte region = item.region;
if (room == IDI_ANY || room == IDI_CUR_ROOM || (room == _state.room && region == _state.region)) {
- if (getVar(e.arg(1)) < _itemTimeLimits[item->id - 1]) {
- item->room = IDI_VOID_ROOM;
+ if (getVar(e.arg(1)) < _itemTimeLimits[item.id - 1]) {
+ item.room = IDI_VOID_ROOM;
lostAnItem = true;
}
}
diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp
index 5fdb6ad8ed4..d4a0759997e 100644
--- a/engines/adl/hires6.cpp
+++ b/engines/adl/hires6.cpp
@@ -319,9 +319,8 @@ void HiRes6Engine::showRoom() {
_itemRemoved = false;
_itemsOnScreen = 0;
- Common::List<Item>::iterator item;
- for (item = _state.items.begin(); item != _state.items.end(); ++item)
- item->isOnScreen = false;
+ for (auto &item : _state.items)
+ item.isOnScreen = false;
}
if (!_state.isDark)
Commit: 52b22ba636b2b7596cb6a1a1d6bbd4a8a9be0a09
https://github.com/scummvm/scummvm/commit/52b22ba636b2b7596cb6a1a1d6bbd4a8a9be0a09
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
BBVS: Use C++ 11 range-based for loops
Changed paths:
engines/bbvs/metaengine.cpp
diff --git a/engines/bbvs/metaengine.cpp b/engines/bbvs/metaengine.cpp
index 69913023ae8..95430ef81f2 100644
--- a/engines/bbvs/metaengine.cpp
+++ b/engines/bbvs/metaengine.cpp
@@ -162,14 +162,14 @@ SaveStateList BbvsMetaEngine::listSaves(const char *target) const {
Bbvs::BbvsEngine::SaveHeader header;
Common::String pattern = target;
pattern += ".###";
- Common::StringArray filenames;
- filenames = saveFileMan->listSavefiles(pattern.c_str());
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern.c_str());
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename.c_str());
if (in) {
if (Bbvs::BbvsEngine::readSaveHeader(in, header) == Bbvs::BbvsEngine::kRSHENoError) {
saveList.push_back(SaveStateDescriptor(this, slotNum, header.description));
Commit: b7530e0af0a88352cf0bf5e8b234afd0d81ab87e
https://github.com/scummvm/scummvm/commit/b7530e0af0a88352cf0bf5e8b234afd0d81ab87e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
DM: Use C++ 11 range-based for loops
Changed paths:
engines/dm/metaengine.cpp
diff --git a/engines/dm/metaengine.cpp b/engines/dm/metaengine.cpp
index 8e944db0b49..9df8f0ea8be 100644
--- a/engines/dm/metaengine.cpp
+++ b/engines/dm/metaengine.cpp
@@ -64,17 +64,16 @@ public:
Common::String pattern = target;
pattern += ".###";
- Common::StringArray filenames;
- filenames = saveFileMan->listSavefiles(pattern.c_str());
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern.c_str());
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
if ((slotNum >= 0) && (slotNum <= 999)) {
- Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename.c_str());
if (in) {
if (DM::readSaveGameHeader(in, &header))
saveList.push_back(SaveStateDescriptor(this, slotNum, header._descr.getDescription()));
Commit: 9eee0e2be3095db98fe99028de8ac0fafc557c01
https://github.com/scummvm/scummvm/commit/9eee0e2be3095db98fe99028de8ac0fafc557c01
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
KINGDOM: Use C++ 11 range-based for loops
Changed paths:
engines/kingdom/metaengine.cpp
diff --git a/engines/kingdom/metaengine.cpp b/engines/kingdom/metaengine.cpp
index 0671ea0427e..b209cac2e62 100644
--- a/engines/kingdom/metaengine.cpp
+++ b/engines/kingdom/metaengine.cpp
@@ -74,21 +74,19 @@ int KingdomMetaEngine::getMaximumSaveSlot() const {
SaveStateList KingdomMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::StringArray filenames;
Common::String saveDesc;
Common::String pattern = Common::String::format("%s.0##", target);
-
- filenames = saveFileMan->listSavefiles(pattern);
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
Kingdom::KingdomSavegameHeader header;
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
- const char *ext = strrchr(file->c_str(), '.');
+ for (const auto &filename : filenames) {
+ const char *ext = strrchr(filename.c_str(), '.');
int slot = ext ? atoi(ext + 1) : -1;
if (slot >= 0 && slot < MAX_SAVES) {
- Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename);
if (in) {
if (Kingdom::KingdomGame::readSavegameHeader(in, header)) {
Commit: bd49804112184540ad1c3d06667dbbdc77e83046
https://github.com/scummvm/scummvm/commit/bd49804112184540ad1c3d06667dbbdc77e83046
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
LILIPUT: Use C++ 11 range-based for loops
Changed paths:
engines/lilliput/metaengine.cpp
diff --git a/engines/lilliput/metaengine.cpp b/engines/lilliput/metaengine.cpp
index c69827b0639..10941143366 100644
--- a/engines/lilliput/metaengine.cpp
+++ b/engines/lilliput/metaengine.cpp
@@ -96,15 +96,16 @@ SaveStateList LilliputMetaEngine::listSaves(const char *target) const {
SaveStateList saveList;
char slot[3];
- int slotNum = 0;
- for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
- slot[0] = filename->c_str()[filename->size() - 6];
- slot[1] = filename->c_str()[filename->size() - 5];
+ int slotNum;
+
+ for (const auto &filename : filenames) {
+ slot[0] = filename.c_str()[filename.size() - 6];
+ slot[1] = filename.c_str()[filename.size() - 5];
slot[2] = '\0';
// Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot
slotNum = atoi(slot);
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
- Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
+ Common::InSaveFile *file = saveFileMan->openForLoading(filename);
if (file) {
int saveVersion = file->readByte();
Commit: e8a321b15244adcadccb9f067bf04124b30e3dfe
https://github.com/scummvm/scummvm/commit/e8a321b15244adcadccb9f067bf04124b30e3dfe
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
SWORD1: Use C++ 11 range-based for loops
Changed paths:
engines/sword1/control.cpp
engines/sword1/metaengine.cpp
diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index 71f153f0d74..8ad897b11a4 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -1412,9 +1412,9 @@ int16 Control::readFileDescriptions() {
int16 totalFiles = 0;
int slotNum = 0;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- slotNum = atoi(file->c_str() + file->size() - 3);
+ slotNum = atoi(filename.c_str() + filename.size() - 3);
while (totalFiles < slotNum) {
Common::strcpy_s((char *)_fileDescriptions[totalFiles], 1, "");
@@ -1422,7 +1422,7 @@ int16 Control::readFileDescriptions() {
}
if (slotNum >= 0 && slotNum < MAXSAVEGAMES) {
- Common::InSaveFile *in = _saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = _saveFileMan->openForLoading(filename);
if (in) {
in->readUint32LE(); // header
in->read(saveName, 40);
diff --git a/engines/sword1/metaengine.cpp b/engines/sword1/metaengine.cpp
index e32825724b5..aaee6d94b8a 100644
--- a/engines/sword1/metaengine.cpp
+++ b/engines/sword1/metaengine.cpp
@@ -319,12 +319,12 @@ SaveStateList SwordMetaEngine::listSaves(const char *target) const {
Common::StringArray filenames = saveFileMan->listSavefiles("sword1.###");
int slotNum = 0;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- slotNum = atoi(file->c_str() + file->size() - 3);
+ slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename);
if (in) {
in->readUint32LE(); // header
in->read(saveName, 40);
Commit: a2a8e23300952aeaf9a6e8e4e5a17ee2abf47cfa
https://github.com/scummvm/scummvm/commit/a2a8e23300952aeaf9a6e8e4e5a17ee2abf47cfa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
SWORD2: Use C++ 11 range-based for loops
Changed paths:
engines/sword2/metaengine.cpp
diff --git a/engines/sword2/metaengine.cpp b/engines/sword2/metaengine.cpp
index 810b66e8e1a..c04dd38d7a1 100644
--- a/engines/sword2/metaengine.cpp
+++ b/engines/sword2/metaengine.cpp
@@ -98,12 +98,12 @@ SaveStateList Sword2MetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename);
if (in) {
in->readUint32LE();
in->read(saveDesc, SAVE_DESCRIPTION_LEN);
Commit: 155bba57d39bd4864b73c274552cc4e26559b979
https://github.com/scummvm/scummvm/commit/155bba57d39bd4864b73c274552cc4e26559b979
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
ASYLUM: Use C++ 11 range-based for loops
Changed paths:
engines/asylum/console.cpp
engines/asylum/puzzles/pipes.cpp
engines/asylum/resources/actor.cpp
engines/asylum/respack.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/sound.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 3d51c766b84..5f3e81f34e1 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -377,8 +377,8 @@ bool Console::cmdListFiles(int argc, const char **argv) {
int count = SearchMan.listMatchingMembers(list, filter);
debugPrintf("Number of matches: %d\n", count);
- for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it)
- debugPrintf(" %s\n", (*it)->getName().c_str());
+ for (const auto &archive : list)
+ debugPrintf(" %s\n", archive->getName().c_str());
return true;
}
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index d87835835b6..dca90a293b9 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -80,16 +80,16 @@ void Peephole::startUpWater(bool flag) {
marks[_id] = true;
- for (Common::List<Connector *>::iterator iter = _connectors.begin(); iter != _connectors.end(); ++iter) {
- for (Common::List<Peephole *>::iterator iter1 = (*iter)->_connectedNodes.begin(); iter1 != (*iter)->_connectedNodes.end(); ++iter1) {
- if (!marks[(*iter1)->getId()]) {
+ for (auto &connector : _connectors) {
+ for (auto &connectedNode : connector->_connectedNodes) {
+ if (!marks[connectedNode->getId()]) {
for (uint32 i = 0; i < 4; ++i) {
- if (isConnected(i) && (*iter1)->getId() > 3)
- (*iter1)->_flowValues[i] += _flowValues[i];
+ if (isConnected(i) && connectedNode->getId() > 3)
+ connectedNode->_flowValues[i] += _flowValues[i];
}
- (*iter1)->startUpWater();
+ connectedNode->startUpWater();
}
}
}
@@ -186,14 +186,14 @@ void Connector::turn(bool updpos) {
}
void Connector::connect(Connector *connector) {
- for (Common::List<Peephole *>::iterator iter = _connectedNodes.begin(); iter != _connectedNodes.end(); ++iter) {
- (*iter)->connect(connector);
- connector->_connectedNodes.push_back(*iter);
+ for (auto &connectedNode : _connectedNodes) {
+ connectedNode->connect(connector);
+ connector->_connectedNodes.push_back(connectedNode);
}
- for (Common::List<Peephole *>::iterator iter = connector->_connectedNodes.begin(); iter != connector->_connectedNodes.end(); ++iter) {
- (*iter)->connect(this);
- _connectedNodes.push_back(*iter);
+ for (auto &connectedNode : connector->_connectedNodes) {
+ connectedNode->connect(this);
+ _connectedNodes.push_back(connectedNode);
}
_isConnected = connector->_isConnected = true;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0d1d17c533e..c160b0c819e 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3559,11 +3559,11 @@ bool Actor::canGetToDest(Common::Array<int> *actions, const Common::Point &point
}
bool Actor::testPolyInLink(const Common::Point &pt, Common::Array<int> *actions) {
- if (actions->size() == 0)
+ if (actions->empty())
return false;
- for (Common::Array<int>::iterator it = actions->begin(); it != actions->end(); it++) {
- if (isInActionArea(pt, getWorld()->actions[*it]))
+ for (auto &action : *actions) {
+ if (isInActionArea(pt, getWorld()->actions[action]))
return true;
}
@@ -3582,8 +3582,7 @@ bool Actor::isInActionArea(const Common::Point &pt, ActionArea *area) {
// Check flags
bool found = false;
- for (uint32 i = 0; i < 10; i++) {
- int32 flag = area->flagNums[i];
+ for (auto &flag : area->flagNums) {
bool state = (flag <= 0) ? _vm->isGameFlagNotSet((GameFlag)-flag) : _vm->isGameFlagSet((GameFlag)flag);
if (!state) {
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 650d38caadc..3cf15d0d546 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -47,10 +47,10 @@ ResourceManager::ResourceManager(AsylumEngine *vm) : _cdNumber(-1), _musicPackId
}
ResourceManager::~ResourceManager() {
- for (ResourceCache::const_iterator it = _resources.begin(); it != _resources.end(); it++)
- delete it->_value;
- for (ResourceCache::const_iterator it = _music.begin(); it != _music.end(); it++)
- delete it->_value;
+ for (const auto &resource : _resources)
+ delete resource._value;
+ for (const auto &music : _music)
+ delete music._value;
}
ResourceEntry *ResourceManager::get(ResourceId id) {
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index e1b72a72e2e..8a943e2ef84 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -703,16 +703,14 @@ void Screen::drawGraphicsInQueue() {
// Sort by priority first
Common::sort(_queueItems.begin(), _queueItems.end(), &Screen::graphicQueueItemComparator);
- for (Common::Array<GraphicQueueItem>::const_iterator i = _queueItems.begin(); i != _queueItems.end(); i++) {
- const GraphicQueueItem *item = i;
-
- if (item->type == kGraphicItemNormal) {
- if (item->transTableNum <= 0 || Config.performance <= 1)
- draw(item->resourceId, item->frameIndex, item->source, item->flags);
+ for (const auto &item : _queueItems) {
+ if (item.type == kGraphicItemNormal) {
+ if (item.transTableNum <= 0 || Config.performance <= 1)
+ draw(item.resourceId, item.frameIndex, item.source, item.flags);
else
- drawTransparent(item->resourceId, item->frameIndex, item->source, item->flags, (uint32)(item->transTableNum - 1));
- } else if (item->type == kGraphicItemMasked) {
- draw(item->resourceId, item->frameIndex, item->source, item->flags, item->resourceIdDestination, item->destination);
+ drawTransparent(item.resourceId, item.frameIndex, item.source, item.flags, (uint32)(item.transTableNum - 1));
+ } else if (item.type == kGraphicItemMasked) {
+ draw(item.resourceId, item.frameIndex, item.source, item.flags, item.resourceIdDestination, item.destination);
}
}
}
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 54740a25d61..67a8599d198 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -266,14 +266,14 @@ void Sound::stop(ResourceId resourceId) {
}
void Sound::stopAll(ResourceId resourceId) {
- for (Common::Array<SoundQueueItem>::iterator it = _soundQueue.begin(); it != _soundQueue.end(); it++)
- if (it->resourceId == resourceId)
- _mixer->stopHandle(it->handle);
+ for (auto &sound : _soundQueue)
+ if (sound.resourceId == resourceId)
+ _mixer->stopHandle(sound.handle);
}
void Sound::stopAll() {
- for (Common::Array<SoundQueueItem>::iterator it = _soundQueue.begin(); it != _soundQueue.end(); it++)
- _mixer->stopHandle(it->handle);
+ for (auto &sound : _soundQueue)
+ _mixer->stopHandle(sound.handle);
}
void Sound::stopMusic() {
Commit: a90db8008fe824469841a91be74176dfa318a7b0
https://github.com/scummvm/scummvm/commit/a90db8008fe824469841a91be74176dfa318a7b0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
BAGEL: Use C++ 11 range-based for loops
Changed paths:
engines/bagel/boflib/gui/window.cpp
diff --git a/engines/bagel/boflib/gui/window.cpp b/engines/bagel/boflib/gui/window.cpp
index 9cd1860701f..f8eff889ace 100644
--- a/engines/bagel/boflib/gui/window.cpp
+++ b/engines/bagel/boflib/gui/window.cpp
@@ -385,9 +385,7 @@ void CBofWindow::checkTimers() {
uint32 currTime = g_system->getMillis();
// Iterate over the timers looking for any that have expired
- for (Common::List<WindowTimer>::iterator it = _timers.begin(); it != _timers.end(); ++it) {
- WindowTimer &timer = *it;
-
+ for (auto &timer : _timers) {
if (currTime >= (timer._lastExpiryTime + timer._interval)) {
// Timer has expired
timer._lastExpiryTime = currTime;
Commit: 8d6388e06866e2144a0a75ef8cffb57d8baae582
https://github.com/scummvm/scummvm/commit/8d6388e06866e2144a0a75ef8cffb57d8baae582
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
CRUISE: Use C++ 11 range-based for loops
Changed paths:
engines/cruise/cruise_main.cpp
engines/cruise/gfxModule.cpp
engines/cruise/metaengine.cpp
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index 5734f2077c7..4c8a25c56f1 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -44,10 +44,8 @@ typedef CruiseEngine::MemInfo MemInfo;
void MemoryList() {
if (!_vm->_memList.empty()) {
debug("Current list of un-freed memory blocks:");
- Common::List<MemInfo *>::iterator i;
- for (i = _vm->_memList.begin(); i != _vm->_memList.end(); ++i) {
- MemInfo const *const v = *i;
- debug("%s - %d", v->fname, v->lineNum);
+ for (auto &m : _vm->_memList) {
+ debug("%s - %d", m->fname, m->lineNum);
}
}
}
diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp
index 0f6baf6b422..65f64934f3a 100644
--- a/engines/cruise/gfxModule.cpp
+++ b/engines/cruise/gfxModule.cpp
@@ -287,8 +287,6 @@ void gfxModuleData_updateScreen() {
}
void flip() {
- CruiseEngine::RectList::iterator dr;
-
// Update the palette
gfxModuleData_updatePalette();
@@ -297,8 +295,7 @@ void flip() {
_vm->_priorFrameRects = _vm->_dirtyRects;
// Merge the prior frame's dirty rects into the current frame's list
- for (dr = tempList.begin(); dr != tempList.end(); ++dr) {
- Common::Rect &r = *dr;
+ for (auto &r : tempList) {
_vm->_dirtyRects.push_back(Common::Rect(r.left, r.top, r.right, r.bottom));
}
@@ -306,8 +303,7 @@ void flip() {
mergeClipRects();
// Copy any modified areas
- for (dr = _vm->_dirtyRects.begin(); dr != _vm->_dirtyRects.end(); ++dr) {
- Common::Rect &r = *dr;
+ for (auto &r : _vm->_dirtyRects) {
g_system->copyRectToScreen(globalScreen + 320 * r.top + r.left, 320,
r.left, r.top, r.width(), r.height());
}
diff --git a/engines/cruise/metaengine.cpp b/engines/cruise/metaengine.cpp
index 4ce3008abbd..c8cac949c84 100644
--- a/engines/cruise/metaengine.cpp
+++ b/engines/cruise/metaengine.cpp
@@ -83,12 +83,12 @@ SaveStateList CruiseMetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (auto &filename : filenames) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 2);
+ int slotNum = atoi(filename.c_str() + filename.size() - 2);
if (slotNum >= 0 && slotNum <= 99) {
- Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename);
if (in) {
Cruise::CruiseSavegameHeader header;
if (Cruise::readSavegameHeader(in, header))
Commit: ad27ff215c0e249259825fda588a9aef16713f1e
https://github.com/scummvm/scummvm/commit/ad27ff215c0e249259825fda588a9aef16713f1e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
DGDS: Use C++ 11 range-based for loops
Changed paths:
engines/dgds/console.cpp
engines/dgds/sound/drivers/adlib.cpp
engines/dgds/sound/drivers/amigamac1.cpp
engines/dgds/sound/drivers/midi.cpp
engines/dgds/sound/music.cpp
diff --git a/engines/dgds/console.cpp b/engines/dgds/console.cpp
index a4597e2e736..416d4a87e44 100644
--- a/engines/dgds/console.cpp
+++ b/engines/dgds/console.cpp
@@ -73,10 +73,10 @@ bool Console::cmdFileSearch(int argc, const char **argv) {
}
const ResourceList &resources = _vm->getResourceManager()->getResources();
- for (ResourceList::const_iterator i = resources.begin(), end = resources.end(); i != end; ++i) {
- if (i->_key.contains(argv[1])) {
- Resource res = i->_value;
- debugPrintf("Resource: %s, volume: %d, position: %d, size: %d, checksum: %d\n", i->_key.c_str(), res.volume, res.pos, res.size, res.checksum);
+ for (const auto &resource : resources) {
+ if (resource._key.contains(argv[1])) {
+ Resource res = resource._value;
+ debugPrintf("Resource: %s, volume: %d, position: %d, size: %d, checksum: %d\n", resource._key.c_str(), res.volume, res.pos, res.size, res.checksum);
}
}
diff --git a/engines/dgds/sound/drivers/adlib.cpp b/engines/dgds/sound/drivers/adlib.cpp
index 9f109101946..ad4001a5650 100644
--- a/engines/dgds/sound/drivers/adlib.cpp
+++ b/engines/dgds/sound/drivers/adlib.cpp
@@ -555,11 +555,8 @@ int MidiDriver_AdLib::findVoice(int channel) {
}
int MidiDriver_AdLib::findVoiceLateSci11(int channel) {
- Common::List<int>::const_iterator it;
-
// Search for unused voice
- for (it = _voiceQueue.begin(); it != _voiceQueue.end(); ++it) {
- int voice = *it;
+ for (const auto &voice : _voiceQueue) {
if (_voices[voice].note == -1 && _voices[voice].patch == _channels[channel].patch) {
_voices[voice].channel = channel;
return voice;
@@ -567,8 +564,7 @@ int MidiDriver_AdLib::findVoiceLateSci11(int channel) {
}
// Same as before, minus the program check
- for (it = _voiceQueue.begin(); it != _voiceQueue.end(); ++it) {
- int voice = *it;
+ for (const auto &voice : _voiceQueue) {
if (_voices[voice].note == -1) {
_voices[voice].channel = channel;
return voice;
@@ -592,8 +588,7 @@ int MidiDriver_AdLib::findVoiceLateSci11(int channel) {
// note on this channel.
int stopChan = (maxExceed > 0) ? maxExceedChan : channel;
- for (it = _voiceQueue.begin(); it != _voiceQueue.end(); ++it) {
- int voice = *it;
+ for (const auto &voice : _voiceQueue) {
if (_voices[voice].channel == stopChan) {
voiceOff(voice);
_voices[voice].channel = channel;
diff --git a/engines/dgds/sound/drivers/amigamac1.cpp b/engines/dgds/sound/drivers/amigamac1.cpp
index 24526eebd27..9c820116061 100644
--- a/engines/dgds/sound/drivers/amigamac1.cpp
+++ b/engines/dgds/sound/drivers/amigamac1.cpp
@@ -230,7 +230,6 @@ protected:
};
Common::Array<Channel *> _channels;
- typedef Common::Array<Channel *>::const_iterator ChanIt;
static const byte _envSpeedToStep[32];
static const byte _envSpeedToSkip[32];
@@ -269,12 +268,12 @@ void MidiPlayer_AmigaMac1::close() {
_mixer->stopHandle(_mixerSoundHandle);
- for (ChanIt c = _channels.begin(); c != _channels.end(); ++c)
- delete *c;
+ for (const auto &channel : _channels)
+ delete channel;
_channels.clear();
- for (VoiceIt v = _voices.begin(); v != _voices.end(); ++v)
- delete *v;
+ for (const auto &voice : _voices)
+ delete voice;
_voices.clear();
freeInstruments();
@@ -446,16 +445,16 @@ bool MidiPlayer_AmigaMac1::loadInstruments(Common::SeekableReadStream &patch, bo
}
void MidiPlayer_AmigaMac1::freeInstruments() {
- for (WaveMap::iterator it = _waves.begin(); it != _waves.end(); ++it)
- delete it->_value;
+ for (auto &wave : _waves)
+ delete wave._value;
_waves.clear();
- for (FreqTableMap::iterator it = _freqTables.begin(); it != _freqTables.end(); ++it)
- delete[] it->_value;
+ for (auto &freq : _freqTables)
+ delete[] freq._value;
_freqTables.clear();
- for (Common::Array<const Instrument *>::iterator it = _instruments.begin(); it != _instruments.end(); ++it)
- delete *it;
+ for (auto &instrument : _instruments)
+ delete instrument;
_instruments.clear();
}
@@ -469,14 +468,13 @@ void MidiPlayer_AmigaMac1::onTimer() {
_timerMutex.unlock();
_mixMutex.lock();
- for (VoiceIt it = _voices.begin(); it != _voices.end(); ++it) {
- Voice *v = *it;
- if (v->_note != -1) {
- ++v->_ticks;
- if (v->_isReleased)
- ++v->_releaseTicks;
- v->processEnvelope();
- v->calcMixVelocity();
+ for (const auto &voice : _voices) {
+ if (voice->_note != -1) {
+ ++voice->_ticks;
+ if (voice->_isReleased)
+ ++voice->_releaseTicks;
+ voice->processEnvelope();
+ voice->calcMixVelocity();
}
}
}
@@ -528,8 +526,8 @@ MidiPlayer_AmigaMac1::Voice *MidiPlayer_AmigaMac1::Channel::findVoice() {
void MidiPlayer_AmigaMac1::Channel::voiceMapping(byte voices) {
int curVoices = 0;
- for (VoiceIt it = _driver._voices.begin(); it != _driver._voices.end(); ++it)
- if ((*it)->_channel == this)
+ for (auto &voice : _driver._voices)
+ if (voice->_channel == this)
curVoices++;
curVoices += _extraVoices;
@@ -543,14 +541,12 @@ void MidiPlayer_AmigaMac1::Channel::voiceMapping(byte voices) {
}
void MidiPlayer_AmigaMac1::Channel::assignVoices(byte voices) {
- for (VoiceIt it = _driver._voices.begin(); it != _driver._voices.end(); ++it) {
- Voice *v = *it;
+ for (const auto &voice : _driver._voices) {
+ if (!voice->_channel) {
+ voice->_channel = this;
- if (!v->_channel) {
- v->_channel = this;
-
- if (v->_note != -1)
- v->noteOff();
+ if (voice->_note != -1)
+ voice->noteOff();
if (--voices == 0)
break;
@@ -569,11 +565,9 @@ void MidiPlayer_AmigaMac1::Channel::releaseVoices(byte voices) {
voices -= _extraVoices;
_extraVoices = 0;
- for (VoiceIt it = _driver._voices.begin(); it != _driver._voices.end(); ++it) {
- Voice *v = *it;
-
- if ((v->_channel == this) && (v->_note == -1)) {
- v->_channel = nullptr;
+ for (const auto &voice : _driver._voices) {
+ if ((voice->_channel == this) && (voice->_note == -1)) {
+ voice->_channel = nullptr;
if (--voices == 0)
return;
}
@@ -583,21 +577,19 @@ void MidiPlayer_AmigaMac1::Channel::releaseVoices(byte voices) {
uint16 maxTicks = 0;
Voice *maxTicksVoice = _driver._voices[0];
- for (VoiceIt it = _driver._voices.begin(); it != _driver._voices.end(); ++it) {
- Voice *v = *it;
-
- if (v->_channel == this) {
+ for (const auto &voice : _driver._voices) {
+ if (voice->_channel == this) {
// The original code seems to be broken here. It reads a word value from
// byte array _voiceSustained.
- uint16 ticks = v->_releaseTicks;
+ uint16 ticks = voice->_releaseTicks;
if (ticks > 0)
ticks += 0x8000;
else
- ticks = v->_ticks;
+ ticks = voice->_ticks;
if (ticks >= maxTicks) {
maxTicks = ticks;
- maxTicksVoice = v;
+ maxTicksVoice = voice;
}
}
}
@@ -610,16 +602,14 @@ void MidiPlayer_AmigaMac1::Channel::releaseVoices(byte voices) {
void MidiPlayer_AmigaMac1::distributeVoices() {
int freeVoices = 0;
- for (VoiceIt it = _voices.begin(); it != _voices.end(); ++it)
- if (!(*it)->_channel)
+ for (const auto &voice : _voices)
+ if (!voice->_channel)
freeVoices++;
if (freeVoices == 0)
return;
- for (ChanIt it = _channels.begin(); it != _channels.end(); ++it) {
- Channel *channel = *it;
-
+ for (const auto &channel : _channels) {
if (channel->_extraVoices != 0) {
if (channel->_extraVoices >= freeVoices) {
channel->_extraVoices -= freeVoices;
@@ -652,24 +642,16 @@ void MidiPlayer_AmigaMac1::Voice::noteOn(int8 note, int8 velocity) {
const Instrument *ins = _driver._instruments[patchId];
// Each patch links to one or more waves, where each wave is assigned to a range of notes.
- Common::Array<NoteRange>::const_iterator noteRange;
- for (noteRange = ins->noteRange.begin(); noteRange != ins->noteRange.end(); ++noteRange) {
- if (noteRange->startNote <= note && note <= noteRange->endNote)
- break;
- }
-
- // Abort if this note has no wave assigned to it
- if (noteRange == ins->noteRange.end())
- return;
-
- const Wave *wave = noteRange->wave;
- const uint32 *freqTable = wave->freqTable;
+ for (auto &curNote : ins->noteRange) {
+ if (curNote.startNote <= note && note <= curNote.endNote) {
+ _noteRange = &curNote;
+ _wave = curNote.wave;
+ _freqTable = curNote.wave->freqTable;
- _noteRange = noteRange;
- _wave = wave;
- _freqTable = freqTable;
-
- play(note, velocity);
+ play(note, velocity);
+ return;
+ }
+ }
}
void MidiPlayer_AmigaMac1::Voice::noteOff() {
@@ -771,13 +753,11 @@ void MidiPlayer_AmigaMac1::Channel::noteOn(int8 note, int8 velocity) {
return;
}
- for (VoiceIt it = _driver._voices.begin(); it != _driver._voices.end(); ++it) {
- Voice *v = *it;
-
- if (v->_channel == this && v->_note == note) {
- v->_isSustained = false;
- v->noteOff();
- v->noteOn(note, velocity);
+ for (const auto &voice : _driver._voices) {
+ if (voice->_channel == this && voice->_note == note) {
+ voice->_isSustained = false;
+ voice->noteOff();
+ voice->noteOn(note, velocity);
return;
}
}
@@ -788,15 +768,13 @@ void MidiPlayer_AmigaMac1::Channel::noteOn(int8 note, int8 velocity) {
}
void MidiPlayer_AmigaMac1::Channel::noteOff(int8 note) {
- for (VoiceIt it = _driver._voices.begin(); it != _driver._voices.end(); ++it) {
- Voice *v = *it;
-
- if (v->_channel == this && v->_note == note) {
+ for (const auto &voice : _driver._voices) {
+ if (voice->_channel == this && voice->_note == note) {
if (_hold)
- v->_isSustained = true;
+ voice->_isSustained = true;
else {
- v->_isReleased = true;
- v->_envCntDown = 0;
+ voice->_isReleased = true;
+ voice->_envCntDown = 0;
}
return;
}
@@ -813,12 +791,10 @@ void MidiPlayer_AmigaMac1::Channel::holdPedal(int8 pedal) {
if (pedal != 0)
return;
- for (VoiceIt it = _driver._voices.begin(); it != _driver._voices.end(); ++it) {
- Voice *v = *it;
-
- if (v->_channel == this && v->_isSustained) {
- v->_isSustained = false;
- v->_isReleased = true;
+ for (const auto &voice : _driver._voices) {
+ if (voice->_channel == this && voice->_isSustained) {
+ voice->_isSustained = false;
+ voice->_isReleased = true;
}
}
}
@@ -826,11 +802,9 @@ void MidiPlayer_AmigaMac1::Channel::holdPedal(int8 pedal) {
void MidiPlayer_AmigaMac1::Channel::setPitchWheel(uint16 pitch) {
_pitch = pitch;
- for (VoiceIt it = _driver._voices.begin(); it != _driver._voices.end(); ++it) {
- Voice *v = *it;
-
- if (v->_note != -1 && v->_channel == this)
- v->calcVoiceStep();
+ for (const auto &voice : _driver._voices) {
+ if (voice->_note != -1 && voice->_channel == this)
+ voice->calcVoiceStep();
}
}
@@ -869,11 +843,9 @@ void MidiPlayer_AmigaMac1::send(uint32 b) {
channel->voiceMapping(op2);
break;
case 0x7b:
- for (VoiceIt it = _voices.begin(); it != _voices.end(); ++it) {
- Voice *v = *it;
-
- if (v->_channel == channel && v->_note != -1)
- v->noteOff();
+ for (const auto &voice : _voices) {
+ if (voice->_channel == channel && voice->_note != -1)
+ voice->noteOff();
}
default:
break;
diff --git a/engines/dgds/sound/drivers/midi.cpp b/engines/dgds/sound/drivers/midi.cpp
index 3cb4dadd637..144b2332fe9 100644
--- a/engines/dgds/sound/drivers/midi.cpp
+++ b/engines/dgds/sound/drivers/midi.cpp
@@ -164,10 +164,9 @@ MidiPlayer_Midi::MidiPlayer_Midi() :
MidiPlayer_Midi::~MidiPlayer_Midi() {
delete _driver;
- const Mt32ToGmMapList::iterator end = Mt32dynamicMappings->end();
- for (Mt32ToGmMapList::iterator it = Mt32dynamicMappings->begin(); it != end; ++it) {
- delete[] (*it).name;
- (*it).name = nullptr;
+ for (auto &mapping : *Mt32dynamicMappings) {
+ delete[] mapping.name;
+ mapping.name = nullptr;
}
Mt32dynamicMappings->clear();
@@ -762,10 +761,9 @@ byte MidiPlayer_Midi::lookupGmInstrument(const char *iname) {
int i = 0;
if (Mt32dynamicMappings != nullptr) {
- const Mt32ToGmMapList::iterator end = Mt32dynamicMappings->end();
- for (Mt32ToGmMapList::iterator it = Mt32dynamicMappings->begin(); it != end; ++it) {
- if (scumm_strnicmp(iname, (*it).name, 10) == 0)
- return getGmInstrument((*it));
+ for (const auto &mapping : *Mt32dynamicMappings) {
+ if (scumm_strnicmp(iname, mapping.name, 10) == 0)
+ return getGmInstrument(mapping);
}
}
@@ -782,10 +780,9 @@ byte MidiPlayer_Midi::lookupGmRhythmKey(const char *iname) {
int i = 0;
if (Mt32dynamicMappings != nullptr) {
- const Mt32ToGmMapList::iterator end = Mt32dynamicMappings->end();
- for (Mt32ToGmMapList::iterator it = Mt32dynamicMappings->begin(); it != end; ++it) {
- if (scumm_strnicmp(iname, (*it).name, 10) == 0)
- return (*it).gmRhythmKey;
+ for (const auto &mapping : *Mt32dynamicMappings) {
+ if (scumm_strnicmp(iname, mapping.name, 10) == 0)
+ return mapping.gmRhythmKey;
}
}
diff --git a/engines/dgds/sound/music.cpp b/engines/dgds/sound/music.cpp
index 31be9e9fae9..317a912347a 100644
--- a/engines/dgds/sound/music.cpp
+++ b/engines/dgds/sound/music.cpp
@@ -138,7 +138,6 @@ void SciMusic::miditimerCallback(void *p) {
}
void SciMusic::onTimer() {
- const MusicList::iterator end = _playList.end();
// sending out queued commands that were "sent" via main thread
sendMidiCommandsFromQueue();
@@ -147,8 +146,8 @@ void SciMusic::onTimer() {
remapChannels(false);
_needsRemap = false;
- for (MusicList::iterator i = _playList.begin(); i != end; ++i)
- (*i)->onTimer();
+ for (auto &music : _playList)
+ music->onTimer();
}
void SciMusic::putMidiCommandInQueue(byte status, byte firstOp, byte secondOp) {
@@ -203,7 +202,6 @@ void SciMusic::clearPlayList() {
}
void SciMusic::pauseAll(bool pause) {
- const MusicList::iterator end = _playList.end();
bool alreadyUnpaused = (_globalPause <= 0);
if (pause)
@@ -225,8 +223,8 @@ void SciMusic::pauseAll(bool pause) {
if (alreadyUnpaused && stillUnpaused)
return;
- for (MusicList::iterator i = _playList.begin(); i != end; ++i) {
- soundToggle(*i, pause);
+ for (auto &music : _playList) {
+ soundToggle(music, pause);
}
}
@@ -843,9 +841,7 @@ void SciMusic::printSongInfo(uint32 obj, Console *con) {
const char *musicStatus[] = { "Stopped", "Initialized", "Paused", "Playing" };
- const MusicList::iterator end = _playList.end();
- for (MusicList::iterator i = _playList.begin(); i != end; ++i) {
- MusicEntry *song = *i;
+ for (auto &song : _playList) {
if (song->soundObj == obj) {
debug(1, "Resource id: %d, status: %s\n", song->resourceId, musicStatus[song->status]);
debug(1, "dataInc: %d, hold: %d, loop: %d\n", song->dataInc, song->hold, song->loop);
@@ -1061,10 +1057,8 @@ void SciMusic::remapChannels(bool mainThread) {
}
// Inform MidiParsers of any unmapped channels
- const MusicList::iterator end = _playList.end();
int songIndex = -1;
- for (MusicList::iterator i = _playList.begin(); i != end; ++i) {
- MusicEntry *song = *i;
+ for (auto &song : _playList) {
songIndex++;
if (!song || !song->pMidiParser)
@@ -1116,9 +1110,9 @@ void SciMusic::remapChannels(bool mainThread) {
continue;
songIndex = -1;
- for (MusicList::iterator iter = _playList.begin(); iter != end; ++iter) {
+ for (auto &song : _playList) {
songIndex++;
- if (map->_map[i]._song == *iter)
+ if (map->_map[i]._song == song)
break;
}
@@ -1146,9 +1140,9 @@ void SciMusic::remapChannels(bool mainThread) {
continue;
songIndex = -1;
- for (MusicList::iterator iter = _playList.begin(); iter != end; ++iter) {
+ for (auto &song : _playList) {
songIndex++;
- if (map->_map[i]._song == *iter)
+ if (map->_map[i]._song == song)
break;
}
@@ -1173,9 +1167,9 @@ void SciMusic::remapChannels(bool mainThread) {
continue;
songIndex = -1;
- for (MusicList::iterator iter = _playList.begin(); iter != end; ++iter) {
+ for (auto &song : _playList) {
songIndex++;
- if (map->_map[i]._song == *iter)
+ if (map->_map[i]._song == song)
break;
}
@@ -1223,11 +1217,9 @@ ChannelRemapping *SciMusic::determineChannelMap() {
int8 reverb = _playList.front()->reverb;
_pMidiDrv->setReverb(reverb == 127 ? _globalReverb : reverb);
- MusicList::iterator songIter;
int songIndex = -1;
- for (songIter = _playList.begin(); songIter != _playList.end(); ++songIter) {
+ for (auto &song : _playList) {
songIndex++;
- MusicEntry *song = *songIter;
if (song->status != kSoundPlaying)
continue;
Commit: ce68bcf1c0feda52f321ad5fd581ef560efcde58
https://github.com/scummvm/scummvm/commit/ce68bcf1c0feda52f321ad5fd581ef560efcde58
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
GROOVIE: Use C++ 11 range-based for loops
Changed paths:
engines/groovie/saveload.cpp
diff --git a/engines/groovie/saveload.cpp b/engines/groovie/saveload.cpp
index 66ad2dd344a..d21ac04089d 100644
--- a/engines/groovie/saveload.cpp
+++ b/engines/groovie/saveload.cpp
@@ -60,9 +60,8 @@ SaveStateList SaveLoad::listValidSaves(const Common::String &target) {
sort(savefiles.begin(), savefiles.end());
// Fill the information for the existing savegames
- Common::StringArray::iterator it = savefiles.begin();
- while (it != savefiles.end()) {
- const char *ext = strrchr(it->c_str(), '.');
+ for (auto &savefile : savefiles) {
+ const char *ext = strrchr(savefile.c_str(), '.');
if (!ext)
continue;
@@ -83,7 +82,6 @@ SaveStateList SaveLoad::listValidSaves(const Common::String &target) {
}
list.push_back(descriptor);
}
- it++;
}
if (!hasReserved) {
Commit: 7c22ff1abd75b01d36a98e599df5028300405ca9
https://github.com/scummvm/scummvm/commit/7c22ff1abd75b01d36a98e599df5028300405ca9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
HADESCH: Use C++ 11 range-based for loops
Changed paths:
engines/hadesch/rooms/monster/projectile.cpp
engines/hadesch/video.cpp
diff --git a/engines/hadesch/rooms/monster/projectile.cpp b/engines/hadesch/rooms/monster/projectile.cpp
index 9d786884039..c5f36a87876 100644
--- a/engines/hadesch/rooms/monster/projectile.cpp
+++ b/engines/hadesch/rooms/monster/projectile.cpp
@@ -181,8 +181,8 @@ void Battleground::launchProjectile(int startScale, Common::Point startPoint, in
}
void Battleground::handleAbsoluteClick(Common::Point p) {
- for (Common::Array<Common::SharedPtr<Projectile> >::iterator it = _projectiles.begin(); it != _projectiles.end(); it++) {
- it->operator->()->handleAbsoluteClick(*it, p);
+ for (auto &projectile : _projectiles) {
+ projectile.operator->()->handleAbsoluteClick(projectile, p);
}
}
@@ -229,8 +229,8 @@ void Battleground::stopFight() {
}
void Battleground::stopProjectiles() {
- for (Common::Array<Common::SharedPtr<Projectile> >::iterator it = _projectiles.begin(); it != _projectiles.end(); it++)
- it->operator->()->stop();
+ for (auto &projectile : _projectiles)
+ projectile.operator->()->stop();
}
class HandlerProjectile : public EventHandler {
diff --git a/engines/hadesch/video.cpp b/engines/hadesch/video.cpp
index 42bca6f7298..3ecf523ea5c 100644
--- a/engines/hadesch/video.cpp
+++ b/engines/hadesch/video.cpp
@@ -551,9 +551,9 @@ void VideoRoom::nextFrame(Common::SharedPtr<GfxContext> context, int time, bool
if (stopped) {
g_system->getMixer()->stopHandle(_anims[i]._soundHandle);
if (_anims[i]._keepLastFrame)
- for (Common::SortedArray<Layer>::iterator it = _layers.begin(); it != _layers.end(); it++)
- if (it->name == _anims[i]._animName)
- it->renderable->selectFrame(-1);
+ for (auto &layer : _layers)
+ if (layer.name == _anims[i]._animName)
+ layer.renderable->selectFrame(-1);
}
if ((soundFinished && animFinished && subFinished) || stopped) {
Commit: 79b605cd6c5962981d2faf9bad5ce254bfb03fd7
https://github.com/scummvm/scummvm/commit/79b605cd6c5962981d2faf9bad5ce254bfb03fd7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
DRACI: Use C++ 11 range-based for loops
Changed paths:
engines/draci/animation.cpp
engines/draci/metaengine.cpp
engines/draci/screen.cpp
engines/draci/sound.cpp
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp
index d2938f31168..2dc8e801623 100644
--- a/engines/draci/animation.cpp
+++ b/engines/draci/animation.cpp
@@ -299,14 +299,12 @@ void AnimationManager::pauseAnimations() {
return;
}
- Common::List<Animation *>::iterator it;
-
- for (it = _animations.begin(); it != _animations.end(); ++it) {
- if ((*it)->getID() > 0 || (*it)->getID() == kTitleText) {
+ for (auto &anim : _animations) {
+ if (anim->getID() > 0 || anim->getID() == kTitleText) {
// Clean up the last frame that was drawn before stopping
- (*it)->markDirtyRect(_vm->_screen->getSurface());
+ anim->markDirtyRect(_vm->_screen->getSurface());
- (*it)->setPaused(true);
+ anim->setPaused(true);
}
}
}
@@ -317,24 +315,20 @@ void AnimationManager::unpauseAnimations() {
return;
}
- Common::List<Animation *>::iterator it;
-
- for (it = _animations.begin(); it != _animations.end(); ++it) {
- if ((*it)->isPaused()) {
+ for (auto &anim : _animations) {
+ if (anim->isPaused()) {
// Clean up the last frame that was drawn before stopping
- (*it)->markDirtyRect(_vm->_screen->getSurface());
+ anim->markDirtyRect(_vm->_screen->getSurface());
- (*it)->setPaused(false);
+ anim->setPaused(false);
}
}
}
Animation *AnimationManager::getAnimation(int id) {
- Common::List<Animation *>::iterator it;
-
- for (it = _animations.begin(); it != _animations.end(); ++it) {
- if ((*it)->getID() == id) {
- return *it;
+ for (auto &anim : _animations) {
+ if (anim->getID() == id) {
+ return anim;
}
}
@@ -361,15 +355,13 @@ void AnimationManager::drawScene(Surface *surf) {
sortAnimations();
- Common::List<Animation *>::iterator it;
-
- for (it = _animations.begin(); it != _animations.end(); ++it) {
- if (! ((*it)->isPlaying()) ) {
+ for (auto &anim : _animations) {
+ if (!(anim->isPlaying())) {
continue;
}
- (*it)->nextFrame(false);
- (*it)->drawFrame(surf);
+ anim->nextFrame(false);
+ anim->drawFrame(surf);
}
}
@@ -463,10 +455,8 @@ void AnimationManager::deleteOverlays() {
void AnimationManager::deleteAll() {
debugC(3, kDraciAnimationDebugLevel, "Deleting all animations...");
- Common::List<Animation *>::iterator it;
-
- for (it = _animations.begin(); it != _animations.end(); ++it) {
- delete *it;
+ for (auto &anim : _animations) {
+ delete anim;
}
_animations.clear();
diff --git a/engines/draci/metaengine.cpp b/engines/draci/metaengine.cpp
index 6c5a266c597..60d7c3c27aa 100644
--- a/engines/draci/metaengine.cpp
+++ b/engines/draci/metaengine.cpp
@@ -61,18 +61,16 @@ bool DraciMetaEngine::hasFeature(MetaEngineFeature f) const {
SaveStateList DraciMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::StringArray filenames;
Common::String pattern("draci.s##");
-
- filenames = saveFileMan->listSavefiles(pattern);
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &filename : filenames) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 2);
+ int slotNum = atoi(filename.c_str() + filename.size() - 2);
if (slotNum >= 0 && slotNum <= 99) {
- Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename);
if (in) {
Draci::DraciSavegameHeader header;
if (Draci::readSavegameHeader(in, header)) {
diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp
index 554b7087ca6..ed21b36ffbe 100644
--- a/engines/draci/screen.cpp
+++ b/engines/draci/screen.cpp
@@ -105,7 +105,6 @@ int Screen::interpolate(int first, int second, int index, int number) {
*/
void Screen::copyToScreen() {
const Common::List<Common::Rect> *dirtyRects = _surface->getDirtyRects();
- Common::List<Common::Rect>::const_iterator it;
// If a full update is needed, update the whole screen
if (_surface->needsFullUpdate()) {
@@ -116,13 +115,12 @@ void Screen::copyToScreen() {
} else {
// Otherwise, update only the dirty rectangles
- for (it = dirtyRects->begin(); it != dirtyRects->end(); ++it) {
-
+ for (const auto &r : *dirtyRects) {
// Pointer to the upper left corner of the rectangle
- byte *ptr = (byte *)_surface->getBasePtr(it->left, it->top);
+ byte *ptr = (byte *)_surface->getBasePtr(r.left, r.top);
_vm->_system->copyRectToScreen(ptr, kScreenWidth,
- it->left, it->top, it->width(), it->height());
+ r.left, r.top, r.width(), r.height());
}
}
diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp
index ffb300cf119..6a3c79450fb 100644
--- a/engines/draci/sound.cpp
+++ b/engines/draci/sound.cpp
@@ -206,8 +206,8 @@ void ZipSoundArchive::openArchive(const char *path, const char *extension, Sound
// The sample files are in the form ####.mp3 but not all numbers are used so we need to
// iterate the archive and find the last file
- for (Common::ArchiveMemberList::iterator iter = files.begin(); iter != files.end(); iter++) {
- Common::String filename = (*iter)->getName();
+ for (auto &file : files) {
+ Common::String filename = file->getName();
filename.erase(filename.size() - 4); // remove .mp3 extension
uint file_number = atoi(filename.c_str());
if(file_number > _sampleCount) // finds the last file (numerically)
@@ -232,8 +232,8 @@ void ZipSoundArchive::clearCache() {
// Just deallocate the link-list of (very short) headers for each
// dubbed sentence played in the current location. If the callers have
// not called .close() on any of the items, call them now.
- for (Common::List<SoundSample>::iterator it = _cache.begin(); it != _cache.end(); ++it) {
- it->close();
+ for (auto &sample : _cache) {
+ sample.close();
}
_cache.clear();
}
Commit: 760511ca70293407d333c563907bad1e7840ba4f
https://github.com/scummvm/scummvm/commit/760511ca70293407d333c563907bad1e7840ba4f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
AGI: Use C++ 11 range-based for loops
Changed paths:
engines/agi/detection.cpp
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index 23b6ead8fba..da2b6b37c91 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -158,15 +158,15 @@ ADDetectedGame AgiMetaEngineDetection::fallbackDetect(const FileMap &allFilesXXX
g_fallbackDesc.version = 0x2917;
// First grab all filenames and at the same time count the number of *.wag files
- for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- if (file->isDirectory()) continue;
- Common::String filename = file->getName();
+ for (auto &file : fslist) {
+ if (file.isDirectory()) continue;
+ Common::String filename = file.getName();
filename.toLowercase();
allFiles[filename] = true; // Save the filename in a hash table
if (filename.hasSuffix(".wag")) {
// Save latest found *.wag file's path (Can be used to open the file, the name can't)
- wagFileNode = *file;
+ wagFileNode = file;
wagFileCount++; // Count found *.wag files
}
}
@@ -199,10 +199,10 @@ ADDetectedGame AgiMetaEngineDetection::fallbackDetect(const FileMap &allFilesXXX
} else { // Try v3
char name[8];
- for (IntMap::const_iterator f = allFiles.begin(); f != allFiles.end(); ++f) {
- if (f->_key.hasSuffix("vol.0")) {
+ for (auto &f : allFiles) {
+ if (f._key.hasSuffix("vol.0")) {
memset(name, 0, 8);
- strncpy(name, f->_key.c_str(), MIN((uint)8, f->_key.size() > 5 ? f->_key.size() - 5 : f->_key.size()));
+ strncpy(name, f._key.c_str(), MIN((uint)8, f._key.size() > 5 ? f._key.size() - 5 : f._key.size()));
if (allFiles.contains("object") && allFiles.contains("words.tok") &&
allFiles.contains(Common::String(name) + "dir")) {
@@ -346,11 +346,11 @@ void AgiMetaEngineDetection::getPotentialDiskImages(
Common::Array<Common::Path> &imageFiles) {
// build an array of files with disk image extensions
- for (FileMap::const_iterator f = allFiles.begin(); f != allFiles.end(); ++f) {
+ for (auto &f : allFiles) {
for (size_t i = 0; i < imageExtensionCount; i++) {
- if (f->_key.baseName().hasSuffixIgnoreCase(imageExtensions[i])) {
- debug(3, "potential disk image: %s", f->_key.baseName().c_str());
- imageFiles.push_back(f->_key);
+ if (f._key.baseName().hasSuffixIgnoreCase(imageExtensions[i])) {
+ debug(3, "potential disk image: %s", f._key.baseName().c_str());
+ imageFiles.push_back(f._key);
break;
}
}
Commit: c78ead8ce3234624c1e296a4643e9ae1ea943562
https://github.com/scummvm/scummvm/commit/c78ead8ce3234624c1e296a4643e9ae1ea943562
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
DRAGONS: Use C++ 11 range-based for loops
Changed paths:
engines/dragons/actor.cpp
engines/dragons/actor.h
engines/dragons/metaengine.cpp
engines/dragons/talk.cpp
diff --git a/engines/dragons/actor.cpp b/engines/dragons/actor.cpp
index c9a3f949f10..664d25ae4ef 100644
--- a/engines/dragons/actor.cpp
+++ b/engines/dragons/actor.cpp
@@ -64,12 +64,14 @@ Actor *ActorManager::loadActor(uint32 resourceId, uint32 sequenceId, int16 x, in
Actor *ActorManager::findFreeActor(int16 resourceId) {
int i = 0;
- for (ActorsIterator it = _actors.begin(); it != _actors.end() && i < 23; ++it, i++) {
- Actor *actor = it;
- if (!(actor->_flags & ACTOR_FLAG_40)) {
- actor->_resourceID = resourceId;
- actor->_walkSpeed = 0x100000;
- return actor;
+ for (auto &actor : _actors) {
+ if (i++ >= 23)
+ break;
+
+ if (!(actor._flags & ACTOR_FLAG_40)) {
+ actor._resourceID = resourceId;
+ actor._walkSpeed = 0x100000;
+ return &actor;
}
}
return nullptr;
diff --git a/engines/dragons/actor.h b/engines/dragons/actor.h
index ecdddd3884f..73c4b141cca 100644
--- a/engines/dragons/actor.h
+++ b/engines/dragons/actor.h
@@ -59,7 +59,6 @@ enum ActorFrameFlags {
class ActorManager {
public:
typedef Common::Array<Actor> Actors;
- typedef Actors::iterator ActorsIterator;
private:
ActorResourceLoader *_actorResourceLoader;
diff --git a/engines/dragons/metaengine.cpp b/engines/dragons/metaengine.cpp
index 73c8c5e3323..b8b83549001 100644
--- a/engines/dragons/metaengine.cpp
+++ b/engines/dragons/metaengine.cpp
@@ -70,14 +70,14 @@ SaveStateList DragonsMetaEngine::listSaves(const char *target) const {
Dragons::SaveHeader header;
Common::String pattern = target;
pattern += ".###";
- Common::StringArray filenames;
- filenames = saveFileMan->listSavefiles(pattern.c_str());
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern.c_str());
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+
+ for (auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename.c_str());
if (in) {
if (Dragons::DragonsEngine::readSaveHeader(in, header) == Dragons::kRSHENoError) {
saveList.push_back(SaveStateDescriptor(this, slotNum, header.description));
diff --git a/engines/dragons/talk.cpp b/engines/dragons/talk.cpp
index 9e703295018..ab0364851ee 100644
--- a/engines/dragons/talk.cpp
+++ b/engines/dragons/talk.cpp
@@ -567,9 +567,9 @@ bool Talk::talkToActor(ScriptOpCall &scriptOpCall) {
return false;
}
- for (Common::Array<TalkDialogEntry*>::iterator it = _dialogEntries.begin(); it != _dialogEntries.end(); it++) {
+ for (auto ¤tEntry : _dialogEntries) {
TalkDialogEntry *entry = (TalkDialogEntry *)malloc(sizeof(TalkDialogEntry));
- memcpy(entry, *it, sizeof(TalkDialogEntry));
+ memcpy(entry, currentEntry, sizeof(TalkDialogEntry));
dialogEntries.push_back(entry);
}
@@ -577,8 +577,8 @@ bool Talk::talkToActor(ScriptOpCall &scriptOpCall) {
do {
_vm->clearAllText();
int numActiveDialogEntries = 0;
- for (Common::Array<TalkDialogEntry*>::iterator it = dialogEntries.begin(); it != dialogEntries.end(); it++) {
- if (!((*it)->flags & 1)) {
+ for (auto ¤tEntry : dialogEntries) {
+ if (!(currentEntry->flags & 1)) {
numActiveDialogEntries++;
}
}
@@ -852,8 +852,8 @@ void Talk::exitTalkMenu(bool isFlag8Set, bool isFlag100Set, Common::Array<TalkDi
_vm->setFlags(ENGINE_FLAG_100);
}
- for (Common::Array<TalkDialogEntry*>::iterator it = dialogEntries.begin(); it != dialogEntries.end(); it++) {
- delete *it;
+ for (auto &entry : dialogEntries) {
+ delete entry;
}
dialogEntries.clear();
_vm->_fontManager->clearText();
@@ -1119,8 +1119,8 @@ uint32 Talk::truncateDialogText(uint16 *srcText, uint16 *destText, uint32 srcLen
}
void Talk::clearDialogEntries() {
- for (Common::Array<TalkDialogEntry*>::iterator it = _dialogEntries.begin(); it != _dialogEntries.end(); it++) {
- delete *it;
+ for (auto &entry : _dialogEntries) {
+ delete entry;
}
_dialogEntries.clear();
}
Commit: 62dc9dcd8f5efb546ba3a470e4d0b30be1015b97
https://github.com/scummvm/scummvm/commit/62dc9dcd8f5efb546ba3a470e4d0b30be1015b97
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
VOYEUR: Use C++ 11 range-based for loops
Changed paths:
engines/voyeur/animation.cpp
engines/voyeur/events.cpp
engines/voyeur/metaengine.cpp
diff --git a/engines/voyeur/animation.cpp b/engines/voyeur/animation.cpp
index 96587d31946..6514d4c5e3f 100644
--- a/engines/voyeur/animation.cpp
+++ b/engines/voyeur/animation.cpp
@@ -310,10 +310,10 @@ const Graphics::Surface *RL2Decoder::RL2VideoTrack::decodeNextFrame() {
}
void RL2Decoder::RL2VideoTrack::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) {
- for (Common::List<Common::Rect>::const_iterator it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
- for (int y = (*it).top; y < (*it).bottom; ++y) {
- const int x = (*it).left;
- memcpy(dst + y * pitch + x, (byte *)_surface->getPixels() + y * getWidth() + x, (*it).right - x);
+ for (const auto &r : _dirtyRects) {
+ for (int y = r.top; y < r.bottom; ++y) {
+ const int x = r.left;
+ memcpy(dst + y * pitch + x, (byte *)_surface->getPixels() + y * getWidth() + x, r.right - x);
}
}
diff --git a/engines/voyeur/events.cpp b/engines/voyeur/events.cpp
index 877314ef967..3df6792e25d 100644
--- a/engines/voyeur/events.cpp
+++ b/engines/voyeur/events.cpp
@@ -184,20 +184,17 @@ void EventsManager::voyeurTimer() {
videoTimer();
// Iterate through the list of registered nodes
- Common::List<IntNode *>::iterator i;
- for (i = _intNodes.begin(); i != _intNodes.end(); ++i) {
- IntNode &node = **i;
-
- if (node._flags & 1)
+ for (auto &node : _intNodes) {
+ if (node->_flags & 1)
continue;
- if (!(node._flags & 2)) {
- if (--node._curTime != 0)
+ if (!(node->_flags & 2)) {
+ if (--node->_curTime != 0)
continue;
- node._curTime = node._timeReset;
+ node->_curTime = node->_timeReset;
}
- (this->*node._intFunc)();
+ (this->*node->_intFunc)();
}
}
diff --git a/engines/voyeur/metaengine.cpp b/engines/voyeur/metaengine.cpp
index 293085e53c7..0351dddfa6f 100644
--- a/engines/voyeur/metaengine.cpp
+++ b/engines/voyeur/metaengine.cpp
@@ -112,21 +112,19 @@ Common::Error VoyeurMetaEngine::createInstance(OSystem *syst, Engine **engine, c
SaveStateList VoyeurMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::StringArray filenames;
Common::String saveDesc;
Common::String pattern = Common::String::format("%s.0##", target);
-
- filenames = saveFileMan->listSavefiles(pattern);
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
Voyeur::VoyeurSavegameHeader header;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
- const char *ext = strrchr(file->c_str(), '.');
+ for (auto &filename : filenames) {
+ const char *ext = strrchr(filename.c_str(), '.');
int slot = ext ? atoi(ext + 1) : -1;
if (slot >= 0 && slot <= MAX_SAVES) {
- Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename);
if (in) {
if (header.read(in)) {
Commit: bc064d97d1792212e83da6b56305565cb1d825b6
https://github.com/scummvm/scummvm/commit/bc064d97d1792212e83da6b56305565cb1d825b6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
AGI: Const correctness
Changed paths:
engines/agi/detection.cpp
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index da2b6b37c91..2b7e52ca927 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -158,7 +158,7 @@ ADDetectedGame AgiMetaEngineDetection::fallbackDetect(const FileMap &allFilesXXX
g_fallbackDesc.version = 0x2917;
// First grab all filenames and at the same time count the number of *.wag files
- for (auto &file : fslist) {
+ for (const auto &file : fslist) {
if (file.isDirectory()) continue;
Common::String filename = file.getName();
filename.toLowercase();
@@ -199,7 +199,7 @@ ADDetectedGame AgiMetaEngineDetection::fallbackDetect(const FileMap &allFilesXXX
} else { // Try v3
char name[8];
- for (auto &f : allFiles) {
+ for (const auto &f : allFiles) {
if (f._key.hasSuffix("vol.0")) {
memset(name, 0, 8);
strncpy(name, f._key.c_str(), MIN((uint)8, f._key.size() > 5 ? f._key.size() - 5 : f._key.size()));
@@ -346,7 +346,7 @@ void AgiMetaEngineDetection::getPotentialDiskImages(
Common::Array<Common::Path> &imageFiles) {
// build an array of files with disk image extensions
- for (auto &f : allFiles) {
+ for (const auto &f : allFiles) {
for (size_t i = 0; i < imageExtensionCount; i++) {
if (f._key.baseName().hasSuffixIgnoreCase(imageExtensions[i])) {
debug(3, "potential disk image: %s", f._key.baseName().c_str());
Commit: 83ced4731cf43a209e2c8322b50c68f11e6506b1
https://github.com/scummvm/scummvm/commit/83ced4731cf43a209e2c8322b50c68f11e6506b1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
DRAGONS: Const correctness
Changed paths:
engines/dragons/metaengine.cpp
diff --git a/engines/dragons/metaengine.cpp b/engines/dragons/metaengine.cpp
index b8b83549001..896c87e48eb 100644
--- a/engines/dragons/metaengine.cpp
+++ b/engines/dragons/metaengine.cpp
@@ -73,7 +73,7 @@ SaveStateList DragonsMetaEngine::listSaves(const char *target) const {
Common::StringArray filenames = saveFileMan->listSavefiles(pattern.c_str());
SaveStateList saveList;
- for (auto &filename : filenames) {
+ for (const auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
Commit: dbde06960c2750f3ce9b171d9d6ac42af4bab2ad
https://github.com/scummvm/scummvm/commit/dbde06960c2750f3ce9b171d9d6ac42af4bab2ad
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
VOYEUR: Const correctness
Changed paths:
engines/voyeur/metaengine.cpp
diff --git a/engines/voyeur/metaengine.cpp b/engines/voyeur/metaengine.cpp
index 0351dddfa6f..f72f669314c 100644
--- a/engines/voyeur/metaengine.cpp
+++ b/engines/voyeur/metaengine.cpp
@@ -119,7 +119,7 @@ SaveStateList VoyeurMetaEngine::listSaves(const char *target) const {
SaveStateList saveList;
Voyeur::VoyeurSavegameHeader header;
- for (auto &filename : filenames) {
+ for (const auto &filename : filenames) {
const char *ext = strrchr(filename.c_str(), '.');
int slot = ext ? atoi(ext + 1) : -1;
Commit: 2eeeabaddaca0be4efb9002acc9f43f184ee6f9c
https://github.com/scummvm/scummvm/commit/2eeeabaddaca0be4efb9002acc9f43f184ee6f9c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
DRASCULA: Use C++ 11 range-based for loops
Changed paths:
engines/drascula/metaengine.cpp
engines/drascula/saveload.cpp
diff --git a/engines/drascula/metaengine.cpp b/engines/drascula/metaengine.cpp
index 69ba250358b..5f9e8581807 100644
--- a/engines/drascula/metaengine.cpp
+++ b/engines/drascula/metaengine.cpp
@@ -107,20 +107,19 @@ bool DrasculaMetaEngine::hasFeature(MetaEngineFeature f) const {
SaveStateList DrasculaMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::StringArray filenames;
Common::String pattern = target;
pattern += ".###";
- filenames = saveFileMan->listSavefiles(pattern);
-
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
int slotNum = 0;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+
+ for (auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- slotNum = atoi(file->c_str() + file->size() - 3);
+ slotNum = atoi(filename.c_str() + filename.size() - 3);
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
- Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename);
if (in) {
SaveStateDescriptor desc = loadMetaData(in, slotNum, false);
if (desc.getSaveSlot() != slotNum) {
diff --git a/engines/drascula/saveload.cpp b/engines/drascula/saveload.cpp
index 8dcf29db76c..ab44e3ce1a7 100644
--- a/engines/drascula/saveload.cpp
+++ b/engines/drascula/saveload.cpp
@@ -58,9 +58,10 @@ void DrasculaEngine::checkForOldSaveGames() {
// Get list of savefiles for target game
Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
Common::Array<int> slots;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+
+ for (auto &filename : filenames) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 2);
+ int slotNum = atoi(filename.c_str() + filename.size() - 2);
// Ensure save slot is within valid range
if (slotNum >= 1 && slotNum <= 10) {
Commit: 8a062f471d196d380c99b00f4ed46a71c2868d4a
https://github.com/scummvm/scummvm/commit/8a062f471d196d380c99b00f4ed46a71c2868d4a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
CINE: Use C++ 11 range-based for loops
Changed paths:
engines/cine/gfx.cpp
engines/cine/main_loop.cpp
engines/cine/metaengine.cpp
engines/cine/object.cpp
engines/cine/saveload.cpp
engines/cine/script_fw.cpp
engines/cine/script_os.cpp
engines/cine/various.cpp
diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp
index 794b109a753..51d0b8dde6d 100644
--- a/engines/cine/gfx.cpp
+++ b/engines/cine/gfx.cpp
@@ -2232,7 +2232,6 @@ void drawSpriteRaw2(const byte *spritePtr, byte transColor, int16 width, int16 h
void maskBgOverlay(int targetBgIdx, const byte *bgPtr, const byte *maskPtr, int16 width, int16 height,
byte *page, int16 x, int16 y) {
int16 i, j, tmpWidth, tmpHeight;
- Common::List<BGIncrust>::iterator it;
const byte *backup = maskPtr;
// background pass
@@ -2259,25 +2258,25 @@ void maskBgOverlay(int targetBgIdx, const byte *bgPtr, const byte *maskPtr, int1
maskPtr = backup;
// incrust pass
- for (it = g_cine->_bgIncrustList.begin(); it != g_cine->_bgIncrustList.end(); ++it) {
+ for (auto &incrust : g_cine->_bgIncrustList) {
// HACK: Remove drawing of red corners around doors in rat maze in Operation Stealth
// by skipping drawing of possible collision table data to non-collision table page.
- if (hacksEnabled && it->bgIdx == kCollisionPageBgIdxAlias && targetBgIdx != kCollisionPageBgIdxAlias) {
+ if (hacksEnabled && incrust.bgIdx == kCollisionPageBgIdxAlias && targetBgIdx != kCollisionPageBgIdxAlias) {
continue;
}
- tmpWidth = g_cine->_animDataTable[it->frame]._realWidth;
- tmpHeight = g_cine->_animDataTable[it->frame]._height;
+ tmpWidth = g_cine->_animDataTable[incrust.frame]._realWidth;
+ tmpHeight = g_cine->_animDataTable[incrust.frame]._height;
byte *mask = (byte *)malloc(tmpWidth * tmpHeight);
- if (it->param == 0) {
- generateMask(g_cine->_animDataTable[it->frame].data(), mask, tmpWidth * tmpHeight, it->part);
- gfxUpdateIncrustMask(mask, it->x, it->y, tmpWidth, tmpHeight, maskPtr, x, y, width, height);
- gfxDrawMaskedSprite(g_cine->_animDataTable[it->frame].data(), mask, tmpWidth, tmpHeight, page, it->x, it->y);
+ if (incrust.param == 0) {
+ generateMask(g_cine->_animDataTable[incrust.frame].data(), mask, tmpWidth * tmpHeight, incrust.part);
+ gfxUpdateIncrustMask(mask, incrust.x, incrust.y, tmpWidth, tmpHeight, maskPtr, x, y, width, height);
+ gfxDrawMaskedSprite(g_cine->_animDataTable[incrust.frame].data(), mask, tmpWidth, tmpHeight, page, incrust.x, incrust.y);
} else {
- memcpy(mask, g_cine->_animDataTable[it->frame].data(), tmpWidth * tmpHeight);
- gfxUpdateIncrustMask(mask, it->x, it->y, tmpWidth, tmpHeight, maskPtr, x, y, width, height);
- gfxFillSprite(mask, tmpWidth, tmpHeight, page, it->x, it->y);
+ memcpy(mask, g_cine->_animDataTable[incrust.frame].data(), tmpWidth * tmpHeight);
+ gfxUpdateIncrustMask(mask, incrust.x, incrust.y, tmpWidth, tmpHeight, maskPtr, x, y, width, height);
+ gfxFillSprite(mask, tmpWidth, tmpHeight, page, incrust.x, incrust.y);
}
free(mask);
diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp
index 4aa27479703..9a9561e6338 100644
--- a/engines/cine/main_loop.cpp
+++ b/engines/cine/main_loop.cpp
@@ -266,8 +266,8 @@ void manageEvents(CallSource callSource, EventTarget eventTarget, bool useMaxMou
}
}
mousePos = g_system->getEventManager()->getMousePos();
- for (Common::Array<Common::Rect>::iterator it = rects.begin(); it != rects.end(); ++it) {
- if (it->contains(mousePos)) {
+ for (auto &r : rects) {
+ if (r.contains(mousePos)) {
foundTarget = true;
break;
}
diff --git a/engines/cine/metaengine.cpp b/engines/cine/metaengine.cpp
index 17083cf72c3..07af26ef951 100644
--- a/engines/cine/metaengine.cpp
+++ b/engines/cine/metaengine.cpp
@@ -124,12 +124,11 @@ SaveStateList CineMetaEngine::listSaves(const char *target) const {
Common::String pattern;
- Common::StringArray::const_iterator file;
-
Common::String filename = target;
filename += ".dir";
Common::InSaveFile *in = saveFileMan->openForLoading(filename);
bool foundAutosave = false;
+
if (in) {
typedef char CommandeType[SAVEGAME_NAME_LEN];
CommandeType saveNames[MAX_SAVEGAMES];
@@ -146,9 +145,9 @@ SaveStateList CineMetaEngine::listSaves(const char *target) const {
pattern += ".#*";
Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
- for (file = filenames.begin(); file != filenames.end(); ++file) {
+ for (const auto &file : filenames) {
// Obtain the extension part of the filename, since it corresponds to the save slot number
- Common::String ext = Common::lastPathComponent(*file, '.');
+ Common::String ext = Common::lastPathComponent(file, '.');
int slotNum = (int)ext.asUint64();
if (ext.equals(Common::String::format("%d", slotNum)) &&
diff --git a/engines/cine/object.cpp b/engines/cine/object.cpp
index 646ab89993b..ab972e9e5d2 100644
--- a/engines/cine/object.cpp
+++ b/engines/cine/object.cpp
@@ -33,8 +33,8 @@ namespace Cine {
/** Resets all elements in the object table. */
void resetObjectTable() {
- for (Common::Array<ObjectStruct>::iterator it = g_cine->_objectTable.begin(); it != g_cine->_objectTable.end(); ++it) {
- it->clear();
+ for (auto &obj : g_cine->_objectTable) {
+ obj.clear();
}
}
diff --git a/engines/cine/saveload.cpp b/engines/cine/saveload.cpp
index 2cde68b496d..39f15834465 100644
--- a/engines/cine/saveload.cpp
+++ b/engines/cine/saveload.cpp
@@ -393,54 +393,49 @@ void saveScreenParams(Common::OutSaveFile &out) {
}
void saveGlobalScripts(Common::OutSaveFile &out) {
- ScriptList::const_iterator it;
out.writeUint16BE(g_cine->_globalScripts.size());
- for (it = g_cine->_globalScripts.begin(); it != g_cine->_globalScripts.end(); ++it) {
- (*it)->save(out);
+ for (const auto &script : g_cine->_globalScripts) {
+ script->save(out);
}
}
void saveObjectScripts(Common::OutSaveFile &out) {
- ScriptList::const_iterator it;
out.writeUint16BE(g_cine->_objectScripts.size());
- for (it = g_cine->_objectScripts.begin(); it != g_cine->_objectScripts.end(); ++it) {
- (*it)->save(out);
+ for (const auto &script : g_cine->_objectScripts) {
+ script->save(out);
}
}
void saveOverlayList(Common::OutSaveFile &out) {
- Common::List<overlay>::const_iterator it;
-
out.writeUint16BE(g_cine->_overlayList.size());
- for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) {
+ for (const auto &ov : g_cine->_overlayList) {
out.writeUint32BE(0); // next
out.writeUint32BE(0); // previous?
- out.writeUint16BE(it->objIdx);
- out.writeUint16BE(it->type);
- out.writeSint16BE(it->x);
- out.writeSint16BE(it->y);
- out.writeSint16BE(it->width);
- out.writeSint16BE(it->color);
+ out.writeUint16BE(ov.objIdx);
+ out.writeUint16BE(ov.type);
+ out.writeSint16BE(ov.x);
+ out.writeSint16BE(ov.y);
+ out.writeSint16BE(ov.width);
+ out.writeSint16BE(ov.color);
}
}
void saveBgIncrustList(Common::OutSaveFile &out) {
- Common::List<BGIncrust>::const_iterator it;
out.writeUint16BE(g_cine->_bgIncrustList.size());
- for (it = g_cine->_bgIncrustList.begin(); it != g_cine->_bgIncrustList.end(); ++it) {
+ for (const auto &inc : g_cine->_bgIncrustList) {
out.writeUint32BE(0); // next
out.writeUint32BE(0); // previous?
- out.writeUint16BE(it->objIdx);
- out.writeUint16BE(it->param);
- out.writeUint16BE(it->x);
- out.writeUint16BE(it->y);
- out.writeUint16BE(it->frame);
- out.writeUint16BE(it->part);
+ out.writeUint16BE(inc.objIdx);
+ out.writeUint16BE(inc.param);
+ out.writeUint16BE(inc.x);
+ out.writeUint16BE(inc.y);
+ out.writeUint16BE(inc.frame);
+ out.writeUint16BE(inc.part);
if (g_cine->getGameType() == Cine::GType_OS) {
- out.writeUint16BE(it->bgIdx);
+ out.writeUint16BE(inc.bgIdx);
}
}
}
@@ -452,24 +447,23 @@ void saveZoneQuery(Common::OutSaveFile &out) {
}
void saveSeqList(Common::OutSaveFile &out) {
- Common::List<SeqListElement>::const_iterator it;
out.writeUint16BE(g_cine->_seqList.size());
- for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) {
- out.writeSint16BE(it->var4);
- out.writeUint16BE(it->objIdx);
- out.writeSint16BE(it->var8);
- out.writeSint16BE(it->frame);
- out.writeSint16BE(it->varC);
- out.writeSint16BE(it->varE);
- out.writeSint16BE(it->var10);
- out.writeSint16BE(it->var12);
- out.writeSint16BE(it->var14);
- out.writeSint16BE(it->var16);
- out.writeSint16BE(it->var18);
- out.writeSint16BE(it->var1A);
- out.writeSint16BE(it->var1C);
- out.writeSint16BE(it->var1E);
+ for (const auto &seq : g_cine->_seqList) {
+ out.writeSint16BE(seq.var4);
+ out.writeUint16BE(seq.objIdx);
+ out.writeSint16BE(seq.var8);
+ out.writeSint16BE(seq.frame);
+ out.writeSint16BE(seq.varC);
+ out.writeSint16BE(seq.varE);
+ out.writeSint16BE(seq.var10);
+ out.writeSint16BE(seq.var12);
+ out.writeSint16BE(seq.var14);
+ out.writeSint16BE(seq.var16);
+ out.writeSint16BE(seq.var18);
+ out.writeSint16BE(seq.var1A);
+ out.writeSint16BE(seq.var1C);
+ out.writeSint16BE(seq.var1E);
}
}
diff --git a/engines/cine/script_fw.cpp b/engines/cine/script_fw.cpp
index 9d85c4bb7ad..88e35572388 100644
--- a/engines/cine/script_fw.cpp
+++ b/engines/cine/script_fw.cpp
@@ -1353,11 +1353,9 @@ int FWScript::o1_endGlobalScript() {
debugC(5, kCineDebugScript, "Line: %d: stopGlobalScript(%d)", _line, scriptIdx);
- ScriptList::iterator it = g_cine->_globalScripts.begin();
-
- for (; it != g_cine->_globalScripts.end(); ++it) {
- if ((*it)->_index == scriptIdx) {
- (*it)->_index = -1;
+ for (auto &script : g_cine->_globalScripts) {
+ if (script->_index == scriptIdx) {
+ script->_index = -1;
}
}
diff --git a/engines/cine/script_os.cpp b/engines/cine/script_os.cpp
index 4ea3c7cf4e3..d2bfb4f5ca1 100644
--- a/engines/cine/script_os.cpp
+++ b/engines/cine/script_os.cpp
@@ -635,11 +635,10 @@ int FWScript::o2_stopObjectScript() {
byte param = getNextByte();
debugC(5, kCineDebugScript, "Line: %d: stopObjectScript(%d)", _line, param);
- ScriptList::iterator it = g_cine->_objectScripts.begin();
- for (; it != g_cine->_objectScripts.end(); ++it) {
- if ((*it)->_index == param) {
- (*it)->_index = -1;
+ for (auto &script : g_cine->_objectScripts) {
+ if (script->_index == param) {
+ script->_index = -1;
}
}
return 0;
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index 661d6ef6fc8..3d072700c91 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -1538,11 +1538,9 @@ void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 par
}
void removeSeq(uint16 param1, uint16 param2, uint16 param3) {
- Common::List<SeqListElement>::iterator it;
-
- for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) {
- if (it->objIdx == param1 && it->var4 == param2 && it->varE == param3) {
- it->var4 = -1;
+ for (auto &seq : g_cine->_seqList) {
+ if (seq.objIdx == param1 && seq.var4 == param2 && seq.varE == param3) {
+ seq.var4 = -1;
break;
}
}
@@ -1550,14 +1548,12 @@ void removeSeq(uint16 param1, uint16 param2, uint16 param3) {
// Checked against Operation Stealth 16 color DOS disassembly, should be correct.
bool isSeqRunning(uint16 param1, uint16 param2, uint16 param3) {
- Common::List<SeqListElement>::iterator it;
-
- for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) {
- if (it->objIdx == param1 && it->var4 == param2 && it->varE == param3) {
+ for (auto &seq : g_cine->_seqList) {
+ if (seq.objIdx == param1 && seq.var4 == param2 && seq.varE == param3) {
// Just to be on the safe side there's a restriction of the
// addition's result to 16-bit arithmetic here like in the
// original. It's possible that it's not strictly needed.
- return ((it->var14 + it->var16) & 0xFFFF) == 0;
+ return ((seq.var14 + seq.var16) & 0xFFFF) == 0;
}
}
@@ -1591,12 +1587,12 @@ void addSeqListElement(uint16 objIdx, int16 param1, int16 param2, int16 frame, i
void modifySeqListElement(uint16 objIdx, int16 var4Test, int16 param1, int16 param2, int16 param3, int16 param4) {
// Find a suitable list element and modify it
- for (Common::List<SeqListElement>::iterator it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) {
- if (it->objIdx == objIdx && it->var4 == var4Test) {
- it->varC = param1;
- it->var18 = param2;
- it->var1A = param3;
- it->var10 = it->var12 = param4;
+ for (auto &seq : g_cine->_seqList) {
+ if (seq.objIdx == objIdx && seq.var4 == var4Test) {
+ seq.varC = param1;
+ seq.var18 = param2;
+ seq.var1A = param3;
+ seq.var10 = seq.var12 = param4;
break;
}
}
@@ -1874,14 +1870,12 @@ void processSeqListElement(SeqListElement &element) {
}
void processSeqList() {
- Common::List<SeqListElement>::iterator it;
-
- for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) {
- if (it->var4 == -1) {
+ for (auto &seq : g_cine->_seqList) {
+ if (seq.var4 == -1) {
continue;
}
- processSeqListElement(*it);
+ processSeqListElement(seq);
}
}
Commit: 5dc28a9d43d56eeb9a448d56251630dc3a49c251
https://github.com/scummvm/scummvm/commit/5dc28a9d43d56eeb9a448d56251630dc3a49c251
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
DREAMWEB: Use C++ 11 range-based for loops
Changed paths:
engines/dreamweb/rain.cpp
engines/dreamweb/rnca_archive.cpp
engines/dreamweb/saveload.cpp
engines/dreamweb/sprite.cpp
engines/dreamweb/stubs.cpp
diff --git a/engines/dreamweb/rain.cpp b/engines/dreamweb/rain.cpp
index 1efd8920557..9e6361003a3 100644
--- a/engines/dreamweb/rain.cpp
+++ b/engines/dreamweb/rain.cpp
@@ -25,16 +25,13 @@
namespace DreamWeb {
void DreamWebEngine::showRain() {
- Common::List<Rain>::iterator i;
-
// Do nothing if there's no rain at all
if (_rainList.empty())
return;
const uint8 *frameData = _mainSprites.getFrameData(58);
- for (i = _rainList.begin(); i != _rainList.end(); ++i) {
- Rain &rain = *i;
+ for (auto &rain : _rainList) {
uint16 y = rain.y + _mapAdY + _mapYStart;
uint16 x = rain.x + _mapAdX + _mapXStart;
uint16 size = rain.size;
diff --git a/engines/dreamweb/rnca_archive.cpp b/engines/dreamweb/rnca_archive.cpp
index 806bc8ef780..44b2352cf8b 100644
--- a/engines/dreamweb/rnca_archive.cpp
+++ b/engines/dreamweb/rnca_archive.cpp
@@ -72,8 +72,8 @@ bool RNCAArchive::hasFile(const Common::Path &path) const {
}
int RNCAArchive::listMembers(Common::ArchiveMemberList &list) const {
- for (FileMap::const_iterator i = _files.begin(), end = _files.end(); i != end; ++i) {
- list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(i->_key, *this)));
+ for (const auto &file : _files) {
+ list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(file._key, *this)));
}
return _files.size();
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 537931d8295..a631c99a71a 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -689,12 +689,12 @@ void DreamWebEngine::loadPosition(unsigned int slot) {
}
// ...and check if the frames overlap.
Common::sort(flist.begin(), flist.end(), Common::Less<FrameExtent>());
- Common::List<FrameExtent>::const_iterator iter;
uint16 curEnd = 0;
- for (iter = flist.begin(); iter != flist.end(); ++iter) {
- if (iter->start < curEnd)
+
+ for (auto &frame : flist) {
+ if (frame.start < curEnd)
error("exFrames data corruption in savegame");
- curEnd = iter->start + iter->length;
+ curEnd = frame.start + frame.length;
}
if (curEnd > _vars._exFramePos) {
if (curEnd > kExframeslen)
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index ef8972327be..05d5f20131b 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -26,9 +26,7 @@ namespace DreamWeb {
void DreamWebEngine::printSprites() {
for (uint priority = 0; priority < 7; ++priority) {
- Common::List<Sprite>::const_iterator i;
- for (i = _spriteTable.begin(); i != _spriteTable.end(); ++i) {
- const Sprite &sprite = *i;
+ for (const auto &sprite : _spriteTable) {
if (priority != sprite.priority)
continue;
if (sprite.hidden == 1)
@@ -88,9 +86,7 @@ void DreamWebEngine::spriteUpdate() {
if (!_spriteTable.empty())
_spriteTable.front().hidden = _vars._ryanOn;
- Common::List<Sprite>::iterator i;
- for (i = _spriteTable.begin(); i != _spriteTable.end(); ++i) {
- Sprite &sprite = *i;
+ for (auto &sprite : _spriteTable) {
if (sprite._mainManCallback)
mainMan(&sprite);
else {
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 86db5966c9a..97527170f3e 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1192,9 +1192,7 @@ void DreamWebEngine::commandOnly(uint8 command) {
}
bool DreamWebEngine::checkIfPerson(uint8 x, uint8 y) {
- Common::List<People>::iterator i;
- for (i = _peopleList.begin(); i != _peopleList.end(); ++i) {
- People &people = *i;
+ for (auto &people : _peopleList) {
Reel *reel = getReelStart(people._reelPointer);
if (reel->frame() == 0xffff)
++reel;
Commit: fda6fc272325bc51b0b2ba4d094744890a95da06
https://github.com/scummvm/scummvm/commit/fda6fc272325bc51b0b2ba4d094744890a95da06
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
FREESCAPE: Use C++ 11 range-based for loops
Changed paths:
engines/freescape/loaders/8bitBinaryLoader.cpp
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index d91eb5a3e34..6364fe2188b 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -748,11 +748,11 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
// Link all groups
if (areaNumber != 255) { // Do not link objects in the room structure
- for (ObjectMap::iterator it = objectsByID->begin(); it != objectsByID->end(); ++it) {
- if (it->_value->getType() == ObjectType::kGroupType) {
- Group *group = (Group *)it->_value;
- for (ObjectMap::iterator itt = objectsByID->begin(); itt != objectsByID->end(); ++itt)
- group->linkObject(itt->_value);
+ for (auto &obj : *objectsByID) {
+ if (obj._value->getType() == ObjectType::kGroupType) {
+ Group *group = (Group *)obj._value;
+ for (auto &objInner : *objectsByID)
+ group->linkObject(objInner._value);
}
}
}
Commit: affc445f7742c80a3ba59ea06e962541e6e66f0c
https://github.com/scummvm/scummvm/commit/affc445f7742c80a3ba59ea06e962541e6e66f0c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
HOPKINS: Use C++ 11 range-based for loops
Changed paths:
engines/hopkins/metaengine.cpp
diff --git a/engines/hopkins/metaengine.cpp b/engines/hopkins/metaengine.cpp
index 972ebce1149..a7a7a9563be 100644
--- a/engines/hopkins/metaengine.cpp
+++ b/engines/hopkins/metaengine.cpp
@@ -135,21 +135,19 @@ Common::Error HopkinsMetaEngine::createInstance(OSystem *syst, Engine **engine,
SaveStateList HopkinsMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::StringArray filenames;
Common::String saveDesc;
Common::String pattern = Common::String::format("%s.0##", target);
-
- filenames = saveFileMan->listSavefiles(pattern);
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
Hopkins::hopkinsSavegameHeader header;
-
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
- const char *ext = strrchr(file->c_str(), '.');
+
+ for (const auto &filename : filenames) {
+ const char *ext = strrchr(filename.c_str(), '.');
int slot = ext ? atoi(ext + 1) : -1;
if (slot >= 0 && slot < MAX_SAVES) {
- Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename);
if (in) {
if (Hopkins::SaveLoadManager::readSavegameHeader(in, header)) {
Commit: b680373e9866c64d4115ea2db63772a21c8d6bfd
https://github.com/scummvm/scummvm/commit/b680373e9866c64d4115ea2db63772a21c8d6bfd
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
LAB: Use C++ 11 range-based for loops
Changed paths:
engines/lab/console.cpp
engines/lab/engine.cpp
engines/lab/interface.cpp
engines/lab/metaengine.cpp
engines/lab/processroom.cpp
diff --git a/engines/lab/console.cpp b/engines/lab/console.cpp
index 50104a7ab2c..8cbe0bd9030 100644
--- a/engines/lab/console.cpp
+++ b/engines/lab/console.cpp
@@ -85,19 +85,18 @@ bool Console::Cmd_DumpSceneResources(int argc, const char **argv) {
debugPrintf("Script:\n");
- for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
- debugPrintf("Rule type: %s", ruleTypes[rule->_ruleType]);
- if (rule->_ruleType == kRuleTypeAction || rule->_ruleType == kRuleTypeOperate)
- debugPrintf(" (item %d, closeup %d)", rule->_param1, rule->_param2);
- else if (rule->_ruleType == kRuleTypeGoForward)
- debugPrintf(" (%s)", directions[rule->_param1]);
- else if (rule->_ruleType == kRuleTypeTurnFromTo)
- debugPrintf(" (from %s to %s)", directions[rule->_param1], directions[rule->_param2]);
+ for (auto &rule : rules) {
+ debugPrintf("Rule type: %s", ruleTypes[rule._ruleType]);
+ if (rule._ruleType == kRuleTypeAction || rule._ruleType == kRuleTypeOperate)
+ debugPrintf(" (item %d, closeup %d)", rule._param1, rule._param2);
+ else if (rule._ruleType == kRuleTypeGoForward)
+ debugPrintf(" (%s)", directions[rule._param1]);
+ else if (rule._ruleType == kRuleTypeTurnFromTo)
+ debugPrintf(" (from %s to %s)", directions[rule._param1], directions[rule._param2]);
debugPrintf("\n");
- ActionList::iterator action;
- for (action = rule->_actionList.begin(); action != rule->_actionList.end(); ++action) {
- debugPrintf(" - %s ('%s', %d, %d, %d)\n", actionTypes[action->_actionType], action->_messages[0].c_str(), action->_param1, action->_param2, action->_param3);
+ for (auto &action : rule._actionList) {
+ debugPrintf(" - %s ('%s', %d, %d, %d)\n", actionTypes[action._actionType], action._messages[0].c_str(), action._param1, action._param2, action._param3);
}
}
@@ -118,13 +117,12 @@ bool Console::Cmd_FindAction(int argc, const char **argv) {
for (int i = 1; i <= _vm->_manyRooms; i++) {
_vm->_resource->readViews(i);
- for (RuleList::iterator rule = _vm->_rooms[i]._rules.begin(); rule != _vm->_rooms[i]._rules.end(); ++rule) {
- ActionList::iterator action;
- for (action = rule->_actionList.begin(); action != rule->_actionList.end(); ++action) {
- if (action->_actionType == actionId &&
- (action->_param1 == param1 || param1 == -1) &&
- (action->_param2 == param2 || param2 == -1) &&
- (action->_param3 == param3 || param3 == -1)) {
+ for (auto &rule: _vm->_rooms[i]._rules) {
+ for (auto &action : rule._actionList) {
+ if (action._actionType == actionId &&
+ (action._param1 == param1 || param1 == -1) &&
+ (action._param2 == param2 || param2 == -1) &&
+ (action._param3 == param3 || param3 == -1)) {
debugPrintf("Found at script %d\n", i);
}
}
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2deeeb505a7..a3cb76cbc3d 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -179,20 +179,19 @@ void LabEngine::freeScreens() {
// We can't use freeButtonList() here, because some buttons are shared
// between the two lists.
- for (ButtonList::iterator buttonIter = _moveButtonList.begin(); buttonIter != _moveButtonList.end(); ++buttonIter) {
- delete *buttonIter;
+ for (auto &buttonIter : _moveButtonList) {
+ delete buttonIter;
}
_moveButtonList.clear();
- for (ButtonList::iterator buttonIter = _invButtonList.begin(); buttonIter != _invButtonList.end(); ++buttonIter) {
- delete *buttonIter;
+ for (auto &buttonIter : _invButtonList) {
+ delete buttonIter;
}
_invButtonList.clear();
}
void LabEngine::perFlipButton(uint16 buttonId) {
- for (ButtonList::iterator button = _moveButtonList.begin(); button != _moveButtonList.end(); ++button) {
- Button *topButton = *button;
+ for (auto &topButton : _moveButtonList) {
if (topButton->_buttonId == buttonId) {
SWAP<Image *>(topButton->_image, topButton->_altImage);
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 2770939398e..c0e6ffa0eaf 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -64,8 +64,7 @@ Button *Interface::createButton(uint16 x, uint16 y, uint16 id, Common::KeyCode k
}
void Interface::freeButtonList(ButtonList *buttonList) {
- for (ButtonList::iterator buttonIter = buttonList->begin(); buttonIter != buttonList->end(); ++buttonIter) {
- Button *button = *buttonIter;
+ for (auto &button : *buttonList) {
delete button->_image;
delete button->_altImage;
delete button;
@@ -75,11 +74,11 @@ void Interface::freeButtonList(ButtonList *buttonList) {
}
void Interface::drawButtonList(ButtonList *buttonList) {
- for (ButtonList::iterator button = buttonList->begin(); button != buttonList->end(); ++button) {
- toggleButton((*button), 1, true);
+ for (auto &button : *buttonList) {
+ toggleButton(button, 1, true);
- if (!(*button)->_isEnabled)
- toggleButton((*button), 1, false);
+ if (!button->_isEnabled)
+ toggleButton(button, 1, false);
}
}
@@ -98,8 +97,7 @@ Button *Interface::checkNumButtonHit(Common::KeyCode key) {
if (!_screenButtonList)
return nullptr;
- for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
- Button *button = *buttonItr;
+ for (auto &button : *_screenButtonList) {
if (!button->_isEnabled)
continue;
@@ -118,8 +116,7 @@ Button *Interface::checkButtonHit(Common::Point pos) {
if (!_screenButtonList)
return nullptr;
- for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
- Button *button = *buttonItr;
+ for (auto &button : *_screenButtonList) {
Common::Rect buttonRect(button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
if (buttonRect.contains(pos) && button->_isEnabled) {
@@ -149,8 +146,7 @@ void Interface::attachButtonList(ButtonList *buttonList) {
}
Button *Interface::getButton(uint16 id) {
- for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
- Button *button = *buttonItr;
+ for (auto &button : *_screenButtonList) {
if (button->_buttonId == id)
return button;
}
diff --git a/engines/lab/metaengine.cpp b/engines/lab/metaengine.cpp
index 78046facd9f..2debd4b9d3e 100644
--- a/engines/lab/metaengine.cpp
+++ b/engines/lab/metaengine.cpp
@@ -85,17 +85,15 @@ SaveStateList LabMetaEngine::listSaves(const char *target) const {
Common::String pattern = target;
pattern += ".###";
- Common::StringArray filenames;
- filenames = saveFileMan->listSavefiles(pattern.c_str());
-
+ Common::StringArray filenames = saveFileMan->listSavefiles(pattern.c_str());
SaveStateList saveList;
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ for (auto &filename : filenames) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
- if ((slotNum >= 0) && (slotNum <= 999)) {
- Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ if (slotNum >= 0 && slotNum <= 999) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(filename);
if (in) {
if (Lab::readSaveGameHeader(in, header))
saveList.push_back(SaveStateDescriptor(this, slotNum, header._descr.getDescription()));
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index b302119fb60..0e2a21b0bfd 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -57,11 +57,10 @@ ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) {
_resource->readViews(roomNum);
ViewDataList &views = _rooms[roomNum]._view[direction];
- ViewDataList::iterator view;
- for (view = views.begin(); view != views.end(); ++view) {
- if (checkConditions(view->_condition))
- return &(*view);
+ for (auto &view : views) {
+ if (checkConditions(view._condition))
+ return &view;
}
error("No view with matching condition found");
@@ -74,28 +73,23 @@ const CloseData *LabEngine::getObject(Common::Point pos, const CloseData *closeP
else
list = &(closePtr->_subCloseUps);
- CloseDataList::const_iterator wrkClosePtr;
-
- for (wrkClosePtr = list->begin(); wrkClosePtr != list->end(); ++wrkClosePtr) {
- Common::Rect objRect;
- objRect = _utils->rectScale(wrkClosePtr->_x1, wrkClosePtr->_y1, wrkClosePtr->_x2, wrkClosePtr->_y2);
+ for (auto &closeData : *list) {
+ Common::Rect objRect = _utils->rectScale(closeData._x1, closeData._y1, closeData._x2, closeData._y2);
if (objRect.contains(pos))
- return &(*wrkClosePtr);
+ return &closeData;
}
return nullptr;
}
const CloseData *LabEngine::findClosePtrMatch(const CloseData *closePtr, const CloseDataList &list) {
- CloseDataList::const_iterator i;
-
- for (i = list.begin(); i != list.end(); ++i) {
- if ((closePtr->_x1 == i->_x1) && (closePtr->_x2 == i->_x2) &&
- (closePtr->_y1 == i->_y1) && (closePtr->_y2 == i->_y2) &&
- (closePtr->_depth == i->_depth))
- return &(*i);
+ for (const auto &closeData : list) {
+ if ((closePtr->_x1 == closeData._x1) && (closePtr->_x2 == closeData._x2) &&
+ (closePtr->_y1 == closeData._y1) && (closePtr->_y2 == closeData._y2) &&
+ (closePtr->_depth == closeData._depth))
+ return &closeData;
- const CloseData *resClosePtr = findClosePtrMatch(closePtr, i->_subCloseUps);
+ const CloseData *resClosePtr = findClosePtrMatch(closePtr, closeData._subCloseUps);
if (resClosePtr)
return resClosePtr;
@@ -221,12 +215,10 @@ bool LabEngine::takeItem(Common::Point pos) {
} else
list = &(_closeDataPtr->_subCloseUps);
- CloseDataList::const_iterator closePtr;
- for (closePtr = list->begin(); closePtr != list->end(); ++closePtr) {
- Common::Rect objRect;
- objRect = _utils->rectScale(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2);
- if (objRect.contains(pos) && (closePtr->_closeUpType < 0)) {
- _conditions->inclElement(abs(closePtr->_closeUpType));
+ for (auto &closeData : *list) {
+ Common::Rect objRect = _utils->rectScale(closeData._x1, closeData._y1, closeData._x2, closeData._y2);
+ if (objRect.contains(pos) && (closeData._closeUpType < 0)) {
+ _conditions->inclElement(abs(closeData._closeUpType));
return true;
}
}
@@ -235,37 +227,36 @@ bool LabEngine::takeItem(Common::Point pos) {
}
void LabEngine::doActions(const ActionList &actionList) {
- ActionList::const_iterator action;
- for (action = actionList.begin(); action != actionList.end(); ++action) {
+ for (const auto &action : actionList) {
updateEvents();
if (_quitLab || shouldQuit())
return;
- switch (action->_actionType) {
+ switch (action._actionType) {
case kActionPlaySound:
- _music->loadSoundEffect(action->_messages[0], false, true);
+ _music->loadSoundEffect(action._messages[0], false, true);
break;
case kActionPlaySoundNoWait: // only used in scene 7 (street, when teleporting to the surreal maze)
- _music->loadSoundEffect(action->_messages[0], false, false);
+ _music->loadSoundEffect(action._messages[0], false, false);
break;
case kActionPlaySoundLooping:
- _music->loadSoundEffect(action->_messages[0], true, false);
+ _music->loadSoundEffect(action._messages[0], true, false);
break;
case kActionShowDiff:
- _graphics->readPict(action->_messages[0], true);
+ _graphics->readPict(action._messages[0], true);
break;
case kActionShowDiffLooping: // used in scene 44 (heart of the labyrinth, minotaur)
- _graphics->readPict(action->_messages[0], false);
+ _graphics->readPict(action._messages[0], false);
break;
case kActionLoadDiff:
- if (!action->_messages[0].empty())
+ if (!action._messages[0].empty())
// Puts a file into memory
- _graphics->loadPict(action->_messages[0]);
+ _graphics->loadPict(action._messages[0]);
break;
case kActionLoadBitmap:
@@ -275,7 +266,7 @@ void LabEngine::doActions(const ActionList &actionList) {
error("Unused opcode kActionShowBitmap has been called");
case kActionTransition:
- _graphics->doTransition((TransitionType)action->_param1, action->_messages[0].c_str());
+ _graphics->doTransition((TransitionType)action._param1, action._messages[0].c_str());
break;
case kActionNoUpdate:
@@ -298,31 +289,31 @@ void LabEngine::doActions(const ActionList &actionList) {
break;
case kActionSetElement:
- _conditions->inclElement(action->_param1);
+ _conditions->inclElement(action._param1);
break;
case kActionUnsetElement:
- _conditions->exclElement(action->_param1);
+ _conditions->exclElement(action._param1);
break;
case kActionShowMessage:
if (_graphics->_longWinInFront)
- _graphics->longDrawMessage(action->_messages[0], true);
+ _graphics->longDrawMessage(action._messages[0], true);
else
- _graphics->drawMessage(action->_messages[0], true);
+ _graphics->drawMessage(action._messages[0], true);
break;
case kActionCShowMessage:
if (!_closeDataPtr)
- _graphics->drawMessage(action->_messages[0], true);
+ _graphics->drawMessage(action._messages[0], true);
break;
case kActionShowMessages:
- _graphics->drawMessage(action->_messages[_utils->getRandom(action->_param1)], true);
+ _graphics->drawMessage(action._messages[_utils->getRandom(action._param1)], true);
break;
case kActionChangeRoom:
- if (action->_param1 & 0x8000) {
+ if (action._param1 & 0x8000) {
// This is a Wyrmkeep Windows trial version, thus stop at this
// point, since we can't check for game payment status
_graphics->readPict(getPictName(true));
@@ -331,15 +322,15 @@ void LabEngine::doActions(const ActionList &actionList) {
break;
}
- _music->checkRoomMusic(_roomNum, action->_param1);
- _roomNum = action->_param1;
- _direction = action->_param2 - 1;
+ _music->checkRoomMusic(_roomNum, action._param1);
+ _roomNum = action._param1;
+ _direction = action._param2 - 1;
_closeDataPtr = nullptr;
_anim->_doBlack = true;
break;
case kActionSetCloseup: {
- Common::Point curPos = Common::Point(_utils->scaleX(action->_param1), _utils->scaleY(action->_param2));
+ Common::Point curPos = Common::Point(_utils->scaleX(action._param1), _utils->scaleY(action._param2));
const CloseData *tmpClosePtr = getObject(curPos, _closeDataPtr);
if (tmpClosePtr)
@@ -352,17 +343,17 @@ void LabEngine::doActions(const ActionList &actionList) {
break;
case kActionSubInv:
- if (_inventory[action->_param1]._quantity)
- (_inventory[action->_param1]._quantity)--;
+ if (_inventory[action._param1]._quantity)
+ (_inventory[action._param1]._quantity)--;
- if (_inventory[action->_param1]._quantity == 0)
- _conditions->exclElement(action->_param1);
+ if (_inventory[action._param1]._quantity == 0)
+ _conditions->exclElement(action._param1);
break;
case kActionAddInv:
- (_inventory[action->_param1]._quantity) += action->_param2;
- _conditions->inclElement(action->_param1);
+ (_inventory[action._param1]._quantity) += action._param2;
+ _conditions->inclElement(action._param1);
break;
case kActionShowDir:
@@ -370,7 +361,7 @@ void LabEngine::doActions(const ActionList &actionList) {
break;
case kActionWaitSecs: {
- uint32 targetMillis = _system->getMillis() + action->_param1 * 1000;
+ uint32 targetMillis = _system->getMillis() + action._param1 * 1000;
_graphics->screenUpdate();
@@ -392,7 +383,7 @@ void LabEngine::doActions(const ActionList &actionList) {
break;
case kActionChangeMusic: // used in scene 46 (museum exhibit, for the alarm)
- _music->changeMusic(action->_messages[0], true, false);
+ _music->changeMusic(action._messages[0], true, false);
break;
case kActionResetMusic: // used in scene 45 (sheriff's office, after museum)
@@ -435,13 +426,13 @@ void LabEngine::doActions(const ActionList &actionList) {
break;
case kActionSpecialCmd:
- if (action->_param1 == 0)
+ if (action._param1 == 0)
_anim->_doBlack = true;
- else if (action->_param1 == 1)
+ else if (action._param1 == 1)
_anim->_doBlack = (_closeDataPtr == nullptr);
- else if (action->_param1 == 2)
+ else if (action._param1 == 2)
_anim->_doBlack = (_closeDataPtr != nullptr);
- else if (action->_param1 == 5) {
+ else if (action._param1 == 5) {
// inverse the palette
for (int idx = (8 * 3); idx < (255 * 3); idx++)
_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];
@@ -450,18 +441,18 @@ void LabEngine::doActions(const ActionList &actionList) {
_graphics->setPalette(_anim->_diffPalette, 256);
waitTOF();
waitTOF();
- } else if (action->_param1 == 4) {
+ } else if (action._param1 == 4) {
// white the palette
_graphics->whiteScreen();
waitTOF();
waitTOF();
- } else if (action->_param1 == 6) {
+ } else if (action._param1 == 6) {
// Restore the palette
waitTOF();
_graphics->setPalette(_anim->_diffPalette, 256);
waitTOF();
waitTOF();
- } else if (action->_param1 == 7) {
+ } else if (action._param1 == 7) {
// Quick pause
waitTOF();
waitTOF();
@@ -489,14 +480,14 @@ bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, const CloseData *cl
rules = &(_rooms[roomNum]._rules);
}
- for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
- if ((rule->_ruleType == kRuleTypeAction) &&
- ((rule->_param1 == action) || ((rule->_param1 == 0) && allowDefaults))) {
- if (((rule->_param2 == closePtr->_closeUpType) ||
- ((rule->_param2 == 0) && allowDefaults)) ||
- ((action == 1) && (rule->_param2 == -closePtr->_closeUpType))) {
- if (checkConditions(rule->_condition)) {
- doActions(rule->_actionList);
+ for (auto &rule : *rules) {
+ if ((rule._ruleType == kRuleTypeAction) &&
+ ((rule._param1 == action) || ((rule._param1 == 0) && allowDefaults))) {
+ if (((rule._param2 == closePtr->_closeUpType) ||
+ ((rule._param2 == 0) && allowDefaults)) ||
+ ((action == 1) && (rule._param2 == -closePtr->_closeUpType))) {
+ if (checkConditions(rule._condition)) {
+ doActions(rule._actionList);
return true;
}
}
@@ -537,12 +528,12 @@ bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, const CloseData *
rules = &(_rooms[roomNum]._rules);
}
- for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
- if ((rule->_ruleType == kRuleTypeOperate) &&
- ((rule->_param1 == itemNum) || ((rule->_param1 == 0) && allowDefaults)) &&
- ((rule->_param2 == closePtr->_closeUpType) || ((rule->_param2 == 0) && allowDefaults))) {
- if (checkConditions(rule->_condition)) {
- doActions(rule->_actionList);
+ for (auto &rule : *rules) {
+ if ((rule._ruleType == kRuleTypeOperate) &&
+ ((rule._param1 == itemNum) || ((rule._param1 == 0) && allowDefaults)) &&
+ ((rule._param2 == closePtr->_closeUpType) || ((rule._param2 == 0) && allowDefaults))) {
+ if (checkConditions(rule._condition)) {
+ doActions(rule._actionList);
return true;
}
}
@@ -583,10 +574,10 @@ bool LabEngine::doOperateRule(Common::Point pos, int16 ItemNum) {
bool LabEngine::doGoForward() {
RuleList &rules = _rooms[_roomNum]._rules;
- for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
- if ((rule->_ruleType == kRuleTypeGoForward) && (rule->_param1 == (_direction + 1))) {
- if (checkConditions(rule->_condition)) {
- doActions(rule->_actionList);
+ for (auto &rule : rules) {
+ if ((rule._ruleType == kRuleTypeGoForward) && (rule._param1 == (_direction + 1))) {
+ if (checkConditions(rule._condition)) {
+ doActions(rule._actionList);
return true;
}
}
@@ -601,12 +592,12 @@ bool LabEngine::doTurn(uint16 from, uint16 to) {
RuleList &rules = _rooms[_roomNum]._rules;
- for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
- if ((rule->_ruleType == kRuleTypeTurn) ||
- ((rule->_ruleType == kRuleTypeTurnFromTo) &&
- (rule->_param1 == from) && (rule->_param2 == to))) {
- if (checkConditions(rule->_condition)) {
- doActions(rule->_actionList);
+ for (auto &rule : rules) {
+ if ((rule._ruleType == kRuleTypeTurn) ||
+ ((rule._ruleType == kRuleTypeTurnFromTo) &&
+ (rule._param1 == from) && (rule._param2 == to))) {
+ if (checkConditions(rule._condition)) {
+ doActions(rule._actionList);
return true;
}
}
@@ -617,10 +608,10 @@ bool LabEngine::doTurn(uint16 from, uint16 to) {
bool LabEngine::doMainView() {
RuleList &rules = _rooms[_roomNum]._rules;
- for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
- if (rule->_ruleType == kRuleTypeGoMainView) {
- if (checkConditions(rule->_condition)) {
- doActions(rule->_actionList);
+ for (auto &rule : rules) {
+ if (rule._ruleType == kRuleTypeGoMainView) {
+ if (checkConditions(rule._condition)) {
+ doActions(rule._actionList);
return true;
}
}
Commit: 7e99e9c3e2710a63b20e73f147e05d2718970964
https://github.com/scummvm/scummvm/commit/7e99e9c3e2710a63b20e73f147e05d2718970964
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
ICB: Use C++ 11 range-based for loops
Changed paths:
engines/icb/configfile.cpp
diff --git a/engines/icb/configfile.cpp b/engines/icb/configfile.cpp
index 0a73306a40f..f4b3d732637 100644
--- a/engines/icb/configfile.cpp
+++ b/engines/icb/configfile.cpp
@@ -42,10 +42,10 @@ void ConfigFile::readFile(const char *filename) {
}
Common::INIFile::SectionList sections = file.getSections();
- for (Common::INIFile::SectionList::const_iterator i = sections.begin(); i != sections.end(); i++) {
- Common::INIFile::SectionKeyList kList = i->getKeys();
- for (Common::INIFile::SectionKeyList::const_iterator j = kList.begin(); j != kList.end(); j++) {
- _dataSet[i->name][j->key] = j->value;
+ for (auto &i : sections) {
+ Common::INIFile::SectionKeyList kList = i.getKeys();
+ for (auto &j : kList) {
+ _dataSet[i.name][j.key] = j.value;
}
}
}
Commit: 404d098e332cec9cdca50a69e6359f4f819d7453
https://github.com/scummvm/scummvm/commit/404d098e332cec9cdca50a69e6359f4f819d7453
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
AUDIO: Use pointers when deleting inside range loops
Changed paths:
audio/decoders/wma.cpp
audio/softsynth/fmtowns_pc98/towns_euphony.cpp
audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
diff --git a/audio/decoders/wma.cpp b/audio/decoders/wma.cpp
index 7f37c551af4..9288a0641b3 100644
--- a/audio/decoders/wma.cpp
+++ b/audio/decoders/wma.cpp
@@ -115,7 +115,7 @@ WMACodec::~WMACodec() {
delete _coefHuffman[i];
}
- for (auto &m : _mdct)
+ for (auto *m : _mdct)
delete m;
}
diff --git a/audio/softsynth/fmtowns_pc98/towns_euphony.cpp b/audio/softsynth/fmtowns_pc98/towns_euphony.cpp
index 4766146b7dc..07a97322767 100644
--- a/audio/softsynth/fmtowns_pc98/towns_euphony.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_euphony.cpp
@@ -78,7 +78,7 @@ EuphonyPlayer::~EuphonyPlayer() {
delete[] _partConfig_volume;
delete[] _partConfig_transpose;
- for (auto &event : _euphonyEvents)
+ for (auto *event : _euphonyEvents)
delete event;
}
diff --git a/audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp b/audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
index fbbcc9bac32..132ee9e22c0 100644
--- a/audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
@@ -213,7 +213,7 @@ _sustain(false), _fading(false), _dataPtr(nullptr), _vbrModInitVal(0), _vbrModCu
#undef CONTROL
TownsPC98_MusicChannel::~TownsPC98_MusicChannel() {
- for (auto &event : _controlEvents)
+ for (auto *event : _controlEvents)
delete event;
}
@@ -613,7 +613,7 @@ TownsPC98_MusicChannel(driver, regOffs, flgs, num, key, prt, id), _algorithm(0x8
#undef CONTROL
TownsPC98_MusicChannelSSG::~TownsPC98_MusicChannelSSG() {
- for (auto &event : _controlEvents)
+ for (auto *event : _controlEvents)
delete event;
delete[] _envPatchData;
_envPatchData = nullptr;
@@ -1001,7 +1001,7 @@ TownsPC98_MusicChannel(driver, regOffs, flgs, num, key, prt, id) {
#undef CONTROL
TownsPC98_MusicChannelPCM::~TownsPC98_MusicChannelPCM() {
- for (auto &event : _controlEvents)
+ for (auto *event : _controlEvents)
delete event;
}
Commit: 32214710350226b7ba30db13567921c502b1ad9b
https://github.com/scummvm/scummvm/commit/32214710350226b7ba30db13567921c502b1ad9b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
BACKENDS: Use pointers when deleting inside range loops
Changed paths:
backends/keymapper/keymap.cpp
backends/keymapper/keymapper.cpp
diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp
index 26d03b55c52..289c1d513ec 100644
--- a/backends/keymapper/keymap.cpp
+++ b/backends/keymapper/keymap.cpp
@@ -55,7 +55,7 @@ Keymap::Keymap(KeymapType type, const String &id, const String &description) :
}
Keymap::~Keymap() {
- for (auto &action : _actions)
+ for (auto *action : _actions)
delete action;
}
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 68ab7e6560e..303cde16552 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -49,7 +49,7 @@ Keymapper::~Keymapper() {
}
void Keymapper::clear() {
- for (auto &keymap : _keymaps) {
+ for (auto *keymap : _keymaps) {
delete keymap;
}
_keymaps.clear();
Commit: b0051b47b09d57330e4390c8b20ffac3a37105ea
https://github.com/scummvm/scummvm/commit/b0051b47b09d57330e4390c8b20ffac3a37105ea
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
BASE: Use pointers when deleting inside range loops
Changed paths:
base/plugins.cpp
diff --git a/base/plugins.cpp b/base/plugins.cpp
index eca21ae2719..aa9310a67e5 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -276,7 +276,7 @@ PluginManager::~PluginManager() {
unloadAllPlugins();
// Delete the plugin providers
- for (auto &pluginProvider : _providers) {
+ for (auto *pluginProvider : _providers) {
delete pluginProvider;
}
}
@@ -290,7 +290,7 @@ PluginManagerUncached::~PluginManagerUncached() {
// They are also referenced from _allEnginePlugins which we clean up here
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, nullptr, false);
- for (auto &enginePlugin : _allEnginePlugins) {
+ for (auto *enginePlugin : _allEnginePlugins) {
delete enginePlugin;
}
_allEnginePlugins.clear();
@@ -518,7 +518,7 @@ void PluginManager::loadAllPlugins() {
void PluginManager::loadAllPluginsOfType(PluginType type) {
for (auto &pluginProvider : _providers) {
PluginList pluginList(pluginProvider->getPlugins());
- for (auto &plugin : pluginList) {
+ for (auto *plugin : pluginList) {
if (plugin->loadPlugin()) {
if (plugin->getType() == type) {
addToPluginsInMemList(plugin);
@@ -542,7 +542,7 @@ void PluginManager::unloadAllPlugins() {
void PluginManager::unloadPluginsExcept(PluginType type, const Plugin *plugin, bool deletePlugin /*=true*/) {
Plugin *found = nullptr;
- for (auto &curPlugin : _pluginsInMem[type]) {
+ for (auto *curPlugin : _pluginsInMem[type]) {
if (curPlugin == plugin) {
found = curPlugin;
} else {
Commit: a28cb792cf6f87bfe5caf5afe01ac21e98bf24b3
https://github.com/scummvm/scummvm/commit/a28cb792cf6f87bfe5caf5afe01ac21e98bf24b3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
VIDEO: Use pointers when deleting inside range loops
Changed paths:
video/subtitles.cpp
video/video_decoder.cpp
diff --git a/video/subtitles.cpp b/video/subtitles.cpp
index a7b75401150..525a8c1de3c 100644
--- a/video/subtitles.cpp
+++ b/video/subtitles.cpp
@@ -43,7 +43,7 @@ SRTParser::~SRTParser() {
}
void SRTParser::cleanup() {
- for (const auto &item : _entries)
+ for (const auto *item : _entries)
delete item;
_entries.clear();
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index 5ad185eeb04..6c5f81b1e0a 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -54,7 +54,7 @@ void VideoDecoder::close() {
if (isPlaying())
stop();
- for (auto &track : _tracks)
+ for (auto *track : _tracks)
delete track;
_tracks.clear();
Commit: 1cfa228906fab981faa036822bae867decc67828
https://github.com/scummvm/scummvm/commit/1cfa228906fab981faa036822bae867decc67828
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
ENGINES: Use pointers when deleting inside range loops
Changed paths:
engines/agi/menu.cpp
engines/dgds/sound/drivers/amigamac1.cpp
engines/draci/animation.cpp
engines/dragons/talk.cpp
engines/illusions/menusystem.cpp
engines/illusions/resourcesystem.cpp
engines/illusions/updatefunctions.cpp
engines/lab/engine.cpp
diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp
index 39d276aaf1c..17f229abb75 100644
--- a/engines/agi/menu.cpp
+++ b/engines/agi/menu.cpp
@@ -58,11 +58,11 @@ GfxMenu::GfxMenu(AgiEngine *vm, GfxMgr *gfx, PictureMgr *picture, TextMgr *text)
}
GfxMenu::~GfxMenu() {
- for (auto &menu : _array)
+ for (auto *menu : _array)
delete menu;
_array.clear();
- for (auto &menuItem : _itemArray)
+ for (auto *menuItem : _itemArray)
delete menuItem;
_itemArray.clear();
}
diff --git a/engines/dgds/sound/drivers/amigamac1.cpp b/engines/dgds/sound/drivers/amigamac1.cpp
index 9c820116061..3d53a5e0d20 100644
--- a/engines/dgds/sound/drivers/amigamac1.cpp
+++ b/engines/dgds/sound/drivers/amigamac1.cpp
@@ -268,11 +268,11 @@ void MidiPlayer_AmigaMac1::close() {
_mixer->stopHandle(_mixerSoundHandle);
- for (const auto &channel : _channels)
+ for (const auto *channel : _channels)
delete channel;
_channels.clear();
- for (const auto &voice : _voices)
+ for (const auto *voice : _voices)
delete voice;
_voices.clear();
@@ -453,7 +453,7 @@ void MidiPlayer_AmigaMac1::freeInstruments() {
delete[] freq._value;
_freqTables.clear();
- for (auto &instrument : _instruments)
+ for (auto *instrument : _instruments)
delete instrument;
_instruments.clear();
}
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp
index 2dc8e801623..b52f705e8ed 100644
--- a/engines/draci/animation.cpp
+++ b/engines/draci/animation.cpp
@@ -455,7 +455,7 @@ void AnimationManager::deleteOverlays() {
void AnimationManager::deleteAll() {
debugC(3, kDraciAnimationDebugLevel, "Deleting all animations...");
- for (auto &anim : _animations) {
+ for (auto *anim : _animations) {
delete anim;
}
diff --git a/engines/dragons/talk.cpp b/engines/dragons/talk.cpp
index ab0364851ee..0788a6e3d74 100644
--- a/engines/dragons/talk.cpp
+++ b/engines/dragons/talk.cpp
@@ -852,7 +852,7 @@ void Talk::exitTalkMenu(bool isFlag8Set, bool isFlag100Set, Common::Array<TalkDi
_vm->setFlags(ENGINE_FLAG_100);
}
- for (auto &entry : dialogEntries) {
+ for (auto *entry : dialogEntries) {
delete entry;
}
dialogEntries.clear();
@@ -1119,7 +1119,7 @@ uint32 Talk::truncateDialogText(uint16 *srcText, uint16 *destText, uint32 srcLen
}
void Talk::clearDialogEntries() {
- for (auto &entry : _dialogEntries) {
+ for (auto *entry : _dialogEntries) {
delete entry;
}
_dialogEntries.clear();
diff --git a/engines/illusions/menusystem.cpp b/engines/illusions/menusystem.cpp
index 8b7e7c03c50..0ef4189b778 100644
--- a/engines/illusions/menusystem.cpp
+++ b/engines/illusions/menusystem.cpp
@@ -58,7 +58,7 @@ BaseMenu::BaseMenu(BaseMenuSystem *menuSystem, uint32 fontId, byte backgroundCol
}
BaseMenu::~BaseMenu() {
- for (auto &menuItem : _menuItems) {
+ for (auto *menuItem : _menuItems) {
delete menuItem;
}
}
diff --git a/engines/illusions/resourcesystem.cpp b/engines/illusions/resourcesystem.cpp
index 7c25920501f..607bd07f0db 100644
--- a/engines/illusions/resourcesystem.cpp
+++ b/engines/illusions/resourcesystem.cpp
@@ -126,7 +126,7 @@ void ResourceSystem::unloadSceneResources(uint32 sceneId1, uint32 sceneId2) {
}
void ResourceSystem::unloadAllResources() {
- for (auto &resource : _resources) {
+ for (auto *resource : _resources) {
delete resource;
}
_resources.clear();
diff --git a/engines/illusions/updatefunctions.cpp b/engines/illusions/updatefunctions.cpp
index e4b273b593d..67551b12e62 100644
--- a/engines/illusions/updatefunctions.cpp
+++ b/engines/illusions/updatefunctions.cpp
@@ -34,7 +34,7 @@ UpdateFunctions::UpdateFunctions() {
UpdateFunctions::~UpdateFunctions() {
// Free update functions
- for (auto &updateFunction : _updateFunctions) {
+ for (auto *updateFunction : _updateFunctions) {
delete updateFunction;
}
}
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index a3cb76cbc3d..d008e92d25d 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -179,13 +179,13 @@ void LabEngine::freeScreens() {
// We can't use freeButtonList() here, because some buttons are shared
// between the two lists.
- for (auto &buttonIter : _moveButtonList) {
- delete buttonIter;
+ for (auto *moveButton : _moveButtonList) {
+ delete moveButton;
}
_moveButtonList.clear();
- for (auto &buttonIter : _invButtonList) {
- delete buttonIter;
+ for (auto *invButton : _invButtonList) {
+ delete invButton;
}
_invButtonList.clear();
}
Commit: 5b1e2d502c3b1c7b4d22eab9fe975b5bf6c14025
https://github.com/scummvm/scummvm/commit/5b1e2d502c3b1c7b4d22eab9fe975b5bf6c14025
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-03-27T13:47:57+08:00
Commit Message:
COMMON: Use C++ 11 range-based for loops
Changed paths:
common/compression/clickteam.cpp
common/compression/installshield_cab.cpp
common/compression/installshieldv3_archive.cpp
common/compression/stuffit.cpp
common/compression/unarj.cpp
common/compression/unzip.cpp
common/coroutines.cpp
common/debug.cpp
common/engine_data.cpp
common/formats/json.cpp
common/formats/prodos.cpp
common/formats/winexe_ne.cpp
common/formats/winexe_pe.cpp
common/formats/xmlparser.cpp
common/macresman.cpp
common/path.cpp
common/recorderfile.cpp
diff --git a/common/compression/clickteam.cpp b/common/compression/clickteam.cpp
index ce7a641edbb..c410fecc76a 100644
--- a/common/compression/clickteam.cpp
+++ b/common/compression/clickteam.cpp
@@ -449,28 +449,26 @@ ClickteamInstaller* ClickteamInstaller::openPatch(Common::SeekableReadStream *st
return nullptr;
if (verifyOriginal && reference) {
- for (Common::HashMap<Common::Path, ClickteamFileDescriptor, Common::Path::IgnoreCase_Hash, Common::Path::IgnoreCase_EqualTo>::iterator i = files.begin(), end = files.end();
- i != end; ++i) {
- if (i->_value._isPatchFile) {
- Common::ScopedPtr<Common::SeekableReadStream> refStream(reference->createReadStreamForMember(i->_key));
+ for (auto &file : files) {
+ if (file._value._isPatchFile) {
+ Common::ScopedPtr<Common::SeekableReadStream> refStream(reference->createReadStreamForMember(file._key));
if (!refStream) {
if (verifyAllowSkip) {
- i->_value._isReferenceMissing = true;
+ file._value._isReferenceMissing = true;
continue;
}
return nullptr;
}
- if (findPatchIdx(i->_value, refStream.get(), i->_key, crc_xor, false) == -1)
+ if (findPatchIdx(file._value, refStream.get(), file._key, crc_xor, false) == -1)
return nullptr;
}
}
}
if (!reference) {
- for (Common::HashMap<Common::Path, ClickteamFileDescriptor, Common::Path::IgnoreCase_Hash, Common::Path::IgnoreCase_EqualTo>::iterator i = files.begin(), end = files.end();
- i != end; ++i) {
- if (i->_value._isPatchFile) {
- i->_value._isReferenceMissing = true;
+ for (auto &file : files) {
+ if (file._value._isPatchFile) {
+ file._value._isReferenceMissing = true;
}
}
}
@@ -485,10 +483,9 @@ bool ClickteamInstaller::hasFile(const Path &path) const {
int ClickteamInstaller::listMembers(ArchiveMemberList &list) const {
int members = 0;
- for (Common::HashMap<Common::Path, ClickteamFileDescriptor, Common::Path::IgnoreCase_Hash, Common::Path::IgnoreCase_EqualTo>::const_iterator i = _files.begin(), end = _files.end();
- i != end; ++i) {
- if (!i->_value._isReferenceMissing) {
- list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(i->_key, *this)));
+ for (const auto &file : _files) {
+ if (!file._value._isReferenceMissing) {
+ list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(file._key, *this)));
++members;
}
}
diff --git a/common/compression/installshield_cab.cpp b/common/compression/installshield_cab.cpp
index 6a4610c42bd..d729d950fee 100644
--- a/common/compression/installshield_cab.cpp
+++ b/common/compression/installshield_cab.cpp
@@ -337,8 +337,8 @@ bool InstallShieldCabinet::hasFile(const Path &path) const {
}
int InstallShieldCabinet::listMembers(ArchiveMemberList &list) const {
- for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
- list.push_back(getMember(it->_key));
+ for (const auto &file : _map)
+ list.push_back(getMember(file._key));
return _map.size();
}
diff --git a/common/compression/installshieldv3_archive.cpp b/common/compression/installshieldv3_archive.cpp
index 47205249c6c..8818ca67e06 100644
--- a/common/compression/installshieldv3_archive.cpp
+++ b/common/compression/installshieldv3_archive.cpp
@@ -78,8 +78,8 @@ bool InstallShieldV3::hasFile(const Common::Path &path) const {
}
int InstallShieldV3::listMembers(Common::ArchiveMemberList &list) const {
- for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
- list.push_back(getMember(it->_key));
+ for (const auto &file : _map)
+ list.push_back(getMember(file._key));
return _map.size();
}
diff --git a/common/compression/stuffit.cpp b/common/compression/stuffit.cpp
index dddfa254a29..069d56c941c 100644
--- a/common/compression/stuffit.cpp
+++ b/common/compression/stuffit.cpp
@@ -285,8 +285,8 @@ bool StuffItArchive::hasFile(const Common::Path &path) const {
}
int StuffItArchive::listMembers(Common::ArchiveMemberList &list) const {
- for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
- list.push_back(getMember(it->_key));
+ for (const auto &file : _map)
+ list.push_back(getMember(file._key));
return _map.size();
}
diff --git a/common/compression/unarj.cpp b/common/compression/unarj.cpp
index e253f6b199c..7cc104bda8e 100644
--- a/common/compression/unarj.cpp
+++ b/common/compression/unarj.cpp
@@ -720,10 +720,9 @@ public:
ArjArchive::~ArjArchive() {
debug(0, "ArjArchive Destructor Called");
- ArjHeadersMap::iterator it = _headers.begin();
- for ( ; it != _headers.end(); ++it) {
- for (uint i = 0; i < it->_value.size(); i++)
- delete it->_value[i]._header;
+ for (auto &header : _headers) {
+ for (uint i = 0; i < header._value.size(); i++)
+ delete header._value[i]._header;
}
}
@@ -780,9 +779,8 @@ bool ArjArchive::hasFile(const Path &path) const {
int ArjArchive::listMembers(ArchiveMemberList &list) const {
int matches = 0;
- ArjHeadersMap::const_iterator it = _headers.begin();
- for ( ; it != _headers.end(); ++it) {
- list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(Path(it->_value[0]._header->filename), *this)));
+ for (const auto &header : _headers) {
+ list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(Path(header._value[0]._header->filename), *this)));
matches++;
}
diff --git a/common/compression/unzip.cpp b/common/compression/unzip.cpp
index 4f0b79f66fb..efd6e146db3 100644
--- a/common/compression/unzip.cpp
+++ b/common/compression/unzip.cpp
@@ -1096,9 +1096,8 @@ int ZipArchive::listMembers(ArchiveMemberList &list) const {
int members = 0;
const unz_s *const archive = (const unz_s *)_zipFile;
- for (ZipHash::const_iterator i = archive->_hash.begin(), end = archive->_hash.end();
- i != end; ++i) {
- list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(i->_key, *this)));
+ for (const auto &hash : archive->_hash) {
+ list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(hash._key, *this)));
++members;
}
diff --git a/common/coroutines.cpp b/common/coroutines.cpp
index bdf9bf9dde9..2f118dd851b 100644
--- a/common/coroutines.cpp
+++ b/common/coroutines.cpp
@@ -61,10 +61,9 @@ static void displayCoroStats() {
// Loop over s_coroFuncs and print info about active coros
if (!s_coroFuncs)
return;
- for (CoroHashMap::const_iterator it = s_coroFuncs->begin();
- it != s_coroFuncs->end(); ++it) {
- if (it->_value != 0)
- debug(" %3d x %s", it->_value, it->_key.c_str());
+ for (const auto &func : s_coroFuncs) {
+ if (func._value != 0)
+ debug(" %3d x %s", func._value, func._key.c_str());
}
}
@@ -130,9 +129,8 @@ CoroutineScheduler::~CoroutineScheduler() {
active = nullptr;
// Clear the event list
- Common::List<EVENT *>::iterator i;
- for (i = _events.begin(); i != _events.end(); ++i)
- delete *i;
+ for (auto *event : _events)
+ delete event;
}
void CoroutineScheduler::reset() {
@@ -205,9 +203,8 @@ void CoroutineScheduler::checkStack() {
// Make sure all processes are accounted for
for (int idx = 0; idx < CORO_NUM_PROCESS; idx++) {
bool found = false;
- for (Common::List<PROCESS *>::iterator i = pList.begin(); i != pList.end(); ++i) {
- PROCESS *pTemp = *i;
- if (*i == &processList[idx]) {
+ for (auto &process : pList) {
+ if (process == &processList[idx]) {
found = true;
break;
}
@@ -247,11 +244,9 @@ void CoroutineScheduler::schedule() {
}
// Disable any events that were pulsed
- Common::List<EVENT *>::iterator i;
- for (i = _events.begin(); i != _events.end(); ++i) {
- EVENT *evt = *i;
- if (evt->pulsing) {
- evt->pulsing = evt->signalled = false;
+ for (auto &event : _events) {
+ if (event->pulsing) {
+ event->pulsing = event->signalled = false;
}
}
}
@@ -671,11 +666,9 @@ PROCESS *CoroutineScheduler::getProcess(uint32 pid) {
}
EVENT *CoroutineScheduler::getEvent(uint32 pid) {
- Common::List<EVENT *>::iterator i;
- for (i = _events.begin(); i != _events.end(); ++i) {
- EVENT *evt = *i;
- if (evt->pid == pid)
- return evt;
+ for (auto &event : _events) {
+ if (event->pid == pid)
+ return event;
}
return nullptr;
diff --git a/common/debug.cpp b/common/debug.cpp
index 5c72180f8b5..66b0fdf5fdf 100644
--- a/common/debug.cpp
+++ b/common/debug.cpp
@@ -73,8 +73,8 @@ bool DebugManager::addDebugChannel(uint32 channel, const String &name, const Str
if (_debugChannels.contains(name))
warning("Duplicate declaration of engine debug channel '%s'", name.c_str());
- for (DebugChannelMap::iterator i = _debugChannels.begin(); i != _debugChannels.end(); ++i)
- if (i->_value.channel == channel)
+ for (auto &debugChannel : _debugChannels)
+ if (debugChannel._value.channel == channel)
error("Duplicate engine debug channel id '%d' for flag '%s'", channel, name.c_str());
_debugChannels[name] = DebugChannel(channel, name, description);
@@ -97,9 +97,9 @@ void DebugManager::removeAllDebugChannels() {
_debugChannels.clear();
addDebugChannels(gDebugChannels);
- for (DebugChannelMap::iterator i = _debugChannels.begin(); i != _debugChannels.end(); ++i)
- if (oldMap.contains(i->_value.channel))
- _debugChannelsEnabled[i->_value.channel] = oldMap[i->_value.channel];
+ for (auto &debugChannel : _debugChannels)
+ if (oldMap.contains(debugChannel._value.channel))
+ _debugChannelsEnabled[debugChannel._value.channel] = oldMap[debugChannel._value.channel];
}
bool DebugManager::enableDebugChannel(const String &name) {
@@ -138,21 +138,21 @@ bool DebugManager::disableDebugChannel(uint32 channel) {
DebugManager::DebugChannelList DebugManager::getDebugChannels() {
DebugChannelList tmp;
- for (DebugChannelMap::iterator i = _debugChannels.begin(); i != _debugChannels.end(); ++i)
- tmp.push_back(i->_value);
+ for (auto &debugChannel : _debugChannels)
+ tmp.push_back(debugChannel._value);
sort(tmp.begin(), tmp.end(), DebugLevelComperator());
return tmp;
}
void DebugManager::enableAllDebugChannels() {
- for (DebugChannelMap::iterator i = _debugChannels.begin(); i != _debugChannels.end(); ++i)
- enableDebugChannel(i->_value.name);
+ for (auto &debugChannel : _debugChannels)
+ enableDebugChannel(debugChannel._value.name);
}
void DebugManager::disableAllDebugChannels() {
- for (DebugChannelMap::iterator i = _debugChannels.begin(); i != _debugChannels.end(); ++i)
- disableDebugChannel(i->_value.name);
+ for (auto &debugChannel : _debugChannels)
+ disableDebugChannel(debugChannel._value.name);
}
bool DebugManager::isDebugChannelEnabled(uint32 channel, bool enforce) {
diff --git a/common/engine_data.cpp b/common/engine_data.cpp
index a533a24eede..251fe006d57 100644
--- a/common/engine_data.cpp
+++ b/common/engine_data.cpp
@@ -182,10 +182,9 @@ int DataArchive::listMembers(Common::ArchiveMemberList &list) const {
int result = _zip->listMembers(innerList);
// Modify the results to change the filename
- for (Common::ArchiveMemberList::iterator it = innerList.begin();
- it != innerList.end(); ++it) {
+ for (auto &archive : innerList) {
Common::ArchiveMemberPtr member = Common::ArchiveMemberPtr(
- new DataArchiveMember(*it, _innerfolder, _publicFolder));
+ new DataArchiveMember(archive, _innerfolder, _publicFolder));
list.push_back(member);
}
@@ -236,7 +235,7 @@ Common::FSNode DataArchiveProxy::getNode(const Common::Path &name) const {
return node;
}
- for(Common::StringArray::const_iterator it = components.begin(); it != components.end() - 1; it++) {
+ for (Common::StringArray::const_iterator it = components.begin(); it != components.end() - 1; it++) {
node = node.getChild(*it);
if (!node.exists())
return node;
diff --git a/common/formats/json.cpp b/common/formats/json.cpp
index 5696617c587..e29ffd7c850 100644
--- a/common/formats/json.cpp
+++ b/common/formats/json.cpp
@@ -50,8 +50,8 @@
#endif
// Macros to free an array/object
-#define FREE_ARRAY(x) { JSONArray::iterator iter; for (iter = x.begin(); iter != x.end(); iter++) { delete *iter; } }
-#define FREE_OBJECT(x) { JSONObject::iterator iter; for (iter = x.begin(); iter != x.end(); iter++) { delete (*iter)._value; } }
+#define FREE_ARRAY(x) { for (auto *i : x) { delete i; } }
+#define FREE_OBJECT(x) { for (auto &i : x) { delete i._value; } }
namespace Common {
@@ -535,7 +535,7 @@ JSONValue *JSONValue::parse(const char **data) {
}
// Special case - empty array
- if (array.size() == 0 && **data == ']') {
+ if (array.empty() && **data == ']') {
(*data)++;
return new JSONValue(array);
}
@@ -704,20 +704,18 @@ JSONValue::JSONValue(const JSONValue &source) {
case JSONType_Array: {
JSONArray source_array = *source._arrayValue;
- JSONArray::iterator iter;
_arrayValue = new JSONArray();
- for (iter = source_array.begin(); iter != source_array.end(); iter++)
- _arrayValue->push_back(new JSONValue(**iter));
+ for (auto &src : source_array)
+ _arrayValue->push_back(new JSONValue(*src));
break;
}
case JSONType_Object: {
JSONObject source_object = *source._objectValue;
_objectValue = new JSONObject();
- JSONObject::iterator iter;
- for (iter = source_object.begin(); iter != source_object.end(); iter++) {
- String name = (*iter)._key;
- (*_objectValue)[name] = new JSONValue(*((*iter)._value));
+ for (auto &src : source_object) {
+ String name = src._key;
+ (*_objectValue)[name] = new JSONValue(*(src._value));
}
break;
}
@@ -738,15 +736,12 @@ JSONValue::JSONValue(const JSONValue &source) {
*/
JSONValue::~JSONValue() {
if (_type == JSONType_Array) {
- JSONArray::iterator iter;
- for (iter = _arrayValue->begin(); iter != _arrayValue->end(); iter++)
- delete *iter;
+ for (auto *array : *_arrayValue)
+ delete array;
delete _arrayValue;
} else if (_type == JSONType_Object) {
- JSONObject::iterator iter;
- for (iter = _objectValue->begin(); iter != _objectValue->end(); iter++) {
- delete (*iter)._value;
- }
+ for (auto &object : *_objectValue)
+ delete object._value;
delete _objectValue;
} else if (_type == JSONType_String) {
delete _stringValue;
@@ -1001,11 +996,8 @@ Array<String> JSONValue::objectKeys() const {
Array<String> keys;
if (_type == JSONType_Object) {
- JSONObject::const_iterator iter = _objectValue->begin();
- while (iter != _objectValue->end()) {
- keys.push_back(iter->_key);
-
- iter++;
+ for (auto &obj : *_objectValue) {
+ keys.push_back(obj._key);
}
}
diff --git a/common/formats/prodos.cpp b/common/formats/prodos.cpp
index 29c78088825..1254c77df9f 100644
--- a/common/formats/prodos.cpp
+++ b/common/formats/prodos.cpp
@@ -400,9 +400,8 @@ bool ProDOSDisk::hasFile(const Common::Path &path) const {
int ProDOSDisk::listMembers(Common::ArchiveMemberList &list) const {
int f = 0;
- Common::HashMap<Common::String, Common::SharedPtr<ProDOSFile>>::const_iterator it;
- for (it = _files.begin(); it != _files.end(); ++it) {
- list.push_back(Common::ArchiveMemberList::value_type(it->_value));
+ for (const auto &file : _files) {
+ list.push_back(Common::ArchiveMemberList::value_type(file._value));
++f;
}
return f;
diff --git a/common/formats/winexe_ne.cpp b/common/formats/winexe_ne.cpp
index 502ec0c653f..a2aefcb92a9 100644
--- a/common/formats/winexe_ne.cpp
+++ b/common/formats/winexe_ne.cpp
@@ -282,9 +282,9 @@ SeekableReadStream *NEResources::getResource(const WinResourceID &type, const Wi
const Array<WinResourceID> NEResources::getIDList(const WinResourceID &type) const {
Array<WinResourceID> idArray;
- for (List<Resource>::const_iterator it = _resources.begin(); it != _resources.end(); ++it)
- if (it->type == type)
- idArray.push_back(it->id);
+ for (const auto &resource : _resources)
+ if (resource.type == type)
+ idArray.push_back(resource.id);
return idArray;
}
diff --git a/common/formats/winexe_pe.cpp b/common/formats/winexe_pe.cpp
index 501ee444f5f..526ae26403b 100644
--- a/common/formats/winexe_pe.cpp
+++ b/common/formats/winexe_pe.cpp
@@ -171,8 +171,8 @@ const Array<WinResourceID> PEResources::getTypeList() const {
if (!_exe)
return array;
- for (TypeMap::const_iterator it = _resources.begin(); it != _resources.end(); it++)
- array.push_back(it->_key);
+ for (const auto &resource : _resources)
+ array.push_back(resource._key);
return array;
}
@@ -185,8 +185,8 @@ const Array<WinResourceID> PEResources::getIDList(const WinResourceID &type) con
const IDMap &idMap = _resources[type];
- for (IDMap::const_iterator it = idMap.begin(); it != idMap.end(); it++)
- array.push_back(it->_key);
+ for (const auto &id : idMap)
+ array.push_back(id._key);
return array;
}
@@ -204,8 +204,8 @@ const Array<WinResourceID> PEResources::getLangList(const WinResourceID &type, c
const LangMap &langMap = idMap[id];
- for (LangMap::const_iterator it = langMap.begin(); it != langMap.end(); it++)
- array.push_back(it->_key);
+ for (const auto &lang : langMap)
+ array.push_back(lang._key);
return array;
}
diff --git a/common/formats/xmlparser.cpp b/common/formats/xmlparser.cpp
index 3cca5a4ef76..f0542a808d4 100644
--- a/common/formats/xmlparser.cpp
+++ b/common/formats/xmlparser.cpp
@@ -34,9 +34,8 @@ XMLParser::~XMLParser() {
delete _XMLkeys;
delete _stream;
- for (List<XMLKeyLayout *>::iterator i = _layoutList.begin();
- i != _layoutList.end(); ++i)
- delete *i;
+ for (auto *layout : _layoutList)
+ delete layout;
_layoutList.clear();
}
@@ -171,12 +170,12 @@ bool XMLParser::parseActiveKey(bool closed) {
StringMap localMap = key->values;
int keyCount = localMap.size();
- for (List<XMLKeyLayout::XMLKeyProperty>::const_iterator i = key->layout->properties.begin(); i != key->layout->properties.end(); ++i) {
- if (i->required && !localMap.contains(i->name))
- return parserError("Missing required property '" + i->name + "' inside key '" + key->name + "'");
- else if (localMap.contains(i->name)) {
+ for (const auto &prop : key->layout->properties) {
+ if (prop.required && !localMap.contains(prop.name))
+ return parserError("Missing required property '" + prop.name + "' inside key '" + key->name + "'");
+ else if (localMap.contains(prop.name)) {
keyCount--;
- localMap.erase(i->name);
+ localMap.erase(prop.name);
}
}
diff --git a/common/macresman.cpp b/common/macresman.cpp
index d5c3b449f53..0dad3367388 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -539,8 +539,8 @@ void MacResManager::listFiles(Array<Path> &files, const Path &pattern) {
SearchMan.listMatchingMembers(memberList, pattern.append(".bin"));
SearchMan.listMatchingMembers(memberList, constructAppleDoubleName(pattern));
- for (ArchiveMemberList::const_iterator i = memberList.begin(), end = memberList.end(); i != end; ++i) {
- String filename = (*i)->getFileName();
+ for (const auto &member : memberList) {
+ String filename = member->getFileName();
// For raw resource forks and MacBinary files we strip the extension
// here to obtain a valid base name.
@@ -559,11 +559,11 @@ void MacResManager::listFiles(Array<Path> &files, const Path &pattern) {
// forks or MacBinary files but not being such around? This might
// depend on the pattern the client requests...
if (!scumm_stricmp(extension, "rsrc")) {
- SeekableReadStream *stream = (*i)->createReadStream();
+ SeekableReadStream *stream = member->createReadStream();
removeExtension = stream && isRawFork(*stream);
delete stream;
} else if (!scumm_stricmp(extension, "bin")) {
- SeekableReadStream *stream = (*i)->createReadStream();
+ SeekableReadStream *stream = member->createReadStream();
removeExtension = stream && isMacBinary(*stream);
delete stream;
}
@@ -579,7 +579,7 @@ void MacResManager::listFiles(Array<Path> &files, const Path &pattern) {
Common::Path(filename, Common::Path::kNoSeparator), &isAppleDoubleName);
if (isAppleDoubleName) {
- SeekableReadStream *stream = (*i)->createReadStream();
+ SeekableReadStream *stream = member->createReadStream();
if (stream->readUint32BE() == 0x00051607) {
filename = filenameAppleDoubleStripped.baseName();
}
@@ -589,13 +589,13 @@ void MacResManager::listFiles(Array<Path> &files, const Path &pattern) {
delete stream;
}
- Common::Path basePath((*i)->getPathInArchive().getParent().appendComponent(filename));
+ Common::Path basePath(member->getPathInArchive().getParent().appendComponent(filename));
baseNames[basePath] = true;
}
// Append resulting base names to list to indicate found files.
- for (BaseNameSet::const_iterator i = baseNames.begin(), end = baseNames.end(); i != end; ++i) {
- files.push_back(i->_key);
+ for (const auto &baseName : baseNames) {
+ files.push_back(baseName._key);
}
}
diff --git a/common/path.cpp b/common/path.cpp
index fc4c9aa2f0e..fda9e758c1f 100644
--- a/common/path.cpp
+++ b/common/path.cpp
@@ -784,9 +784,8 @@ Path Path::normalize() const {
// Well, we don't start with ESCAPE so there is still a chance we get unescaped
needUnescape = true;
- StringArray::const_iterator it;
- for (it = comps.begin(); it != comps.end(); it++) {
- if (!canUnescape(false, false, it->c_str())) {
+ for (const auto &comp : comps) {
+ if (!canUnescape(false, false, comp.c_str())) {
// Nope we can't get unescaped
needUnescape = false;
break;
diff --git a/common/recorderfile.cpp b/common/recorderfile.cpp
index 01713fae19b..d123247be7f 100644
--- a/common/recorderfile.cpp
+++ b/common/recorderfile.cpp
@@ -104,8 +104,8 @@ void PlaybackFile::close() {
delete _screenshotsFile;
_screenshotsFile = NULL;
}
- for (HashMap<String, SaveFileBuffer>::iterator i = _header.saveFiles.begin(); i != _header.saveFiles.end(); ++i) {
- free(i->_value.buffer);
+ for (auto &saveFile : _header.saveFiles) {
+ free(saveFile._value.buffer);
}
_header.saveFiles.clear();
_mode = kClosed;
More information about the Scummvm-git-logs
mailing list