summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2020-06-17 23:52:03 -0500
committerJohn Fultz <jfultz@wolfram.com>2020-06-17 23:52:03 -0500
commitb7413384aafca679584df1e5e18dd7e6282ff4f3 (patch)
tree65e5e434fc0dcc7e2dc51520a659219a575bbc68
parent61aa7d337a045759e06803c89b5f364ca4ed26b1 (diff)
Xcode compiler warnings.
* Replace std::random_shuffle() with std::shuffle(). * Populate switch statements which were checking the Move enums, but not Move::PlaceError. * endl -> Qt::endl for QTextStream usage. * QString::SkipEmptyParts -> Qt::SkipEmptyParts * QLabel::pixmap() now takes Qt::ReturnByValue * Use QElapsedTimer where appropriate.
-rw-r--r--bag.cpp2
-rw-r--r--datamanager.h5
-rw-r--r--game.cpp1
-rw-r--r--move.cpp1
-rw-r--r--quacker/boarddisplay.cpp4
-rw-r--r--quacker/graphicalreporter.cpp18
-rw-r--r--quacker/graphicalreporter.h7
-rw-r--r--quacker/letterbox.cpp4
-rw-r--r--quacker/letterbox.h5
-rw-r--r--quacker/quacker.cpp2
-rw-r--r--quacker/rackdisplay.cpp4
-rw-r--r--quackleio/gcgio.cpp40
-rw-r--r--quackleio/gcgio.h5
-rw-r--r--quackleio/streamingreporter.cpp2
-rw-r--r--quackleio/streamingreporter.h6
-rw-r--r--rack.cpp2
-rw-r--r--reporter.cpp1
17 files changed, 76 insertions, 33 deletions
diff --git a/bag.cpp b/bag.cpp
index 7aa1622..6fb831c 100644
--- a/bag.cpp
+++ b/bag.cpp
@@ -176,7 +176,7 @@ LetterString Bag::refill(Rack &rack, const LetterString &drawingOrder)
LongLetterString Bag::shuffledTiles() const
{
LongLetterString ret(m_tiles);
- random_shuffle(ret.begin(), ret.end());
+ DataManager::self()->shuffle(ret);
return ret;
}
diff --git a/datamanager.h b/datamanager.h
index 219a500..91b7408 100644
--- a/datamanager.h
+++ b/datamanager.h
@@ -126,6 +126,11 @@ public:
void seedRandomNumbers(unsigned int seed);
void seedRandomNumbers(seed_seq& seed);
int randomInteger(int low, int high);
+ template <typename T> void shuffle(T& collection)
+ {
+ lock_guard<mutex> lock(m_RngMutex);
+ std::shuffle(collection.begin(), collection.end(), m_mersenneTwisterRng);
+ }
private:
static DataManager *m_self;
diff --git a/game.cpp b/game.cpp
index a1b09c7..aa5a63f 100644
--- a/game.cpp
+++ b/game.cpp
@@ -331,6 +331,7 @@ int GamePosition::validateMove(const Move &move) const
switch (move.action)
{
case Move::Place:
+ case Move::PlaceError:
case Move::Exchange:
if (!currentPlayer().rack().contains(move.usedTiles()))
ret |= InvalidTiles;
diff --git a/move.cpp b/move.cpp
index 349f7d0..9a023f4 100644
--- a/move.cpp
+++ b/move.cpp
@@ -145,6 +145,7 @@ UVString Move::xml() const
break;
case Place:
+ case PlaceError:
{
actionString = MARK_UV("place");
diff --git a/quacker/boarddisplay.cpp b/quacker/boarddisplay.cpp
index e64cb36..677179e 100644
--- a/quacker/boarddisplay.cpp
+++ b/quacker/boarddisplay.cpp
@@ -128,7 +128,11 @@ void BoardWithQuickEntry::provideHelp()
void BoardWithQuickEntry::processCommand(const QString &command)
{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList items(command.split(" ", Qt::SkipEmptyParts));
+#else
QStringList items(command.split(" ", QString::SkipEmptyParts));
+#endif
Quackle::Move move(Quackle::Move::createNonmove());
if (items.size() <= 0)
diff --git a/quacker/graphicalreporter.cpp b/quacker/graphicalreporter.cpp
index 8111f7b..86b539d 100644
--- a/quacker/graphicalreporter.cpp
+++ b/quacker/graphicalreporter.cpp
@@ -94,27 +94,27 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu
if (image.save(filename, "PNG"))
{
- m_indexStream << QString("<a href=\"%1\">%2</a>").arg(filebasename).arg(title) << endl;
+ m_indexStream << QString("<a href=\"%1\">%2</a>").arg(filebasename).arg(title) << m_endl;
}
else
{
QMessageBox::critical(0, GraphicalBoard::tr("Error Writing File - Quacker"), GraphicalBoard::tr("Could not write image %1.").arg(filename));
}
- m_indexStream << "<p><img src=\"" << filebasename << "\"></p>" << endl;
+ m_indexStream << "<p><img src=\"" << filebasename << "\"></p>" << m_endl;
}
else
{
m_indexStream << title;
const int boardTileSize = position.gameOver()? 45 : 25;
- m_indexStream << QuackleIO::Util::sanitizeUserVisibleLetterString(QuackleIO::Util::uvStringToQString(position.board().htmlBoard(boardTileSize))) << endl;
+ m_indexStream << QuackleIO::Util::sanitizeUserVisibleLetterString(QuackleIO::Util::uvStringToQString(position.board().htmlBoard(boardTileSize))) << m_endl;
}
}
const Quackle::PlayerList players(position.endgameAdjustedScores());
- m_indexStream << "<table cellspacing=6>" << endl;
+ m_indexStream << "<table cellspacing=6>" << m_endl;
for (Quackle::PlayerList::const_iterator it = players.begin(); it != players.end(); ++it)
{
m_indexStream << "<tr>";
@@ -131,9 +131,9 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu
<< "<td>" << QuackleIO::Util::sanitizeUserVisibleLetterString(QuackleIO::Util::uvStringToQString((*it).rack().toString())) << "</td>"
<< "<td>" << (*it).score() << "</td>"
<< "</tr>"
- << endl;
+ << m_endl;
}
- m_indexStream << "</table>" << endl;
+ m_indexStream << "</table>" << m_endl;
if (computerPlayer && !position.gameOver())
{
@@ -153,7 +153,7 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu
moves.push_back(position.committedMove());
}
- m_indexStream << "<ol>" << endl;
+ m_indexStream << "<ol>" << m_endl;
for (Quackle::MoveList::const_iterator it = moves.begin(); it != moves.end(); ++it)
{
QString item;
@@ -203,9 +203,9 @@ void GraphicalReporter::reportPosition(const Quackle::GamePosition &position, Qu
item += QString(" &nbsp;&larr;");
if (!item.isEmpty())
- m_indexStream << "<li>" << item << "</li>" << endl;
+ m_indexStream << "<li>" << item << "</li>" << m_endl;
}
- m_indexStream << "</ol>" << endl;
+ m_indexStream << "</ol>" << m_endl;
}
m_indexStream << "\n\n";
diff --git a/quacker/graphicalreporter.h b/quacker/graphicalreporter.h
index fd2b52d..997fdb4 100644
--- a/quacker/graphicalreporter.h
+++ b/quacker/graphicalreporter.h
@@ -60,4 +60,11 @@ protected:
bool m_generateImages;
};
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !defined(m_endl)
+# define m_endl Qt::endl
+#elif !defined(m_endl)
+# define m_endl endl
+#endif
+
+
#endif
diff --git a/quacker/letterbox.cpp b/quacker/letterbox.cpp
index 8edcaa5..aeed7af 100644
--- a/quacker/letterbox.cpp
+++ b/quacker/letterbox.cpp
@@ -358,7 +358,11 @@ ClueResult Letterbox::parseComment(const QString &comment)
if (comment.isEmpty())
return ClueResult();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList items = comment.split(" ", Qt::SkipEmptyParts);
+#else
QStringList items = comment.split(" ", QString::SkipEmptyParts);
+#endif
ClueResult ret;
diff --git a/quacker/letterbox.h b/quacker/letterbox.h
index 8aa171d..c340f1d 100644
--- a/quacker/letterbox.h
+++ b/quacker/letterbox.h
@@ -19,6 +19,7 @@
#ifndef QUACKER_LETTERBOX_H
#define QUACKER_LETTERBOX_H
+#include <QElapsedTimer>
#include <QMainWindow>
#include <QValidator>
#include <QTextEdit>
@@ -204,8 +205,8 @@ private:
ListerDialog *m_listerDialog;
QTimer *m_timer;
- QTime m_time;
- QTime m_pauseTime;
+ QElapsedTimer m_time;
+ QElapsedTimer m_pauseTime;
int m_pauseMs;
int m_keystrokes;
diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp
index 20b2f88..4e91498 100644
--- a/quacker/quacker.cpp
+++ b/quacker/quacker.cpp
@@ -656,7 +656,7 @@ void TopLevel::initializeGame(const Quackle::PlayerList &players)
UVString prevFirst = m_firstPlayerName;
while (m_firstPlayerName == prevFirst || m_firstPlayerName.empty())
{
- random_shuffle(newPlayers.begin(), newPlayers.end());
+ QUACKLE_DATAMANAGER->shuffle(newPlayers);
m_firstPlayerName = newPlayers.front().name();
if (all_of(newPlayers.begin(),
newPlayers.end(),
diff --git a/quacker/rackdisplay.cpp b/quacker/rackdisplay.cpp
index 59b91e7..b0f10f5 100644
--- a/quacker/rackdisplay.cpp
+++ b/quacker/rackdisplay.cpp
@@ -242,7 +242,11 @@ GraphicalRack::mousePressEvent (QMouseEvent* event)
if (!child)
return;
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
+ QPixmap pixmap = child->pixmap(Qt::ReturnByValue);
+#else
QPixmap pixmap = *(child->pixmap());
+#endif
QByteArray itemData;
QDataStream dataStream (&itemData, QIODevice::WriteOnly);
diff --git a/quackleio/gcgio.cpp b/quackleio/gcgio.cpp
index 54067ba..862f07b 100644
--- a/quackleio/gcgio.cpp
+++ b/quackleio/gcgio.cpp
@@ -36,7 +36,7 @@ Quackle::Game *GCGIO::read(const QString &filename, int flags)
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
- UVcerr << "Could not open gcg " << QuackleIO::Util::qstringToString(filename) << endl;
+ UVcerr << "Could not open gcg " << QuackleIO::Util::qstringToString(filename) << m_endl;
return new Quackle::Game;
}
@@ -64,7 +64,11 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
while (!stream.atEnd())
{
line = stream.readLine();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList strings = line.split(QRegExp("\\s+"), Qt::SkipEmptyParts);
+#else
QStringList strings = line.split(QRegExp("\\s+"), QString::SkipEmptyParts);
+#endif
if (line.startsWith("#"))
{
@@ -77,7 +81,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
if (strings.isEmpty())
{
- UVcerr << "GCG error reading " << Util::qstringToString(line) << ": no player abbreviation in #player" << endl;
+ UVcerr << "GCG error reading " << Util::qstringToString(line) << ": no player abbreviation in #player" << m_endl;
return ret;
}
@@ -86,7 +90,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
if (strings.isEmpty())
{
- UVcerr << "GCG error reading " << Util::qstringToString(line) << ": no player name in #player" << endl;
+ UVcerr << "GCG error reading " << Util::qstringToString(line) << ": no player name in #player" << m_endl;
return ret;
}
@@ -112,7 +116,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
if (strings.isEmpty())
{
- UVcerr << "GCG error reading " << Util::qstringToString(line) << ": no rack in #rack" << endl;
+ UVcerr << "GCG error reading " << Util::qstringToString(line) << ": no rack in #rack" << m_endl;
return ret;
}
@@ -148,7 +152,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
if (strings.isEmpty())
{
- UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << endl;
+ UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << m_endl;
return ret;
}
@@ -169,7 +173,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
if (strings.isEmpty())
{
- UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << endl;
+ UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << m_endl;
return ret;
}
@@ -209,7 +213,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
if (strings.isEmpty())
{
- UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << endl;
+ UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << m_endl;
return ret;
}
}
@@ -219,7 +223,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
if (strings.isEmpty())
{
- UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << endl;
+ UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << m_endl;
return ret;
}
@@ -235,7 +239,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags)
if (strings.isEmpty())
{
- UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << endl;
+ UVcerr << "GCG error reading " << Util::qstringToString(line) << ": incomplete move" << m_endl;
return ret;
}
@@ -330,17 +334,17 @@ void GCGIO::write(const Quackle::Game &game, QTextStream &stream)
{
Quackle::PlayerList players = game.players();
stream.setCodec(QTextCodec::codecForName("UTF-8"));
- stream << "#character-encoding UTF-8" << endl;
+ stream << "#character-encoding UTF-8" << m_endl;
for (Quackle::PlayerList::iterator it = players.begin(); it != players.end(); ++it)
{
- stream << "#player" << (*it).id() + 1 << " " << Util::uvStringToQString((*it).abbreviatedName()) << " " << Util::uvStringToQString((*it).name()) << endl;
+ stream << "#player" << (*it).id() + 1 << " " << Util::uvStringToQString((*it).abbreviatedName()) << " " << Util::uvStringToQString((*it).name()) << m_endl;
}
if (!game.title().empty())
- stream << "#title " << Util::uvStringToQString(game.title()) << endl;
+ stream << "#title " << Util::uvStringToQString(game.title()) << m_endl;
if (!game.description().empty())
- stream << "#description " << Util::uvStringToQString(game.description()) << endl;
+ stream << "#description " << Util::uvStringToQString(game.description()) << m_endl;
const Quackle::PositionList::const_iterator end(game.history().end());
for (Quackle::PositionList::const_iterator it = game.history().begin(); it != end; ++it)
@@ -365,11 +369,11 @@ void GCGIO::write(const Quackle::Game &game, QTextStream &stream)
QString rackString = Util::letterStringToQString((*it).currentPlayer().rack().alphaTiles());
if (move.action == Quackle::Move::UnusedTilesBonusError)
rackString = QString();
- stream << ">" << Util::uvStringToQString((*it).currentPlayer().abbreviatedName()) << ": " << rackString << " " << Util::uvStringToQString(move.toString()) << " +" << outputScore << " " << outputScore + (*it).currentPlayer().score() << endl;
+ stream << ">" << Util::uvStringToQString((*it).currentPlayer().abbreviatedName()) << ": " << rackString << " " << Util::uvStringToQString(move.toString()) << " +" << outputScore << " " << outputScore + (*it).currentPlayer().score() << m_endl;
if (move.isChallengedPhoney())
{
- stream << ">" << Util::uvStringToQString((*it).currentPlayer().abbreviatedName()) << ": " << rackString << " -- -" << outputScore << " " << move.effectiveScore() + (*it).currentPlayer().score() << endl;
+ stream << ">" << Util::uvStringToQString((*it).currentPlayer().abbreviatedName()) << ": " << rackString << " -- -" << outputScore << " " << move.effectiveScore() + (*it).currentPlayer().score() << m_endl;
}
if (outputScoreAddition != 0)
@@ -393,19 +397,19 @@ void GCGIO::write(const Quackle::Game &game, QTextStream &stream)
}
}
- stream << ">" << Util::uvStringToQString((*it).currentPlayer().abbreviatedName()) << ": " << nextRack << " (challenge) " << ((outputScoreAddition > 0)? "+" : "") << outputScoreAddition << " " << (outputScoreAddition + outputScore + (*it).currentPlayer().score()) << endl;
+ stream << ">" << Util::uvStringToQString((*it).currentPlayer().abbreviatedName()) << ": " << nextRack << " (challenge) " << ((outputScoreAddition > 0)? "+" : "") << outputScoreAddition << " " << (outputScoreAddition + outputScore + (*it).currentPlayer().score()) << m_endl;
}
}
if (!(*it).explanatoryNote().empty())
- stream << "#note " << Util::uvStringToQString((*it).explanatoryNote()) << endl;
+ stream << "#note " << Util::uvStringToQString((*it).explanatoryNote()) << m_endl;
}
const Quackle::GamePosition &lastPosition = game.history().lastPosition();
if (!lastPosition.gameOver())
{
- stream << "#rack" << lastPosition.currentPlayer().id() + 1 << " " << Util::letterStringToQString(lastPosition.currentPlayer().rack().alphaTiles()) << endl;
+ stream << "#rack" << lastPosition.currentPlayer().id() + 1 << " " << Util::letterStringToQString(lastPosition.currentPlayer().rack().alphaTiles()) << m_endl;
}
}
diff --git a/quackleio/gcgio.h b/quackleio/gcgio.h
index 3442056..2ae76f8 100644
--- a/quackleio/gcgio.h
+++ b/quackleio/gcgio.h
@@ -40,6 +40,11 @@ private:
int readSignedInt(const QString &intString) const;
};
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !defined(m_endl)
+# define m_endl Qt::endl
+#elif !defined(m_endl)
+# define m_endl endl
+#endif
}
#endif
diff --git a/quackleio/streamingreporter.cpp b/quackleio/streamingreporter.cpp
index 62ee576..5e6837d 100644
--- a/quackleio/streamingreporter.cpp
+++ b/quackleio/streamingreporter.cpp
@@ -41,7 +41,7 @@ void StreamingReporter::reportGame(const Quackle::Game &game, Quackle::ComputerP
Quackle::Reporter::reportPosition((*it), computerPlayer, &subreport);
// endl flushes the stream, which we want
- stream << Util::uvStringToQString(subreport) << endl;
+ stream << Util::uvStringToQString(subreport) << m_endl;
}
UVString stats;
diff --git a/quackleio/streamingreporter.h b/quackleio/streamingreporter.h
index 911ca9e..a6a82c9 100644
--- a/quackleio/streamingreporter.h
+++ b/quackleio/streamingreporter.h
@@ -45,4 +45,10 @@ public:
}
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !defined(m_endl)
+# define m_endl Qt::endl
+#elif !defined(m_endl)
+# define m_endl endl
+#endif
+
#endif
diff --git a/rack.cpp b/rack.cpp
index e34c4b1..0a878de 100644
--- a/rack.cpp
+++ b/rack.cpp
@@ -92,7 +92,7 @@ bool Rack::contains(const LetterString &used) const
void Rack::shuffle()
{
- random_shuffle(m_tiles.begin(), m_tiles.end());
+ DataManager::self()->shuffle(m_tiles);
}
int Rack::score() const
diff --git a/reporter.cpp b/reporter.cpp
index 4b13161..92435d6 100644
--- a/reporter.cpp
+++ b/reporter.cpp
@@ -152,6 +152,7 @@ void Reporter::reportPosition(const GamePosition &position, ComputerPlayer *comp
switch ((*it).action)
{
case Move::Place:
+ case Move::PlaceError:
s << (*it).positionString();
break;