Commit 23132eee authored by Andrius Štikonas's avatar Andrius Štikonas

Port away from Q_FOREACH.

parent 3f29d795
project(kgoldrunner)
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
set (QT_MIN_VERSION "5.3.0")
set (QT_MIN_VERSION "5.7.0")
set (KF5_MIN_VERSION "5.15.0")
find_package(ECM 1.7.0 REQUIRED CONFIG)
......
#include "kgrdebug.h"
/****************************************************************************
* Copyright 2009 Ian Wadham <iandw.au@gmail.com> *
* *
......@@ -17,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************/
#include "kgrdebug.h"
#include "kgreditor.h"
#include "kgrscene.h"
#include "kgrview.h"
......@@ -772,7 +771,7 @@ bool KGrEditor::ownerOK (Owner o)
// Check that this owner has at least one set of game data.
bool OK = false;
foreach (KGrGameData * d, gameList) {
for (KGrGameData * d : qAsConst(gameList)) {
if (d->owner == o) {
OK = true;
break;
......@@ -809,7 +808,7 @@ bool KGrEditor::saveGameData (Owner o)
int i, len;
char ch;
foreach (KGrGameData * gData, gameList) {
for (KGrGameData * gData : qAsConst(gameList)) {
if (gData->owner == o) {
line = QString ("%1 %2 %3 %4\n")
.arg (gData->nLevels, 3, 10, QChar('0')) // int 00n
......
#include "kgrdebug.h"
/****************************************************************************
* Copyright 2003 Marco Krüger <grisuji@gmx.de> *
* Copyright 2003,2009 Ian Wadham <iandw.au@gmail.com> *
......@@ -18,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************/
#include "kgrdebug.h"
#include "kgrgame.h"
#include "kgrview.h"
......@@ -448,7 +447,7 @@ void KGrGame::initGame()
level = 1;
int n = 0;
dbk1 << gameIndex << level << "Search:" << prevGamePrefix << prevLevel;
foreach (KGrGameData * gameData, gameList) {
for (KGrGameData * gameData : qAsConst(gameList)) {
dbk1 << "Trying:" << n << gameData->prefix;
if (gameData->prefix == prevGamePrefix) {
gameIndex = n;
......
......@@ -47,7 +47,7 @@ IOStatus KGrGameIO::fetchGameListData
}
// Loop to read each file containing game-data.
foreach (const QString &filename, files) {
for (const QString &filename : qAsConst(files)) {
if (filename == "game_ende.txt") {
continue; // Skip the "ENDE" file.
}
......
......@@ -196,7 +196,7 @@ void KGrLevelGrid::calculateCellAccess (const int i, const int j)
void KGrLevelGrid::placeHiddenLadders()
{
foreach (int offset, hiddenLadders) {
for (const int &offset : qAsConst(hiddenLadders)) {
int i = offset % width;
int j = offset / width;
changeCellAt (i, j, LADDER);
......
#include "kgrdebug.h"
/****************************************************************************
* Copyright 2009 Ian Wadham <iandw.au@gmail.com> *
* *
......@@ -30,6 +28,7 @@
#include "kgrrulebook.h"
#include "kgrlevelgrid.h"
#include "kgrrunner.h"
#include "kgrdebug.h"
#include "kgoldrunner_debug.h"
#include <KMessageBox> // TODO - Remove.
......@@ -231,7 +230,7 @@ void KGrLevelPlayer::init (KGrView * view,
view->gameScene(), SLOT (startAnimation (int, bool, int, int,
int, Direction, AnimationType)));
foreach (KGrEnemy * enemy, enemies) {
for (KGrEnemy * enemy : qAsConst(enemies)) {
connect (enemy, SIGNAL (startAnimation (int, bool, int, int,
int, Direction, AnimationType)),
view->gameScene(), SLOT (startAnimation (int, bool, int, int,
......@@ -241,7 +240,7 @@ void KGrLevelPlayer::init (KGrView * view,
// Connect the scoring.
connect (hero, SIGNAL (incScore(int)),
game, SLOT (incScore(int)));
foreach (KGrEnemy * enemy, enemies) {
for (KGrEnemy * enemy : qAsConst(enemies)) {
connect (enemy, SIGNAL (incScore(int)),
game, SLOT (incScore(int)));
}
......@@ -614,7 +613,7 @@ bool KGrLevelPlayer::heroCaught (const int heroX, const int heroY)
return false;
}
int enemyX, enemyY, pointsPerCell_1;
foreach (KGrEnemy * enemy, enemies) {
for (KGrEnemy * enemy : qAsConst(enemies)) {
pointsPerCell_1 = enemy->whereAreYou (enemyX, enemyY) - 1;
if (((heroX < enemyX) ? ((heroX + pointsPerCell_1) >= enemyX) :
(heroX <= (enemyX + pointsPerCell_1))) &&
......@@ -636,7 +635,7 @@ KGrEnemy * KGrLevelPlayer::standOnEnemy (const int spriteId,
return 0;
}
int enemyX, enemyY, pointsPerCell;
foreach (KGrEnemy * enemy, enemies) {
for (KGrEnemy * enemy : qAsConst(enemies)) {
pointsPerCell = enemy->whereAreYou (enemyX, enemyY);
if (((enemyY == (y + pointsPerCell)) ||
(enemyY == (y + pointsPerCell - 1))) &&
......@@ -789,7 +788,7 @@ void KGrLevelPlayer::tick (bool missed, int scaledTime)
return;
}
foreach (KGrEnemy * enemy, enemies) {
for (KGrEnemy * enemy : qAsConst(enemies)) {
enemy->run (scaledTime);
}
......@@ -1220,7 +1219,7 @@ void KGrLevelPlayer::startLogging()
void KGrLevelPlayer::showFigurePositions()
{
hero->showState();
foreach (KGrEnemy * enemy, enemies) {
for (KGrEnemy * enemy : qAsConst(enemies)) {
enemy->showState();
}
}
......
......@@ -87,7 +87,8 @@ void KGrRenderer::matchThemes (const KgTheme * currentSetTheme)
// Start of game or change of theme: initialise the counts of pixmap keys.
initPixmapKeys();
foreach (const KgTheme * actorsTheme, m_actorsProvider->themes()) {
const auto themes = m_actorsProvider->themes();
for (const KgTheme * actorsTheme : themes) {
if (actorsTheme->customData("Set") ==
currentSetTheme->customData("Set")) {
m_actorsProvider->setCurrentTheme (actorsTheme);
......
......@@ -135,13 +135,13 @@ void KGrScene::redrawScene ()
m_gradient.setColorAt (0.85, QColor (0, 0, 0, 0));
int index = 0;
foreach (KGameRenderedItem * tile, m_tiles) {
for (KGameRenderedItem * tile : qAsConst(m_tiles)) {
if (tile) {
setTile (tile, tileSize, index/m_tilesHigh, index%m_tilesHigh);
}
index++;
}
foreach (KGrSprite * sprite, m_sprites) {
for (KGrSprite * sprite : qAsConst(m_sprites)) {
if (sprite) {
sprite->changeCoordinateSystem
(m_topLeftX, m_topLeftY, tileSize);
......@@ -483,7 +483,7 @@ int KGrScene::makeSprite (const char type, int i, int j)
void KGrScene::animate (bool missed)
{
foreach (KGrSprite * sprite, m_sprites) {
for (KGrSprite * sprite : qAsConst(m_sprites)) {
if (sprite != 0) {
sprite->animate (missed);
}
......@@ -561,7 +561,7 @@ void KGrScene::gotGold (const int spriteId, const int i, const int j,
void KGrScene::showHiddenLadders (const QList<int> & ladders, const int width)
{
foreach (int offset, ladders) {
for (const int &offset : ladders) {
int i = offset % width;
int j = offset / width;
paintCell (i, j, LADDER);
......
......@@ -358,8 +358,8 @@ void KGrSLDialog::slSetGames (int cIndex)
sortOrder1 << 'N' << 'C' << 'T';
sortOrder2 << 'T' << 'K';
foreach (char sortItem1, sortOrder1) {
foreach (char sortItem2, sortOrder2) {
for (char sortItem1 : qAsConst(sortOrder1)) {
for (char sortItem2 : qAsConst(sortOrder2)) {
for (i = 0; i < imax; i++) {
if ((myGameList.at (i)->skill == sortItem1) &&
(myGameList.at (i)->rules == sortItem2)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment