Skip to content

Commit db832d9

Browse files
committed
Revise: use QLineF/QPointF instead of QLine/QPoint to pacify clang-tidy Bot
It seemed to be unhappy about "narrowing conversions" of `double`s to `int`s. when a local line and point with integer coordinates are created - and which are then used to create others which have floating point values. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
1 parent 2382e27 commit db832d9

1 file changed

Lines changed: 27 additions & 25 deletions

File tree

src/T2DMap.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,9 @@ void T2DMap::paintAreaExits(QPainter& painter, QPen& pen, QList<int>& exitList,
21202120

21212121
QVector3D p1(ex, ey, ez);
21222122
QVector3D p2(rx, ry, rz);
2123-
QLine line;
2123+
// This was a QLine (so used integer coordinates), but lets
2124+
// try with a QLineF as we are using floating point numbers:
2125+
QLineF line;
21242126
if (!areaExit) {
21252127
// Non-area exit:
21262128
if (!oneWayExits.contains(rID)) {
@@ -2193,37 +2195,37 @@ void T2DMap::paintAreaExits(QPainter& painter, QPen& pen, QList<int>& exitList,
21932195
pen.setColor(mpMap->getColor(k));
21942196
painter.setPen(pen);
21952197
if (room->getSouth() == rID) {
2196-
line = QLine(p2.x(), p2.y() + 2.0 * mRoomHeight,
2197-
p2.x(), p2.y());
2198-
clickPoint = QPoint(p2.x(), p2.y() + mRoomHeight);
2198+
line = QLineF(p2.x(), p2.y() + 2.0 * mRoomHeight,
2199+
p2.x(), p2.y());
2200+
clickPoint = QPointF(p2.x(), p2.y() + mRoomHeight);
21992201
} else if (room->getNorth() == rID) {
2200-
line = QLine(p2.x(), p2.y() - 2.0 * mRoomHeight,
2201-
p2.x(), p2.y());
2202-
clickPoint = QPoint(p2.x(), p2.y() - mRoomHeight);
2202+
line = QLineF(p2.x(), p2.y() - 2.0 * mRoomHeight,
2203+
p2.x(), p2.y());
2204+
clickPoint = QPointF(p2.x(), p2.y() - mRoomHeight);
22032205
} else if (room->getWest() == rID) {
2204-
line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y(),
2205-
p2.x(), p2.y());
2206-
clickPoint = QPoint(p2.x() - mRoomWidth, p2.y());
2206+
line = QLineF(p2.x() - 2.0 * mRoomWidth, p2.y(),
2207+
p2.x(), p2.y());
2208+
clickPoint = QPointF(p2.x() - mRoomWidth, p2.y());
22072209
} else if (room->getEast() == rID) {
2208-
line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y(),
2209-
p2.x(), p2.y());
2210-
clickPoint = QPoint(p2.x() + mRoomWidth, p2.y());
2210+
line = QLineF(p2.x() + 2.0 * mRoomWidth, p2.y(),
2211+
p2.x(), p2.y());
2212+
clickPoint = QPointF(p2.x() + mRoomWidth, p2.y());
22112213
} else if (room->getNorthwest() == rID) {
2212-
line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight,
2213-
p2.x(), p2.y());
2214-
clickPoint = QPoint(p2.x() - mRoomWidth, p2.y() - mRoomHeight);
2214+
line = QLineF(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight,
2215+
p2.x(), p2.y());
2216+
clickPoint = QPointF(p2.x() - mRoomWidth, p2.y() - mRoomHeight);
22152217
} else if (room->getNortheast() == rID) {
2216-
line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight,
2217-
p2.x(), p2.y());
2218-
clickPoint = QPoint(p2.x() + mRoomWidth, p2.y() - mRoomHeight);
2218+
line = QLineF(p2.x() + 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight,
2219+
p2.x(), p2.y());
2220+
clickPoint = QPointF(p2.x() + mRoomWidth, p2.y() - mRoomHeight);
22192221
} else if (room->getSoutheast() == rID) {
2220-
line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight,
2221-
p2.x(), p2.y());
2222-
clickPoint = QPoint(p2.x() + mRoomWidth, p2.y() + mRoomHeight);
2222+
line = QLineF(p2.x() + 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight,
2223+
p2.x(), p2.y());
2224+
clickPoint = QPointF(p2.x() + mRoomWidth, p2.y() + mRoomHeight);
22232225
} else if (room->getSouthwest() == rID) {
2224-
line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight,
2225-
p2.x(), p2.y());
2226-
clickPoint = QPoint(p2.x() - mRoomWidth, p2.y() + mRoomHeight);
2226+
line = QLineF(p2.x() - 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight,
2227+
p2.x(), p2.y());
2228+
clickPoint = QPointF(p2.x() - mRoomWidth, p2.y() + mRoomHeight);
22272229
}
22282230
areaExitsMap[k] = clickPoint;
22292231
// line ENDS at the center of the room, and the START sticks out

0 commit comments

Comments
 (0)